@@ -24,7 +24,6 @@ use bitcoin::sighash::EcdsaSighashType;
24
24
use bitcoin:: transaction:: Version ;
25
25
use bitcoin:: transaction:: { Transaction , TxIn , TxOut } ;
26
26
27
- use bech32:: u5;
28
27
use bitcoin:: hashes:: sha256:: Hash as Sha256 ;
29
28
use bitcoin:: hashes:: sha256d:: Hash as Sha256dHash ;
30
29
use bitcoin:: hashes:: { Hash , HashEngine } ;
@@ -37,6 +36,8 @@ use bitcoin::secp256k1::All;
37
36
use bitcoin:: secp256k1:: { Keypair , PublicKey , Scalar , Secp256k1 , SecretKey , Signing } ;
38
37
use bitcoin:: { secp256k1, Psbt , Sequence , Txid , WPubkeyHash , Witness } ;
39
38
39
+ use lightning_invoice:: RawBolt11Invoice ;
40
+
40
41
use crate :: chain:: transaction:: OutPoint ;
41
42
use crate :: crypto:: utils:: { hkdf_extract_expand_twice, sign, sign_with_aux_rand} ;
42
43
use crate :: ln:: chan_utils;
@@ -69,7 +70,6 @@ use crate::sign::ecdsa::EcdsaChannelSigner;
69
70
#[ cfg( taproot) ]
70
71
use crate :: sign:: taproot:: TaprootChannelSigner ;
71
72
use crate :: util:: atomic_counter:: AtomicCounter ;
72
- use crate :: util:: invoice:: construct_invoice_preimage;
73
73
use core:: convert:: TryInto ;
74
74
use core:: ops:: Deref ;
75
75
use core:: sync:: atomic:: { AtomicUsize , Ordering } ;
@@ -867,7 +867,7 @@ pub trait NodeSigner {
867
867
///
868
868
/// Errors if the [`Recipient`] variant is not supported by the implementation.
869
869
fn sign_invoice (
870
- & self , hrp_bytes : & [ u8 ] , invoice_data : & [ u5 ] , recipient : Recipient ,
870
+ & self , invoice : & RawBolt11Invoice , recipient : Recipient ,
871
871
) -> Result < RecoverableSignature , ( ) > ;
872
872
873
873
/// Signs the [`TaggedHash`] of a BOLT 12 invoice request.
@@ -2174,17 +2174,14 @@ impl NodeSigner for KeysManager {
2174
2174
}
2175
2175
2176
2176
fn sign_invoice (
2177
- & self , hrp_bytes : & [ u8 ] , invoice_data : & [ u5 ] , recipient : Recipient ,
2177
+ & self , invoice : & RawBolt11Invoice , recipient : Recipient ,
2178
2178
) -> Result < RecoverableSignature , ( ) > {
2179
- let preimage = construct_invoice_preimage ( & hrp_bytes , & invoice_data ) ;
2179
+ let hash = invoice . signable_hash ( ) ;
2180
2180
let secret = match recipient {
2181
2181
Recipient :: Node => Ok ( & self . node_secret ) ,
2182
2182
Recipient :: PhantomNode => Err ( ( ) ) ,
2183
2183
} ?;
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) )
2188
2185
}
2189
2186
2190
2187
fn sign_bolt12_invoice_request (
@@ -2352,17 +2349,14 @@ impl NodeSigner for PhantomKeysManager {
2352
2349
}
2353
2350
2354
2351
fn sign_invoice (
2355
- & self , hrp_bytes : & [ u8 ] , invoice_data : & [ u5 ] , recipient : Recipient ,
2352
+ & self , invoice : & RawBolt11Invoice , recipient : Recipient ,
2356
2353
) -> Result < RecoverableSignature , ( ) > {
2357
- let preimage = construct_invoice_preimage ( & hrp_bytes , & invoice_data ) ;
2354
+ let hash = invoice . signable_hash ( ) ;
2358
2355
let secret = match recipient {
2359
2356
Recipient :: Node => & self . inner . node_secret ,
2360
2357
Recipient :: PhantomNode => & self . phantom_secret ,
2361
2358
} ;
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) )
2366
2360
}
2367
2361
2368
2362
fn sign_bolt12_invoice_request (
0 commit comments