12
12
use crate :: blinded_path:: BlindedPath ;
13
13
use crate :: io;
14
14
use crate :: ln:: features:: { Bolt12InvoiceFeatures , OfferFeatures } ;
15
+ use crate :: ln:: inbound_payment:: ExpandedKey ;
15
16
use crate :: ln:: msgs:: DecodeError ;
16
17
use crate :: offers:: invoice:: {
17
18
check_invoice_signing_pubkey, construct_payment_paths, filter_fallbacks, BlindedPathIter ,
@@ -94,9 +95,10 @@ impl<'a> StaticInvoiceBuilder<'a> {
94
95
///
95
96
/// Unless [`StaticInvoiceBuilder::relative_expiry`] is set, the invoice will expire 24 hours
96
97
/// after `created_at`.
97
- pub fn for_offer_using_keys (
98
+ pub fn for_offer_using_keys < T : secp256k1 :: Signing > (
98
99
offer : & ' a Offer , payment_paths : Vec < ( BlindedPayInfo , BlindedPath ) > ,
99
- message_paths : Vec < BlindedPath > , created_at : Duration , keys : Keypair ,
100
+ message_paths : Vec < BlindedPath > , created_at : Duration , expanded_key : & ExpandedKey ,
101
+ secp_ctx : & Secp256k1 < T > ,
100
102
) -> Result < Self , Bolt12SemanticError > {
101
103
if offer. chains ( ) . len ( ) > 1 {
102
104
return Err ( Bolt12SemanticError :: UnexpectedChain ) ;
@@ -108,6 +110,13 @@ impl<'a> StaticInvoiceBuilder<'a> {
108
110
109
111
let offer_signing_pubkey =
110
112
offer. signing_pubkey ( ) . ok_or ( Bolt12SemanticError :: MissingSigningPubkey ) ?;
113
+
114
+ let keys = offer
115
+ . verify ( & expanded_key, & secp_ctx)
116
+ . map_err ( |( ) | Bolt12SemanticError :: InvalidMetadata ) ?
117
+ . 1
118
+ . ok_or ( Bolt12SemanticError :: MissingSigningPubkey ) ?;
119
+
111
120
let signing_pubkey = keys. public_key ( ) ;
112
121
if signing_pubkey != offer_signing_pubkey {
113
122
return Err ( Bolt12SemanticError :: InvalidSigningPubkey ) ;
0 commit comments