@@ -106,7 +106,7 @@ impl OfferBuilder {
106106 let offer = OfferContents {
107107 chains : None , metadata : None , amount : None , description,
108108 features : OfferFeatures :: empty ( ) , absolute_expiry : None , issuer : None , paths : None ,
109- supported_quantity : Quantity :: one ( ) , signing_pubkey : Some ( signing_pubkey ) ,
109+ supported_quantity : Quantity :: one ( ) , signing_pubkey,
110110 } ;
111111 OfferBuilder { offer }
112112 }
@@ -263,7 +263,7 @@ pub(super) struct OfferContents {
263263 issuer : Option < String > ,
264264 paths : Option < Vec < BlindedPath > > ,
265265 supported_quantity : Quantity ,
266- signing_pubkey : Option < PublicKey > ,
266+ signing_pubkey : PublicKey ,
267267}
268268
269269impl Offer {
@@ -359,7 +359,7 @@ impl Offer {
359359
360360 /// The public key used by the recipient to sign invoices.
361361 pub fn signing_pubkey ( & self ) -> PublicKey {
362- self . contents . signing_pubkey . unwrap ( )
362+ self . contents . signing_pubkey
363363 }
364364
365365 /// Creates an [`InvoiceRequest`] for the offer with the given `metadata` and `payer_id`, which
@@ -497,7 +497,7 @@ impl OfferContents {
497497 paths : self . paths . as_ref ( ) ,
498498 issuer : self . issuer . as_ref ( ) ,
499499 quantity_max : self . supported_quantity . to_tlv_record ( ) ,
500- node_id : self . signing_pubkey . as_ref ( ) ,
500+ node_id : Some ( & self . signing_pubkey ) ,
501501 }
502502 }
503503}
@@ -634,13 +634,14 @@ impl TryFrom<OfferTlvStream> for OfferContents {
634634 Some ( n) => Quantity :: Bounded ( NonZeroU64 :: new ( n) . unwrap ( ) ) ,
635635 } ;
636636
637- if node_id. is_none ( ) {
638- return Err ( SemanticError :: MissingSigningPubkey ) ;
639- }
637+ let signing_pubkey = match node_id {
638+ None => return Err ( SemanticError :: MissingSigningPubkey ) ,
639+ Some ( node_id) => node_id,
640+ } ;
640641
641642 Ok ( OfferContents {
642643 chains, metadata, amount, description, features, absolute_expiry, issuer, paths,
643- supported_quantity, signing_pubkey : node_id ,
644+ supported_quantity, signing_pubkey,
644645 } )
645646 }
646647}
@@ -1126,11 +1127,13 @@ mod tests {
11261127 panic ! ( "error parsing offer: {:?}" , e) ;
11271128 }
11281129
1129- let mut builder = OfferBuilder :: new ( "foo" . into ( ) , pubkey ( 42 ) ) ;
1130- builder . offer . signing_pubkey = None ;
1130+ let mut tlv_stream = offer . as_tlv_stream ( ) ;
1131+ tlv_stream . node_id = None ;
11311132
1132- let offer = builder. build ( ) . unwrap ( ) ;
1133- match offer. to_string ( ) . parse :: < Offer > ( ) {
1133+ let mut encoded_offer = Vec :: new ( ) ;
1134+ tlv_stream. write ( & mut encoded_offer) . unwrap ( ) ;
1135+
1136+ match Offer :: try_from ( encoded_offer) {
11341137 Ok ( _) => panic ! ( "expected error" ) ,
11351138 Err ( e) => {
11361139 assert_eq ! ( e, ParseError :: InvalidSemantics ( SemanticError :: MissingSigningPubkey ) ) ;
0 commit comments