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;
@@ -1061,7 +1061,7 @@ impl Channel {
1061
1061
1062
1062
let funding_redeemscript = self.get_funding_redeemscript();
1063
1063
1064
-
let sighash = Message::from_slice(&bip143::SighashComponents::new(&tx).sighash_all(&tx.input[0],&funding_redeemscript,self.channel_value_satoshis)[..]).unwrap();
1064
+
let sighash = hash_to_message!(&bip143::SighashComponents::new(&tx).sighash_all(&tx.input[0],&funding_redeemscript,self.channel_value_satoshis)[..]);
1065
1065
let our_sig = self.secp_ctx.sign(&sighash,&self.local_keys.funding_key);
1066
1066
1067
1067
tx.input[0].witness.push(Vec::new());// First is the multisig dummy
@@ -1098,7 +1098,7 @@ impl Channel {
1098
1098
let htlc_redeemscript = chan_utils::get_htlc_redeemscript(&htlc,&keys);
1099
1099
1100
1100
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");
1101
-
let sighash = Message::from_slice(&bip143::SighashComponents::new(&tx).sighash_all(&tx.input[0],&htlc_redeemscript, htlc.amount_msat / 1000)[..]).unwrap();
1101
+
let sighash = hash_to_message!(&bip143::SighashComponents::new(&tx).sighash_all(&tx.input[0],&htlc_redeemscript, htlc.amount_msat / 1000)[..]);
1102
1102
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();
1405
+
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)[..]);
1406
1406
1407
1407
// They sign the "local" commitment transaction...
1408
1408
secp_check!(self.secp_ctx.verify(&local_sighash,&sig,&self.their_funding_pubkey.unwrap()),"Invalid funding_created signature from peer");
@@ -1412,7 +1412,7 @@ impl Channel {
1412
1412
1413
1413
let remote_keys = self.build_remote_transaction_keys()?;
1414
1414
let remote_initial_commitment_tx = self.build_commitment_transaction(self.cur_remote_commitment_transaction_number,&remote_keys,false,false,self.feerate_per_kw).0;
1415
-
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();
1415
+
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)[..]);
1416
1416
1417
1417
// 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();
1484
+
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)[..]);
1485
1485
1486
1486
// They sign the "local" commitment transaction, allowing us to broadcast the tx if we wish.
1487
1487
secp_check!(self.secp_ctx.verify(&local_sighash,&msg.signature,&self.their_funding_pubkey.unwrap()),"Invalid funding_signed signature from peer");
@@ -1694,7 +1694,7 @@ impl Channel {
1694
1694
(commitment_tx.0, commitment_tx.1, htlcs_cloned)
1695
1695
};
1696
1696
let local_commitment_txid = local_commitment_tx.0.txid();
1697
-
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();
1697
+
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)[..]);
1698
1698
secp_check!(self.secp_ctx.verify(&local_sighash,&msg.signature,&self.their_funding_pubkey.unwrap()),"Invalid commitment tx signature from peer");
1699
1699
1700
1700
//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();
2454
-
let sighash = Message::from_slice(&bip143::SighashComponents::new(&closing_tx).sighash_all(&closing_tx.input[0],&funding_redeemscript,self.channel_value_satoshis)[..]).unwrap();
2454
+
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()?;
2990
2990
let remote_initial_commitment_tx = self.build_commitment_transaction(self.cur_remote_commitment_transaction_number,&remote_keys,false,false,self.feerate_per_kw).0;
2991
-
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();
2991
+
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)[..]);
2992
2992
2993
2993
// 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();
3078
+
let msghash = hash_to_message!(&Sha256dHash::from_data(&msg.encode()[..])[..]);
3079
3079
let sig = self.secp_ctx.sign(&msghash,&self.local_keys.funding_key);
3080
3080
3081
3081
Ok((msg, sig))
@@ -3290,15 +3290,15 @@ impl Channel {
3290
3290
let remote_keys = self.build_remote_transaction_keys()?;
3291
3291
let remote_commitment_tx = self.build_commitment_transaction(self.cur_remote_commitment_transaction_number,&remote_keys,false,true, feerate_per_kw);
3292
3292
let remote_commitment_txid = remote_commitment_tx.0.txid();
3293
-
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();
3293
+
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)[..]);
3294
3294
let our_sig = self.secp_ctx.sign(&remote_sighash,&self.local_keys.funding_key);
0 commit comments