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: lightning/src/chain/keysinterface.rs
+9-9Lines changed: 9 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,7 @@
11
11
//! spendable on-chain outputs which the user owns and is responsible for using just as any other
12
12
//! on-chain output which is theirs.
13
13
14
-
use bitcoin::blockdata::transaction::{Transaction,TxOut};
14
+
use bitcoin::blockdata::transaction::{Transaction,TxOut,SigHashType};
15
15
use bitcoin::blockdata::script::{Script,Builder};
16
16
use bitcoin::blockdata::opcodes;
17
17
use bitcoin::network::constants::Network;
@@ -477,7 +477,7 @@ impl ChannelKeys for InMemoryChannelKeys {
477
477
let accepted_data = self.accepted_channel_data.as_ref().expect("must accept before signing");
478
478
let channel_funding_redeemscript = make_funding_redeemscript(&funding_pubkey,&accepted_data.remote_channel_pubkeys.funding_pubkey);
479
479
480
-
let commitment_sighash = hash_to_message!(&bip143::SighashComponents::new(&commitment_tx).sighash_all(&commitment_tx.input[0],&channel_funding_redeemscript,self.channel_value_satoshis)[..]);
480
+
let commitment_sighash = hash_to_message!(&bip143::SigHashCache::new(commitment_tx).signature_hash(0,&channel_funding_redeemscript,self.channel_value_satoshis,SigHashType::All)[..]);
481
481
let commitment_sig = secp_ctx.sign(&commitment_sighash,&self.funding_key);
482
482
483
483
let commitment_txid = commitment_tx.txid();
@@ -487,7 +487,7 @@ impl ChannelKeys for InMemoryChannelKeys {
487
487
ifletSome(_) = htlc.transaction_output_index{
488
488
let htlc_tx = chan_utils::build_htlc_transaction(&commitment_txid, feerate_per_kw, accepted_data.local_to_self_delay, htlc,&keys.a_delayed_payment_key,&keys.revocation_key);
489
489
let htlc_redeemscript = chan_utils::get_htlc_redeemscript(&htlc,&keys);
490
-
let htlc_sighash = hash_to_message!(&bip143::SighashComponents::new(&htlc_tx).sighash_all(&htlc_tx.input[0],&htlc_redeemscript, htlc.amount_msat / 1000)[..]);
490
+
let htlc_sighash = hash_to_message!(&bip143::SigHashCache::new(&htlc_tx).signature_hash(0,&htlc_redeemscript, htlc.amount_msat / 1000,SigHashType::All)[..]);
491
491
let our_htlc_key = match chan_utils::derive_private_key(&secp_ctx,&keys.per_commitment_point,&self.htlc_base_key){
492
492
Ok(s) => s,
493
493
Err(_) => returnErr(()),
@@ -548,8 +548,8 @@ impl ChannelKeys for InMemoryChannelKeys {
let htlc_redeemscript = get_htlc_redeemscript_with_explicit_keys(&this_htlc.0,&self.local_keys.a_htlc_key,&self.local_keys.b_htlc_key,&self.local_keys.revocation_key);
694
694
695
-
let sighash = hash_to_message!(&bip143::SighashComponents::new(&htlc_tx).sighash_all(&htlc_tx.input[0],&htlc_redeemscript, this_htlc.0.amount_msat / 1000)[..]);
695
+
let sighash = hash_to_message!(&bip143::SigHashCache::new(&htlc_tx).signature_hash(0,&htlc_redeemscript, this_htlc.0.amount_msat / 1000,SigHashType::All)[..]);
let local_keys = self.build_local_transaction_keys(self.cur_local_commitment_transaction_number)?;
1479
1478
let local_initial_commitment_tx = self.build_commitment_transaction(self.cur_local_commitment_transaction_number,&local_keys,true,false,self.feerate_per_kw, logger).0;
1480
-
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)[..]);
1479
+
let local_sighash = hash_to_message!(&bip143::SigHashCache::new(&local_initial_commitment_tx).signature_hash(0,&funding_script,self.channel_value_satoshis,SigHashType::All)[..]);
1481
1480
1482
1481
// They sign the "local" commitment transaction...
1483
1482
log_trace!(logger,"Checking funding_created tx signature {} by key {} against tx {} (sighash {}) with redeemscript {}", log_bytes!(sig.serialize_compact()[..]), log_bytes!(self.their_funding_pubkey().serialize()), encode::serialize_hex(&local_initial_commitment_tx), log_bytes!(local_sighash[..]), encode::serialize_hex(&funding_script));
let local_keys = self.build_local_transaction_keys(self.cur_local_commitment_transaction_number)?;
1583
1582
let local_initial_commitment_tx = self.build_commitment_transaction(self.cur_local_commitment_transaction_number,&local_keys,true,false,self.feerate_per_kw, logger).0;
1584
-
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)[..]);
1583
+
let local_sighash = hash_to_message!(&bip143::SigHashCache::new(&local_initial_commitment_tx).signature_hash(0,&funding_script,self.channel_value_satoshis,SigHashType::All)[..]);
1585
1584
1586
1585
let their_funding_pubkey = &self.their_pubkeys.as_ref().unwrap().funding_pubkey;
let local_commitment_txid = local_commitment_tx.0.txid();
1985
-
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)[..]);
1984
+
let local_sighash = hash_to_message!(&bip143::SigHashCache::new(&local_commitment_tx.0).signature_hash(0,&funding_script,self.channel_value_satoshis,SigHashType::All)[..]);
1986
1985
log_trace!(logger,"Checking commitment tx signature {} by key {} against tx {} (sighash {}) with redeemscript {}", log_bytes!(msg.signature.serialize_compact()[..]), log_bytes!(self.their_funding_pubkey().serialize()), encode::serialize_hex(&local_commitment_tx.0), log_bytes!(local_sighash[..]), encode::serialize_hex(&funding_script));
returnErr(ChannelError::Close(format!("Remote sent us a closing_signed with a fee greater than the value they can claim. Fee in message: {}", msg.fee_satoshis)));
let redeemscript = chan.get_funding_redeemscript();
4695
4693
let their_signature = Signature::from_der(&hex::decode($their_sig_hex).unwrap()[..]).unwrap();
4696
-
let sighash = Message::from_slice(&bip143::SighashComponents::new(&unsigned_tx.0).sighash_all(&unsigned_tx.0.input[0],&redeemscript, chan.channel_value_satoshis)[..]).unwrap();
4694
+
let sighash = Message::from_slice(&bip143::SigHashCache::new(&unsigned_tx.0).signature_hash(0,&redeemscript, chan.channel_value_satoshis,SigHashType::All)[..]).unwrap();
0 commit comments