@@ -106,7 +106,7 @@ impl OfferBuilder {
106
106
let offer = OfferContents {
107
107
chains : None , metadata : None , amount : None , description,
108
108
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,
110
110
} ;
111
111
OfferBuilder { offer }
112
112
}
@@ -263,7 +263,7 @@ pub(super) struct OfferContents {
263
263
issuer : Option < String > ,
264
264
paths : Option < Vec < BlindedPath > > ,
265
265
supported_quantity : Quantity ,
266
- signing_pubkey : Option < PublicKey > ,
266
+ signing_pubkey : PublicKey ,
267
267
}
268
268
269
269
impl Offer {
@@ -359,7 +359,7 @@ impl Offer {
359
359
360
360
/// The public key used by the recipient to sign invoices.
361
361
pub fn signing_pubkey ( & self ) -> PublicKey {
362
- self . contents . signing_pubkey . unwrap ( )
362
+ self . contents . signing_pubkey
363
363
}
364
364
365
365
/// Creates an [`InvoiceRequest`] for the offer with the given `metadata` and `payer_id`, which
@@ -497,7 +497,7 @@ impl OfferContents {
497
497
paths : self . paths . as_ref ( ) ,
498
498
issuer : self . issuer . as_ref ( ) ,
499
499
quantity_max : self . supported_quantity . to_tlv_record ( ) ,
500
- node_id : self . signing_pubkey . as_ref ( ) ,
500
+ node_id : Some ( & self . signing_pubkey ) ,
501
501
}
502
502
}
503
503
}
@@ -634,13 +634,14 @@ impl TryFrom<OfferTlvStream> for OfferContents {
634
634
Some ( n) => Quantity :: Bounded ( NonZeroU64 :: new ( n) . unwrap ( ) ) ,
635
635
} ;
636
636
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
+ } ;
640
641
641
642
Ok ( OfferContents {
642
643
chains, metadata, amount, description, features, absolute_expiry, issuer, paths,
643
- supported_quantity, signing_pubkey : node_id ,
644
+ supported_quantity, signing_pubkey,
644
645
} )
645
646
}
646
647
}
@@ -1126,11 +1127,13 @@ mod tests {
1126
1127
panic ! ( "error parsing offer: {:?}" , e) ;
1127
1128
}
1128
1129
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 ;
1131
1132
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) {
1134
1137
Ok ( _) => panic ! ( "expected error" ) ,
1135
1138
Err ( e) => {
1136
1139
assert_eq ! ( e, ParseError :: InvalidSemantics ( SemanticError :: MissingSigningPubkey ) ) ;
0 commit comments