1212use crate :: blinded_path:: BlindedPath ;
1313use crate :: io;
1414use crate :: ln:: features:: { Bolt12InvoiceFeatures , OfferFeatures } ;
15+ use crate :: ln:: inbound_payment:: ExpandedKey ;
1516use crate :: ln:: msgs:: DecodeError ;
1617use crate :: offers:: invoice:: {
1718 check_invoice_signing_pubkey, construct_payment_paths, filter_fallbacks, BlindedPathIter ,
@@ -94,9 +95,10 @@ impl<'a> StaticInvoiceBuilder<'a> {
9495 ///
9596 /// Unless [`StaticInvoiceBuilder::relative_expiry`] is set, the invoice will expire 24 hours
9697 /// after `created_at`.
97- pub fn for_offer_using_keys (
98+ pub fn for_offer_using_keys < T : secp256k1 :: Signing > (
9899 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 > ,
100102 ) -> Result < Self , Bolt12SemanticError > {
101103 if offer. chains ( ) . len ( ) > 1 {
102104 return Err ( Bolt12SemanticError :: UnexpectedChain ) ;
@@ -108,6 +110,13 @@ impl<'a> StaticInvoiceBuilder<'a> {
108110
109111 let offer_signing_pubkey =
110112 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+
111120 let signing_pubkey = keys. public_key ( ) ;
112121 if signing_pubkey != offer_signing_pubkey {
113122 return Err ( Bolt12SemanticError :: InvalidSigningPubkey ) ;
0 commit comments