Skip to content

Commit 02b5416

Browse files
committed
migration to rust-bitcoin 0.17
typedef Sha256dHash with bitcoin_hashes::sha256d::Hash SecretKey -> PrivateKey.key assume compressed public keys
1 parent fef2eba commit 02b5416

19 files changed

+97
-83
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ max_level_info = []
2222
max_level_debug = []
2323

2424
[dependencies]
25-
bitcoin = "0.16"
25+
bitcoin = "0.17"
2626
bitcoin_hashes = "0.3"
2727
rand = "0.4"
2828
secp256k1 = "0.12"
2929

3030
[dev-dependencies.bitcoin]
31-
version = "0.16"
31+
version = "0.17"
3232
features = ["bitcoinconsensus"]
3333

3434
[dev-dependencies]

fuzz/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ libfuzzer_fuzz = ["libfuzzer-sys"]
1818
[dependencies]
1919
afl = { version = "0.4", optional = true }
2020
lightning = { path = "..", features = ["fuzztarget"] }
21-
bitcoin = { version = "0.16", features = ["fuzztarget"] }
22-
bitcoin_hashes = { version = "0.2", features=["fuzztarget"] }
21+
bitcoin = { version = "0.17", features = ["fuzztarget"] }
22+
bitcoin_hashes = { version = "0.3", features=["fuzztarget"] }
2323
hex = "0.3"
2424
honggfuzz = { version = "0.5", optional = true }
2525
secp256k1 = { version = "0.12", features=["fuzztarget"] }

fuzz/fuzz_targets/chanmon_deser_target.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
// To modify it, modify msg_target_template.txt and run gen_target.sh instead.
33

44
extern crate bitcoin;
5+
extern crate bitcoin_hashes;
56
extern crate lightning;
67

7-
use bitcoin::util::hash::Sha256dHash;
8+
use bitcoin_hashes::sha256d::Hash as Sha256dHash;
89

910
use lightning::ln::channelmonitor;
1011
use lightning::util::reset_rng_state;

fuzz/fuzz_targets/full_stack_target.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,13 @@ use bitcoin::blockdata::script::{Builder, Script};
1818
use bitcoin::blockdata::opcodes;
1919
use bitcoin::consensus::encode::deserialize;
2020
use bitcoin::network::constants::Network;
21-
use bitcoin::util::hash::{BitcoinHash, Sha256dHash};
21+
use bitcoin::util::hash::BitcoinHash;
2222

2323
use bitcoin_hashes::Hash as TraitImport;
2424
use bitcoin_hashes::HashEngine as TraitImportEngine;
2525
use bitcoin_hashes::sha256::Hash as Sha256;
2626
use bitcoin_hashes::hash160::Hash as Hash160;
27+
use bitcoin_hashes::sha256d::Hash as Sha256dHash;
2728

2829
use lightning::chain::chaininterface::{BroadcasterInterface,ConfirmationTarget,ChainListener,FeeEstimator,ChainWatchInterfaceUtil};
2930
use lightning::chain::transaction::OutPoint;

fuzz/fuzz_targets/router_target.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
extern crate bitcoin;
2+
extern crate bitcoin_hashes;
23
extern crate lightning;
34
extern crate secp256k1;
45

5-
use bitcoin::util::hash::Sha256dHash;
6+
use bitcoin_hashes::sha256d::Hash as Sha256dHash;
67
use bitcoin::blockdata::script::{Script, Builder};
78

89
use lightning::chain::chaininterface::{ChainError,ChainWatchInterface, ChainListener};

src/chain/chaininterface.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ use bitcoin::blockdata::block::{Block, BlockHeader};
88
use bitcoin::blockdata::transaction::Transaction;
99
use bitcoin::blockdata::script::Script;
1010
use bitcoin::blockdata::constants::genesis_block;
11-
use bitcoin::util::hash::{BitcoinHash, Sha256dHash};
11+
use bitcoin::util::hash::BitcoinHash;
12+
use bitcoin_hashes::sha256d::Hash as Sha256dHash;
1213
use bitcoin::network::constants::Network;
1314

1415
use util::logger::Logger;

src/chain/keysinterface.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -141,23 +141,23 @@ impl KeysManager {
141141
let secp_ctx = Secp256k1::signing_only();
142142
match ExtendedPrivKey::new_master(network.clone(), seed) {
143143
Ok(master_key) => {
144-
let node_secret = master_key.ckd_priv(&secp_ctx, ChildNumber::from_hardened_idx(0)).expect("Your RNG is busted").secret_key;
145-
let destination_script = match master_key.ckd_priv(&secp_ctx, ChildNumber::from_hardened_idx(1)) {
144+
let node_secret = master_key.ckd_priv(&secp_ctx, ChildNumber::from_hardened_idx(0).unwrap()).expect("Your RNG is busted").private_key.key;
145+
let destination_script = match master_key.ckd_priv(&secp_ctx, ChildNumber::from_hardened_idx(1).unwrap()) {
146146
Ok(destination_key) => {
147-
let pubkey_hash160 = Hash160::hash(&ExtendedPubKey::from_private(&secp_ctx, &destination_key).public_key.serialize()[..]);
147+
let pubkey_hash160 = Hash160::hash(&ExtendedPubKey::from_private(&secp_ctx, &destination_key).public_key.key.serialize()[..]);
148148
Builder::new().push_opcode(opcodes::all::OP_PUSHBYTES_0)
149149
.push_slice(&pubkey_hash160.into_inner())
150150
.into_script()
151151
},
152152
Err(_) => panic!("Your RNG is busted"),
153153
};
154-
let shutdown_pubkey = match master_key.ckd_priv(&secp_ctx, ChildNumber::from_hardened_idx(2)) {
155-
Ok(shutdown_key) => ExtendedPubKey::from_private(&secp_ctx, &shutdown_key).public_key,
154+
let shutdown_pubkey = match master_key.ckd_priv(&secp_ctx, ChildNumber::from_hardened_idx(2).unwrap()) {
155+
Ok(shutdown_key) => ExtendedPubKey::from_private(&secp_ctx, &shutdown_key).public_key.key,
156156
Err(_) => panic!("Your RNG is busted"),
157157
};
158-
let channel_master_key = master_key.ckd_priv(&secp_ctx, ChildNumber::from_hardened_idx(3)).expect("Your RNG is busted");
159-
let session_master_key = master_key.ckd_priv(&secp_ctx, ChildNumber::from_hardened_idx(4)).expect("Your RNG is busted");
160-
let channel_id_master_key = master_key.ckd_priv(&secp_ctx, ChildNumber::from_hardened_idx(5)).expect("Your RNG is busted");
158+
let channel_master_key = master_key.ckd_priv(&secp_ctx, ChildNumber::from_hardened_idx(3).unwrap()).expect("Your RNG is busted");
159+
let session_master_key = master_key.ckd_priv(&secp_ctx, ChildNumber::from_hardened_idx(4).unwrap()).expect("Your RNG is busted");
160+
let channel_id_master_key = master_key.ckd_priv(&secp_ctx, ChildNumber::from_hardened_idx(5).unwrap()).expect("Your RNG is busted");
161161
KeysManager {
162162
secp_ctx,
163163
node_secret,
@@ -207,8 +207,8 @@ impl KeysInterface for KeysManager {
207207
sha.input(&byte_utils::be64_to_array(now.as_secs()));
208208

209209
let child_ix = self.channel_child_index.fetch_add(1, Ordering::AcqRel);
210-
let child_privkey = self.channel_master_key.ckd_priv(&self.secp_ctx, ChildNumber::from_hardened_idx(child_ix as u32)).expect("Your RNG is busted");
211-
sha.input(&child_privkey.secret_key[..]);
210+
let child_privkey = self.channel_master_key.ckd_priv(&self.secp_ctx, ChildNumber::from_hardened_idx(child_ix as u32).expect("key space exhausted")).expect("Your RNG is busted");
211+
sha.input(&child_privkey.private_key.key[..]);
212212

213213
seed = Sha256::from_engine(sha).into_inner();
214214

@@ -251,8 +251,8 @@ impl KeysInterface for KeysManager {
251251
sha.input(&byte_utils::be64_to_array(now.as_secs()));
252252

253253
let child_ix = self.session_child_index.fetch_add(1, Ordering::AcqRel);
254-
let child_privkey = self.session_master_key.ckd_priv(&self.secp_ctx, ChildNumber::from_hardened_idx(child_ix as u32)).expect("Your RNG is busted");
255-
sha.input(&child_privkey.secret_key[..]);
254+
let child_privkey = self.session_master_key.ckd_priv(&self.secp_ctx, ChildNumber::from_hardened_idx(child_ix as u32).expect("key space exhausted")).expect("Your RNG is busted");
255+
sha.input(&child_privkey.private_key.key[..]);
256256
SecretKey::from_slice(&Sha256::from_engine(sha).into_inner()).expect("Your RNG is busted")
257257
}
258258

@@ -264,8 +264,8 @@ impl KeysInterface for KeysManager {
264264
sha.input(&byte_utils::be64_to_array(now.as_secs()));
265265

266266
let child_ix = self.channel_id_child_index.fetch_add(1, Ordering::AcqRel);
267-
let child_privkey = self.channel_id_master_key.ckd_priv(&self.secp_ctx, ChildNumber::from_hardened_idx(child_ix as u32)).expect("Your RNG is busted");
268-
sha.input(&child_privkey.secret_key[..]);
267+
let child_privkey = self.channel_id_master_key.ckd_priv(&self.secp_ctx, ChildNumber::from_hardened_idx(child_ix as u32).expect("key space exhausted")).expect("Your RNG is busted");
268+
sha.input(&child_privkey.private_key.key[..]);
269269

270270
(Sha256::from_engine(sha).into_inner())
271271
}

src/chain/transaction.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Contains simple structs describing parts of transactions on the chain.
22
3-
use bitcoin::util::hash::Sha256dHash;
3+
use bitcoin_hashes::sha256d::Hash as Sha256dHash;
44
use bitcoin::blockdata::transaction::OutPoint as BitcoinOutPoint;
55

66
/// A reference to a transaction output.

src/ln/chan_utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
use bitcoin::blockdata::script::{Script,Builder};
22
use bitcoin::blockdata::opcodes;
33
use bitcoin::blockdata::transaction::{TxIn,TxOut,OutPoint,Transaction};
4-
use bitcoin::util::hash::{Sha256dHash};
54

65
use bitcoin_hashes::{Hash, HashEngine};
76
use bitcoin_hashes::sha256::Hash as Sha256;
87
use bitcoin_hashes::ripemd160::Hash as Ripemd160;
98
use bitcoin_hashes::hash160::Hash as Hash160;
9+
use bitcoin_hashes::sha256d::Hash as Sha256dHash;
1010

1111
use ln::channelmanager::PaymentHash;
1212

src/ln/channel.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ use bitcoin::blockdata::block::BlockHeader;
22
use bitcoin::blockdata::script::{Script,Builder};
33
use bitcoin::blockdata::transaction::{TxIn, TxOut, Transaction, SigHashType};
44
use bitcoin::blockdata::opcodes;
5-
use bitcoin::util::hash::{BitcoinHash, Sha256dHash};
5+
use bitcoin::util::hash::BitcoinHash;
66
use bitcoin::util::bip143;
77
use bitcoin::consensus::encode::{self, Encodable, Decodable};
88

99
use bitcoin_hashes::{Hash, HashEngine};
1010
use bitcoin_hashes::sha256::Hash as Sha256;
1111
use bitcoin_hashes::hash160::Hash as Hash160;
12+
use bitcoin_hashes::sha256d::Hash as Sha256dHash;
1213

1314
use secp256k1::key::{PublicKey,SecretKey};
1415
use secp256k1::{Secp256k1,Signature};
@@ -3143,7 +3144,7 @@ impl Channel {
31433144
excess_data: Vec::new(),
31443145
};
31453146

3146-
let msghash = hash_to_message!(&Sha256dHash::from_data(&msg.encode()[..])[..]);
3147+
let msghash = hash_to_message!(&Sha256dHash::hash(&msg.encode()[..])[..]);
31473148
let sig = self.secp_ctx.sign(&msghash, &self.local_keys.funding_key);
31483149

31493150
Ok((msg, sig))
@@ -3954,12 +3955,12 @@ impl<R : ::std::io::Read> ReadableArgs<R, Arc<Logger>> for Channel {
39543955

39553956
#[cfg(test)]
39563957
mod tests {
3957-
use bitcoin::util::hash::{Sha256dHash, Hash160};
39583958
use bitcoin::util::bip143;
39593959
use bitcoin::consensus::encode::serialize;
39603960
use bitcoin::blockdata::script::{Script, Builder};
39613961
use bitcoin::blockdata::transaction::Transaction;
39623962
use bitcoin::blockdata::opcodes;
3963+
use bitcoin_hashes::hex::FromHex;
39633964
use hex;
39643965
use ln::channelmanager::{HTLCSource, PaymentPreimage, PaymentHash};
39653966
use ln::channel::{Channel,ChannelKeys,InboundHTLCOutput,OutboundHTLCOutput,InboundHTLCState,OutboundHTLCState,HTLCOutputInCommitment,TxCreationKeys};
@@ -3974,6 +3975,8 @@ mod tests {
39743975
use secp256k1::{Secp256k1,Message,Signature};
39753976
use secp256k1::key::{SecretKey,PublicKey};
39763977
use bitcoin_hashes::sha256::Hash as Sha256;
3978+
use bitcoin_hashes::sha256d::Hash as Sha256dHash;
3979+
use bitcoin_hashes::hash160::Hash as Hash160;
39773980
use bitcoin_hashes::Hash;
39783981
use std::sync::Arc;
39793982

@@ -4000,7 +4003,7 @@ mod tests {
40004003
fn get_destination_script(&self) -> Script {
40014004
let secp_ctx = Secp256k1::signing_only();
40024005
let channel_monitor_claim_key = SecretKey::from_slice(&hex::decode("0fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff").unwrap()[..]).unwrap();
4003-
let our_channel_monitor_claim_key_hash = Hash160::from_data(&PublicKey::from_secret_key(&secp_ctx, &channel_monitor_claim_key).serialize());
4006+
let our_channel_monitor_claim_key_hash = Hash160::hash(&PublicKey::from_secret_key(&secp_ctx, &channel_monitor_claim_key).serialize());
40044007
Builder::new().push_opcode(opcodes::all::OP_PUSHBYTES_0).push_slice(&our_channel_monitor_claim_key_hash[..]).into_script()
40054008
}
40064009

src/ln/channelmanager.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@ use bitcoin::blockdata::block::BlockHeader;
1212
use bitcoin::blockdata::transaction::Transaction;
1313
use bitcoin::blockdata::constants::genesis_block;
1414
use bitcoin::network::constants::Network;
15-
use bitcoin::util::hash::{BitcoinHash, Sha256dHash};
15+
use bitcoin::util::hash::BitcoinHash;
1616

1717
use bitcoin_hashes::{Hash, HashEngine};
1818
use bitcoin_hashes::hmac::{Hmac, HmacEngine};
1919
use bitcoin_hashes::sha256::Hash as Sha256;
20+
use bitcoin_hashes::sha256d::Hash as Sha256dHash;
2021
use bitcoin_hashes::cmp::fixed_time_eq;
2122

2223
use secp256k1::key::{SecretKey,PublicKey};
@@ -964,7 +965,7 @@ impl ChannelManager {
964965
excess_data: Vec::new(),
965966
};
966967

967-
let msg_hash = Sha256dHash::from_data(&unsigned.encode()[..]);
968+
let msg_hash = Sha256dHash::hash(&unsigned.encode()[..]);
968969
let sig = self.secp_ctx.sign(&hash_to_message!(&msg_hash[..]), &self.our_network_key);
969970

970971
Ok(msgs::ChannelUpdate {
@@ -1158,7 +1159,7 @@ impl ChannelManager {
11581159
Ok(res) => res,
11591160
Err(_) => return None, // Only in case of state precondition violations eg channel is closing
11601161
};
1161-
let msghash = hash_to_message!(&Sha256dHash::from_data(&announcement.encode()[..])[..]);
1162+
let msghash = hash_to_message!(&Sha256dHash::hash(&announcement.encode()[..])[..]);
11621163
let our_node_sig = self.secp_ctx.sign(&msghash, &self.our_network_key);
11631164

11641165
Some(msgs::AnnouncementSignatures {
@@ -2182,7 +2183,7 @@ impl ChannelManager {
21822183
try_chan_entry!(self, chan.get_mut().get_channel_announcement(our_node_id.clone(), self.genesis_hash.clone()), channel_state, chan);
21832184

21842185
let were_node_one = announcement.node_id_1 == our_node_id;
2185-
let msghash = hash_to_message!(&Sha256dHash::from_data(&announcement.encode()[..])[..]);
2186+
let msghash = hash_to_message!(&Sha256dHash::hash(&announcement.encode()[..])[..]);
21862187
if self.secp_ctx.verify(&msghash, &msg.node_signature, if were_node_one { &announcement.node_id_2 } else { &announcement.node_id_1 }).is_err() ||
21872188
self.secp_ctx.verify(&msghash, &msg.bitcoin_signature, if were_node_one { &announcement.bitcoin_key_2 } else { &announcement.bitcoin_key_1 }).is_err() {
21882189
try_chan_entry!(self, Err(ChannelError::Close("Bad announcement_signatures node_signature")), channel_state, chan);

src/ln/channelmonitor.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@ use bitcoin::blockdata::transaction::OutPoint as BitcoinOutPoint;
1717
use bitcoin::blockdata::script::{Script, Builder};
1818
use bitcoin::blockdata::opcodes;
1919
use bitcoin::consensus::encode::{self, Decodable, Encodable};
20-
use bitcoin::util::hash::{BitcoinHash,Sha256dHash};
20+
use bitcoin::util::hash::BitcoinHash;
2121
use bitcoin::util::bip143;
2222

2323
use bitcoin_hashes::Hash;
2424
use bitcoin_hashes::sha256::Hash as Sha256;
2525
use bitcoin_hashes::hash160::Hash as Hash160;
26+
use bitcoin_hashes::sha256d::Hash as Sha256dHash;
2627

2728
use secp256k1::{Secp256k1,Signature};
2829
use secp256k1::key::{SecretKey,PublicKey};
@@ -1179,7 +1180,7 @@ impl ChannelMonitor {
11791180
// on-chain claims, so we can do that at the same time.
11801181
macro_rules! check_htlc_fails {
11811182
($txid: expr, $commitment_tx: expr) => {
1182-
if let Some(ref outpoints) = self.remote_claimable_outpoints.get(&$txid) {
1183+
if let Some(ref outpoints) = self.remote_claimable_outpoints.get($txid) {
11831184
for &(ref htlc, ref source_option) in outpoints.iter() {
11841185
if let &Some(ref source) = source_option {
11851186
log_trace!(self, "Failing HTLC with payment_hash {} from {} remote commitment tx due to broadcast of revoked remote commitment transaction", log_bytes!(htlc.payment_hash.0), $commitment_tx);
@@ -1243,7 +1244,7 @@ impl ChannelMonitor {
12431244
// on-chain claims, so we can do that at the same time.
12441245
macro_rules! check_htlc_fails {
12451246
($txid: expr, $commitment_tx: expr, $id: tt) => {
1246-
if let Some(ref latest_outpoints) = self.remote_claimable_outpoints.get(&$txid) {
1247+
if let Some(ref latest_outpoints) = self.remote_claimable_outpoints.get($txid) {
12471248
$id: for &(ref htlc, ref source_option) in latest_outpoints.iter() {
12481249
if let &Some(ref source) = source_option {
12491250
// Check if the HTLC is present in the commitment transaction that was

src/ln/functional_tests.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ use util::ser::{Writeable, ReadableArgs};
2121
use util::config::UserConfig;
2222
use util::rng;
2323

24-
use bitcoin::util::hash::{BitcoinHash, Sha256dHash};
24+
use bitcoin::util::hash::BitcoinHash;
25+
use bitcoin_hashes::sha256d::Hash as Sha256dHash;
2526
use bitcoin::util::bip143;
2627
use bitcoin::util::address::Address;
2728
use bitcoin::util::bip32::{ChildNumber, ExtendedPubKey, ExtendedPrivKey};
@@ -2486,7 +2487,7 @@ fn test_force_close_fail_back() {
24862487
// Now check that if we add the preimage to ChannelMonitor it broadcasts our HTLC-Success..
24872488
{
24882489
let mut monitors = nodes[2].chan_monitor.simple_monitor.monitors.lock().unwrap();
2489-
monitors.get_mut(&OutPoint::new(Sha256dHash::from(&payment_event.commitment_msg.channel_id[..]), 0)).unwrap()
2490+
monitors.get_mut(&OutPoint::new(Sha256dHash::from_slice(&payment_event.commitment_msg.channel_id[..]).unwrap(), 0)).unwrap()
24902491
.provide_payment_preimage(&our_payment_hash, &our_payment_preimage);
24912492
}
24922493
nodes[2].chain_monitor.block_connected_checked(&header, 1, &[&tx], &[1]);
@@ -3018,7 +3019,7 @@ fn test_invalid_channel_announcement() {
30183019

30193020
macro_rules! sign_msg {
30203021
($unsigned_msg: expr) => {
3021-
let msghash = Message::from_slice(&Sha256dHash::from_data(&$unsigned_msg.encode()[..])[..]).unwrap();
3022+
let msghash = Message::from_slice(&Sha256dHash::hash(&$unsigned_msg.encode()[..])[..]).unwrap();
30223023
let as_bitcoin_sig = secp_ctx.sign(&msghash, &as_chan.get_local_keys().funding_key);
30233024
let bs_bitcoin_sig = secp_ctx.sign(&msghash, &bs_chan.get_local_keys().funding_key);
30243025
let as_node_sig = secp_ctx.sign(&msghash, &nodes[0].keys_manager.get_node_secret());
@@ -3045,7 +3046,7 @@ fn test_invalid_channel_announcement() {
30453046
assert!(nodes[0].router.handle_channel_announcement(&chan_announcement).is_err());
30463047

30473048
let mut unsigned_msg = dummy_unsigned_msg!();
3048-
unsigned_msg.chain_hash = Sha256dHash::from_data(&[1,2,3,4,5,6,7,8,9]);
3049+
unsigned_msg.chain_hash = Sha256dHash::hash(&[1,2,3,4,5,6,7,8,9]);
30493050
sign_msg!(unsigned_msg);
30503051
assert!(nodes[0].router.handle_channel_announcement(&chan_announcement).is_err());
30513052
}
@@ -3267,7 +3268,7 @@ macro_rules! check_spendable_outputs {
32673268
};
32683269
let secp_ctx = Secp256k1::new();
32693270
let remotepubkey = PublicKey::from_secret_key(&secp_ctx, &key);
3270-
let witness_script = Address::p2pkh(&remotepubkey, Network::Testnet).script_pubkey();
3271+
let witness_script = Address::p2pkh(&::bitcoin::PublicKey{compressed: true, key: remotepubkey}, Network::Testnet).script_pubkey();
32713272
let sighash = Message::from_slice(&bip143::SighashComponents::new(&spend_tx).sighash_all(&spend_tx.input[0], &witness_script, output.value)[..]).unwrap();
32723273
let remotesig = secp_ctx.sign(&sighash, key);
32733274
spend_tx.input[0].witness.push(remotesig.serialize_der().to_vec());
@@ -3322,7 +3323,7 @@ macro_rules! check_spendable_outputs {
33223323
let secret = {
33233324
match ExtendedPrivKey::new_master(Network::Testnet, &$node.node_seed) {
33243325
Ok(master_key) => {
3325-
match master_key.ckd_priv(&secp_ctx, ChildNumber::from_hardened_idx($der_idx)) {
3326+
match master_key.ckd_priv(&secp_ctx, ChildNumber::from_hardened_idx($der_idx).expect("key space exhausted")) {
33263327
Ok(key) => key,
33273328
Err(_) => panic!("Your RNG is busted"),
33283329
}
@@ -3333,10 +3334,10 @@ macro_rules! check_spendable_outputs {
33333334
let pubkey = ExtendedPubKey::from_private(&secp_ctx, &secret).public_key;
33343335
let witness_script = Address::p2pkh(&pubkey, Network::Testnet).script_pubkey();
33353336
let sighash = Message::from_slice(&bip143::SighashComponents::new(&spend_tx).sighash_all(&spend_tx.input[0], &witness_script, output.value)[..]).unwrap();
3336-
let sig = secp_ctx.sign(&sighash, &secret.secret_key);
3337+
let sig = secp_ctx.sign(&sighash, &secret.private_key.key);
33373338
spend_tx.input[0].witness.push(sig.serialize_der().to_vec());
33383339
spend_tx.input[0].witness[0].push(SigHashType::All as u8);
3339-
spend_tx.input[0].witness.push(pubkey.serialize().to_vec());
3340+
spend_tx.input[0].witness.push(pubkey.key.serialize().to_vec());
33403341
txn.push(spend_tx);
33413342
},
33423343
}
@@ -4456,7 +4457,7 @@ impl msgs::ChannelUpdate {
44564457
msgs::ChannelUpdate {
44574458
signature: Signature::from(FFISignature::new()),
44584459
contents: msgs::UnsignedChannelUpdate {
4459-
chain_hash: Sha256dHash::from_data(&vec![0u8][..]),
4460+
chain_hash: Sha256dHash::hash(&vec![0u8][..]),
44604461
short_channel_id: 0,
44614462
timestamp: 0,
44624463
flags: 0,

0 commit comments

Comments
 (0)