@@ -122,11 +122,11 @@ impl OfferBuilder {
122122 /// Use a different pubkey per offer to avoid correlating offers.
123123 pub fn new ( description : String , signing_pubkey : SigningPubkey ) -> Self {
124124 let ( metadata_material, signing_pubkey) = match signing_pubkey {
125- SigningPubkey :: Explicit ( pubkey) => ( None , Some ( pubkey) ) ,
125+ SigningPubkey :: Explicit ( pubkey) => ( None , pubkey) ,
126126 SigningPubkey :: Derived ( expanded_key, nonce) => {
127127 let metadata_material = ( nonce, expanded_key. hmac_for_offer ( nonce) ) ;
128128 let signing_pubkey = expanded_key. signing_pubkey_for_offer ( nonce) ;
129- ( Some ( metadata_material) , Some ( signing_pubkey) )
129+ ( Some ( metadata_material) , signing_pubkey)
130130 } ,
131131 } ;
132132 let offer = OfferContents {
@@ -156,9 +156,10 @@ impl OfferBuilder {
156156 /// Sets the [`Offer::metadata`] to the given bytes.
157157 ///
158158 /// Successive calls to this method will override the previous setting. Errors if the builder
159- /// was constructed with [`SigningPubkey::Derived`].
159+ /// was constructed with [`SigningPubkey::Derived`] or if [`OfferBuilder::metadata_derived`] was
160+ /// called.
160161 pub fn metadata ( mut self , metadata : Vec < u8 > ) -> Result < Self , SemanticError > {
161- if self . offer . signing_pubkey . is_none ( ) {
162+ if self . metadata_material . is_some ( ) {
162163 return Err ( SemanticError :: UnexpectedMetadata ) ;
163164 }
164165
@@ -263,10 +264,6 @@ impl OfferBuilder {
263264 self . offer . metadata = Some ( metadata) ;
264265 }
265266
266- if self . offer . signing_pubkey . is_none ( ) {
267- return Err ( SemanticError :: MissingSigningPubkey ) ;
268- }
269-
270267 let mut bytes = Vec :: new ( ) ;
271268 self . offer . write ( & mut bytes) . unwrap ( ) ;
272269
@@ -328,7 +325,7 @@ pub(super) struct OfferContents {
328325 issuer : Option < String > ,
329326 paths : Option < Vec < BlindedPath > > ,
330327 supported_quantity : Quantity ,
331- signing_pubkey : Option < PublicKey > ,
328+ signing_pubkey : PublicKey ,
332329}
333330
334331impl Offer {
@@ -542,7 +539,7 @@ impl OfferContents {
542539 }
543540
544541 pub ( super ) fn signing_pubkey ( & self ) -> PublicKey {
545- self . signing_pubkey . unwrap ( )
542+ self . signing_pubkey
546543 }
547544
548545 /// Verifies that the offer metadata was produced from the offer in the TLV stream.
@@ -595,7 +592,7 @@ impl OfferContents {
595592 paths : self . paths . as_ref ( ) ,
596593 issuer : self . issuer . as_ref ( ) ,
597594 quantity_max : self . supported_quantity . to_tlv_record ( ) ,
598- node_id : self . signing_pubkey . as_ref ( ) ,
595+ node_id : Some ( & self . signing_pubkey ) ,
599596 }
600597 }
601598}
@@ -740,7 +737,7 @@ impl TryFrom<OfferTlvStream> for OfferContents {
740737
741738 let signing_pubkey = match node_id {
742739 None => return Err ( SemanticError :: MissingSigningPubkey ) ,
743- Some ( node_id) => Some ( node_id) ,
740+ Some ( node_id) => node_id,
744741 } ;
745742
746743 Ok ( OfferContents {
0 commit comments