@@ -24,7 +24,6 @@ use bitcoin::sighash::EcdsaSighashType;
2424use bitcoin:: transaction:: Version ;
2525use bitcoin:: transaction:: { Transaction , TxIn , TxOut } ;
2626
27- use bech32:: u5;
2827use bitcoin:: hashes:: sha256:: Hash as Sha256 ;
2928use bitcoin:: hashes:: sha256d:: Hash as Sha256dHash ;
3029use bitcoin:: hashes:: { Hash , HashEngine } ;
@@ -37,6 +36,8 @@ use bitcoin::secp256k1::All;
3736use bitcoin:: secp256k1:: { Keypair , PublicKey , Scalar , Secp256k1 , SecretKey , Signing } ;
3837use bitcoin:: { secp256k1, Psbt , Sequence , Txid , WPubkeyHash , Witness } ;
3938
39+ use lightning_invoice:: RawBolt11Invoice ;
40+
4041use crate :: chain:: transaction:: OutPoint ;
4142use crate :: crypto:: utils:: { hkdf_extract_expand_twice, sign, sign_with_aux_rand} ;
4243use crate :: ln:: chan_utils;
@@ -69,7 +70,6 @@ use crate::sign::ecdsa::EcdsaChannelSigner;
6970#[ cfg( taproot) ]
7071use crate :: sign:: taproot:: TaprootChannelSigner ;
7172use crate :: util:: atomic_counter:: AtomicCounter ;
72- use crate :: util:: invoice:: construct_invoice_preimage;
7373use core:: convert:: TryInto ;
7474use core:: ops:: Deref ;
7575use core:: sync:: atomic:: { AtomicUsize , Ordering } ;
@@ -867,7 +867,7 @@ pub trait NodeSigner {
867867 ///
868868 /// Errors if the [`Recipient`] variant is not supported by the implementation.
869869 fn sign_invoice (
870- & self , hrp_bytes : & [ u8 ] , invoice_data : & [ u5 ] , recipient : Recipient ,
870+ & self , invoice : & RawBolt11Invoice , recipient : Recipient ,
871871 ) -> Result < RecoverableSignature , ( ) > ;
872872
873873 /// Signs the [`TaggedHash`] of a BOLT 12 invoice request.
@@ -2174,17 +2174,14 @@ impl NodeSigner for KeysManager {
21742174 }
21752175
21762176 fn sign_invoice (
2177- & self , hrp_bytes : & [ u8 ] , invoice_data : & [ u5 ] , recipient : Recipient ,
2177+ & self , invoice : & RawBolt11Invoice , recipient : Recipient ,
21782178 ) -> Result < RecoverableSignature , ( ) > {
2179- let preimage = construct_invoice_preimage ( & hrp_bytes , & invoice_data ) ;
2179+ let hash = invoice . signable_hash ( ) ;
21802180 let secret = match recipient {
21812181 Recipient :: Node => Ok ( & self . node_secret ) ,
21822182 Recipient :: PhantomNode => Err ( ( ) ) ,
21832183 } ?;
2184- Ok ( self . secp_ctx . sign_ecdsa_recoverable (
2185- & hash_to_message ! ( & Sha256 :: hash( & preimage) . to_byte_array( ) ) ,
2186- secret,
2187- ) )
2184+ Ok ( self . secp_ctx . sign_ecdsa_recoverable ( & hash_to_message ! ( & hash) , secret) )
21882185 }
21892186
21902187 fn sign_bolt12_invoice_request (
@@ -2352,17 +2349,14 @@ impl NodeSigner for PhantomKeysManager {
23522349 }
23532350
23542351 fn sign_invoice (
2355- & self , hrp_bytes : & [ u8 ] , invoice_data : & [ u5 ] , recipient : Recipient ,
2352+ & self , invoice : & RawBolt11Invoice , recipient : Recipient ,
23562353 ) -> Result < RecoverableSignature , ( ) > {
2357- let preimage = construct_invoice_preimage ( & hrp_bytes , & invoice_data ) ;
2354+ let hash = invoice . signable_hash ( ) ;
23582355 let secret = match recipient {
23592356 Recipient :: Node => & self . inner . node_secret ,
23602357 Recipient :: PhantomNode => & self . phantom_secret ,
23612358 } ;
2362- Ok ( self . inner . secp_ctx . sign_ecdsa_recoverable (
2363- & hash_to_message ! ( & Sha256 :: hash( & preimage) . to_byte_array( ) ) ,
2364- secret,
2365- ) )
2359+ Ok ( self . inner . secp_ctx . sign_ecdsa_recoverable ( & hash_to_message ! ( & hash) , secret) )
23662360 }
23672361
23682362 fn sign_bolt12_invoice_request (
0 commit comments