@@ -122,11 +122,11 @@ impl OfferBuilder {
122
122
/// Use a different pubkey per offer to avoid correlating offers.
123
123
pub fn new ( description : String , signing_pubkey : SigningPubkey ) -> Self {
124
124
let ( metadata_material, signing_pubkey) = match signing_pubkey {
125
- SigningPubkey :: Explicit ( pubkey) => ( None , Some ( pubkey) ) ,
125
+ SigningPubkey :: Explicit ( pubkey) => ( None , pubkey) ,
126
126
SigningPubkey :: Derived ( expanded_key, nonce) => {
127
127
let metadata_material = ( nonce, expanded_key. hmac_for_offer ( nonce) ) ;
128
128
let signing_pubkey = expanded_key. signing_pubkey_for_offer ( nonce) ;
129
- ( Some ( metadata_material) , Some ( signing_pubkey) )
129
+ ( Some ( metadata_material) , signing_pubkey)
130
130
} ,
131
131
} ;
132
132
let offer = OfferContents {
@@ -156,9 +156,10 @@ impl OfferBuilder {
156
156
/// Sets the [`Offer::metadata`] to the given bytes.
157
157
///
158
158
/// 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.
160
161
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 ( ) {
162
163
return Err ( SemanticError :: UnexpectedMetadata ) ;
163
164
}
164
165
@@ -263,10 +264,6 @@ impl OfferBuilder {
263
264
self . offer . metadata = Some ( metadata) ;
264
265
}
265
266
266
- if self . offer . signing_pubkey . is_none ( ) {
267
- return Err ( SemanticError :: MissingSigningPubkey ) ;
268
- }
269
-
270
267
let mut bytes = Vec :: new ( ) ;
271
268
self . offer . write ( & mut bytes) . unwrap ( ) ;
272
269
@@ -328,7 +325,7 @@ pub(super) struct OfferContents {
328
325
issuer : Option < String > ,
329
326
paths : Option < Vec < BlindedPath > > ,
330
327
supported_quantity : Quantity ,
331
- signing_pubkey : Option < PublicKey > ,
328
+ signing_pubkey : PublicKey ,
332
329
}
333
330
334
331
impl Offer {
@@ -542,7 +539,7 @@ impl OfferContents {
542
539
}
543
540
544
541
pub ( super ) fn signing_pubkey ( & self ) -> PublicKey {
545
- self . signing_pubkey . unwrap ( )
542
+ self . signing_pubkey
546
543
}
547
544
548
545
/// Verifies that the offer metadata was produced from the offer in the TLV stream.
@@ -595,7 +592,7 @@ impl OfferContents {
595
592
paths : self . paths . as_ref ( ) ,
596
593
issuer : self . issuer . as_ref ( ) ,
597
594
quantity_max : self . supported_quantity . to_tlv_record ( ) ,
598
- node_id : self . signing_pubkey . as_ref ( ) ,
595
+ node_id : Some ( & self . signing_pubkey ) ,
599
596
}
600
597
}
601
598
}
@@ -740,7 +737,7 @@ impl TryFrom<OfferTlvStream> for OfferContents {
740
737
741
738
let signing_pubkey = match node_id {
742
739
None => return Err ( SemanticError :: MissingSigningPubkey ) ,
743
- Some ( node_id) => Some ( node_id) ,
740
+ Some ( node_id) => node_id,
744
741
} ;
745
742
746
743
Ok ( OfferContents {
0 commit comments