Skip to content

Commit 39b562e

Browse files
authored
Merge pull request #377 from elichai/2019-08-update-deps
Updating dependencies
2 parents ab8f5a8 + 2030206 commit 39b562e

File tree

8 files changed

+39
-33
lines changed

8 files changed

+39
-33
lines changed

Cargo.toml

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

2424
[dependencies]
25-
bitcoin = "0.18"
26-
bitcoin_hashes = "0.3"
27-
secp256k1 = "0.12"
25+
bitcoin = "0.20"
26+
bitcoin_hashes = "0.7"
27+
secp256k1 = "0.15"
2828

2929
[dev-dependencies.bitcoin]
30-
version = "0.18"
30+
version = "0.20"
3131
features = ["bitcoinconsensus"]
3232

3333
[dev-dependencies]

fuzz/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ libfuzzer_fuzz = ["libfuzzer-sys"]
1818
[dependencies]
1919
afl = { version = "0.4", optional = true }
2020
lightning = { path = "..", features = ["fuzztarget"] }
21-
bitcoin = { version = "0.18", features = ["fuzztarget"] }
22-
bitcoin_hashes = { version = "0.3", features=["fuzztarget"] }
21+
bitcoin = { version = "0.20", features = ["fuzztarget"] }
22+
bitcoin_hashes = { version = "0.7", features = ["fuzztarget"] }
2323
hex = "0.3"
2424
honggfuzz = { version = "0.5", optional = true }
25-
secp256k1 = { version = "0.12", features=["fuzztarget"] }
25+
secp256k1 = { version = "0.15", features=["fuzztarget"] }
2626
libfuzzer-sys = { git = "https://github.com/rust-fuzz/libfuzzer-sys.git", optional = true }
2727

2828
[build-dependencies]

net-tokio/Cargo.toml

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

1111
[dependencies]
12-
bitcoin = "0.18"
13-
bitcoin_hashes = "0.3"
12+
bitcoin = "0.20"
13+
bitcoin_hashes = "0.7"
1414
lightning = { version = "0.0.9", path = "../" }
15-
secp256k1 = "0.12"
15+
secp256k1 = "0.15"
1616
tokio-codec = "0.1"
1717
futures = "0.1"
1818
tokio = "0.1"

src/ln/chan_utils.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ pub fn get_revokeable_redeemscript(revocation_key: &PublicKey, to_self_delay: u1
133133
.push_slice(&revocation_key.serialize())
134134
.push_opcode(opcodes::all::OP_ELSE)
135135
.push_int(to_self_delay as i64)
136-
.push_opcode(opcodes::OP_CSV)
136+
.push_opcode(opcodes::all::OP_CSV)
137137
.push_opcode(opcodes::all::OP_DROP)
138138
.push_slice(&delayed_payment_key.serialize())
139139
.push_opcode(opcodes::all::OP_ENDIF)
@@ -206,7 +206,7 @@ pub fn get_htlc_redeemscript_with_explicit_keys(htlc: &HTLCOutputInCommitment, a
206206
.push_opcode(opcodes::all::OP_ELSE)
207207
.push_opcode(opcodes::all::OP_DROP)
208208
.push_int(htlc.cltv_expiry as i64)
209-
.push_opcode(opcodes::OP_CLTV)
209+
.push_opcode(opcodes::all::OP_CLTV)
210210
.push_opcode(opcodes::all::OP_DROP)
211211
.push_opcode(opcodes::all::OP_CHECKSIG)
212212
.push_opcode(opcodes::all::OP_ENDIF)

src/ln/channel.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2784,7 +2784,7 @@ impl Channel {
27842784
}
27852785
}
27862786

2787-
let proposed_sat_per_kw = msg.fee_satoshis * 1000 / closing_tx.get_weight();
2787+
let proposed_sat_per_kw = msg.fee_satoshis * 1000 / closing_tx.get_weight() as u64;
27882788
if self.channel_outbound {
27892789
let our_max_feerate = fee_estimator.get_est_sat_per_1000_weight(ConfirmationTarget::Normal);
27902790
if proposed_sat_per_kw > our_max_feerate {

src/ln/channelmonitor.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -488,13 +488,13 @@ macro_rules! subtract_high_prio_fee {
488488
($self: ident, $fee_estimator: expr, $value: expr, $predicted_weight: expr, $spent_txid: expr, $used_feerate: expr) => {
489489
{
490490
$used_feerate = $fee_estimator.get_est_sat_per_1000_weight(ConfirmationTarget::HighPriority);
491-
let mut fee = $used_feerate * $predicted_weight / 1000;
491+
let mut fee = $used_feerate * ($predicted_weight as u64) / 1000;
492492
if $value <= fee {
493493
$used_feerate = $fee_estimator.get_est_sat_per_1000_weight(ConfirmationTarget::Normal);
494-
fee = $used_feerate * $predicted_weight / 1000;
494+
fee = $used_feerate * ($predicted_weight as u64) / 1000;
495495
if $value <= fee {
496496
$used_feerate = $fee_estimator.get_est_sat_per_1000_weight(ConfirmationTarget::Background);
497-
fee = $used_feerate * $predicted_weight / 1000;
497+
fee = $used_feerate * ($predicted_weight as u64) / 1000;
498498
if $value <= fee {
499499
log_error!($self, "Failed to generate an on-chain punishment tx spending {} as even low priority fee ({} sat) was more than the entire claim balance ({} sat)",
500500
$spent_txid, fee, $value);
@@ -602,7 +602,7 @@ impl ChannelMonitor {
602602
}
603603
}
604604

605-
fn get_witnesses_weight(inputs: &[InputDescriptors]) -> u64 {
605+
fn get_witnesses_weight(inputs: &[InputDescriptors]) -> usize {
606606
let mut tx_weight = 2; // count segwit flags
607607
for inp in inputs {
608608
// We use expected weight (and not actual) as signatures and time lock delays may vary
@@ -3307,7 +3307,7 @@ mod tests {
33073307
let secp_ctx = Secp256k1::new();
33083308
let privkey = SecretKey::from_slice(&hex::decode("0101010101010101010101010101010101010101010101010101010101010101").unwrap()[..]).unwrap();
33093309
let pubkey = PublicKey::from_secret_key(&secp_ctx, &privkey);
3310-
let mut sum_actual_sigs: u64 = 0;
3310+
let mut sum_actual_sigs = 0;
33113311

33123312
macro_rules! sign_input {
33133313
($sighash_parts: expr, $input: expr, $idx: expr, $amount: expr, $input_type: expr, $sum_actual_sigs: expr) => {
@@ -3323,7 +3323,7 @@ mod tests {
33233323
let sig = secp_ctx.sign(&sighash, &privkey);
33243324
$input.witness.push(sig.serialize_der().to_vec());
33253325
$input.witness[0].push(SigHashType::All as u8);
3326-
sum_actual_sigs += $input.witness[0].len() as u64;
3326+
sum_actual_sigs += $input.witness[0].len();
33273327
if *$input_type == InputDescriptors::RevokedOutput {
33283328
$input.witness.push(vec!(1));
33293329
} else if *$input_type == InputDescriptors::RevokedOfferedHTLC || *$input_type == InputDescriptors::RevokedReceivedHTLC {
@@ -3366,7 +3366,7 @@ mod tests {
33663366
for (idx, inp) in claim_tx.input.iter_mut().zip(inputs_des.iter()).enumerate() {
33673367
sign_input!(sighash_parts, inp.0, idx as u32, 0, inp.1, sum_actual_sigs);
33683368
}
3369-
assert_eq!(base_weight + ChannelMonitor::get_witnesses_weight(&inputs_des[..]), claim_tx.get_weight() + /* max_length_sig */ (73 * inputs_des.len() as u64 - sum_actual_sigs));
3369+
assert_eq!(base_weight + ChannelMonitor::get_witnesses_weight(&inputs_des[..]), claim_tx.get_weight() + /* max_length_sig */ (73 * inputs_des.len() - sum_actual_sigs));
33703370

33713371
// Claim tx with 1 offered HTLCs, 3 received HTLCs
33723372
claim_tx.input.clear();
@@ -3388,7 +3388,7 @@ mod tests {
33883388
for (idx, inp) in claim_tx.input.iter_mut().zip(inputs_des.iter()).enumerate() {
33893389
sign_input!(sighash_parts, inp.0, idx as u32, 0, inp.1, sum_actual_sigs);
33903390
}
3391-
assert_eq!(base_weight + ChannelMonitor::get_witnesses_weight(&inputs_des[..]), claim_tx.get_weight() + /* max_length_sig */ (73 * inputs_des.len() as u64 - sum_actual_sigs));
3391+
assert_eq!(base_weight + ChannelMonitor::get_witnesses_weight(&inputs_des[..]), claim_tx.get_weight() + /* max_length_sig */ (73 * inputs_des.len() - sum_actual_sigs));
33923392

33933393
// Justice tx with 1 revoked HTLC-Success tx output
33943394
claim_tx.input.clear();
@@ -3408,7 +3408,7 @@ mod tests {
34083408
for (idx, inp) in claim_tx.input.iter_mut().zip(inputs_des.iter()).enumerate() {
34093409
sign_input!(sighash_parts, inp.0, idx as u32, 0, inp.1, sum_actual_sigs);
34103410
}
3411-
assert_eq!(base_weight + ChannelMonitor::get_witnesses_weight(&inputs_des[..]), claim_tx.get_weight() + /* max_length_isg */ (73 * inputs_des.len() as u64 - sum_actual_sigs));
3411+
assert_eq!(base_weight + ChannelMonitor::get_witnesses_weight(&inputs_des[..]), claim_tx.get_weight() + /* max_length_isg */ (73 * inputs_des.len() - sum_actual_sigs));
34123412
}
34133413

34143414
// Further testing is done in the ChannelManager integration tests.

src/ln/functional_test_utils.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ use secp256k1::key::PublicKey;
2929
use rand::{thread_rng,Rng};
3030

3131
use std::cell::RefCell;
32-
use std::collections::HashMap;
33-
use std::default::Default;
3432
use std::rc::Rc;
3533
use std::sync::{Arc, Mutex};
3634
use std::mem;
@@ -307,10 +305,13 @@ pub fn create_announced_chan_between_nodes_with_value(nodes: &Vec<Node>, a: usiz
307305
macro_rules! check_spends {
308306
($tx: expr, $spends_tx: expr) => {
309307
{
310-
let mut funding_tx_map = HashMap::new();
311-
let spends_tx = $spends_tx;
312-
funding_tx_map.insert(spends_tx.txid(), spends_tx);
313-
$tx.verify(&funding_tx_map).unwrap();
308+
$tx.verify(|out_point| {
309+
if out_point.txid == $spends_tx.txid() {
310+
$spends_tx.output.get(out_point.vout as usize).cloned()
311+
} else {
312+
None
313+
}
314+
}).unwrap();
314315
}
315316
}
316317
}

src/ln/functional_tests.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2030,11 +2030,16 @@ fn claim_htlc_outputs_single_tx() {
20302030
assert_eq!(node_txn[1].input.len(), 1);
20312031
assert_eq!(node_txn[2].input.len(), 1);
20322032

2033-
let mut revoked_tx_map = HashMap::new();
2034-
revoked_tx_map.insert(revoked_local_txn[0].txid(), revoked_local_txn[0].clone());
2035-
node_txn[0].verify(&revoked_tx_map).unwrap();
2036-
node_txn[1].verify(&revoked_tx_map).unwrap();
2037-
node_txn[2].verify(&revoked_tx_map).unwrap();
2033+
fn get_txout(out_point: &BitcoinOutPoint, tx: &Transaction) -> Option<TxOut> {
2034+
if out_point.txid == tx.txid() {
2035+
tx.output.get(out_point.vout as usize).cloned()
2036+
} else {
2037+
None
2038+
}
2039+
}
2040+
node_txn[0].verify(|out|get_txout(out, &revoked_local_txn[0])).unwrap();
2041+
node_txn[1].verify(|out|get_txout(out, &revoked_local_txn[0])).unwrap();
2042+
node_txn[2].verify(|out|get_txout(out, &revoked_local_txn[0])).unwrap();
20382043

20392044
let mut witness_lens = BTreeSet::new();
20402045
witness_lens.insert(node_txn[0].input[0].witness.last().unwrap().len());

0 commit comments

Comments
 (0)