Skip to content

Commit b9707da

Browse files
committed
Update to latest upstream rust-bitcoin
1 parent 3defcc8 commit b9707da

16 files changed

+124
-133
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/ln/channel.rs

Lines changed: 8 additions & 10 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

@@ -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,7 +4450,6 @@ 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};
@@ -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

lightning/src/ln/channelmanager.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ use bitcoin::blockdata::block::BlockHeader;
2121
use bitcoin::blockdata::transaction::Transaction;
2222
use bitcoin::blockdata::constants::genesis_block;
2323
use bitcoin::network::constants::Network;
24-
use bitcoin::util::hash::BitcoinHash;
2524

2625
use bitcoin::hashes::{Hash, HashEngine};
2726
use bitcoin::hashes::hmac::{Hmac, HmacEngine};
@@ -724,7 +723,7 @@ impl<ChanSigner: ChannelKeys, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref>
724723

725724
ChannelManager {
726725
default_configuration: config.clone(),
727-
genesis_hash: genesis_block(network).header.bitcoin_hash(),
726+
genesis_hash: genesis_block(network).header.block_hash(),
728727
fee_estimator: fee_est,
729728
monitor,
730729
tx_broadcaster,
@@ -3060,7 +3059,7 @@ impl<ChanSigner: ChannelKeys, M: Deref + Sync + Send, T: Deref + Sync + Send, K:
30603059
L::Target: Logger,
30613060
{
30623061
fn block_connected(&self, header: &BlockHeader, height: u32, txn_matched: &[&Transaction], indexes_of_txn_matched: &[usize]) {
3063-
let header_hash = header.bitcoin_hash();
3062+
let header_hash = header.block_hash();
30643063
log_trace!(self.logger, "Block {} at height {} connected with {} txn matched", header_hash, height, txn_matched.len());
30653064
let _ = self.total_consistency_lock.read().unwrap();
30663065
let mut failed_channels = Vec::new();
@@ -3200,7 +3199,7 @@ impl<ChanSigner: ChannelKeys, M: Deref + Sync + Send, T: Deref + Sync + Send, K:
32003199
self.finish_force_close_channel(failure);
32013200
}
32023201
self.latest_block_height.fetch_sub(1, Ordering::AcqRel);
3203-
*self.last_block_hash.try_lock().expect("block_(dis)connected must not be called in parallel") = header.bitcoin_hash();
3202+
*self.last_block_hash.try_lock().expect("block_(dis)connected must not be called in parallel") = header.block_hash();
32043203
}
32053204
}
32063205

lightning/src/ln/channelmonitor.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ use bitcoin::blockdata::transaction::OutPoint as BitcoinOutPoint;
2626
use bitcoin::blockdata::script::{Script, Builder};
2727
use bitcoin::blockdata::opcodes;
2828
use bitcoin::consensus::encode;
29-
use bitcoin::util::hash::BitcoinHash;
3029

3130
use bitcoin::hashes::Hash;
3231
use bitcoin::hashes::sha256::Hash as Sha256;
@@ -203,7 +202,7 @@ impl<Key : Send + cmp::Eq + hash::Hash, ChanSigner: ChannelKeys, T: Deref + Sync
203202
C::Target: ChainWatchInterface,
204203
{
205204
fn block_connected(&self, header: &BlockHeader, height: u32, txn_matched: &[&Transaction], _indexes_of_txn_matched: &[usize]) {
206-
let block_hash = header.bitcoin_hash();
205+
let block_hash = header.block_hash();
207206
{
208207
let mut monitors = self.monitors.lock().unwrap();
209208
for monitor in monitors.values_mut() {
@@ -219,7 +218,7 @@ impl<Key : Send + cmp::Eq + hash::Hash, ChanSigner: ChannelKeys, T: Deref + Sync
219218
}
220219

221220
fn block_disconnected(&self, header: &BlockHeader, disconnected_height: u32) {
222-
let block_hash = header.bitcoin_hash();
221+
let block_hash = header.block_hash();
223222
let mut monitors = self.monitors.lock().unwrap();
224223
for monitor in monitors.values_mut() {
225224
monitor.block_disconnected(disconnected_height, &block_hash, &*self.broadcaster, &*self.fee_estimator, &*self.logger);

lightning/src/ln/functional_test_utils.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ use util::errors::APIError;
2727
use util::config::UserConfig;
2828
use util::ser::{ReadableArgs, Writeable, Readable};
2929

30-
use bitcoin::util::hash::BitcoinHash;
3130
use bitcoin::blockdata::block::BlockHeader;
3231
use bitcoin::blockdata::transaction::{Transaction, TxOut};
3332
use bitcoin::network::constants::Network;
@@ -45,12 +44,12 @@ use std::mem;
4544
use std::collections::HashMap;
4645

4746
pub const CHAN_CONFIRM_DEPTH: u32 = 100;
48-
pub fn confirm_transaction<'a, 'b: 'a>(notifier: &'a chaininterface::BlockNotifierRef<'b, &chaininterface::ChainWatchInterfaceUtil>, chain: &chaininterface::ChainWatchInterfaceUtil, tx: &Transaction, chan_id: u32) {
47+
pub fn confirm_transaction<'a, 'b: 'a>(notifier: &'a chaininterface::BlockNotifierRef<'b, &chaininterface::ChainWatchInterfaceUtil>, chain: &chaininterface::ChainWatchInterfaceUtil, tx: &Transaction, chan_id: i32) {
4948
assert!(chain.does_match_tx(tx));
5049
let mut header = BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
5150
notifier.block_connected_checked(&header, 1, &[tx; 1], &[chan_id as usize; 1]);
5251
for i in 2..CHAN_CONFIRM_DEPTH {
53-
header = BlockHeader { version: 0x20000000, prev_blockhash: header.bitcoin_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
52+
header = BlockHeader { version: 0x20000000, prev_blockhash: header.block_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
5453
notifier.block_connected_checked(&header, i, &vec![], &[0; 0]);
5554
}
5655
}
@@ -59,10 +58,10 @@ pub fn connect_blocks<'a, 'b>(notifier: &'a chaininterface::BlockNotifierRef<'b,
5958
let mut header = BlockHeader { version: 0x2000000, prev_blockhash: if parent { prev_blockhash } else { Default::default() }, merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
6059
notifier.block_connected_checked(&header, height + 1, &Vec::new(), &Vec::new());
6160
for i in 2..depth + 1 {
62-
header = BlockHeader { version: 0x20000000, prev_blockhash: header.bitcoin_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
61+
header = BlockHeader { version: 0x20000000, prev_blockhash: header.block_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
6362
notifier.block_connected_checked(&header, height + i, &Vec::new(), &Vec::new());
6463
}
65-
header.bitcoin_hash()
64+
header.block_hash()
6665
}
6766

6867
pub struct TestChanMonCfg {
@@ -324,7 +323,7 @@ pub fn create_funding_transaction<'a, 'b, 'c>(node: &Node<'a, 'b, 'c>, expected_
324323
assert_eq!(*channel_value_satoshis, expected_chan_value);
325324
assert_eq!(user_channel_id, expected_user_chan_id);
326325

327-
let tx = Transaction { version: chan_id as u32, lock_time: 0, input: Vec::new(), output: vec![TxOut {
326+
let tx = Transaction { version: chan_id as i32, lock_time: 0, input: Vec::new(), output: vec![TxOut {
328327
value: *channel_value_satoshis, script_pubkey: output_script.clone(),
329328
}]};
330329
let funding_outpoint = OutPoint { txid: tx.txid(), index: 0 };

0 commit comments

Comments
 (0)