Update to latest upstream rust-bitcoin
authorMatt Corallo <git@bluematt.me>
Tue, 25 Aug 2020 21:12:00 +0000 (17:12 -0400)
committerMatt Corallo <git@bluematt.me>
Thu, 10 Sep 2020 20:20:01 +0000 (16:20 -0400)
16 files changed:
fuzz/Cargo.toml
fuzz/src/chanmon_consistency.rs
fuzz/src/full_stack.rs
lightning-net-tokio/Cargo.toml
lightning/Cargo.toml
lightning/src/chain/chaininterface.rs
lightning/src/ln/channel.rs
lightning/src/ln/channelmanager.rs
lightning/src/ln/channelmonitor.rs
lightning/src/ln/functional_test_utils.rs
lightning/src/ln/functional_tests.rs
lightning/src/ln/msgs.rs
lightning/src/ln/reorg_tests.rs
lightning/src/routing/network_graph.rs
lightning/src/routing/router.rs
lightning/src/util/test_utils.rs

index 115f3e8a4dc0db632cf417b0ae840051da4c783d..cb5d40eaa5837500fccd0e3201ed2feb1b31fb41 100644 (file)
@@ -19,7 +19,7 @@ stdin_fuzz = []
 [dependencies]
 afl = { version = "0.4", optional = true }
 lightning = { path = "../lightning", features = ["fuzztarget"] }
-bitcoin = { version = "0.23", features = ["fuzztarget"] }
+bitcoin = { version = "0.24", features = ["fuzztarget"] }
 hex = "0.3"
 honggfuzz = { version = "0.5", optional = true }
 libfuzzer-sys = { git = "https://github.com/rust-fuzz/libfuzzer-sys.git", optional = true }
index 3191eb27308767c97a9d9e770873dbfd154618dc..ca05e5db942ae4a10fcf7257a3e69f5bc939f374 100644 (file)
@@ -18,7 +18,6 @@
 //! send-side handling is correct, other peers. We consider it a failure if any action results in a
 //! channel being force-closed.
 
-use bitcoin::BitcoinHash;
 use bitcoin::blockdata::block::BlockHeader;
 use bitcoin::blockdata::transaction::{Transaction, TxOut};
 use bitcoin::blockdata::script::{Builder, Script};
@@ -317,7 +316,7 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
                        }
                        $node.block_connected(&header, 1, &txn, &posn);
                        for i in 2..100 {
-                               header = BlockHeader { version: 0x20000000, prev_blockhash: header.bitcoin_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
+                               header = BlockHeader { version: 0x20000000, prev_blockhash: header.block_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
                                $node.block_connected(&header, i, &Vec::new(), &[0; 0]);
                        }
                } }
index 543357d39bc1c252cffc0ac542dee882b4b46f5c..9991ea3b3659d278d1fc15cb798abfc57625495e 100644 (file)
@@ -19,7 +19,6 @@ use bitcoin::blockdata::script::{Builder, Script};
 use bitcoin::blockdata::opcodes;
 use bitcoin::consensus::encode::deserialize;
 use bitcoin::network::constants::Network;
-use bitcoin::util::hash::BitcoinHash;
 
 use bitcoin::hashes::Hash as TraitImport;
 use bitcoin::hashes::HashEngine as TraitImportEngine;
@@ -204,10 +203,10 @@ impl<'a> MoneyLossDetector<'a> {
                self.manager.block_connected(&header, self.height as u32, &txn[..], &txn_idxs[..]);
                (*self.monitor).block_connected(&header, self.height as u32, &txn[..], &txn_idxs[..]);
                if self.header_hashes.len() > self.height {
-                       self.header_hashes[self.height] = header.bitcoin_hash();
+                       self.header_hashes[self.height] = header.block_hash();
                } else {
                        assert_eq!(self.header_hashes.len(), self.height);
-                       self.header_hashes.push(header.bitcoin_hash());
+                       self.header_hashes.push(header.block_hash());
                }
                self.max_height = cmp::max(self.height, self.max_height);
        }
index bdcb911395d939e31229a24b9b9851feb939d82d..1a4b28168d9b46e41e43ffbe66f57d264daeceed 100644 (file)
@@ -10,7 +10,7 @@ For Rust-Lightning clients which wish to make direct connections to Lightning P2
 """
 
 [dependencies]
-bitcoin = "0.23"
+bitcoin = "0.24"
 lightning = { version = "0.0.11", path = "../lightning" }
 tokio = { version = ">=0.2.12", features = [ "io-util", "macros", "rt-core", "sync", "tcp", "time" ] }
 
index 20a6460d62dfec24bfe84d7aaaf823395e5912fd..3b12468e9c4a964e353dc6df9978719312b10366 100644 (file)
@@ -23,10 +23,10 @@ max_level_debug = []
 unsafe_revoked_tx_signing = []
 
 [dependencies]
-bitcoin = "0.23"
+bitcoin = "0.24"
 
 [dev-dependencies.bitcoin]
-version = "0.23"
+version = "0.24"
 features = ["bitcoinconsensus"]
 
 [dev-dependencies]
index fe3914545c6e05ac17bf012dd8598041c327b6f4..2da2ae8c7eb618a49308e664e4a8edd50266bd58 100644 (file)
@@ -17,7 +17,6 @@ use bitcoin::blockdata::block::{Block, BlockHeader};
 use bitcoin::blockdata::transaction::Transaction;
 use bitcoin::blockdata::script::Script;
 use bitcoin::blockdata::constants::genesis_block;
-use bitcoin::util::hash::BitcoinHash;
 use bitcoin::network::constants::Network;
 use bitcoin::hash_types::{Txid, BlockHash};
 
@@ -366,7 +365,7 @@ impl ChainWatchInterface for ChainWatchInterfaceUtil {
        }
 
        fn get_chain_utxo(&self, genesis_hash: BlockHash, _unspent_tx_output_identifier: u64) -> Result<(Script, u64), ChainError> {
-               if genesis_hash != genesis_block(self.network).header.bitcoin_hash() {
+               if genesis_hash != genesis_block(self.network).header.block_hash() {
                        return Err(ChainError::NotWatched);
                }
                Err(ChainError::NotSupported)
index 066f71c537876f382bf6372b5ba17139fd50a46a..ff7c60ad1f91b020fd2bba7b06e15653024fee2b 100644 (file)
@@ -11,7 +11,6 @@ use bitcoin::blockdata::block::BlockHeader;
 use bitcoin::blockdata::script::{Script,Builder};
 use bitcoin::blockdata::transaction::{TxIn, TxOut, Transaction, SigHashType};
 use bitcoin::blockdata::opcodes;
-use bitcoin::util::hash::BitcoinHash;
 use bitcoin::util::bip143;
 use bitcoin::consensus::encode;
 
@@ -3327,7 +3326,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
                        }
                });
                let non_shutdown_state = self.channel_state & (!MULTI_STATE_FLAGS);
-               if header.bitcoin_hash() != self.last_block_connected {
+               if header.block_hash() != self.last_block_connected {
                        if self.funding_tx_confirmations > 0 {
                                self.funding_tx_confirmations += 1;
                        }
@@ -3376,8 +3375,8 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
                                }
                        }
                }
-               if header.bitcoin_hash() != self.last_block_connected {
-                       self.last_block_connected = header.bitcoin_hash();
+               if header.block_hash() != self.last_block_connected {
+                       self.last_block_connected = header.block_hash();
                        self.update_time_counter = cmp::max(self.update_time_counter, header.time);
                        if self.funding_tx_confirmations > 0 {
                                if self.funding_tx_confirmations == self.minimum_depth as u64 {
@@ -3399,7 +3398,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
                                                // funding_tx_confirmed_in and return.
                                                false
                                        };
-                                       self.funding_tx_confirmed_in = Some(header.bitcoin_hash());
+                                       self.funding_tx_confirmed_in = Some(self.last_block_connected);
 
                                        //TODO: Note that this must be a duplicate of the previous commitment point they sent us,
                                        //as otherwise we will have a commitment transaction that they can't revoke (well, kinda,
@@ -3433,10 +3432,10 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
                                return true;
                        }
                }
-               if Some(header.bitcoin_hash()) == self.funding_tx_confirmed_in {
+               self.last_block_connected = header.block_hash();
+               if Some(self.last_block_connected) == self.funding_tx_confirmed_in {
                        self.funding_tx_confirmations = self.minimum_depth as u64 - 1;
                }
-               self.last_block_connected = header.bitcoin_hash();
                false
        }
 
@@ -4451,7 +4450,6 @@ impl<ChanSigner: ChannelKeys + Readable> Readable for Channel<ChanSigner> {
 
 #[cfg(test)]
 mod tests {
-       use bitcoin::BitcoinHash;
        use bitcoin::util::bip143;
        use bitcoin::consensus::encode::serialize;
        use bitcoin::blockdata::script::{Script, Builder};
@@ -4545,7 +4543,7 @@ mod tests {
                // Now change the fee so we can check that the fee in the open_channel message is the
                // same as the old fee.
                fee_est.fee_est = 500;
-               let open_channel_msg = node_a_chan.get_open_channel(genesis_block(network).header.bitcoin_hash());
+               let open_channel_msg = node_a_chan.get_open_channel(genesis_block(network).header.block_hash());
                assert_eq!(open_channel_msg.feerate_per_kw, original_fee);
        }
 
@@ -4566,7 +4564,7 @@ mod tests {
                let mut node_a_chan = Channel::<EnforcingChannelKeys>::new_outbound(&&feeest, &&keys_provider, node_a_node_id, 10000000, 100000, 42, &config).unwrap();
 
                // Create Node B's channel by receiving Node A's open_channel message
-               let open_channel_msg = node_a_chan.get_open_channel(genesis_block(network).header.bitcoin_hash());
+               let open_channel_msg = node_a_chan.get_open_channel(genesis_block(network).header.block_hash());
                let node_b_node_id = PublicKey::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[7; 32]).unwrap());
                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();
 
index 6116a49eee6088cc716cd8c60551ad463700bb79..ee99012c5846922d7265f2d7336d9d7fec129ed3 100644 (file)
@@ -21,7 +21,6 @@ use bitcoin::blockdata::block::BlockHeader;
 use bitcoin::blockdata::transaction::Transaction;
 use bitcoin::blockdata::constants::genesis_block;
 use bitcoin::network::constants::Network;
-use bitcoin::util::hash::BitcoinHash;
 
 use bitcoin::hashes::{Hash, HashEngine};
 use bitcoin::hashes::hmac::{Hmac, HmacEngine};
@@ -724,7 +723,7 @@ impl<ChanSigner: ChannelKeys, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref>
 
                ChannelManager {
                        default_configuration: config.clone(),
-                       genesis_hash: genesis_block(network).header.bitcoin_hash(),
+                       genesis_hash: genesis_block(network).header.block_hash(),
                        fee_estimator: fee_est,
                        monitor,
                        tx_broadcaster,
@@ -3060,7 +3059,7 @@ impl<ChanSigner: ChannelKeys, M: Deref + Sync + Send, T: Deref + Sync + Send, K:
                                L::Target: Logger,
 {
        fn block_connected(&self, header: &BlockHeader, height: u32, txn_matched: &[&Transaction], indexes_of_txn_matched: &[usize]) {
-               let header_hash = header.bitcoin_hash();
+               let header_hash = header.block_hash();
                log_trace!(self.logger, "Block {} at height {} connected with {} txn matched", header_hash, height, txn_matched.len());
                let _ = self.total_consistency_lock.read().unwrap();
                let mut failed_channels = Vec::new();
@@ -3200,7 +3199,7 @@ impl<ChanSigner: ChannelKeys, M: Deref + Sync + Send, T: Deref + Sync + Send, K:
                        self.finish_force_close_channel(failure);
                }
                self.latest_block_height.fetch_sub(1, Ordering::AcqRel);
-               *self.last_block_hash.try_lock().expect("block_(dis)connected must not be called in parallel") = header.bitcoin_hash();
+               *self.last_block_hash.try_lock().expect("block_(dis)connected must not be called in parallel") = header.block_hash();
        }
 }
 
index 570982fb70c280de5637adedafccced787bcaacb..49168627f5448647f8bc150fdce7aa72a862b738 100644 (file)
@@ -26,7 +26,6 @@ use bitcoin::blockdata::transaction::OutPoint as BitcoinOutPoint;
 use bitcoin::blockdata::script::{Script, Builder};
 use bitcoin::blockdata::opcodes;
 use bitcoin::consensus::encode;
-use bitcoin::util::hash::BitcoinHash;
 
 use bitcoin::hashes::Hash;
 use bitcoin::hashes::sha256::Hash as Sha256;
@@ -203,7 +202,7 @@ impl<Key : Send + cmp::Eq + hash::Hash, ChanSigner: ChannelKeys, T: Deref + Sync
         C::Target: ChainWatchInterface,
 {
        fn block_connected(&self, header: &BlockHeader, height: u32, txn_matched: &[&Transaction], _indexes_of_txn_matched: &[usize]) {
-               let block_hash = header.bitcoin_hash();
+               let block_hash = header.block_hash();
                {
                        let mut monitors = self.monitors.lock().unwrap();
                        for monitor in monitors.values_mut() {
@@ -219,7 +218,7 @@ impl<Key : Send + cmp::Eq + hash::Hash, ChanSigner: ChannelKeys, T: Deref + Sync
        }
 
        fn block_disconnected(&self, header: &BlockHeader, disconnected_height: u32) {
-               let block_hash = header.bitcoin_hash();
+               let block_hash = header.block_hash();
                let mut monitors = self.monitors.lock().unwrap();
                for monitor in monitors.values_mut() {
                        monitor.block_disconnected(disconnected_height, &block_hash, &*self.broadcaster, &*self.fee_estimator, &*self.logger);
index b3d5e8c9e9da934a72989a88a287816cae79446a..3a58345505ee8730aa3194ed8485f86f8ad81d70 100644 (file)
@@ -27,7 +27,6 @@ use util::errors::APIError;
 use util::config::UserConfig;
 use util::ser::{ReadableArgs, Writeable, Readable};
 
-use bitcoin::util::hash::BitcoinHash;
 use bitcoin::blockdata::block::BlockHeader;
 use bitcoin::blockdata::transaction::{Transaction, TxOut};
 use bitcoin::network::constants::Network;
@@ -45,12 +44,12 @@ use std::mem;
 use std::collections::HashMap;
 
 pub const CHAN_CONFIRM_DEPTH: u32 = 100;
-pub fn confirm_transaction<'a, 'b: 'a>(notifier: &'a chaininterface::BlockNotifierRef<'b, &chaininterface::ChainWatchInterfaceUtil>, chain: &chaininterface::ChainWatchInterfaceUtil, tx: &Transaction, chan_id: u32) {
+pub fn confirm_transaction<'a, 'b: 'a>(notifier: &'a chaininterface::BlockNotifierRef<'b, &chaininterface::ChainWatchInterfaceUtil>, chain: &chaininterface::ChainWatchInterfaceUtil, tx: &Transaction, chan_id: i32) {
        assert!(chain.does_match_tx(tx));
        let mut header = BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
        notifier.block_connected_checked(&header, 1, &[tx; 1], &[chan_id as usize; 1]);
        for i in 2..CHAN_CONFIRM_DEPTH {
-               header = BlockHeader { version: 0x20000000, prev_blockhash: header.bitcoin_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
+               header = BlockHeader { version: 0x20000000, prev_blockhash: header.block_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
                notifier.block_connected_checked(&header, i, &vec![], &[0; 0]);
        }
 }
@@ -59,10 +58,10 @@ pub fn connect_blocks<'a, 'b>(notifier: &'a chaininterface::BlockNotifierRef<'b,
        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 };
        notifier.block_connected_checked(&header, height + 1, &Vec::new(), &Vec::new());
        for i in 2..depth + 1 {
-               header = BlockHeader { version: 0x20000000, prev_blockhash: header.bitcoin_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
+               header = BlockHeader { version: 0x20000000, prev_blockhash: header.block_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
                notifier.block_connected_checked(&header, height + i, &Vec::new(), &Vec::new());
        }
-       header.bitcoin_hash()
+       header.block_hash()
 }
 
 pub struct TestChanMonCfg {
@@ -324,7 +323,7 @@ pub fn create_funding_transaction<'a, 'b, 'c>(node: &Node<'a, 'b, 'c>, expected_
                        assert_eq!(*channel_value_satoshis, expected_chan_value);
                        assert_eq!(user_channel_id, expected_user_chan_id);
 
-                       let tx = Transaction { version: chan_id as u32, lock_time: 0, input: Vec::new(), output: vec![TxOut {
+                       let tx = Transaction { version: chan_id as i32, lock_time: 0, input: Vec::new(), output: vec![TxOut {
                                value: *channel_value_satoshis, script_pubkey: output_script.clone(),
                        }]};
                        let funding_outpoint = OutPoint { txid: tx.txid(), index: 0 };
index ef5b0e0c77388aff3835254a4d63ae701a7d4afe..55b03304199faf4e8415f48b684c67a81fd07170 100644 (file)
@@ -32,7 +32,6 @@ use util::errors::APIError;
 use util::ser::{Writeable, Writer, ReadableArgs, Readable};
 use util::config::UserConfig;
 
-use bitcoin::util::hash::BitcoinHash;
 use bitcoin::hashes::sha256d::Hash as Sha256dHash;
 use bitcoin::hashes::HashEngine;
 use bitcoin::hash_types::{Txid, BlockHash, WPubkeyHash};
@@ -2424,7 +2423,7 @@ fn channel_monitor_network_test() {
                let mut header = BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
                nodes[3].block_notifier.block_connected_checked(&header, 2, &Vec::new()[..], &[0; 0]);
                for i in 3..TEST_FINAL_CLTV + 2 + LATENCY_GRACE_PERIOD_BLOCKS + 1 {
-                       header = BlockHeader { version: 0x20000000, prev_blockhash: header.bitcoin_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
+                       header = BlockHeader { version: 0x20000000, prev_blockhash: header.block_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
                        nodes[3].block_notifier.block_connected_checked(&header, i, &Vec::new()[..], &[0; 0]);
                }
                let events = nodes[3].node.get_and_clear_pending_msg_events();
@@ -2456,7 +2455,7 @@ fn channel_monitor_network_test() {
 
                nodes[4].block_notifier.block_connected_checked(&header, 2, &Vec::new()[..], &[0; 0]);
                for i in 3..TEST_FINAL_CLTV + 2 - CLTV_CLAIM_BUFFER + 1 {
-                       header = BlockHeader { version: 0x20000000, prev_blockhash: header.bitcoin_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
+                       header = BlockHeader { version: 0x20000000, prev_blockhash: header.block_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
                        nodes[4].block_notifier.block_connected_checked(&header, i, &Vec::new()[..], &[0; 0]);
                }
                let events = nodes[4].node.get_and_clear_pending_msg_events();
@@ -2470,7 +2469,7 @@ fn channel_monitor_network_test() {
                check_added_monitors!(nodes[4], 1);
                test_txn_broadcast(&nodes[4], &chan_4, None, HTLCType::SUCCESS);
 
-               header = BlockHeader { version: 0x20000000, prev_blockhash: header.bitcoin_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
+               header = BlockHeader { version: 0x20000000, prev_blockhash: header.block_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
                nodes[4].block_notifier.block_connected(&Block { header, txdata: vec![node_txn[0].clone()] }, TEST_FINAL_CLTV - 5);
 
                check_preimage_claim(&nodes[4], &node_txn);
@@ -2533,7 +2532,7 @@ fn test_justice_tx() {
                nodes[0].block_notifier.block_connected(&Block { header, txdata: vec![revoked_local_txn[0].clone()] }, 1);
                // Verify broadcast of revoked HTLC-timeout
                let node_txn = test_txn_broadcast(&nodes[0], &chan_5, Some(revoked_local_txn[0].clone()), HTLCType::TIMEOUT);
-               header = BlockHeader { version: 0x20000000, prev_blockhash: header.bitcoin_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
+               header = BlockHeader { version: 0x20000000, prev_blockhash: header.block_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
                check_added_monitors!(nodes[0], 1);
                // Broadcast revoked HTLC-timeout on node 1
                nodes[1].block_notifier.block_connected(&Block { header, txdata: vec![node_txn[1].clone()] }, 1);
@@ -2578,7 +2577,7 @@ fn test_justice_tx() {
 
                nodes[1].block_notifier.block_connected(&Block { header, txdata: vec![revoked_local_txn[0].clone()] }, 1);
                let node_txn = test_txn_broadcast(&nodes[1], &chan_6, Some(revoked_local_txn[0].clone()), HTLCType::SUCCESS);
-               header = BlockHeader { version: 0x20000000, prev_blockhash: header.bitcoin_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
+               header = BlockHeader { version: 0x20000000, prev_blockhash: header.block_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
                check_added_monitors!(nodes[1], 1);
                nodes[0].block_notifier.block_connected(&Block { header, txdata: vec![node_txn[1].clone()] }, 1);
                test_revoked_htlc_claim_txn_broadcast(&nodes[0], node_txn[1].clone(), revoked_local_txn[0].clone());
@@ -2657,7 +2656,7 @@ fn claim_htlc_outputs_shared_tx() {
                check_added_monitors!(nodes[0], 1);
                nodes[1].block_notifier.block_connected(&Block { header, txdata: vec![revoked_local_txn[0].clone()] }, 1);
                check_added_monitors!(nodes[1], 1);
-               connect_blocks(&nodes[1].block_notifier, ANTI_REORG_DELAY - 1, 1, true, header.bitcoin_hash());
+               connect_blocks(&nodes[1].block_notifier, ANTI_REORG_DELAY - 1, 1, true, header.block_hash());
                expect_payment_failed!(nodes[1], payment_hash_2, true);
 
                let node_txn = nodes[1].tx_broadcaster.txn_broadcasted.lock().unwrap();
@@ -2722,7 +2721,7 @@ fn claim_htlc_outputs_single_tx() {
                check_added_monitors!(nodes[1], 1);
                expect_pending_htlcs_forwardable_ignore!(nodes[0]);
 
-               connect_blocks(&nodes[1].block_notifier, ANTI_REORG_DELAY - 1, 200, true, header.bitcoin_hash());
+               connect_blocks(&nodes[1].block_notifier, ANTI_REORG_DELAY - 1, 200, true, header.block_hash());
                expect_payment_failed!(nodes[1], payment_hash_2, true);
 
                let node_txn = nodes[1].tx_broadcaster.txn_broadcasted.lock().unwrap();
@@ -3019,7 +3018,7 @@ fn test_htlc_on_chain_timeout() {
        }
 
        nodes[1].block_notifier.block_connected(&Block { header, txdata: vec![timeout_tx]}, 1);
-       connect_blocks(&nodes[1].block_notifier, ANTI_REORG_DELAY - 1, 1, true, header.bitcoin_hash());
+       connect_blocks(&nodes[1].block_notifier, ANTI_REORG_DELAY - 1, 1, true, header.block_hash());
        check_added_monitors!(nodes[1], 1);
        check_closed_broadcast!(nodes[1], false);
 
@@ -3081,7 +3080,7 @@ fn test_simple_commitment_revoked_fail_backward() {
 
        let header = BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42};
        nodes[1].block_notifier.block_connected(&Block { header, txdata: vec![revoked_local_txn[0].clone()] }, 1);
-       connect_blocks(&nodes[1].block_notifier, ANTI_REORG_DELAY - 1, 1, true, header.bitcoin_hash());
+       connect_blocks(&nodes[1].block_notifier, ANTI_REORG_DELAY - 1, 1, true, header.block_hash());
        check_added_monitors!(nodes[1], 1);
        check_closed_broadcast!(nodes[1], false);
 
@@ -3235,7 +3234,7 @@ fn do_test_commitment_revoked_fail_backward_exhaustive(deliver_bs_raa: bool, use
        let header = BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42};
        nodes[1].block_notifier.block_connected(&Block { header, txdata: vec![revoked_local_txn[0].clone()] }, 1);
        check_added_monitors!(nodes[1], 1);
-       connect_blocks(&nodes[1].block_notifier, ANTI_REORG_DELAY - 1, 1, true, header.bitcoin_hash());
+       connect_blocks(&nodes[1].block_notifier, ANTI_REORG_DELAY - 1, 1, true, header.block_hash());
 
        let events = nodes[1].node.get_and_clear_pending_events();
        assert_eq!(events.len(), if deliver_bs_raa { 1 } else { 2 });
@@ -3535,7 +3534,7 @@ fn test_unconf_chan() {
        let mut header = BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
        headers.push(header.clone());
        for _i in 2..100 {
-               header = BlockHeader { version: 0x20000000, prev_blockhash: header.bitcoin_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
+               header = BlockHeader { version: 0x20000000, prev_blockhash: header.block_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
                headers.push(header.clone());
        }
        let mut height = 99;
@@ -4088,7 +4087,7 @@ fn do_test_htlc_timeout(send_partial_mpp: bool) {
        nodes[0].block_notifier.block_connected_checked(&header, 101, &[], &[]);
        nodes[1].block_notifier.block_connected_checked(&header, 101, &[], &[]);
        for i in 102..TEST_FINAL_CLTV + 100 + 1 - CLTV_CLAIM_BUFFER - LATENCY_GRACE_PERIOD_BLOCKS {
-               header.prev_blockhash = header.bitcoin_hash();
+               header.prev_blockhash = header.block_hash();
                nodes[0].block_notifier.block_connected_checked(&header, i, &[], &[]);
                nodes[1].block_notifier.block_connected_checked(&header, i, &[], &[]);
        }
@@ -4158,14 +4157,14 @@ fn do_test_holding_cell_htlc_add_timeouts(forwarded_htlc: bool) {
        let mut header = BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
        nodes[1].block_notifier.block_connected_checked(&header, 101, &[], &[]);
        for i in 102..TEST_FINAL_CLTV + 100 - CLTV_CLAIM_BUFFER - LATENCY_GRACE_PERIOD_BLOCKS {
-               header.prev_blockhash = header.bitcoin_hash();
+               header.prev_blockhash = header.block_hash();
                nodes[1].block_notifier.block_connected_checked(&header, i, &[], &[]);
        }
 
        assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
        assert!(nodes[1].node.get_and_clear_pending_events().is_empty());
 
-       header.prev_blockhash = header.bitcoin_hash();
+       header.prev_blockhash = header.block_hash();
        nodes[1].block_notifier.block_connected_checked(&header, TEST_FINAL_CLTV + 100 - CLTV_CLAIM_BUFFER - LATENCY_GRACE_PERIOD_BLOCKS, &[], &[]);
 
        if forwarded_htlc {
@@ -4232,7 +4231,7 @@ fn test_invalid_channel_announcement() {
                () => {
                        msgs::UnsignedChannelAnnouncement {
                                features: ChannelFeatures::known(),
-                               chain_hash: genesis_block(Network::Testnet).header.bitcoin_hash(),
+                               chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                                short_channel_id: as_chan.get_short_channel_id().unwrap(),
                                node_id_1: if were_node_one { as_network_key } else { bs_network_key },
                                node_id_2: if were_node_one { bs_network_key } else { as_network_key },
@@ -4267,7 +4266,7 @@ fn test_invalid_channel_announcement() {
 
        // Configured with Network::Testnet
        let mut unsigned_msg = dummy_unsigned_msg!();
-       unsigned_msg.chain_hash = genesis_block(Network::Bitcoin).header.bitcoin_hash();
+       unsigned_msg.chain_hash = genesis_block(Network::Bitcoin).header.block_hash();
        sign_msg!(unsigned_msg);
        assert!(nodes[0].net_graph_msg_handler.handle_channel_announcement(&chan_announcement).is_err());
 
@@ -4798,7 +4797,7 @@ fn test_claim_sizeable_push_msat() {
 
        let header = BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
        nodes[1].block_notifier.block_connected(&Block { header, txdata: vec![node_txn[0].clone()] }, 0);
-       connect_blocks(&nodes[1].block_notifier, ANTI_REORG_DELAY - 1, 1, true, header.bitcoin_hash());
+       connect_blocks(&nodes[1].block_notifier, ANTI_REORG_DELAY - 1, 1, true, header.block_hash());
 
        let spend_txn = check_spendable_outputs!(nodes[1], 1, node_cfgs[1].keys_manager, 100000);
        assert_eq!(spend_txn.len(), 1);
@@ -4828,7 +4827,7 @@ fn test_claim_on_remote_sizeable_push_msat() {
        nodes[1].block_notifier.block_connected(&Block { header, txdata: vec![node_txn[0].clone()] }, 0);
        check_closed_broadcast!(nodes[1], false);
        check_added_monitors!(nodes[1], 1);
-       connect_blocks(&nodes[1].block_notifier, ANTI_REORG_DELAY - 1, 1, true, header.bitcoin_hash());
+       connect_blocks(&nodes[1].block_notifier, ANTI_REORG_DELAY - 1, 1, true, header.block_hash());
 
        let spend_txn = check_spendable_outputs!(nodes[1], 1, node_cfgs[1].keys_manager, 100000);
        assert_eq!(spend_txn.len(), 2);
@@ -4859,9 +4858,9 @@ fn test_claim_on_remote_revoked_sizeable_push_msat() {
        check_added_monitors!(nodes[1], 1);
 
        let node_txn = nodes[1].tx_broadcaster.txn_broadcasted.lock().unwrap();
-       let header_1 = BlockHeader { version: 0x20000000, prev_blockhash: header.bitcoin_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
+       let header_1 = BlockHeader { version: 0x20000000, prev_blockhash: header.block_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
        nodes[1].block_notifier.block_connected(&Block { header: header_1, txdata: vec![node_txn[0].clone()] }, 1);
-       connect_blocks(&nodes[1].block_notifier, ANTI_REORG_DELAY - 1, 1, true, header.bitcoin_hash());
+       connect_blocks(&nodes[1].block_notifier, ANTI_REORG_DELAY - 1, 1, true, header.block_hash());
 
        let spend_txn = check_spendable_outputs!(nodes[1], 1, node_cfgs[1].keys_manager, 100000);
        assert_eq!(spend_txn.len(), 3);
@@ -4910,9 +4909,9 @@ fn test_static_spendable_outputs_preimage_tx() {
        check_spends!(node_txn[1], chan_1.3);
        check_spends!(node_txn[2], node_txn[1]);
 
-       let header_1 = BlockHeader { version: 0x20000000, prev_blockhash: header.bitcoin_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
+       let header_1 = BlockHeader { version: 0x20000000, prev_blockhash: header.block_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
        nodes[1].block_notifier.block_connected(&Block { header: header_1, txdata: vec![node_txn[0].clone()] }, 1);
-       connect_blocks(&nodes[1].block_notifier, ANTI_REORG_DELAY - 1, 1, true, header.bitcoin_hash());
+       connect_blocks(&nodes[1].block_notifier, ANTI_REORG_DELAY - 1, 1, true, header.block_hash());
 
        let spend_txn = check_spendable_outputs!(nodes[1], 1, node_cfgs[1].keys_manager, 100000);
        assert_eq!(spend_txn.len(), 1);
@@ -4956,9 +4955,9 @@ fn test_static_spendable_outputs_timeout_tx() {
        check_spends!(node_txn[1], chan_1.3.clone());
        check_spends!(node_txn[2], node_txn[1]);
 
-       let header_1 = BlockHeader { version: 0x20000000, prev_blockhash: header.bitcoin_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
+       let header_1 = BlockHeader { version: 0x20000000, prev_blockhash: header.block_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
        nodes[1].block_notifier.block_connected(&Block { header: header_1, txdata: vec![node_txn[0].clone()] }, 1);
-       connect_blocks(&nodes[1].block_notifier, ANTI_REORG_DELAY - 1, 1, true, header.bitcoin_hash());
+       connect_blocks(&nodes[1].block_notifier, ANTI_REORG_DELAY - 1, 1, true, header.block_hash());
        expect_payment_failed!(nodes[1], our_payment_hash, true);
 
        let spend_txn = check_spendable_outputs!(nodes[1], 1, node_cfgs[1].keys_manager, 100000);
@@ -4993,9 +4992,9 @@ fn test_static_spendable_outputs_justice_tx_revoked_commitment_tx() {
        assert_eq!(node_txn[0].input.len(), 2);
        check_spends!(node_txn[0], revoked_local_txn[0]);
 
-       let header_1 = BlockHeader { version: 0x20000000, prev_blockhash: header.bitcoin_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
+       let header_1 = BlockHeader { version: 0x20000000, prev_blockhash: header.block_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
        nodes[1].block_notifier.block_connected(&Block { header: header_1, txdata: vec![node_txn[0].clone()] }, 1);
-       connect_blocks(&nodes[1].block_notifier, ANTI_REORG_DELAY - 1, 1, true, header.bitcoin_hash());
+       connect_blocks(&nodes[1].block_notifier, ANTI_REORG_DELAY - 1, 1, true, header.block_hash());
 
        let spend_txn = check_spendable_outputs!(nodes[1], 1, node_cfgs[1].keys_manager, 100000);
        assert_eq!(spend_txn.len(), 1);
@@ -5047,9 +5046,9 @@ fn test_static_spendable_outputs_justice_tx_revoked_htlc_timeout_tx() {
        assert_eq!(node_txn[3].input.len(), 1);
        check_spends!(node_txn[3], revoked_local_txn[0]);
 
-       let header_1 = BlockHeader { version: 0x20000000, prev_blockhash: header.bitcoin_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
+       let header_1 = BlockHeader { version: 0x20000000, prev_blockhash: header.block_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
        nodes[1].block_notifier.block_connected(&Block { header: header_1, txdata: vec![node_txn[0].clone(), node_txn[2].clone()] }, 1);
-       connect_blocks(&nodes[1].block_notifier, ANTI_REORG_DELAY - 1, 1, true, header.bitcoin_hash());
+       connect_blocks(&nodes[1].block_notifier, ANTI_REORG_DELAY - 1, 1, true, header.block_hash());
 
        // Check B's ChannelMonitor was able to generate the right spendable output descriptor
        let spend_txn = check_spendable_outputs!(nodes[1], 1, node_cfgs[1].keys_manager, 100000);
@@ -5097,9 +5096,9 @@ fn test_static_spendable_outputs_justice_tx_revoked_htlc_success_tx() {
        assert_eq!(node_txn[2].input.len(), 1);
        check_spends!(node_txn[2], revoked_htlc_txn[0]);
 
-       let header_1 = BlockHeader { version: 0x20000000, prev_blockhash: header.bitcoin_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
+       let header_1 = BlockHeader { version: 0x20000000, prev_blockhash: header.block_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
        nodes[0].block_notifier.block_connected(&Block { header: header_1, txdata: vec![node_txn[0].clone(), node_txn[2].clone()] }, 1);
-       connect_blocks(&nodes[0].block_notifier, ANTI_REORG_DELAY - 1, 1, true, header.bitcoin_hash());
+       connect_blocks(&nodes[0].block_notifier, ANTI_REORG_DELAY - 1, 1, true, header.block_hash());
 
        // Check A's ChannelMonitor was able to generate the right spendable output descriptor
        let spend_txn = check_spendable_outputs!(nodes[0], 1, node_cfgs[0].keys_manager, 100000);
@@ -5283,7 +5282,7 @@ fn test_duplicate_payment_hash_one_failure_one_success() {
        check_spends!(htlc_success_txn[1], commitment_txn[0]);
 
        nodes[1].block_notifier.block_connected(&Block { header, txdata: vec![htlc_timeout_tx] }, 200);
-       connect_blocks(&nodes[1].block_notifier, ANTI_REORG_DELAY - 1, 200, true, header.bitcoin_hash());
+       connect_blocks(&nodes[1].block_notifier, ANTI_REORG_DELAY - 1, 200, true, header.block_hash());
        expect_pending_htlcs_forwardable!(nodes[1]);
        let htlc_updates = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
        assert!(htlc_updates.update_add_htlcs.is_empty());
@@ -5367,9 +5366,9 @@ fn test_dynamic_spendable_outputs_local_htlc_success_tx() {
                vec![node_txn[0].clone(), node_txn[2].clone()]
        };
 
-       let header_201 = BlockHeader { version: 0x20000000, prev_blockhash: header.bitcoin_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
+       let header_201 = BlockHeader { version: 0x20000000, prev_blockhash: header.block_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
        nodes[1].block_notifier.block_connected(&Block { header: header_201, txdata: node_txn.clone() }, 201);
-       connect_blocks(&nodes[1].block_notifier, ANTI_REORG_DELAY - 1, 201, true, header_201.bitcoin_hash());
+       connect_blocks(&nodes[1].block_notifier, ANTI_REORG_DELAY - 1, 201, true, header_201.block_hash());
 
        // Verify that B is able to spend its own HTLC-Success tx thanks to spendable output event given back by its ChannelMonitor
        let spend_txn = check_spendable_outputs!(nodes[1], 1, node_cfgs[1].keys_manager, 100000);
@@ -5513,7 +5512,7 @@ fn do_test_fail_backwards_unrevoked_remote_announce(deliver_last_raa: bool, anno
        } else {
                nodes[2].block_notifier.block_connected(&Block { header, txdata: vec![ds_prev_commitment_tx[0].clone()]}, 1);
        }
-       connect_blocks(&nodes[2].block_notifier, ANTI_REORG_DELAY - 1, 1, true,  header.bitcoin_hash());
+       connect_blocks(&nodes[2].block_notifier, ANTI_REORG_DELAY - 1, 1, true,  header.block_hash());
        check_closed_broadcast!(nodes[2], false);
        expect_pending_htlcs_forwardable!(nodes[2]);
        check_added_monitors!(nodes[2], 3);
@@ -5663,9 +5662,9 @@ fn test_dynamic_spendable_outputs_local_htlc_timeout_tx() {
                node_txn[0].clone()
        };
 
-       let header_201 = BlockHeader { version: 0x20000000, prev_blockhash: header.bitcoin_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
+       let header_201 = BlockHeader { version: 0x20000000, prev_blockhash: header.block_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
        nodes[0].block_notifier.block_connected(&Block { header: header_201, txdata: vec![htlc_timeout.clone()] }, 201);
-       connect_blocks(&nodes[0].block_notifier, ANTI_REORG_DELAY - 1, 201, true, header_201.bitcoin_hash());
+       connect_blocks(&nodes[0].block_notifier, ANTI_REORG_DELAY - 1, 201, true, header_201.block_hash());
        expect_payment_failed!(nodes[0], our_payment_hash, true);
 
        // Verify that A is able to spend its own HTLC-Timeout tx thanks to spendable output event given back by its ChannelMonitor
@@ -5733,9 +5732,9 @@ fn test_key_derivation_params() {
                node_txn[0].clone()
        };
 
-       let header_201 = BlockHeader { version: 0x20000000, prev_blockhash: header.bitcoin_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
+       let header_201 = BlockHeader { version: 0x20000000, prev_blockhash: header.block_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
        nodes[0].block_notifier.block_connected(&Block { header: header_201, txdata: vec![htlc_timeout.clone()] }, 201);
-       connect_blocks(&nodes[0].block_notifier, ANTI_REORG_DELAY - 1, 201, true, header_201.bitcoin_hash());
+       connect_blocks(&nodes[0].block_notifier, ANTI_REORG_DELAY - 1, 201, true, header_201.block_hash());
        expect_payment_failed!(nodes[0], our_payment_hash, true);
 
        // Verify that A is able to spend its own HTLC-Timeout tx thanks to spendable output event given back by its ChannelMonitor
@@ -5761,14 +5760,14 @@ fn test_static_output_closing_tx() {
 
        let header = BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
        nodes[0].block_notifier.block_connected(&Block { header, txdata: vec![closing_tx.clone()] }, 0);
-       connect_blocks(&nodes[0].block_notifier, ANTI_REORG_DELAY - 1, 0, true, header.bitcoin_hash());
+       connect_blocks(&nodes[0].block_notifier, ANTI_REORG_DELAY - 1, 0, true, header.block_hash());
 
        let spend_txn = check_spendable_outputs!(nodes[0], 2, node_cfgs[0].keys_manager, 100000);
        assert_eq!(spend_txn.len(), 1);
        check_spends!(spend_txn[0], closing_tx);
 
        nodes[1].block_notifier.block_connected(&Block { header, txdata: vec![closing_tx.clone()] }, 0);
-       connect_blocks(&nodes[1].block_notifier, ANTI_REORG_DELAY - 1, 0, true, header.bitcoin_hash());
+       connect_blocks(&nodes[1].block_notifier, ANTI_REORG_DELAY - 1, 0, true, header.block_hash());
 
        let spend_txn = check_spendable_outputs!(nodes[1], 2, node_cfgs[1].keys_manager, 100000);
        assert_eq!(spend_txn.len(), 1);
@@ -5809,7 +5808,7 @@ fn do_htlc_claim_local_commitment_only(use_dust: bool) {
        let mut header = BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
        for i in 1..TEST_FINAL_CLTV - CLTV_CLAIM_BUFFER + CHAN_CONFIRM_DEPTH + 1 {
                nodes[1].block_notifier.block_connected_checked(&header, i, &Vec::new(), &Vec::new());
-               header.prev_blockhash = header.bitcoin_hash();
+               header.prev_blockhash = header.block_hash();
        }
        test_txn_broadcast(&nodes[1], &chan, None, if use_dust { HTLCType::NONE } else { HTLCType::SUCCESS });
        check_closed_broadcast!(nodes[1], false);
@@ -5840,7 +5839,7 @@ fn do_htlc_claim_current_remote_commitment_only(use_dust: bool) {
 
        for i in 1..TEST_FINAL_CLTV + LATENCY_GRACE_PERIOD_BLOCKS + CHAN_CONFIRM_DEPTH + 1 {
                nodes[0].block_notifier.block_connected(&Block { header, txdata: Vec::new()}, i);
-               header.prev_blockhash = header.bitcoin_hash();
+               header.prev_blockhash = header.block_hash();
        }
        test_txn_broadcast(&nodes[0], &chan, None, HTLCType::NONE);
        check_closed_broadcast!(nodes[0], false);
@@ -5883,7 +5882,7 @@ fn do_htlc_claim_previous_remote_commitment_only(use_dust: bool, check_revoke_no
        let mut header = BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
        for i in 1..TEST_FINAL_CLTV + LATENCY_GRACE_PERIOD_BLOCKS + CHAN_CONFIRM_DEPTH + 1 {
                nodes[0].block_notifier.block_connected_checked(&header, i, &Vec::new(), &Vec::new());
-               header.prev_blockhash = header.bitcoin_hash();
+               header.prev_blockhash = header.block_hash();
        }
        if !check_revoke_no_close {
                test_txn_broadcast(&nodes[0], &chan, None, HTLCType::NONE);
@@ -6427,7 +6426,7 @@ fn bolt2_open_channel_sending_node_checks_part2() {
        assert!(node0_to_1_send_open_channel.to_self_delay==BREAKDOWN_TIMEOUT);
 
        // BOLT #2 spec: Sending node must ensure the chain_hash value identifies the chain it wishes to open the channel within.
-       let chain_hash=genesis_block(Network::Testnet).header.bitcoin_hash();
+       let chain_hash=genesis_block(Network::Testnet).header.block_hash();
        assert_eq!(node0_to_1_send_open_channel.chain_hash,chain_hash);
 
        // BOLT #2 spec: Sending node must set funding_pubkey, revocation_basepoint, htlc_basepoint, payment_basepoint, and delayed_payment_basepoint to valid DER-encoded, compressed, secp256k1 pubkeys.
@@ -7519,7 +7518,7 @@ fn do_test_failure_delay_dust_htlc_local_commitment(announce_latest: bool) {
        check_added_monitors!(nodes[0], 1);
 
        assert_eq!(nodes[0].node.get_and_clear_pending_events().len(), 0);
-       connect_blocks(&nodes[0].block_notifier, ANTI_REORG_DELAY - 1, 1, true,  header.bitcoin_hash());
+       connect_blocks(&nodes[0].block_notifier, ANTI_REORG_DELAY - 1, 1, true,  header.block_hash());
        let events = nodes[0].node.get_and_clear_pending_events();
        // Only 2 PaymentFailed events should show up, over-dust HTLC has to be failed by timeout tx
        assert_eq!(events.len(), 2);
@@ -7591,7 +7590,7 @@ fn test_no_failure_dust_htlc_local_commitment() {
        assert_eq!(nodes[0].node.get_and_clear_pending_events().len(), 0);
        assert_eq!(nodes[0].node.get_and_clear_pending_msg_events().len(), 0);
        // We broadcast a few more block to check everything is all right
-       connect_blocks(&nodes[0].block_notifier, 20, 1, true,  header.bitcoin_hash());
+       connect_blocks(&nodes[0].block_notifier, 20, 1, true,  header.block_hash());
        assert_eq!(nodes[0].node.get_and_clear_pending_events().len(), 0);
        assert_eq!(nodes[0].node.get_and_clear_pending_msg_events().len(), 0);
 
@@ -7636,15 +7635,15 @@ fn do_test_sweep_outbound_htlc_failure_update(revoked: bool, local: bool) {
                check_added_monitors!(nodes[0], 1);
                assert_eq!(nodes[0].node.get_and_clear_pending_events().len(), 0);
                timeout_tx.push(nodes[0].tx_broadcaster.txn_broadcasted.lock().unwrap()[0].clone());
-               let parent_hash  = connect_blocks(&nodes[0].block_notifier, ANTI_REORG_DELAY - 1, 2, true, header.bitcoin_hash());
+               let parent_hash  = connect_blocks(&nodes[0].block_notifier, ANTI_REORG_DELAY - 1, 2, true, header.block_hash());
                expect_payment_failed!(nodes[0], dust_hash, true);
                assert_eq!(timeout_tx[0].input[0].witness.last().unwrap().len(), OFFERED_HTLC_SCRIPT_WEIGHT);
                // We fail non-dust-HTLC 2 by broadcast of local HTLC-timeout tx on local commitment tx
                let header_2 = BlockHeader { version: 0x20000000, prev_blockhash: parent_hash, merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
                assert_eq!(nodes[0].node.get_and_clear_pending_events().len(), 0);
                nodes[0].block_notifier.block_connected(&Block { header: header_2, txdata: vec![timeout_tx[0].clone()]}, 7);
-               let header_3 = BlockHeader { version: 0x20000000, prev_blockhash: header_2.bitcoin_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
-               connect_blocks(&nodes[0].block_notifier, ANTI_REORG_DELAY - 1, 8, true, header_3.bitcoin_hash());
+               let header_3 = BlockHeader { version: 0x20000000, prev_blockhash: header_2.block_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
+               connect_blocks(&nodes[0].block_notifier, ANTI_REORG_DELAY - 1, 8, true, header_3.block_hash());
                expect_payment_failed!(nodes[0], non_dust_hash, true);
        } else {
                // We fail dust-HTLC 1 by broadcast of remote commitment tx. If revoked, fail also non-dust HTLC
@@ -7653,7 +7652,7 @@ fn do_test_sweep_outbound_htlc_failure_update(revoked: bool, local: bool) {
                check_added_monitors!(nodes[0], 1);
                assert_eq!(nodes[0].node.get_and_clear_pending_events().len(), 0);
                timeout_tx.push(nodes[0].tx_broadcaster.txn_broadcasted.lock().unwrap()[0].clone());
-               let parent_hash  = connect_blocks(&nodes[0].block_notifier, ANTI_REORG_DELAY - 1, 2, true, header.bitcoin_hash());
+               let parent_hash  = connect_blocks(&nodes[0].block_notifier, ANTI_REORG_DELAY - 1, 2, true, header.block_hash());
                let header_2 = BlockHeader { version: 0x20000000, prev_blockhash: parent_hash, merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
                if !revoked {
                        expect_payment_failed!(nodes[0], dust_hash, true);
@@ -7661,8 +7660,8 @@ fn do_test_sweep_outbound_htlc_failure_update(revoked: bool, local: bool) {
                        // We fail non-dust-HTLC 2 by broadcast of local timeout tx on remote commitment tx
                        nodes[0].block_notifier.block_connected(&Block { header: header_2, txdata: vec![timeout_tx[0].clone()]}, 7);
                        assert_eq!(nodes[0].node.get_and_clear_pending_events().len(), 0);
-                       let header_3 = BlockHeader { version: 0x20000000, prev_blockhash: header_2.bitcoin_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
-                       connect_blocks(&nodes[0].block_notifier, ANTI_REORG_DELAY - 1, 8, true, header_3.bitcoin_hash());
+                       let header_3 = BlockHeader { version: 0x20000000, prev_blockhash: header_2.block_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
+                       connect_blocks(&nodes[0].block_notifier, ANTI_REORG_DELAY - 1, 8, true, header_3.block_hash());
                        expect_payment_failed!(nodes[0], non_dust_hash, true);
                } else {
                        // If revoked, both dust & non-dust HTLCs should have been failed after ANTI_REORG_DELAY confs of revoked
@@ -7950,7 +7949,7 @@ fn test_data_loss_protect() {
        assert_eq!(node_txn[0].output.len(), 2);
        let header = BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42};
        nodes[0].block_notifier.block_connected(&Block { header, txdata: vec![node_txn[0].clone()]}, 0);
-       connect_blocks(&nodes[0].block_notifier, ANTI_REORG_DELAY - 1, 0, true, header.bitcoin_hash());
+       connect_blocks(&nodes[0].block_notifier, ANTI_REORG_DELAY - 1, 0, true, header.block_hash());
        let spend_txn = check_spendable_outputs!(nodes[0], 1, node_cfgs[0].keys_manager, 100000);
        assert_eq!(spend_txn.len(), 1);
        check_spends!(spend_txn[0], node_txn[0]);
@@ -8122,7 +8121,7 @@ fn test_bump_penalty_txn_on_revoked_commitment() {
        };
 
        // After exhaustion of height timer, a new bumped justice tx should have been broadcast, check it
-       let header = connect_blocks(&nodes[1].block_notifier, 3, 115,  true, header.bitcoin_hash());
+       let header = connect_blocks(&nodes[1].block_notifier, 3, 115,  true, header.block_hash());
        let mut penalty_2 = penalty_1;
        let mut feerate_2 = 0;
        {
@@ -8216,7 +8215,7 @@ fn test_bump_penalty_txn_on_revoked_htlcs() {
        }
 
        // Broadcast set of revoked txn on A
-       let header_128 = connect_blocks(&nodes[0].block_notifier, 128, 0, true, header.bitcoin_hash());
+       let header_128 = connect_blocks(&nodes[0].block_notifier, 128, 0, true, header.block_hash());
        expect_pending_htlcs_forwardable_ignore!(nodes[0]);
 
        let header_129 = BlockHeader { version: 0x20000000, prev_blockhash: header_128, merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
@@ -8240,7 +8239,7 @@ fn test_bump_penalty_txn_on_revoked_htlcs() {
        }
 
        // Connect three more block to see if bumped penalty are issued for HTLC txn
-       let header_130 = BlockHeader { version: 0x20000000, prev_blockhash: header_129.bitcoin_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
+       let header_130 = BlockHeader { version: 0x20000000, prev_blockhash: header_129.block_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
        nodes[0].block_notifier.block_connected(&Block { header: header_130, txdata: penalty_txn }, 130);
        {
                let mut node_txn = nodes[0].tx_broadcaster.txn_broadcasted.lock().unwrap();
@@ -8253,7 +8252,7 @@ fn test_bump_penalty_txn_on_revoked_htlcs() {
        };
 
        // Few more blocks to confirm penalty txn
-       let header_135 = connect_blocks(&nodes[0].block_notifier, 5, 130, true, header_130.bitcoin_hash());
+       let header_135 = connect_blocks(&nodes[0].block_notifier, 5, 130, true, header_130.block_hash());
        assert!(nodes[0].tx_broadcaster.txn_broadcasted.lock().unwrap().is_empty());
        let header_144 = connect_blocks(&nodes[0].block_notifier, 9, 135, true, header_135);
        let node_txn = {
@@ -8274,7 +8273,7 @@ fn test_bump_penalty_txn_on_revoked_htlcs() {
        // Broadcast claim txn and confirm blocks to avoid further bumps on this outputs
        let header_145 = BlockHeader { version: 0x20000000, prev_blockhash: header_144, merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
        nodes[0].block_notifier.block_connected(&Block { header: header_145, txdata: node_txn }, 145);
-       connect_blocks(&nodes[0].block_notifier, 20, 145, true, header_145.bitcoin_hash());
+       connect_blocks(&nodes[0].block_notifier, 20, 145, true, header_145.block_hash());
        {
                let mut node_txn = nodes[0].tx_broadcaster.txn_broadcasted.lock().unwrap();
                // We verify than no new transaction has been broadcast because previously
@@ -8362,7 +8361,7 @@ fn test_bump_penalty_txn_on_remote_commitment() {
        assert_ne!(feerate_preimage, 0);
 
        // After exhaustion of height timer, new bumped claim txn should have been broadcast, check it
-       connect_blocks(&nodes[1].block_notifier, 15, 1,  true, header.bitcoin_hash());
+       connect_blocks(&nodes[1].block_notifier, 15, 1,  true, header.block_hash());
        {
                let mut node_txn = nodes[1].tx_broadcaster.txn_broadcasted.lock().unwrap();
                assert_eq!(node_txn.len(), 2);
@@ -8468,7 +8467,7 @@ fn test_set_outpoints_partial_claiming() {
        };
 
        // Broadcast partial claim on node A, should regenerate a claiming tx with HTLC dropped
-       let header = BlockHeader { version: 0x20000000, prev_blockhash: header.bitcoin_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
+       let header = BlockHeader { version: 0x20000000, prev_blockhash: header.block_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
        nodes[0].block_notifier.block_connected(&Block { header, txdata: vec![partial_claim_tx.clone()] }, 102);
        {
                let mut node_txn = nodes[0].tx_broadcaster.txn_broadcasted.lock().unwrap();
@@ -8568,9 +8567,9 @@ fn test_bump_txn_sanitize_tracking_maps() {
                node_txn.clear();
                penalty_txn
        };
-       let header_130 = BlockHeader { version: 0x20000000, prev_blockhash: header_129.bitcoin_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
+       let header_130 = BlockHeader { version: 0x20000000, prev_blockhash: header_129.block_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
        nodes[0].block_notifier.block_connected(&Block { header: header_130, txdata: penalty_txn }, 130);
-       connect_blocks(&nodes[0].block_notifier, 5, 130,  false, header_130.bitcoin_hash());
+       connect_blocks(&nodes[0].block_notifier, 5, 130,  false, header_130.block_hash());
        {
                let monitors = nodes[0].chan_monitor.simple_monitor.monitors.lock().unwrap();
                if let Some(monitor) = monitors.get(&OutPoint { txid: chan.3.txid(), index: 0 }) {
index d77a39e59772ec9239d271ab55a988bd4b9fbc8a..22bca6ee19c4e71624cbe20d33dec1d248945fde 100644 (file)
@@ -1963,7 +1963,11 @@ mod tests {
                let script = Builder::new().push_opcode(opcodes::OP_TRUE).into_script();
                let shutdown = msgs::Shutdown {
                        channel_id: [2; 32],
-                       scriptpubkey: if script_type == 1 { Address::p2pkh(&::bitcoin::PublicKey{compressed: true, key: pubkey_1}, Network::Testnet).script_pubkey() } else if script_type == 2 { Address::p2sh(&script, Network::Testnet).script_pubkey() } else if script_type == 3 { Address::p2wpkh(&::bitcoin::PublicKey{compressed: true, key: pubkey_1}, Network::Testnet).script_pubkey() } else { Address::p2wsh(&script, Network::Testnet).script_pubkey() },
+                       scriptpubkey:
+                                    if script_type == 1 { Address::p2pkh(&::bitcoin::PublicKey{compressed: true, key: pubkey_1}, Network::Testnet).script_pubkey() }
+                               else if script_type == 2 { Address::p2sh(&script, Network::Testnet).script_pubkey() }
+                               else if script_type == 3 { Address::p2wpkh(&::bitcoin::PublicKey{compressed: true, key: pubkey_1}, Network::Testnet).unwrap().script_pubkey() }
+                               else                     { Address::p2wsh(&script, Network::Testnet).script_pubkey() },
                };
                let encoded_value = shutdown.encode();
                let mut target_value = hex::decode("0202020202020202020202020202020202020202020202020202020202020202").unwrap();
index 95f575fbff4a1c76a439eb829d17b82977ad5b76..cb274b5e903ef6e4cdcc5e96730cebe696d005ef 100644 (file)
@@ -14,7 +14,6 @@ use ln::features::InitFeatures;
 use ln::msgs::{ChannelMessageHandler, ErrorAction, HTLCFailChannelUpdate};
 use util::events::{Event, EventsProvider, MessageSendEvent, MessageSendEventsProvider};
 
-use bitcoin::util::hash::BitcoinHash;
 use bitcoin::blockdata::block::{Block, BlockHeader};
 
 use std::default::Default;
@@ -106,7 +105,7 @@ fn do_test_onchain_htlc_reorg(local_commitment: bool, claim: bool) {
        // At CHAN_CONFIRM_DEPTH + 1 we have a confirmation count of 1, so CHAN_CONFIRM_DEPTH +
        // ANTI_REORG_DELAY - 1 will give us a confirmation count of ANTI_REORG_DELAY - 1.
        for i in CHAN_CONFIRM_DEPTH + 2..CHAN_CONFIRM_DEPTH + ANTI_REORG_DELAY - 1 {
-               header = BlockHeader { version: 0x20000000, prev_blockhash: header.bitcoin_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
+               header = BlockHeader { version: 0x20000000, prev_blockhash: header.block_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
                nodes[1].block_notifier.block_connected_checked(&header, i, &vec![], &[0; 0]);
                headers.push(header.clone());
        }
@@ -127,7 +126,7 @@ fn do_test_onchain_htlc_reorg(local_commitment: bool, claim: bool) {
                assert_eq!(nodes[1].node.get_and_clear_pending_events().len(), 0);
        } else {
                // Confirm the timeout tx and check that we fail the HTLC backwards
-               header = BlockHeader { version: 0x20000000, prev_blockhash: header.bitcoin_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
+               header = BlockHeader { version: 0x20000000, prev_blockhash: header.block_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
                nodes[1].block_notifier.block_connected_checked(&header, CHAN_CONFIRM_DEPTH + ANTI_REORG_DELAY, &vec![], &[0; 0]);
                expect_pending_htlcs_forwardable!(nodes[1]);
        }
index c46781d11b5888b8e0f55114a525db4ea0908a75..6e51b7d092ab92b86067d71f45703213b31829f3 100644 (file)
@@ -838,7 +838,6 @@ mod tests {
        use bitcoin::blockdata::constants::genesis_block;
        use bitcoin::blockdata::script::Builder;
        use bitcoin::blockdata::opcodes;
-       use bitcoin::util::hash::BitcoinHash;
 
        use hex;
 
@@ -906,7 +905,7 @@ mod tests {
                        // Announce a channel to add a corresponding node.
                        let unsigned_announcement = UnsignedChannelAnnouncement {
                                features: ChannelFeatures::known(),
-                               chain_hash: genesis_block(Network::Testnet).header.bitcoin_hash(),
+                               chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                                short_channel_id: 0,
                                node_id_1,
                                node_id_2,
@@ -996,7 +995,7 @@ mod tests {
 
                let mut unsigned_announcement = UnsignedChannelAnnouncement {
                        features: ChannelFeatures::known(),
-                       chain_hash: genesis_block(Network::Testnet).header.bitcoin_hash(),
+                       chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 0,
                        node_id_1,
                        node_id_2,
@@ -1176,7 +1175,7 @@ mod tests {
 
                let zero_hash = Sha256dHash::hash(&[0; 32]);
                let short_channel_id = 0;
-               let chain_hash = genesis_block(Network::Testnet).header.bitcoin_hash();
+               let chain_hash = genesis_block(Network::Testnet).header.block_hash();
                let amount_sats = 1000_000;
 
                {
@@ -1339,7 +1338,7 @@ mod tests {
                let node_2_btckey = &SecretKey::from_slice(&[39; 32]).unwrap();
 
                let short_channel_id = 0;
-               let chain_hash = genesis_block(Network::Testnet).header.bitcoin_hash();
+               let chain_hash = genesis_block(Network::Testnet).header.block_hash();
 
                {
                        // There is no nodes in the table at the beginning.
@@ -1454,7 +1453,7 @@ mod tests {
                let node_2_btckey = &SecretKey::from_slice(&[39; 32]).unwrap();
 
                let short_channel_id = 1;
-               let chain_hash = genesis_block(Network::Testnet).header.bitcoin_hash();
+               let chain_hash = genesis_block(Network::Testnet).header.block_hash();
 
                // Channels were not announced yet.
                let channels_with_announcements = net_graph_msg_handler.get_next_channel_announcements(0, 1);
@@ -1588,7 +1587,7 @@ mod tests {
                let node_2_btckey = &SecretKey::from_slice(&[39; 32]).unwrap();
 
                let short_channel_id = 1;
-               let chain_hash = genesis_block(Network::Testnet).header.bitcoin_hash();
+               let chain_hash = genesis_block(Network::Testnet).header.block_hash();
 
                // No nodes yet.
                let next_announcements = net_graph_msg_handler.get_next_node_announcements(None, 10);
@@ -1708,7 +1707,7 @@ mod tests {
                let node_id_2 = PublicKey::from_secret_key(&secp_ctx, node_2_privkey);
                let unsigned_announcement = UnsignedChannelAnnouncement {
                        features: ChannelFeatures::known(),
-                       chain_hash: genesis_block(Network::Testnet).header.bitcoin_hash(),
+                       chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 0,
                        node_id_1,
                        node_id_2,
index 23232a0d0fb85d05423b61f09788dfef0e9dc0e5..1960c7b4e52cde08a5a59c49dd7942d6a11635d0 100644 (file)
@@ -424,7 +424,6 @@ mod tests {
        use bitcoin::hashes::Hash;
        use bitcoin::network::constants::Network;
        use bitcoin::blockdata::constants::genesis_block;
-       use bitcoin::util::hash::BitcoinHash;
 
        use hex;
 
@@ -441,7 +440,7 @@ mod tests {
 
                let unsigned_announcement = UnsignedChannelAnnouncement {
                        features,
-                       chain_hash: genesis_block(Network::Testnet).header.bitcoin_hash(),
+                       chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id,
                        node_id_1,
                        node_id_2,
@@ -598,7 +597,7 @@ mod tests {
 
                add_channel(&net_graph_msg_handler, &secp_ctx, &our_privkey, &privkeys[0], ChannelFeatures::from_le_bytes(id_to_feature_flags(1)), 1);
                update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[0], UnsignedChannelUpdate {
-                       chain_hash: genesis_block(Network::Testnet).header.bitcoin_hash(),
+                       chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 1,
                        timestamp: 1,
                        flags: 1,
@@ -614,7 +613,7 @@ mod tests {
 
                add_channel(&net_graph_msg_handler, &secp_ctx, &our_privkey, &privkeys[1], ChannelFeatures::from_le_bytes(id_to_feature_flags(2)), 2);
                update_channel(&net_graph_msg_handler, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
-                       chain_hash: genesis_block(Network::Testnet).header.bitcoin_hash(),
+                       chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 2,
                        timestamp: 1,
                        flags: 0,
@@ -626,7 +625,7 @@ mod tests {
                        excess_data: Vec::new()
                });
                update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[1], UnsignedChannelUpdate {
-                       chain_hash: genesis_block(Network::Testnet).header.bitcoin_hash(),
+                       chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 2,
                        timestamp: 1,
                        flags: 1,
@@ -642,7 +641,7 @@ mod tests {
 
                add_channel(&net_graph_msg_handler, &secp_ctx, &our_privkey, &privkeys[7], ChannelFeatures::from_le_bytes(id_to_feature_flags(12)), 12);
                update_channel(&net_graph_msg_handler, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
-                       chain_hash: genesis_block(Network::Testnet).header.bitcoin_hash(),
+                       chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 12,
                        timestamp: 1,
                        flags: 0,
@@ -654,7 +653,7 @@ mod tests {
                        excess_data: Vec::new()
                });
                update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[7], UnsignedChannelUpdate {
-                       chain_hash: genesis_block(Network::Testnet).header.bitcoin_hash(),
+                       chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 12,
                        timestamp: 1,
                        flags: 1,
@@ -670,7 +669,7 @@ mod tests {
 
                add_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[0], &privkeys[2], ChannelFeatures::from_le_bytes(id_to_feature_flags(3)), 3);
                update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[0], UnsignedChannelUpdate {
-                       chain_hash: genesis_block(Network::Testnet).header.bitcoin_hash(),
+                       chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 3,
                        timestamp: 1,
                        flags: 0,
@@ -682,7 +681,7 @@ mod tests {
                        excess_data: Vec::new()
                });
                update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[2], UnsignedChannelUpdate {
-                       chain_hash: genesis_block(Network::Testnet).header.bitcoin_hash(),
+                       chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 3,
                        timestamp: 1,
                        flags: 1,
@@ -696,7 +695,7 @@ mod tests {
 
                add_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[1], &privkeys[2], ChannelFeatures::from_le_bytes(id_to_feature_flags(4)), 4);
                update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[1], UnsignedChannelUpdate {
-                       chain_hash: genesis_block(Network::Testnet).header.bitcoin_hash(),
+                       chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 4,
                        timestamp: 1,
                        flags: 0,
@@ -708,7 +707,7 @@ mod tests {
                        excess_data: Vec::new()
                });
                update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[2], UnsignedChannelUpdate {
-                       chain_hash: genesis_block(Network::Testnet).header.bitcoin_hash(),
+                       chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 4,
                        timestamp: 1,
                        flags: 1,
@@ -722,7 +721,7 @@ mod tests {
 
                add_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[7], &privkeys[2], ChannelFeatures::from_le_bytes(id_to_feature_flags(13)), 13);
                update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[7], UnsignedChannelUpdate {
-                       chain_hash: genesis_block(Network::Testnet).header.bitcoin_hash(),
+                       chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 13,
                        timestamp: 1,
                        flags: 0,
@@ -734,7 +733,7 @@ mod tests {
                        excess_data: Vec::new()
                });
                update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[2], UnsignedChannelUpdate {
-                       chain_hash: genesis_block(Network::Testnet).header.bitcoin_hash(),
+                       chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 13,
                        timestamp: 1,
                        flags: 1,
@@ -750,7 +749,7 @@ mod tests {
 
                add_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[2], &privkeys[4], ChannelFeatures::from_le_bytes(id_to_feature_flags(6)), 6);
                update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[2], UnsignedChannelUpdate {
-                       chain_hash: genesis_block(Network::Testnet).header.bitcoin_hash(),
+                       chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 6,
                        timestamp: 1,
                        flags: 0,
@@ -762,7 +761,7 @@ mod tests {
                        excess_data: Vec::new()
                });
                update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[4], UnsignedChannelUpdate {
-                       chain_hash: genesis_block(Network::Testnet).header.bitcoin_hash(),
+                       chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 6,
                        timestamp: 1,
                        flags: 1,
@@ -776,7 +775,7 @@ mod tests {
 
                add_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[4], &privkeys[3], ChannelFeatures::from_le_bytes(id_to_feature_flags(11)), 11);
                update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[4], UnsignedChannelUpdate {
-                       chain_hash: genesis_block(Network::Testnet).header.bitcoin_hash(),
+                       chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 11,
                        timestamp: 1,
                        flags: 0,
@@ -788,7 +787,7 @@ mod tests {
                        excess_data: Vec::new()
                });
                update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[3], UnsignedChannelUpdate {
-                       chain_hash: genesis_block(Network::Testnet).header.bitcoin_hash(),
+                       chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 11,
                        timestamp: 1,
                        flags: 1,
@@ -806,7 +805,7 @@ mod tests {
 
                add_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[2], &privkeys[5], ChannelFeatures::from_le_bytes(id_to_feature_flags(7)), 7);
                update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[2], UnsignedChannelUpdate {
-                       chain_hash: genesis_block(Network::Testnet).header.bitcoin_hash(),
+                       chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 7,
                        timestamp: 1,
                        flags: 0,
@@ -818,7 +817,7 @@ mod tests {
                        excess_data: Vec::new()
                });
                update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[5], UnsignedChannelUpdate {
-                       chain_hash: genesis_block(Network::Testnet).header.bitcoin_hash(),
+                       chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 7,
                        timestamp: 1,
                        flags: 1,
@@ -866,7 +865,7 @@ mod tests {
 
                // // Disable channels 4 and 12 by flags=2
                update_channel(&net_graph_msg_handler, &secp_ctx, &privkeys[1], UnsignedChannelUpdate {
-                       chain_hash: genesis_block(Network::Testnet).header.bitcoin_hash(),
+                       chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 4,
                        timestamp: 2,
                        flags: 2, // to disable
@@ -878,7 +877,7 @@ mod tests {
                        excess_data: Vec::new()
                });
                update_channel(&net_graph_msg_handler, &secp_ctx, &our_privkey, UnsignedChannelUpdate {
-                       chain_hash: genesis_block(Network::Testnet).header.bitcoin_hash(),
+                       chain_hash: genesis_block(Network::Testnet).header.block_hash(),
                        short_channel_id: 12,
                        timestamp: 2,
                        flags: 2, // to disable
index 78263ecacad311ff8590d62aa740fc9cbb412794..bdd4620cb3f763bbccdf268a6bb1ea84fa784d7e 100644 (file)
@@ -21,7 +21,6 @@ use util::events;
 use util::logger::{Logger, Level, Record};
 use util::ser::{Readable, Writer, Writeable};
 
-use bitcoin::BitcoinHash;
 use bitcoin::blockdata::constants::genesis_block;
 use bitcoin::blockdata::transaction::Transaction;
 use bitcoin::blockdata::script::{Builder, Script};
@@ -196,7 +195,7 @@ fn get_dummy_channel_announcement(short_chan_id: u64) -> msgs::ChannelAnnounceme
        let node_2_btckey = SecretKey::from_slice(&[39; 32]).unwrap();
        let unsigned_ann = msgs::UnsignedChannelAnnouncement {
                features: ChannelFeatures::known(),
-               chain_hash: genesis_block(network).header.bitcoin_hash(),
+               chain_hash: genesis_block(network).header.block_hash(),
                short_channel_id: short_chan_id,
                node_id_1: PublicKey::from_secret_key(&secp_ctx, &node_1_privkey),
                node_id_2: PublicKey::from_secret_key(&secp_ctx, &node_2_privkey),
@@ -220,7 +219,7 @@ fn get_dummy_channel_update(short_chan_id: u64) -> msgs::ChannelUpdate {
        msgs::ChannelUpdate {
                signature: Signature::from(FFISignature::new()),
                contents: msgs::UnsignedChannelUpdate {
-                       chain_hash: genesis_block(network).header.bitcoin_hash(),
+                       chain_hash: genesis_block(network).header.block_hash(),
                        short_channel_id: short_chan_id,
                        timestamp: 0,
                        flags: 0,