Skip to content

Commit ea4ccf6

Browse files
authored
Merge pull request #609 from LNP-BP/refactor-deps
Refactor dependencies
2 parents 12e2a81 + dde344a commit ea4ccf6

35 files changed

+300
-282
lines changed

fuzz/Cargo.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,9 @@ stdin_fuzz = []
1919
[dependencies]
2020
afl = { version = "0.4", optional = true }
2121
lightning = { path = "../lightning", features = ["fuzztarget"] }
22-
bitcoin = { version = "0.21", features = ["fuzztarget"] }
23-
bitcoin_hashes = { version = "0.7", features = ["fuzztarget"] }
22+
bitcoin = { version = "0.23", features = ["fuzztarget"] }
2423
hex = "0.3"
2524
honggfuzz = { version = "0.5", optional = true }
26-
secp256k1 = { version = "0.15", features=["fuzztarget"] }
2725
libfuzzer-sys = { git = "https://github.com/rust-fuzz/libfuzzer-sys.git", optional = true }
2826

2927
[build-dependencies]

fuzz/src/chanmon_consistency.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,9 @@ use bitcoin::blockdata::script::{Builder, Script};
1616
use bitcoin::blockdata::opcodes;
1717
use bitcoin::network::constants::Network;
1818

19-
use bitcoin_hashes::Hash as TraitImport;
20-
use bitcoin_hashes::hash160::Hash as Hash160;
21-
use bitcoin_hashes::sha256::Hash as Sha256;
22-
use bitcoin_hashes::sha256d::Hash as Sha256d;
19+
use bitcoin::hashes::Hash as TraitImport;
20+
use bitcoin::hashes::sha256::Hash as Sha256;
21+
use bitcoin::hash_types::{BlockHash, WPubkeyHash};
2322

2423
use lightning::chain::chaininterface;
2524
use lightning::chain::transaction::OutPoint;
@@ -40,8 +39,8 @@ use lightning::util::ser::{Readable, ReadableArgs, Writeable, Writer};
4039

4140
use utils::test_logger;
4241

43-
use secp256k1::key::{PublicKey,SecretKey};
44-
use secp256k1::Secp256k1;
42+
use bitcoin::secp256k1::key::{PublicKey,SecretKey};
43+
use bitcoin::secp256k1::Secp256k1;
4544

4645
use std::mem;
4746
use std::cmp::Ordering;
@@ -114,7 +113,7 @@ impl channelmonitor::ManyChannelMonitor<EnforcingChannelKeys> for TestChannelMon
114113
hash_map::Entry::Occupied(entry) => entry,
115114
hash_map::Entry::Vacant(_) => panic!("Didn't have monitor on update call"),
116115
};
117-
let mut deserialized_monitor = <(Sha256d, channelmonitor::ChannelMonitor<EnforcingChannelKeys>)>::
116+
let mut deserialized_monitor = <(BlockHash, channelmonitor::ChannelMonitor<EnforcingChannelKeys>)>::
118117
read(&mut Cursor::new(&map_entry.get().1), Arc::clone(&self.logger)).unwrap().1;
119118
deserialized_monitor.update_monitor(update.clone(), &&TestBroadcaster {}).unwrap();
120119
let mut ser = VecWriter(Vec::new());
@@ -144,7 +143,7 @@ impl KeysInterface for KeyProvider {
144143
fn get_destination_script(&self) -> Script {
145144
let secp_ctx = Secp256k1::signing_only();
146145
let channel_monitor_claim_key = SecretKey::from_slice(&[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, self.node_id]).unwrap();
147-
let our_channel_monitor_claim_key_hash = Hash160::hash(&PublicKey::from_secret_key(&secp_ctx, &channel_monitor_claim_key).serialize());
146+
let our_channel_monitor_claim_key_hash = WPubkeyHash::hash(&PublicKey::from_secret_key(&secp_ctx, &channel_monitor_claim_key).serialize());
148147
Builder::new().push_opcode(opcodes::all::OP_PUSHBYTES_0).push_slice(&our_channel_monitor_claim_key_hash[..]).into_script()
149148
}
150149

@@ -215,7 +214,7 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
215214
let mut monitors = HashMap::new();
216215
let mut old_monitors = $old_monitors.latest_monitors.lock().unwrap();
217216
for (outpoint, (update_id, monitor_ser)) in old_monitors.drain() {
218-
monitors.insert(outpoint, <(Sha256d, ChannelMonitor<EnforcingChannelKeys>)>::read(&mut Cursor::new(&monitor_ser), Arc::clone(&logger)).expect("Failed to read monitor").1);
217+
monitors.insert(outpoint, <(BlockHash, ChannelMonitor<EnforcingChannelKeys>)>::read(&mut Cursor::new(&monitor_ser), Arc::clone(&logger)).expect("Failed to read monitor").1);
219218
monitor.latest_monitors.lock().unwrap().insert(outpoint, (update_id, monitor_ser));
220219
}
221220
let mut monitor_refs = HashMap::new();
@@ -233,7 +232,7 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
233232
channel_monitors: &mut monitor_refs,
234233
};
235234

236-
(<(Sha256d, ChannelManager<EnforcingChannelKeys, Arc<TestChannelMonitor>, Arc<TestBroadcaster>, Arc<KeyProvider>, Arc<FuzzEstimator>>)>::read(&mut Cursor::new(&$ser.0), read_args).expect("Failed to read manager").1, monitor)
235+
(<(BlockHash, ChannelManager<EnforcingChannelKeys, Arc<TestChannelMonitor>, Arc<TestBroadcaster>, Arc<KeyProvider>, Arc<FuzzEstimator>>)>::read(&mut Cursor::new(&$ser.0), read_args).expect("Failed to read manager").1, monitor)
237236
} }
238237
}
239238

fuzz/src/chanmon_deser.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// This file is auto-generated by gen_target.sh based on msg_target_template.txt
22
// To modify it, modify msg_target_template.txt and run gen_target.sh instead.
33

4-
use bitcoin_hashes::sha256d::Hash as Sha256dHash;
4+
use bitcoin::hash_types::BlockHash;
55

66
use lightning::util::enforcing_trait_impls::EnforcingChannelKeys;
77
use lightning::ln::channelmonitor;
@@ -26,10 +26,10 @@ impl Writer for VecWriter {
2626
#[inline]
2727
pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
2828
let logger = Arc::new(test_logger::TestLogger::new("".to_owned(), out));
29-
if let Ok((latest_block_hash, monitor)) = <(Sha256dHash, channelmonitor::ChannelMonitor<EnforcingChannelKeys>)>::read(&mut Cursor::new(data), logger.clone()) {
29+
if let Ok((latest_block_hash, monitor)) = <(BlockHash, channelmonitor::ChannelMonitor<EnforcingChannelKeys>)>::read(&mut Cursor::new(data), logger.clone()) {
3030
let mut w = VecWriter(Vec::new());
3131
monitor.write_for_disk(&mut w).unwrap();
32-
let deserialized_copy = <(Sha256dHash, channelmonitor::ChannelMonitor<EnforcingChannelKeys>)>::read(&mut Cursor::new(&w.0), logger.clone()).unwrap();
32+
let deserialized_copy = <(BlockHash, channelmonitor::ChannelMonitor<EnforcingChannelKeys>)>::read(&mut Cursor::new(&w.0), logger.clone()).unwrap();
3333
assert!(latest_block_hash == deserialized_copy.0);
3434
assert!(monitor == deserialized_copy.1);
3535
}

fuzz/src/full_stack.rs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@ use bitcoin::consensus::encode::deserialize;
1212
use bitcoin::network::constants::Network;
1313
use bitcoin::util::hash::BitcoinHash;
1414

15-
use bitcoin_hashes::Hash as TraitImport;
16-
use bitcoin_hashes::HashEngine as TraitImportEngine;
17-
use bitcoin_hashes::sha256::Hash as Sha256;
18-
use bitcoin_hashes::hash160::Hash as Hash160;
19-
use bitcoin_hashes::sha256d::Hash as Sha256dHash;
15+
use bitcoin::hashes::Hash as TraitImport;
16+
use bitcoin::hashes::HashEngine as TraitImportEngine;
17+
use bitcoin::hashes::sha256::Hash as Sha256;
18+
use bitcoin::hash_types::{Txid, BlockHash, WPubkeyHash};
2019

2120
use lightning::chain::chaininterface::{BroadcasterInterface,ConfirmationTarget,ChainListener,FeeEstimator,ChainWatchInterfaceUtil};
2221
use lightning::chain::transaction::OutPoint;
@@ -32,13 +31,12 @@ use lightning::util::config::UserConfig;
3231

3332
use utils::test_logger;
3433

35-
use secp256k1::key::{PublicKey,SecretKey};
36-
use secp256k1::Secp256k1;
34+
use bitcoin::secp256k1::key::{PublicKey,SecretKey};
35+
use bitcoin::secp256k1::Secp256k1;
3736

3837
use std::cell::RefCell;
3938
use std::collections::{HashMap, hash_map};
4039
use std::cmp;
41-
use std::hash::Hash;
4240
use std::sync::Arc;
4341
use std::sync::atomic::{AtomicU64,AtomicUsize,Ordering};
4442

@@ -129,7 +127,7 @@ impl<'a> PartialEq for Peer<'a> {
129127
}
130128
}
131129
impl<'a> Eq for Peer<'a> {}
132-
impl<'a> Hash for Peer<'a> {
130+
impl<'a> std::hash::Hash for Peer<'a> {
133131
fn hash<H : std::hash::Hasher>(&self, h: &mut H) {
134132
self.id.hash(h)
135133
}
@@ -142,8 +140,8 @@ struct MoneyLossDetector<'a> {
142140

143141
peers: &'a RefCell<[bool; 256]>,
144142
funding_txn: Vec<Transaction>,
145-
txids_confirmed: HashMap<Sha256dHash, usize>,
146-
header_hashes: Vec<Sha256dHash>,
143+
txids_confirmed: HashMap<Txid, usize>,
144+
header_hashes: Vec<BlockHash>,
147145
height: usize,
148146
max_height: usize,
149147
blocks_connected: u32,
@@ -241,7 +239,7 @@ impl KeysInterface for KeyProvider {
241239
fn get_destination_script(&self) -> Script {
242240
let secp_ctx = Secp256k1::signing_only();
243241
let channel_monitor_claim_key = SecretKey::from_slice(&hex::decode("0fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff").unwrap()[..]).unwrap();
244-
let our_channel_monitor_claim_key_hash = <Hash160 as bitcoin_hashes::Hash>::hash(&PublicKey::from_secret_key(&secp_ctx, &channel_monitor_claim_key).serialize());
242+
let our_channel_monitor_claim_key_hash = WPubkeyHash::hash(&PublicKey::from_secret_key(&secp_ctx, &channel_monitor_claim_key).serialize());
245243
Builder::new().push_opcode(opcodes::all::OP_PUSHBYTES_0).push_slice(&our_channel_monitor_claim_key_hash[..]).into_script()
246244
}
247245

fuzz/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
extern crate bitcoin;
2-
extern crate bitcoin_hashes;
32
extern crate lightning;
4-
extern crate secp256k1;
53
extern crate hex;
64

75
pub mod utils;

fuzz/src/peer_crypt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use lightning::ln::peer_channel_encryptor::PeerChannelEncryptor;
22

3-
use secp256k1::key::{PublicKey,SecretKey};
3+
use bitcoin::secp256k1::key::{PublicKey,SecretKey};
44

55
use utils::test_logger;
66

fuzz/src/router.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
use bitcoin_hashes::sha256d::Hash as Sha256dHash;
21
use bitcoin::blockdata::script::{Script, Builder};
32
use bitcoin::blockdata::block::Block;
43
use bitcoin::blockdata::transaction::Transaction;
4+
use bitcoin::hash_types::{Txid, BlockHash};
55

66
use lightning::chain::chaininterface::{ChainError,ChainWatchInterface};
77
use lightning::ln::channelmanager::ChannelDetails;
@@ -12,7 +12,7 @@ use lightning::ln::router::{Router, RouteHint};
1212
use lightning::util::logger::Logger;
1313
use lightning::util::ser::Readable;
1414

15-
use secp256k1::key::PublicKey;
15+
use bitcoin::secp256k1::key::PublicKey;
1616

1717
use utils::test_logger;
1818

@@ -72,15 +72,15 @@ struct DummyChainWatcher {
7272
}
7373

7474
impl ChainWatchInterface for DummyChainWatcher {
75-
fn install_watch_tx(&self, _txid: &Sha256dHash, _script_pub_key: &Script) { }
76-
fn install_watch_outpoint(&self, _outpoint: (Sha256dHash, u32), _out_script: &Script) { }
75+
fn install_watch_tx(&self, _txid: &Txid, _script_pub_key: &Script) { }
76+
fn install_watch_outpoint(&self, _outpoint: (Txid, u32), _out_script: &Script) { }
7777
fn watch_all_txn(&self) { }
7878
fn filter_block<'a>(&self, _block: &'a Block) -> (Vec<&'a Transaction>, Vec<u32>) {
7979
(Vec::new(), Vec::new())
8080
}
8181
fn reentered(&self) -> usize { 0 }
8282

83-
fn get_chain_utxo(&self, _genesis_hash: Sha256dHash, _unspent_tx_output_identifier: u64) -> Result<(Script, u64), ChainError> {
83+
fn get_chain_utxo(&self, _genesis_hash: BlockHash, _unspent_tx_output_identifier: u64) -> Result<(Script, u64), ChainError> {
8484
match self.input.get_slice(2) {
8585
Some(&[0, _]) => Err(ChainError::NotSupported),
8686
Some(&[1, _]) => Err(ChainError::NotWatched),

lightning-net-tokio/Cargo.toml

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

1212
[dependencies]
13-
bitcoin = "0.21"
14-
bitcoin_hashes = "0.7"
13+
bitcoin = "0.23"
1514
lightning = { version = "0.0.11", path = "../lightning" }
16-
secp256k1 = "0.15"
1715
tokio = { version = ">=0.2.12", features = [ "io-util", "macros", "rt-core", "sync", "tcp", "time" ] }
1816

1917
[dev-dependencies]

lightning-net-tokio/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
//! ```
1717
//! use tokio::sync::mpsc;
1818
//! use tokio::net::TcpStream;
19-
//! use secp256k1::key::PublicKey;
19+
//! use bitcoin::secp256k1::key::PublicKey;
2020
//! use lightning::util::events::EventsProvider;
2121
//! use std::net::SocketAddr;
2222
//! use std::sync::Arc;
@@ -59,7 +59,7 @@
5959
//! }
6060
//! ```
6161
62-
use secp256k1::key::PublicKey;
62+
use bitcoin::secp256k1::key::PublicKey;
6363

6464
use tokio::net::TcpStream;
6565
use tokio::{io, time};
@@ -481,7 +481,7 @@ mod tests {
481481
use lightning::ln::msgs::*;
482482
use lightning::ln::peer_handler::{MessageHandler, PeerManager};
483483
use lightning::util::events::*;
484-
use secp256k1::{Secp256k1, SecretKey, PublicKey};
484+
use bitcoin::secp256k1::{Secp256k1, SecretKey, PublicKey};
485485

486486
use tokio::sync::mpsc;
487487

lightning/Cargo.toml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Still missing tons of error-handling. See GitHub issues for suggested projects i
1313
[features]
1414
# Supports tracking channels with a non-bitcoin chain hashes. Currently enables all kinds of fun DoS attacks.
1515
non_bitcoin_chain_hash_routing = []
16-
fuzztarget = ["secp256k1/fuzztarget", "bitcoin/fuzztarget", "bitcoin_hashes/fuzztarget"]
16+
fuzztarget = ["bitcoin/fuzztarget"]
1717
# Unlog messages superior at targeted level.
1818
max_level_off = []
1919
max_level_error = []
@@ -22,12 +22,10 @@ max_level_info = []
2222
max_level_debug = []
2323

2424
[dependencies]
25-
bitcoin = "0.21"
26-
bitcoin_hashes = "0.7"
27-
secp256k1 = "0.15"
25+
bitcoin = "0.23"
2826

2927
[dev-dependencies.bitcoin]
30-
version = "0.21"
28+
version = "0.23"
3129
features = ["bitcoinconsensus"]
3230

3331
[dev-dependencies]

lightning/src/chain/chaininterface.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ use bitcoin::blockdata::transaction::Transaction;
99
use bitcoin::blockdata::script::Script;
1010
use bitcoin::blockdata::constants::genesis_block;
1111
use bitcoin::util::hash::BitcoinHash;
12-
use bitcoin_hashes::sha256d::Hash as Sha256dHash;
1312
use bitcoin::network::constants::Network;
13+
use bitcoin::hash_types::{Txid, BlockHash};
1414

1515
use util::logger::Logger;
1616

@@ -40,11 +40,11 @@ pub enum ChainError {
4040
/// events).
4141
pub trait ChainWatchInterface: Sync + Send {
4242
/// Provides a txid/random-scriptPubKey-in-the-tx which much be watched for.
43-
fn install_watch_tx(&self, txid: &Sha256dHash, script_pub_key: &Script);
43+
fn install_watch_tx(&self, txid: &Txid, script_pub_key: &Script);
4444

4545
/// Provides an outpoint which must be watched for, providing any transactions which spend the
4646
/// given outpoint.
47-
fn install_watch_outpoint(&self, outpoint: (Sha256dHash, u32), out_script: &Script);
47+
fn install_watch_outpoint(&self, outpoint: (Txid, u32), out_script: &Script);
4848

4949
/// Indicates that a listener needs to see all transactions.
5050
fn watch_all_txn(&self);
@@ -53,7 +53,7 @@ pub trait ChainWatchInterface: Sync + Send {
5353
/// short_channel_id (aka unspent_tx_output_identier). For BTC/tBTC channels the top three
5454
/// bytes are the block height, the next 3 the transaction index within the block, and the
5555
/// final two the output within the transaction.
56-
fn get_chain_utxo(&self, genesis_hash: Sha256dHash, unspent_tx_output_identifier: u64) -> Result<(Script, u64), ChainError>;
56+
fn get_chain_utxo(&self, genesis_hash: BlockHash, unspent_tx_output_identifier: u64) -> Result<(Script, u64), ChainError>;
5757

5858
/// Gets the list of transactions and transaction indices that the ChainWatchInterface is
5959
/// watching for.
@@ -135,11 +135,11 @@ pub struct ChainWatchedUtil {
135135
// We are more conservative in matching during testing to ensure everything matches *exactly*,
136136
// even though during normal runtime we take more optimized match approaches...
137137
#[cfg(test)]
138-
watched_txn: HashSet<(Sha256dHash, Script)>,
138+
watched_txn: HashSet<(Txid, Script)>,
139139
#[cfg(not(test))]
140140
watched_txn: HashSet<Script>,
141141

142-
watched_outpoints: HashSet<(Sha256dHash, u32)>,
142+
watched_outpoints: HashSet<(Txid, u32)>,
143143
}
144144

145145
impl ChainWatchedUtil {
@@ -154,7 +154,7 @@ impl ChainWatchedUtil {
154154

155155
/// Registers a tx for monitoring, returning true if it was a new tx and false if we'd already
156156
/// been watching for it.
157-
pub fn register_tx(&mut self, txid: &Sha256dHash, script_pub_key: &Script) -> bool {
157+
pub fn register_tx(&mut self, txid: &Txid, script_pub_key: &Script) -> bool {
158158
if self.watch_all { return false; }
159159
#[cfg(test)]
160160
{
@@ -169,7 +169,7 @@ impl ChainWatchedUtil {
169169

170170
/// Registers an outpoint for monitoring, returning true if it was a new outpoint and false if
171171
/// we'd already been watching for it
172-
pub fn register_outpoint(&mut self, outpoint: (Sha256dHash, u32), _script_pub_key: &Script) -> bool {
172+
pub fn register_outpoint(&mut self, outpoint: (Txid, u32), _script_pub_key: &Script) -> bool {
173173
if self.watch_all { return false; }
174174
self.watched_outpoints.insert(outpoint)
175175
}
@@ -332,14 +332,14 @@ impl PartialEq for ChainWatchInterfaceUtil {
332332

333333
/// Register listener
334334
impl ChainWatchInterface for ChainWatchInterfaceUtil {
335-
fn install_watch_tx(&self, txid: &Sha256dHash, script_pub_key: &Script) {
335+
fn install_watch_tx(&self, txid: &Txid, script_pub_key: &Script) {
336336
let mut watched = self.watched.lock().unwrap();
337337
if watched.register_tx(txid, script_pub_key) {
338338
self.reentered.fetch_add(1, Ordering::Relaxed);
339339
}
340340
}
341341

342-
fn install_watch_outpoint(&self, outpoint: (Sha256dHash, u32), out_script: &Script) {
342+
fn install_watch_outpoint(&self, outpoint: (Txid, u32), out_script: &Script) {
343343
let mut watched = self.watched.lock().unwrap();
344344
if watched.register_outpoint(outpoint, out_script) {
345345
self.reentered.fetch_add(1, Ordering::Relaxed);
@@ -353,7 +353,7 @@ impl ChainWatchInterface for ChainWatchInterfaceUtil {
353353
}
354354
}
355355

356-
fn get_chain_utxo(&self, genesis_hash: Sha256dHash, _unspent_tx_output_identifier: u64) -> Result<(Script, u64), ChainError> {
356+
fn get_chain_utxo(&self, genesis_hash: BlockHash, _unspent_tx_output_identifier: u64) -> Result<(Script, u64), ChainError> {
357357
if genesis_hash != genesis_block(self.network).header.bitcoin_hash() {
358358
return Err(ChainError::NotWatched);
359359
}

lightning/src/chain/keysinterface.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ use bitcoin::network::constants::Network;
99
use bitcoin::util::bip32::{ExtendedPrivKey, ExtendedPubKey, ChildNumber};
1010
use bitcoin::util::bip143;
1111

12-
use bitcoin_hashes::{Hash, HashEngine};
13-
use bitcoin_hashes::sha256::HashEngine as Sha256State;
14-
use bitcoin_hashes::sha256::Hash as Sha256;
15-
use bitcoin_hashes::sha256d::Hash as Sha256dHash;
16-
use bitcoin_hashes::hash160::Hash as Hash160;
12+
use bitcoin::hashes::{Hash, HashEngine};
13+
use bitcoin::hashes::sha256::HashEngine as Sha256State;
14+
use bitcoin::hashes::sha256::Hash as Sha256;
15+
use bitcoin::hashes::sha256d::Hash as Sha256dHash;
16+
use bitcoin::hash_types::WPubkeyHash;
1717

18-
use secp256k1::key::{SecretKey, PublicKey};
19-
use secp256k1::{Secp256k1, Signature, Signing};
20-
use secp256k1;
18+
use bitcoin::secp256k1::key::{SecretKey, PublicKey};
19+
use bitcoin::secp256k1::{Secp256k1, Signature, Signing};
20+
use bitcoin::secp256k1;
2121

2222
use util::byte_utils;
2323
use util::logger::Logger;
@@ -513,9 +513,9 @@ impl KeysManager {
513513
let node_secret = master_key.ckd_priv(&secp_ctx, ChildNumber::from_hardened_idx(0).unwrap()).expect("Your RNG is busted").private_key.key;
514514
let destination_script = match master_key.ckd_priv(&secp_ctx, ChildNumber::from_hardened_idx(1).unwrap()) {
515515
Ok(destination_key) => {
516-
let pubkey_hash160 = Hash160::hash(&ExtendedPubKey::from_private(&secp_ctx, &destination_key).public_key.key.serialize()[..]);
516+
let wpubkey_hash = WPubkeyHash::hash(&ExtendedPubKey::from_private(&secp_ctx, &destination_key).public_key.to_bytes());
517517
Builder::new().push_opcode(opcodes::all::OP_PUSHBYTES_0)
518-
.push_slice(&pubkey_hash160.into_inner())
518+
.push_slice(&wpubkey_hash.into_inner())
519519
.into_script()
520520
},
521521
Err(_) => panic!("Your RNG is busted"),

0 commit comments

Comments
 (0)