Skip to content

Updating dependencies #377

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ max_level_info = []
max_level_debug = []

[dependencies]
bitcoin = "0.18"
bitcoin_hashes = "0.3"
secp256k1 = "0.12"
bitcoin = "0.20"
bitcoin_hashes = "0.7"
secp256k1 = "0.15"

[dev-dependencies.bitcoin]
version = "0.18"
version = "0.20"
features = ["bitcoinconsensus"]

[dev-dependencies]
Expand Down
6 changes: 3 additions & 3 deletions fuzz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ libfuzzer_fuzz = ["libfuzzer-sys"]
[dependencies]
afl = { version = "0.4", optional = true }
lightning = { path = "..", features = ["fuzztarget"] }
bitcoin = { version = "0.18", features = ["fuzztarget"] }
bitcoin_hashes = { version = "0.3", features=["fuzztarget"] }
bitcoin = { version = "0.20", features = ["fuzztarget"] }
bitcoin_hashes = { version = "0.7", features = ["fuzztarget"] }
hex = "0.3"
honggfuzz = { version = "0.5", optional = true }
secp256k1 = { version = "0.12", features=["fuzztarget"] }
secp256k1 = { version = "0.15", features=["fuzztarget"] }
libfuzzer-sys = { git = "https://github.com/rust-fuzz/libfuzzer-sys.git", optional = true }

[build-dependencies]
Expand Down
6 changes: 3 additions & 3 deletions net-tokio/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ For Rust-Lightning clients which wish to make direct connections to Lightning P2
"""

[dependencies]
bitcoin = "0.18"
bitcoin_hashes = "0.3"
bitcoin = "0.20"
bitcoin_hashes = "0.7"
lightning = { version = "0.0.9", path = "../" }
secp256k1 = "0.12"
secp256k1 = "0.15"
tokio-codec = "0.1"
futures = "0.1"
tokio = "0.1"
Expand Down
4 changes: 2 additions & 2 deletions src/ln/chan_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ pub fn get_revokeable_redeemscript(revocation_key: &PublicKey, to_self_delay: u1
.push_slice(&revocation_key.serialize())
.push_opcode(opcodes::all::OP_ELSE)
.push_int(to_self_delay as i64)
.push_opcode(opcodes::OP_CSV)
.push_opcode(opcodes::all::OP_CSV)
.push_opcode(opcodes::all::OP_DROP)
.push_slice(&delayed_payment_key.serialize())
.push_opcode(opcodes::all::OP_ENDIF)
Expand Down Expand Up @@ -206,7 +206,7 @@ pub fn get_htlc_redeemscript_with_explicit_keys(htlc: &HTLCOutputInCommitment, a
.push_opcode(opcodes::all::OP_ELSE)
.push_opcode(opcodes::all::OP_DROP)
.push_int(htlc.cltv_expiry as i64)
.push_opcode(opcodes::OP_CLTV)
.push_opcode(opcodes::all::OP_CLTV)
.push_opcode(opcodes::all::OP_DROP)
.push_opcode(opcodes::all::OP_CHECKSIG)
.push_opcode(opcodes::all::OP_ENDIF)
Expand Down
2 changes: 1 addition & 1 deletion src/ln/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2784,7 +2784,7 @@ impl Channel {
}
}

let proposed_sat_per_kw = msg.fee_satoshis * 1000 / closing_tx.get_weight();
let proposed_sat_per_kw = msg.fee_satoshis * 1000 / closing_tx.get_weight() as u64;
if self.channel_outbound {
let our_max_feerate = fee_estimator.get_est_sat_per_1000_weight(ConfirmationTarget::Normal);
if proposed_sat_per_kw > our_max_feerate {
Expand Down
18 changes: 9 additions & 9 deletions src/ln/channelmonitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -488,13 +488,13 @@ macro_rules! subtract_high_prio_fee {
($self: ident, $fee_estimator: expr, $value: expr, $predicted_weight: expr, $spent_txid: expr, $used_feerate: expr) => {
{
$used_feerate = $fee_estimator.get_est_sat_per_1000_weight(ConfirmationTarget::HighPriority);
let mut fee = $used_feerate * $predicted_weight / 1000;
let mut fee = $used_feerate * ($predicted_weight as u64) / 1000;
if $value <= fee {
$used_feerate = $fee_estimator.get_est_sat_per_1000_weight(ConfirmationTarget::Normal);
fee = $used_feerate * $predicted_weight / 1000;
fee = $used_feerate * ($predicted_weight as u64) / 1000;
if $value <= fee {
$used_feerate = $fee_estimator.get_est_sat_per_1000_weight(ConfirmationTarget::Background);
fee = $used_feerate * $predicted_weight / 1000;
fee = $used_feerate * ($predicted_weight as u64) / 1000;
if $value <= fee {
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)",
$spent_txid, fee, $value);
Expand Down Expand Up @@ -602,7 +602,7 @@ impl ChannelMonitor {
}
}

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

macro_rules! sign_input {
($sighash_parts: expr, $input: expr, $idx: expr, $amount: expr, $input_type: expr, $sum_actual_sigs: expr) => {
Expand All @@ -3323,7 +3323,7 @@ mod tests {
let sig = secp_ctx.sign(&sighash, &privkey);
$input.witness.push(sig.serialize_der().to_vec());
$input.witness[0].push(SigHashType::All as u8);
sum_actual_sigs += $input.witness[0].len() as u64;
sum_actual_sigs += $input.witness[0].len();
if *$input_type == InputDescriptors::RevokedOutput {
$input.witness.push(vec!(1));
} else if *$input_type == InputDescriptors::RevokedOfferedHTLC || *$input_type == InputDescriptors::RevokedReceivedHTLC {
Expand Down Expand Up @@ -3366,7 +3366,7 @@ mod tests {
for (idx, inp) in claim_tx.input.iter_mut().zip(inputs_des.iter()).enumerate() {
sign_input!(sighash_parts, inp.0, idx as u32, 0, inp.1, sum_actual_sigs);
}
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));
assert_eq!(base_weight + ChannelMonitor::get_witnesses_weight(&inputs_des[..]), claim_tx.get_weight() + /* max_length_sig */ (73 * inputs_des.len() - sum_actual_sigs));

// Claim tx with 1 offered HTLCs, 3 received HTLCs
claim_tx.input.clear();
Expand All @@ -3388,7 +3388,7 @@ mod tests {
for (idx, inp) in claim_tx.input.iter_mut().zip(inputs_des.iter()).enumerate() {
sign_input!(sighash_parts, inp.0, idx as u32, 0, inp.1, sum_actual_sigs);
}
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));
assert_eq!(base_weight + ChannelMonitor::get_witnesses_weight(&inputs_des[..]), claim_tx.get_weight() + /* max_length_sig */ (73 * inputs_des.len() - sum_actual_sigs));

// Justice tx with 1 revoked HTLC-Success tx output
claim_tx.input.clear();
Expand All @@ -3408,7 +3408,7 @@ mod tests {
for (idx, inp) in claim_tx.input.iter_mut().zip(inputs_des.iter()).enumerate() {
sign_input!(sighash_parts, inp.0, idx as u32, 0, inp.1, sum_actual_sigs);
}
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));
assert_eq!(base_weight + ChannelMonitor::get_witnesses_weight(&inputs_des[..]), claim_tx.get_weight() + /* max_length_isg */ (73 * inputs_des.len() - sum_actual_sigs));
}

// Further testing is done in the ChannelManager integration tests.
Expand Down
13 changes: 7 additions & 6 deletions src/ln/functional_test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ use secp256k1::key::PublicKey;
use rand::{thread_rng,Rng};

use std::cell::RefCell;
use std::collections::HashMap;
use std::default::Default;
use std::rc::Rc;
use std::sync::{Arc, Mutex};
use std::mem;
Expand Down Expand Up @@ -307,10 +305,13 @@ pub fn create_announced_chan_between_nodes_with_value(nodes: &Vec<Node>, a: usiz
macro_rules! check_spends {
($tx: expr, $spends_tx: expr) => {
{
let mut funding_tx_map = HashMap::new();
let spends_tx = $spends_tx;
funding_tx_map.insert(spends_tx.txid(), spends_tx);
$tx.verify(&funding_tx_map).unwrap();
$tx.verify(|out_point| {
if out_point.txid == $spends_tx.txid() {
$spends_tx.output.get(out_point.vout as usize).cloned()
} else {
None
}
}).unwrap();
}
}
}
Expand Down
15 changes: 10 additions & 5 deletions src/ln/functional_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2030,11 +2030,16 @@ fn claim_htlc_outputs_single_tx() {
assert_eq!(node_txn[1].input.len(), 1);
assert_eq!(node_txn[2].input.len(), 1);

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

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