@@ -125,11 +125,11 @@ impl OfferBuilder {
125125 /// Use a different pubkey per offer to avoid correlating offers.
126126 pub fn new ( description : String , signing_pubkey : SigningPubkey ) -> Self {
127127 let ( metadata_material, signing_pubkey) = match signing_pubkey {
128- SigningPubkey :: Explicit ( pubkey) => ( None , Some ( pubkey) ) ,
128+ SigningPubkey :: Explicit ( pubkey) => ( None , pubkey) ,
129129 SigningPubkey :: Derived ( expanded_key, nonce) => {
130130 let metadata_material = ( nonce, expanded_key. hmac_for_offer ( nonce) ) ;
131131 let signing_pubkey = expanded_key. signing_pubkey_for_offer ( nonce) ;
132- ( Some ( metadata_material) , Some ( signing_pubkey) )
132+ ( Some ( metadata_material) , signing_pubkey)
133133 } ,
134134 } ;
135135 let offer = OfferContents {
@@ -159,9 +159,10 @@ impl OfferBuilder {
159159 /// Sets the [`Offer::metadata`] to the given bytes.
160160 ///
161161 /// Successive calls to this method will override the previous setting. Errors if the builder
162- /// was constructed with [`SigningPubkey::Derived`].
162+ /// was constructed with [`SigningPubkey::Derived`] or if [`OfferBuilder::metadata_derived`] was
163+ /// called.
163164 pub fn metadata ( mut self , metadata : Vec < u8 > ) -> Result < Self , SemanticError > {
164- if self . offer . signing_pubkey . is_none ( ) {
165+ if self . metadata_material . is_some ( ) {
165166 return Err ( SemanticError :: UnexpectedMetadata ) ;
166167 }
167168
@@ -267,10 +268,6 @@ impl OfferBuilder {
267268 self . offer . metadata = Some ( metadata) ;
268269 }
269270
270- if self . offer . signing_pubkey . is_none ( ) {
271- return Err ( SemanticError :: MissingSigningPubkey ) ;
272- }
273-
274271 let mut bytes = Vec :: new ( ) ;
275272 self . offer . write ( & mut bytes) . unwrap ( ) ;
276273
@@ -332,7 +329,7 @@ pub(super) struct OfferContents {
332329 issuer : Option < String > ,
333330 paths : Option < Vec < BlindedPath > > ,
334331 supported_quantity : Quantity ,
335- signing_pubkey : Option < PublicKey > ,
332+ signing_pubkey : PublicKey ,
336333}
337334
338335impl Offer {
@@ -546,7 +543,7 @@ impl OfferContents {
546543 }
547544
548545 pub ( super ) fn signing_pubkey ( & self ) -> PublicKey {
549- self . signing_pubkey . unwrap ( )
546+ self . signing_pubkey
550547 }
551548
552549 /// Verifies that the offer metadata was produced from the offer in the TLV stream.
@@ -599,7 +596,7 @@ impl OfferContents {
599596 paths : self . paths . as_ref ( ) ,
600597 issuer : self . issuer . as_ref ( ) ,
601598 quantity_max : self . supported_quantity . to_tlv_record ( ) ,
602- node_id : self . signing_pubkey . as_ref ( ) ,
599+ node_id : Some ( & self . signing_pubkey ) ,
603600 }
604601 }
605602}
@@ -745,7 +742,7 @@ impl TryFrom<OfferTlvStream> for OfferContents {
745742
746743 let signing_pubkey = match node_id {
747744 None => return Err ( SemanticError :: MissingSigningPubkey ) ,
748- Some ( node_id) => Some ( node_id) ,
745+ Some ( node_id) => node_id,
749746 } ;
750747
751748 Ok ( OfferContents {
0 commit comments