@@ -226,7 +226,7 @@ macro_rules! offer_explicit_metadata_builder_methods { (
226
226
offer: OfferContents {
227
227
chains: None , metadata: None , amount: None , description,
228
228
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 ) ,
230
230
} ,
231
231
metadata_strategy: core:: marker:: PhantomData ,
232
232
secp_ctx: None ,
@@ -265,7 +265,7 @@ macro_rules! offer_derived_metadata_builder_methods { ($secp_context: ty) => {
265
265
offer: OfferContents {
266
266
chains: None , metadata: Some ( metadata) , amount: None , description,
267
267
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) ,
269
269
} ,
270
270
metadata_strategy: core:: marker:: PhantomData ,
271
271
secp_ctx: Some ( secp_ctx) ,
@@ -391,7 +391,7 @@ macro_rules! offer_builder_methods { (
391
391
let ( derived_metadata, keys) = metadata. derive_from( tlv_stream, $self. secp_ctx) ;
392
392
metadata = derived_metadata;
393
393
if let Some ( keys) = keys {
394
- $self. offer. signing_pubkey = keys. public_key( ) ;
394
+ $self. offer. signing_pubkey = Some ( keys. public_key( ) ) ;
395
395
}
396
396
}
397
397
@@ -542,7 +542,7 @@ pub(super) struct OfferContents {
542
542
issuer : Option < String > ,
543
543
paths : Option < Vec < BlindedPath > > ,
544
544
supported_quantity : Quantity ,
545
- signing_pubkey : PublicKey ,
545
+ signing_pubkey : Option < PublicKey > ,
546
546
}
547
547
548
548
macro_rules! offer_accessors { ( $self: ident, $contents: expr) => {
@@ -604,7 +604,7 @@ macro_rules! offer_accessors { ($self: ident, $contents: expr) => {
604
604
}
605
605
606
606
/// 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 > {
608
608
$contents. signing_pubkey( )
609
609
}
610
610
} }
@@ -886,7 +886,7 @@ impl OfferContents {
886
886
}
887
887
}
888
888
889
- pub ( super ) fn signing_pubkey ( & self ) -> PublicKey {
889
+ pub ( super ) fn signing_pubkey ( & self ) -> Option < PublicKey > {
890
890
self . signing_pubkey
891
891
}
892
892
@@ -905,8 +905,12 @@ impl OfferContents {
905
905
_ => true ,
906
906
}
907
907
} ) ;
908
+ let signing_pubkey = match self . signing_pubkey ( ) {
909
+ Some ( signing_pubkey) => signing_pubkey,
910
+ None => return Err ( ( ) ) ,
911
+ } ;
908
912
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
910
914
) ?;
911
915
912
916
let offer_id = OfferId :: from_valid_invreq_tlv_stream ( bytes) ;
@@ -941,7 +945,7 @@ impl OfferContents {
941
945
paths : self . paths . as_ref ( ) ,
942
946
issuer : self . issuer . as_ref ( ) ,
943
947
quantity_max : self . supported_quantity . to_tlv_record ( ) ,
944
- node_id : Some ( & self . signing_pubkey ) ,
948
+ node_id : self . signing_pubkey . as_ref ( ) ,
945
949
}
946
950
}
947
951
}
@@ -1091,7 +1095,7 @@ impl TryFrom<OfferTlvStream> for OfferContents {
1091
1095
1092
1096
let signing_pubkey = match node_id {
1093
1097
None => return Err ( Bolt12SemanticError :: MissingSigningPubkey ) ,
1094
- Some ( node_id) => node_id,
1098
+ Some ( node_id) => Some ( node_id) ,
1095
1099
} ;
1096
1100
1097
1101
Ok ( OfferContents {
@@ -1154,7 +1158,7 @@ mod tests {
1154
1158
assert_eq ! ( offer. paths( ) , & [ ] ) ;
1155
1159
assert_eq ! ( offer. issuer( ) , None ) ;
1156
1160
assert_eq ! ( offer. supported_quantity( ) , Quantity :: One ) ;
1157
- assert_eq ! ( offer. signing_pubkey( ) , pubkey( 42 ) ) ;
1161
+ assert_eq ! ( offer. signing_pubkey( ) , Some ( pubkey( 42 ) ) ) ;
1158
1162
1159
1163
assert_eq ! (
1160
1164
offer. as_tlv_stream( ) ,
@@ -1251,7 +1255,7 @@ mod tests {
1251
1255
:: deriving_signing_pubkey ( desc, node_id, & expanded_key, & entropy, & secp_ctx)
1252
1256
. amount_msats ( 1000 )
1253
1257
. build ( ) . unwrap ( ) ;
1254
- assert_eq ! ( offer. signing_pubkey( ) , node_id) ;
1258
+ assert_eq ! ( offer. signing_pubkey( ) , Some ( node_id) ) ;
1255
1259
1256
1260
let invoice_request = offer. request_invoice ( vec ! [ 1 ; 32 ] , payer_pubkey ( ) ) . unwrap ( )
1257
1261
. build ( ) . unwrap ( )
@@ -1313,7 +1317,7 @@ mod tests {
1313
1317
. amount_msats ( 1000 )
1314
1318
. path ( blinded_path)
1315
1319
. build ( ) . unwrap ( ) ;
1316
- assert_ne ! ( offer. signing_pubkey( ) , node_id) ;
1320
+ assert_ne ! ( offer. signing_pubkey( ) , Some ( node_id) ) ;
1317
1321
1318
1322
let invoice_request = offer. request_invoice ( vec ! [ 1 ; 32 ] , payer_pubkey ( ) ) . unwrap ( )
1319
1323
. build ( ) . unwrap ( )
@@ -1471,7 +1475,7 @@ mod tests {
1471
1475
. unwrap ( ) ;
1472
1476
let tlv_stream = offer. as_tlv_stream ( ) ;
1473
1477
assert_eq ! ( offer. paths( ) , paths. as_slice( ) ) ;
1474
- assert_eq ! ( offer. signing_pubkey( ) , pubkey( 42 ) ) ;
1478
+ assert_eq ! ( offer. signing_pubkey( ) , Some ( pubkey( 42 ) ) ) ;
1475
1479
assert_ne ! ( pubkey( 42 ) , pubkey( 44 ) ) ;
1476
1480
assert_eq ! ( tlv_stream. paths, Some ( & paths) ) ;
1477
1481
assert_eq ! ( tlv_stream. node_id, Some ( & pubkey( 42 ) ) ) ;
0 commit comments