Skip to content

Commit 2dd8b3e

Browse files
authored
Merge pull request #686 from TheBlueMatt/2020-09-bump-deps
Bump rust-bitcoin and friends
2 parents 3defcc8 + 25b0c2a commit 2dd8b3e

20 files changed

+185
-182
lines changed

fuzz/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ stdin_fuzz = []
1919
[dependencies]
2020
afl = { version = "0.4", optional = true }
2121
lightning = { path = "../lightning", features = ["fuzztarget"] }
22-
bitcoin = { version = "0.23", features = ["fuzztarget"] }
22+
bitcoin = { version = "0.24", features = ["fuzztarget"] }
2323
hex = "0.3"
2424
honggfuzz = { version = "0.5", optional = true }
2525
libfuzzer-sys = { git = "https://github.com/rust-fuzz/libfuzzer-sys.git", optional = true }

fuzz/src/chanmon_consistency.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
//! send-side handling is correct, other peers. We consider it a failure if any action results in a
1919
//! channel being force-closed.
2020
21-
use bitcoin::BitcoinHash;
2221
use bitcoin::blockdata::block::BlockHeader;
2322
use bitcoin::blockdata::transaction::{Transaction, TxOut};
2423
use bitcoin::blockdata::script::{Builder, Script};
@@ -317,7 +316,7 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
317316
}
318317
$node.block_connected(&header, 1, &txn, &posn);
319318
for i in 2..100 {
320-
header = BlockHeader { version: 0x20000000, prev_blockhash: header.bitcoin_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
319+
header = BlockHeader { version: 0x20000000, prev_blockhash: header.block_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
321320
$node.block_connected(&header, i, &Vec::new(), &[0; 0]);
322321
}
323322
} }

fuzz/src/full_stack.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ use bitcoin::blockdata::script::{Builder, Script};
1919
use bitcoin::blockdata::opcodes;
2020
use bitcoin::consensus::encode::deserialize;
2121
use bitcoin::network::constants::Network;
22-
use bitcoin::util::hash::BitcoinHash;
2322

2423
use bitcoin::hashes::Hash as TraitImport;
2524
use bitcoin::hashes::HashEngine as TraitImportEngine;
@@ -204,10 +203,10 @@ impl<'a> MoneyLossDetector<'a> {
204203
self.manager.block_connected(&header, self.height as u32, &txn[..], &txn_idxs[..]);
205204
(*self.monitor).block_connected(&header, self.height as u32, &txn[..], &txn_idxs[..]);
206205
if self.header_hashes.len() > self.height {
207-
self.header_hashes[self.height] = header.bitcoin_hash();
206+
self.header_hashes[self.height] = header.block_hash();
208207
} else {
209208
assert_eq!(self.header_hashes.len(), self.height);
210-
self.header_hashes.push(header.bitcoin_hash());
209+
self.header_hashes.push(header.block_hash());
211210
}
212211
self.max_height = cmp::max(self.height, self.max_height);
213212
}

lightning-net-tokio/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ For Rust-Lightning clients which wish to make direct connections to Lightning P2
1010
"""
1111

1212
[dependencies]
13-
bitcoin = "0.23"
13+
bitcoin = "0.24"
1414
lightning = { version = "0.0.11", path = "../lightning" }
1515
tokio = { version = ">=0.2.12", features = [ "io-util", "macros", "rt-core", "sync", "tcp", "time" ] }
1616

lightning/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ max_level_debug = []
2323
unsafe_revoked_tx_signing = []
2424

2525
[dependencies]
26-
bitcoin = "0.23"
26+
bitcoin = "0.24"
2727

2828
[dev-dependencies.bitcoin]
29-
version = "0.23"
29+
version = "0.24"
3030
features = ["bitcoinconsensus"]
3131

3232
[dev-dependencies]

lightning/src/chain/chaininterface.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ use bitcoin::blockdata::block::{Block, BlockHeader};
1717
use bitcoin::blockdata::transaction::Transaction;
1818
use bitcoin::blockdata::script::Script;
1919
use bitcoin::blockdata::constants::genesis_block;
20-
use bitcoin::util::hash::BitcoinHash;
2120
use bitcoin::network::constants::Network;
2221
use bitcoin::hash_types::{Txid, BlockHash};
2322

@@ -366,7 +365,7 @@ impl ChainWatchInterface for ChainWatchInterfaceUtil {
366365
}
367366

368367
fn get_chain_utxo(&self, genesis_hash: BlockHash, _unspent_tx_output_identifier: u64) -> Result<(Script, u64), ChainError> {
369-
if genesis_hash != genesis_block(self.network).header.bitcoin_hash() {
368+
if genesis_hash != genesis_block(self.network).header.block_hash() {
370369
return Err(ChainError::NotWatched);
371370
}
372371
Err(ChainError::NotSupported)

lightning/src/chain/keysinterface.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//! spendable on-chain outputs which the user owns and is responsible for using just as any other
1212
//! on-chain output which is theirs.
1313
14-
use bitcoin::blockdata::transaction::{Transaction, TxOut};
14+
use bitcoin::blockdata::transaction::{Transaction, TxOut, SigHashType};
1515
use bitcoin::blockdata::script::{Script, Builder};
1616
use bitcoin::blockdata::opcodes;
1717
use bitcoin::network::constants::Network;
@@ -477,7 +477,7 @@ impl ChannelKeys for InMemoryChannelKeys {
477477
let accepted_data = self.accepted_channel_data.as_ref().expect("must accept before signing");
478478
let channel_funding_redeemscript = make_funding_redeemscript(&funding_pubkey, &accepted_data.remote_channel_pubkeys.funding_pubkey);
479479

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)[..]);
481481
let commitment_sig = secp_ctx.sign(&commitment_sighash, &self.funding_key);
482482

483483
let commitment_txid = commitment_tx.txid();
@@ -487,7 +487,7 @@ impl ChannelKeys for InMemoryChannelKeys {
487487
if let Some(_) = htlc.transaction_output_index {
488488
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);
489489
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)[..]);
491491
let our_htlc_key = match chan_utils::derive_private_key(&secp_ctx, &keys.per_commitment_point, &self.htlc_base_key) {
492492
Ok(s) => s,
493493
Err(_) => return Err(()),
@@ -548,8 +548,8 @@ impl ChannelKeys for InMemoryChannelKeys {
548548
};
549549
chan_utils::get_revokeable_redeemscript(&revocation_pubkey, self.local_to_self_delay(), &remote_delayedpubkey)
550550
};
551-
let sighash_parts = bip143::SighashComponents::new(&justice_tx);
552-
let sighash = hash_to_message!(&sighash_parts.sighash_all(&justice_tx.input[input], &witness_script, amount)[..]);
551+
let mut sighash_parts = bip143::SigHashCache::new(justice_tx);
552+
let sighash = hash_to_message!(&sighash_parts.signature_hash(input, &witness_script, amount, SigHashType::All)[..]);
553553
return Ok(secp_ctx.sign(&sighash, &revocation_key))
554554
}
555555

@@ -562,8 +562,8 @@ impl ChannelKeys for InMemoryChannelKeys {
562562
} else { return Err(()) }
563563
} else { return Err(()) }
564564
} else { return Err(()) };
565-
let sighash_parts = bip143::SighashComponents::new(&htlc_tx);
566-
let sighash = hash_to_message!(&sighash_parts.sighash_all(&htlc_tx.input[input], &witness_script, amount)[..]);
565+
let mut sighash_parts = bip143::SigHashCache::new(htlc_tx);
566+
let sighash = hash_to_message!(&sighash_parts.signature_hash(input, &witness_script, amount, SigHashType::All)[..]);
567567
return Ok(secp_ctx.sign(&sighash, &htlc_key))
568568
}
569569
Err(())
@@ -578,8 +578,8 @@ impl ChannelKeys for InMemoryChannelKeys {
578578
let remote_channel_data = self.accepted_channel_data.as_ref().expect("must accept before signing");
579579
let channel_funding_redeemscript = make_funding_redeemscript(&funding_pubkey, &remote_channel_data.remote_channel_pubkeys.funding_pubkey);
580580

581-
let sighash = hash_to_message!(&bip143::SighashComponents::new(closing_tx)
582-
.sighash_all(&closing_tx.input[0], &channel_funding_redeemscript, self.channel_value_satoshis)[..]);
581+
let sighash = hash_to_message!(&bip143::SigHashCache::new(closing_tx)
582+
.signature_hash(0, &channel_funding_redeemscript, self.channel_value_satoshis, SigHashType::All)[..]);
583583
Ok(secp_ctx.sign(&sighash, &self.funding_key))
584584
}
585585

lightning/src/ln/chan_utils.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -651,8 +651,8 @@ impl LocalCommitmentTransaction {
651651
/// ChannelKeys::sign_local_commitment() calls directly.
652652
/// Channel value is amount locked in funding_outpoint.
653653
pub fn get_local_sig<T: secp256k1::Signing>(&self, funding_key: &SecretKey, funding_redeemscript: &Script, channel_value_satoshis: u64, secp_ctx: &Secp256k1<T>) -> Signature {
654-
let sighash = hash_to_message!(&bip143::SighashComponents::new(&self.unsigned_tx)
655-
.sighash_all(&self.unsigned_tx.input[0], funding_redeemscript, channel_value_satoshis)[..]);
654+
let sighash = hash_to_message!(&bip143::SigHashCache::new(&self.unsigned_tx)
655+
.signature_hash(0, funding_redeemscript, channel_value_satoshis, SigHashType::All)[..]);
656656
secp_ctx.sign(&sighash, funding_key)
657657
}
658658

@@ -692,7 +692,7 @@ impl LocalCommitmentTransaction {
692692

693693
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);
694694

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)[..]);
696696
ret.push(Some(secp_ctx.sign(&sighash, &our_htlc_key)));
697697
} else {
698698
ret.push(None);

lightning/src/ln/channel.rs

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ use bitcoin::blockdata::block::BlockHeader;
1111
use bitcoin::blockdata::script::{Script,Builder};
1212
use bitcoin::blockdata::transaction::{TxIn, TxOut, Transaction, SigHashType};
1313
use bitcoin::blockdata::opcodes;
14-
use bitcoin::util::hash::BitcoinHash;
1514
use bitcoin::util::bip143;
1615
use bitcoin::consensus::encode;
1716

@@ -1477,7 +1476,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
14771476

14781477
let local_keys = self.build_local_transaction_keys(self.cur_local_commitment_transaction_number)?;
14791478
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)[..]);
14811480

14821481
// They sign the "local" commitment transaction...
14831482
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));
@@ -1581,7 +1580,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
15811580

15821581
let local_keys = self.build_local_transaction_keys(self.cur_local_commitment_transaction_number)?;
15831582
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)[..]);
15851584

15861585
let their_funding_pubkey = &self.their_pubkeys.as_ref().unwrap().funding_pubkey;
15871586

@@ -1982,7 +1981,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
19821981
(commitment_tx.0, commitment_tx.1, htlcs_cloned)
19831982
};
19841983
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)[..]);
19861985
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));
19871986
if let Err(_) = self.secp_ctx.verify(&local_sighash, &msg.signature, &self.their_funding_pubkey()) {
19881987
return Err((None, ChannelError::Close("Invalid commitment tx signature from peer".to_owned())));
@@ -2011,7 +2010,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
20112010
if let Some(_) = htlc.transaction_output_index {
20122011
let htlc_tx = self.build_htlc_transaction(&local_commitment_txid, &htlc, true, &local_keys, feerate_per_kw);
20132012
let htlc_redeemscript = chan_utils::get_htlc_redeemscript(&htlc, &local_keys);
2014-
let htlc_sighash = hash_to_message!(&bip143::SighashComponents::new(&htlc_tx).sighash_all(&htlc_tx.input[0], &htlc_redeemscript, htlc.amount_msat / 1000)[..]);
2013+
let htlc_sighash = hash_to_message!(&bip143::SigHashCache::new(&htlc_tx).signature_hash(0, &htlc_redeemscript, htlc.amount_msat / 1000, SigHashType::All)[..]);
20152014
log_trace!(logger, "Checking HTLC tx signature {} by key {} against tx {} (sighash {}) with redeemscript {}", log_bytes!(msg.htlc_signatures[idx].serialize_compact()[..]), log_bytes!(local_keys.b_htlc_key.serialize()), encode::serialize_hex(&htlc_tx), log_bytes!(htlc_sighash[..]), encode::serialize_hex(&htlc_redeemscript));
20162015
if let Err(_) = self.secp_ctx.verify(&htlc_sighash, &msg.htlc_signatures[idx], &local_keys.b_htlc_key) {
20172016
return Err((None, ChannelError::Close("Invalid HTLC tx signature from peer".to_owned())));
@@ -3015,7 +3014,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
30153014
if used_total_fee != msg.fee_satoshis {
30163015
return Err(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)));
30173016
}
3018-
let mut sighash = hash_to_message!(&bip143::SighashComponents::new(&closing_tx).sighash_all(&closing_tx.input[0], &funding_redeemscript, self.channel_value_satoshis)[..]);
3017+
let mut sighash = hash_to_message!(&bip143::SigHashCache::new(&closing_tx).signature_hash(0, &funding_redeemscript, self.channel_value_satoshis, SigHashType::All)[..]);
30193018

30203019
let their_funding_pubkey = &self.their_pubkeys.as_ref().unwrap().funding_pubkey;
30213020

@@ -3025,7 +3024,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
30253024
// The remote end may have decided to revoke their output due to inconsistent dust
30263025
// limits, so check for that case by re-checking the signature here.
30273026
closing_tx = self.build_closing_transaction(msg.fee_satoshis, true).0;
3028-
sighash = hash_to_message!(&bip143::SighashComponents::new(&closing_tx).sighash_all(&closing_tx.input[0], &funding_redeemscript, self.channel_value_satoshis)[..]);
3027+
sighash = hash_to_message!(&bip143::SigHashCache::new(&closing_tx).signature_hash(0, &funding_redeemscript, self.channel_value_satoshis, SigHashType::All)[..]);
30293028
secp_check!(self.secp_ctx.verify(&sighash, &msg.signature, self.their_funding_pubkey()), "Invalid closing tx signature from peer".to_owned());
30303029
},
30313030
};
@@ -3327,7 +3326,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
33273326
}
33283327
});
33293328
let non_shutdown_state = self.channel_state & (!MULTI_STATE_FLAGS);
3330-
if header.bitcoin_hash() != self.last_block_connected {
3329+
if header.block_hash() != self.last_block_connected {
33313330
if self.funding_tx_confirmations > 0 {
33323331
self.funding_tx_confirmations += 1;
33333332
}
@@ -3376,8 +3375,8 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
33763375
}
33773376
}
33783377
}
3379-
if header.bitcoin_hash() != self.last_block_connected {
3380-
self.last_block_connected = header.bitcoin_hash();
3378+
if header.block_hash() != self.last_block_connected {
3379+
self.last_block_connected = header.block_hash();
33813380
self.update_time_counter = cmp::max(self.update_time_counter, header.time);
33823381
if self.funding_tx_confirmations > 0 {
33833382
if self.funding_tx_confirmations == self.minimum_depth as u64 {
@@ -3399,7 +3398,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
33993398
// funding_tx_confirmed_in and return.
34003399
false
34013400
};
3402-
self.funding_tx_confirmed_in = Some(header.bitcoin_hash());
3401+
self.funding_tx_confirmed_in = Some(self.last_block_connected);
34033402

34043403
//TODO: Note that this must be a duplicate of the previous commitment point they sent us,
34053404
//as otherwise we will have a commitment transaction that they can't revoke (well, kinda,
@@ -3433,10 +3432,10 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
34333432
return true;
34343433
}
34353434
}
3436-
if Some(header.bitcoin_hash()) == self.funding_tx_confirmed_in {
3435+
self.last_block_connected = header.block_hash();
3436+
if Some(self.last_block_connected) == self.funding_tx_confirmed_in {
34373437
self.funding_tx_confirmations = self.minimum_depth as u64 - 1;
34383438
}
3439-
self.last_block_connected = header.bitcoin_hash();
34403439
false
34413440
}
34423441

@@ -4451,11 +4450,10 @@ impl<ChanSigner: ChannelKeys + Readable> Readable for Channel<ChanSigner> {
44514450

44524451
#[cfg(test)]
44534452
mod tests {
4454-
use bitcoin::BitcoinHash;
44554453
use bitcoin::util::bip143;
44564454
use bitcoin::consensus::encode::serialize;
44574455
use bitcoin::blockdata::script::{Script, Builder};
4458-
use bitcoin::blockdata::transaction::{Transaction, TxOut};
4456+
use bitcoin::blockdata::transaction::{Transaction, TxOut, SigHashType};
44594457
use bitcoin::blockdata::constants::genesis_block;
44604458
use bitcoin::blockdata::opcodes;
44614459
use bitcoin::network::constants::Network;
@@ -4545,7 +4543,7 @@ mod tests {
45454543
// Now change the fee so we can check that the fee in the open_channel message is the
45464544
// same as the old fee.
45474545
fee_est.fee_est = 500;
4548-
let open_channel_msg = node_a_chan.get_open_channel(genesis_block(network).header.bitcoin_hash());
4546+
let open_channel_msg = node_a_chan.get_open_channel(genesis_block(network).header.block_hash());
45494547
assert_eq!(open_channel_msg.feerate_per_kw, original_fee);
45504548
}
45514549

@@ -4566,7 +4564,7 @@ mod tests {
45664564
let mut node_a_chan = Channel::<EnforcingChannelKeys>::new_outbound(&&feeest, &&keys_provider, node_a_node_id, 10000000, 100000, 42, &config).unwrap();
45674565

45684566
// Create Node B's channel by receiving Node A's open_channel message
4569-
let open_channel_msg = node_a_chan.get_open_channel(genesis_block(network).header.bitcoin_hash());
4567+
let open_channel_msg = node_a_chan.get_open_channel(genesis_block(network).header.block_hash());
45704568
let node_b_node_id = PublicKey::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[7; 32]).unwrap());
45714569
let mut node_b_chan = Channel::<EnforcingChannelKeys>::new_from_req(&&feeest, &&keys_provider, node_b_node_id, InitFeatures::known(), &open_channel_msg, 7, &config).unwrap();
45724570

@@ -4693,7 +4691,7 @@ mod tests {
46934691
};
46944692
let redeemscript = chan.get_funding_redeemscript();
46954693
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();
46974695
secp_ctx.verify(&sighash, &their_signature, chan.their_funding_pubkey()).unwrap();
46984696

46994697
let mut per_htlc = Vec::new();
@@ -4720,7 +4718,7 @@ mod tests {
47204718
let ref htlc = unsigned_tx.1[$htlc_idx];
47214719
let htlc_tx = chan.build_htlc_transaction(&unsigned_tx.0.txid(), &htlc, true, &keys, chan.feerate_per_kw);
47224720
let htlc_redeemscript = chan_utils::get_htlc_redeemscript(&htlc, &keys);
4723-
let htlc_sighash = Message::from_slice(&bip143::SighashComponents::new(&htlc_tx).sighash_all(&htlc_tx.input[0], &htlc_redeemscript, htlc.amount_msat / 1000)[..]).unwrap();
4721+
let htlc_sighash = Message::from_slice(&bip143::SigHashCache::new(&htlc_tx).signature_hash(0, &htlc_redeemscript, htlc.amount_msat / 1000, SigHashType::All)[..]).unwrap();
47244722
secp_ctx.verify(&htlc_sighash, &remote_signature, &keys.b_htlc_key).unwrap();
47254723

47264724
let mut preimage: Option<PaymentPreimage> = None;

0 commit comments

Comments
 (0)