You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/ln/channel.rs
+16-16Lines changed: 16 additions & 16 deletions
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,7 @@ use bitcoin_hashes::sha256::Hash as Sha256;
11
11
use bitcoin_hashes::hash160::HashasHash160;
12
12
13
13
use secp256k1::key::{PublicKey,SecretKey};
14
-
use secp256k1::{Secp256k1,Message,Signature};
14
+
use secp256k1::{Secp256k1,Signature};
15
15
use secp256k1;
16
16
17
17
use ln::msgs;
@@ -1067,7 +1067,7 @@ impl Channel {
1067
1067
1068
1068
let funding_redeemscript = self.get_funding_redeemscript();
1069
1069
1070
-
let sighash = Message::from_slice(&bip143::SighashComponents::new(&tx).sighash_all(&tx.input[0],&funding_redeemscript,self.channel_value_satoshis)[..]).unwrap();
1070
+
let sighash = hash_to_message!(&bip143::SighashComponents::new(&tx).sighash_all(&tx.input[0],&funding_redeemscript,self.channel_value_satoshis)[..]);
1071
1071
let our_sig = self.secp_ctx.sign(&sighash,&self.local_keys.funding_key);
1072
1072
1073
1073
tx.input[0].witness.push(Vec::new());// First is the multisig dummy
@@ -1104,7 +1104,7 @@ impl Channel {
1104
1104
let htlc_redeemscript = chan_utils::get_htlc_redeemscript(&htlc,&keys);
1105
1105
1106
1106
let our_htlc_key = secp_check!(chan_utils::derive_private_key(&self.secp_ctx,&keys.per_commitment_point,&self.local_keys.htlc_base_key),"Derived invalid key, peer is maliciously selecting parameters");
1107
-
let sighash = Message::from_slice(&bip143::SighashComponents::new(&tx).sighash_all(&tx.input[0],&htlc_redeemscript, htlc.amount_msat / 1000)[..]).unwrap();
1107
+
let sighash = hash_to_message!(&bip143::SighashComponents::new(&tx).sighash_all(&tx.input[0],&htlc_redeemscript, htlc.amount_msat / 1000)[..]);
1108
1108
let is_local_tx = PublicKey::from_secret_key(&self.secp_ctx,&our_htlc_key) == keys.a_htlc_key;
let local_sighash = Message::from_slice(&bip143::SighashComponents::new(&local_initial_commitment_tx).sighash_all(&local_initial_commitment_tx.input[0],&funding_script,self.channel_value_satoshis)[..]).unwrap();
1411
+
let local_sighash = hash_to_message!(&bip143::SighashComponents::new(&local_initial_commitment_tx).sighash_all(&local_initial_commitment_tx.input[0],&funding_script,self.channel_value_satoshis)[..]);
1412
1412
1413
1413
// They sign the "local" commitment transaction...
1414
1414
secp_check!(self.secp_ctx.verify(&local_sighash,&sig,&self.their_funding_pubkey.unwrap()),"Invalid funding_created signature from peer");
@@ -1418,7 +1418,7 @@ impl Channel {
1418
1418
1419
1419
let remote_keys = self.build_remote_transaction_keys()?;
1420
1420
let remote_initial_commitment_tx = self.build_commitment_transaction(self.cur_remote_commitment_transaction_number,&remote_keys,false,false,self.feerate_per_kw).0;
1421
-
let remote_sighash = Message::from_slice(&bip143::SighashComponents::new(&remote_initial_commitment_tx).sighash_all(&remote_initial_commitment_tx.input[0],&funding_script,self.channel_value_satoshis)[..]).unwrap();
1421
+
let remote_sighash = hash_to_message!(&bip143::SighashComponents::new(&remote_initial_commitment_tx).sighash_all(&remote_initial_commitment_tx.input[0],&funding_script,self.channel_value_satoshis)[..]);
1422
1422
1423
1423
// We sign the "remote" commitment transaction, allowing them to broadcast the tx if they wish.
let local_sighash = Message::from_slice(&bip143::SighashComponents::new(&local_initial_commitment_tx).sighash_all(&local_initial_commitment_tx.input[0],&funding_script,self.channel_value_satoshis)[..]).unwrap();
1490
+
let local_sighash = hash_to_message!(&bip143::SighashComponents::new(&local_initial_commitment_tx).sighash_all(&local_initial_commitment_tx.input[0],&funding_script,self.channel_value_satoshis)[..]);
1491
1491
1492
1492
// They sign the "local" commitment transaction, allowing us to broadcast the tx if we wish.
1493
1493
secp_check!(self.secp_ctx.verify(&local_sighash,&msg.signature,&self.their_funding_pubkey.unwrap()),"Invalid funding_signed signature from peer");
@@ -1699,7 +1699,7 @@ impl Channel {
1699
1699
(commitment_tx.0, commitment_tx.1, htlcs_cloned)
1700
1700
};
1701
1701
let local_commitment_txid = local_commitment_tx.0.txid();
1702
-
let local_sighash = Message::from_slice(&bip143::SighashComponents::new(&local_commitment_tx.0).sighash_all(&local_commitment_tx.0.input[0],&funding_script,self.channel_value_satoshis)[..]).unwrap();
1702
+
let local_sighash = hash_to_message!(&bip143::SighashComponents::new(&local_commitment_tx.0).sighash_all(&local_commitment_tx.0.input[0],&funding_script,self.channel_value_satoshis)[..]);
1703
1703
secp_check!(self.secp_ctx.verify(&local_sighash,&msg.signature,&self.their_funding_pubkey.unwrap()),"Invalid commitment tx signature from peer");
1704
1704
1705
1705
//If channel fee was updated by funder confirm funder can afford the new fee rate when applied to the current local commitment transaction
let funding_redeemscript = self.get_funding_redeemscript();
2459
-
let sighash = Message::from_slice(&bip143::SighashComponents::new(&closing_tx).sighash_all(&closing_tx.input[0],&funding_redeemscript,self.channel_value_satoshis)[..]).unwrap();
2459
+
let sighash = hash_to_message!(&bip143::SighashComponents::new(&closing_tx).sighash_all(&closing_tx.input[0],&funding_redeemscript,self.channel_value_satoshis)[..]);
let remote_keys = self.build_remote_transaction_keys()?;
2995
2995
let remote_initial_commitment_tx = self.build_commitment_transaction(self.cur_remote_commitment_transaction_number,&remote_keys,false,false,self.feerate_per_kw).0;
2996
-
let remote_sighash = Message::from_slice(&bip143::SighashComponents::new(&remote_initial_commitment_tx).sighash_all(&remote_initial_commitment_tx.input[0],&funding_script,self.channel_value_satoshis)[..]).unwrap();
2996
+
let remote_sighash = hash_to_message!(&bip143::SighashComponents::new(&remote_initial_commitment_tx).sighash_all(&remote_initial_commitment_tx.input[0],&funding_script,self.channel_value_satoshis)[..]);
2997
2997
2998
2998
// We sign the "remote" commitment transaction, allowing them to broadcast the tx if they wish.
let msghash = Message::from_slice(&Sha256dHash::from_data(&msg.encode()[..])[..]).unwrap();
3083
+
let msghash = hash_to_message!(&Sha256dHash::from_data(&msg.encode()[..])[..]);
3084
3084
let sig = self.secp_ctx.sign(&msghash,&self.local_keys.funding_key);
3085
3085
3086
3086
Ok((msg, sig))
@@ -3295,15 +3295,15 @@ impl Channel {
3295
3295
let remote_keys = self.build_remote_transaction_keys()?;
3296
3296
let remote_commitment_tx = self.build_commitment_transaction(self.cur_remote_commitment_transaction_number,&remote_keys,false,true, feerate_per_kw);
3297
3297
let remote_commitment_txid = remote_commitment_tx.0.txid();
3298
-
let remote_sighash = Message::from_slice(&bip143::SighashComponents::new(&remote_commitment_tx.0).sighash_all(&remote_commitment_tx.0.input[0],&funding_script,self.channel_value_satoshis)[..]).unwrap();
3298
+
let remote_sighash = hash_to_message!(&bip143::SighashComponents::new(&remote_commitment_tx.0).sighash_all(&remote_commitment_tx.0.input[0],&funding_script,self.channel_value_satoshis)[..]);
3299
3299
let our_sig = self.secp_ctx.sign(&remote_sighash,&self.local_keys.funding_key);
0 commit comments