@@ -226,7 +226,7 @@ macro_rules! offer_explicit_metadata_builder_methods { (
226226 offer: OfferContents {
227227 chains: None , metadata: None , amount: None , description,
228228 features: OfferFeatures :: empty( ) , absolute_expiry: None , issuer: None , paths: None ,
229- supported_quantity: Quantity :: One , signing_pubkey,
229+ supported_quantity: Quantity :: One , signing_pubkey: Some ( signing_pubkey ) ,
230230 } ,
231231 metadata_strategy: core:: marker:: PhantomData ,
232232 secp_ctx: None ,
@@ -265,7 +265,7 @@ macro_rules! offer_derived_metadata_builder_methods { ($secp_context: ty) => {
265265 offer: OfferContents {
266266 chains: None , metadata: Some ( metadata) , amount: None , description,
267267 features: OfferFeatures :: empty( ) , absolute_expiry: None , issuer: None , paths: None ,
268- supported_quantity: Quantity :: One , signing_pubkey: node_id,
268+ supported_quantity: Quantity :: One , signing_pubkey: Some ( node_id) ,
269269 } ,
270270 metadata_strategy: core:: marker:: PhantomData ,
271271 secp_ctx: Some ( secp_ctx) ,
@@ -391,7 +391,7 @@ macro_rules! offer_builder_methods { (
391391 let ( derived_metadata, keys) = metadata. derive_from( tlv_stream, $self. secp_ctx) ;
392392 metadata = derived_metadata;
393393 if let Some ( keys) = keys {
394- $self. offer. signing_pubkey = keys. public_key( ) ;
394+ $self. offer. signing_pubkey = Some ( keys. public_key( ) ) ;
395395 }
396396 }
397397
@@ -542,7 +542,7 @@ pub(super) struct OfferContents {
542542 issuer : Option < String > ,
543543 paths : Option < Vec < BlindedPath > > ,
544544 supported_quantity : Quantity ,
545- signing_pubkey : PublicKey ,
545+ signing_pubkey : Option < PublicKey > ,
546546}
547547
548548macro_rules! offer_accessors { ( $self: ident, $contents: expr) => {
@@ -604,7 +604,7 @@ macro_rules! offer_accessors { ($self: ident, $contents: expr) => {
604604 }
605605
606606 /// The public key used by the recipient to sign invoices.
607- pub fn signing_pubkey( & $self) -> bitcoin:: secp256k1:: PublicKey {
607+ pub fn signing_pubkey( & $self) -> Option < bitcoin:: secp256k1:: PublicKey > {
608608 $contents. signing_pubkey( )
609609 }
610610} }
@@ -886,7 +886,7 @@ impl OfferContents {
886886 }
887887 }
888888
889- pub ( super ) fn signing_pubkey ( & self ) -> PublicKey {
889+ pub ( super ) fn signing_pubkey ( & self ) -> Option < PublicKey > {
890890 self . signing_pubkey
891891 }
892892
@@ -905,8 +905,12 @@ impl OfferContents {
905905 _ => true ,
906906 }
907907 } ) ;
908+ let signing_pubkey = match self . signing_pubkey ( ) {
909+ Some ( signing_pubkey) => signing_pubkey,
910+ None => return Err ( ( ) ) ,
911+ } ;
908912 let keys = signer:: verify_recipient_metadata (
909- metadata, key, IV_BYTES , self . signing_pubkey ( ) , tlv_stream, secp_ctx
913+ metadata, key, IV_BYTES , signing_pubkey, tlv_stream, secp_ctx
910914 ) ?;
911915
912916 let offer_id = OfferId :: from_valid_invreq_tlv_stream ( bytes) ;
@@ -941,7 +945,7 @@ impl OfferContents {
941945 paths : self . paths . as_ref ( ) ,
942946 issuer : self . issuer . as_ref ( ) ,
943947 quantity_max : self . supported_quantity . to_tlv_record ( ) ,
944- node_id : Some ( & self . signing_pubkey ) ,
948+ node_id : self . signing_pubkey . as_ref ( ) ,
945949 }
946950 }
947951}
@@ -1091,7 +1095,7 @@ impl TryFrom<OfferTlvStream> for OfferContents {
10911095
10921096 let signing_pubkey = match node_id {
10931097 None => return Err ( Bolt12SemanticError :: MissingSigningPubkey ) ,
1094- Some ( node_id) => node_id,
1098+ Some ( node_id) => Some ( node_id) ,
10951099 } ;
10961100
10971101 Ok ( OfferContents {
@@ -1154,7 +1158,7 @@ mod tests {
11541158 assert_eq ! ( offer. paths( ) , & [ ] ) ;
11551159 assert_eq ! ( offer. issuer( ) , None ) ;
11561160 assert_eq ! ( offer. supported_quantity( ) , Quantity :: One ) ;
1157- assert_eq ! ( offer. signing_pubkey( ) , pubkey( 42 ) ) ;
1161+ assert_eq ! ( offer. signing_pubkey( ) , Some ( pubkey( 42 ) ) ) ;
11581162
11591163 assert_eq ! (
11601164 offer. as_tlv_stream( ) ,
@@ -1251,7 +1255,7 @@ mod tests {
12511255 :: deriving_signing_pubkey ( desc, node_id, & expanded_key, & entropy, & secp_ctx)
12521256 . amount_msats ( 1000 )
12531257 . build ( ) . unwrap ( ) ;
1254- assert_eq ! ( offer. signing_pubkey( ) , node_id) ;
1258+ assert_eq ! ( offer. signing_pubkey( ) , Some ( node_id) ) ;
12551259
12561260 let invoice_request = offer. request_invoice ( vec ! [ 1 ; 32 ] , payer_pubkey ( ) ) . unwrap ( )
12571261 . build ( ) . unwrap ( )
@@ -1313,7 +1317,7 @@ mod tests {
13131317 . amount_msats ( 1000 )
13141318 . path ( blinded_path)
13151319 . build ( ) . unwrap ( ) ;
1316- assert_ne ! ( offer. signing_pubkey( ) , node_id) ;
1320+ assert_ne ! ( offer. signing_pubkey( ) , Some ( node_id) ) ;
13171321
13181322 let invoice_request = offer. request_invoice ( vec ! [ 1 ; 32 ] , payer_pubkey ( ) ) . unwrap ( )
13191323 . build ( ) . unwrap ( )
@@ -1471,7 +1475,7 @@ mod tests {
14711475 . unwrap ( ) ;
14721476 let tlv_stream = offer. as_tlv_stream ( ) ;
14731477 assert_eq ! ( offer. paths( ) , paths. as_slice( ) ) ;
1474- assert_eq ! ( offer. signing_pubkey( ) , pubkey( 42 ) ) ;
1478+ assert_eq ! ( offer. signing_pubkey( ) , Some ( pubkey( 42 ) ) ) ;
14751479 assert_ne ! ( pubkey( 42 ) , pubkey( 44 ) ) ;
14761480 assert_eq ! ( tlv_stream. paths, Some ( & paths) ) ;
14771481 assert_eq ! ( tlv_stream. node_id, Some ( & pubkey( 42 ) ) ) ;
0 commit comments