check_added_monitors!(nodes[1], 1);
assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
- assert_eq!(get_feerate!(nodes[0], channel_id), feerate + 30);
- assert_eq!(get_feerate!(nodes[1], channel_id), feerate + 30);
+ assert_eq!(get_feerate!(nodes[0], nodes[1], channel_id), feerate + 30);
+ assert_eq!(get_feerate!(nodes[1], nodes[0], channel_id), feerate + 30);
close_channel(&nodes[0], &nodes[1], &chan.2, chan.3, true);
check_closed_event!(nodes[0], 1, ClosureReason::CooperativeClosure);
check_closed_event!(nodes[1], 1, ClosureReason::CooperativeClosure);
let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs);
let chan = create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 100000, 95000000, channelmanager::provided_init_features(), channelmanager::provided_init_features());
- let chan_stat = get_channel_value_stat!(nodes[0], chan.2);
+ let chan_stat = get_channel_value_stat!(nodes[0], nodes[1], chan.2);
let channel_reserve = chan_stat.channel_reserve_msat;
// The 2* and +1 are for the fee spike reserve.
- let commit_tx_fee = 2 * commit_tx_fee_msat(get_feerate!(nodes[0], chan.2), 1 + 1, get_opt_anchors!(nodes[0], chan.2));
+ let commit_tx_fee = 2 * commit_tx_fee_msat(get_feerate!(nodes[0], nodes[1], chan.2), 1 + 1, get_opt_anchors!(nodes[0], nodes[1], chan.2));
let max_can_send = 5000000 - channel_reserve - commit_tx_fee;
let (route, our_payment_hash, _, our_payment_secret) = get_route_and_payment_hash!(nodes[0], nodes[1], max_can_send + 1);
let err = nodes[0].node.send_payment(&route, our_payment_hash, &Some(our_payment_secret), PaymentId(our_payment_hash.0)).err().unwrap();
// nodes[0] just sent. In the code for construction of this message, "local" refers
// to the sender of the message, and "remote" refers to the receiver.
- let feerate_per_kw = get_feerate!(nodes[0], chan.2);
+ let feerate_per_kw = get_feerate!(nodes[0], nodes[1], chan.2);
const INITIAL_COMMITMENT_NUMBER: u64 = (1 << 48) - 1;
let feemsat = 239;
let total_routing_fee_msat = (nodes.len() - 2) as u64 * feemsat;
- let chan_stat = get_channel_value_stat!(nodes[0], chan.2);
- let feerate = get_feerate!(nodes[0], chan.2);
- let opt_anchors = get_opt_anchors!(nodes[0], chan.2);
+ let chan_stat = get_channel_value_stat!(nodes[0], nodes[1], chan.2);
+ let feerate = get_feerate!(nodes[0], nodes[1], chan.2);
+ let opt_anchors = get_opt_anchors!(nodes[0], nodes[1], chan.2);
// Add a 2* and +1 for the fee spike reserve.
let commit_tx_fee_2_htlc = 2*commit_tx_fee_msat(feerate, 2 + 1, opt_anchors);
let chan_1 = create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 190000, 1001, channelmanager::provided_init_features(), channelmanager::provided_init_features());
let chan_2 = create_announced_chan_between_nodes_with_value(&nodes, 1, 2, 190000, 1001, channelmanager::provided_init_features(), channelmanager::provided_init_features());
- let mut stat01 = get_channel_value_stat!(nodes[0], chan_1.2);
- let mut stat11 = get_channel_value_stat!(nodes[1], chan_1.2);
+ let mut stat01 = get_channel_value_stat!(nodes[0], nodes[1], chan_1.2);
+ let mut stat11 = get_channel_value_stat!(nodes[1], nodes[0], chan_1.2);
- let mut stat12 = get_channel_value_stat!(nodes[1], chan_2.2);
- let mut stat22 = get_channel_value_stat!(nodes[2], chan_2.2);
+ let mut stat12 = get_channel_value_stat!(nodes[1], nodes[2], chan_2.2);
+ let mut stat22 = get_channel_value_stat!(nodes[2], nodes[1], chan_2.2);
macro_rules! expect_forward {
($node: expr) => {{
let feemsat = 239; // set above
let total_fee_msat = (nodes.len() - 2) as u64 * feemsat;
- let feerate = get_feerate!(nodes[0], chan_1.2);
- let opt_anchors = get_opt_anchors!(nodes[0], chan_1.2);
+ let feerate = get_feerate!(nodes[0], nodes[1], chan_1.2);
+ let opt_anchors = get_opt_anchors!(nodes[0], nodes[1], chan_1.2);
let recv_value_0 = stat01.counterparty_max_htlc_value_in_flight_msat - total_fee_msat;
claim_payment(&nodes[0], &[&nodes[1], &nodes[2]], payment_preimage);
let (stat01_, stat11_, stat12_, stat22_) = (
- get_channel_value_stat!(nodes[0], chan_1.2),
- get_channel_value_stat!(nodes[1], chan_1.2),
- get_channel_value_stat!(nodes[1], chan_2.2),
- get_channel_value_stat!(nodes[2], chan_2.2),
+ get_channel_value_stat!(nodes[0], nodes[1], chan_1.2),
+ get_channel_value_stat!(nodes[1], nodes[0], chan_1.2),
+ get_channel_value_stat!(nodes[1], nodes[2], chan_2.2),
+ get_channel_value_stat!(nodes[2], nodes[1], chan_2.2),
);
assert_eq!(stat01_.value_to_self_msat, stat01.value_to_self_msat - amt_msat);
let recv_value_21 = recv_value_2/2 - additional_htlc_cost_msat/2;
let recv_value_22 = recv_value_2 - recv_value_21 - total_fee_msat - additional_htlc_cost_msat;
{
- let stat = get_channel_value_stat!(nodes[0], chan_1.2);
+ let stat = get_channel_value_stat!(nodes[0], nodes[1], chan_1.2);
assert_eq!(stat.value_to_self_msat - (stat.pending_outbound_htlcs_amount_msat + recv_value_21 + recv_value_22 + total_fee_msat + total_fee_msat + commit_tx_fee_3_htlcs), stat.channel_reserve_msat);
}
let commit_tx_fee_1_htlc = 2*commit_tx_fee_msat(feerate, 1 + 1, opt_anchors);
let expected_value_to_self = stat01.value_to_self_msat - (recv_value_1 + total_fee_msat) - (recv_value_21 + total_fee_msat) - (recv_value_22 + total_fee_msat) - (recv_value_3 + total_fee_msat);
- let stat0 = get_channel_value_stat!(nodes[0], chan_1.2);
+ let stat0 = get_channel_value_stat!(nodes[0], nodes[1], chan_1.2);
assert_eq!(stat0.value_to_self_msat, expected_value_to_self);
assert_eq!(stat0.value_to_self_msat, stat0.channel_reserve_msat + commit_tx_fee_1_htlc);
- let stat2 = get_channel_value_stat!(nodes[2], chan_2.2);
+ let stat2 = get_channel_value_stat!(nodes[2], nodes[1], chan_2.2);
assert_eq!(stat2.value_to_self_msat, stat22.value_to_self_msat + recv_value_1 + recv_value_21 + recv_value_22 + recv_value_3);
}
let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs);
let chan_1 = create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features());
- let b_chan_values = get_channel_value_stat!(nodes[1], chan_1.2);
+ let b_chan_values = get_channel_value_stat!(nodes[1], nodes[0], chan_1.2);
// Route the first two HTLCs.
let payment_value_1 = b_chan_values.channel_reserve_msat - b_chan_values.value_to_self_msat - 10000;
let (payment_preimage_1, payment_hash_1, _) = route_payment(&nodes[0], &[&nodes[1]], payment_value_1);
nodes[1].node.handle_update_fee(&nodes[0].node.get_our_node_id(), update_msg.unwrap());
- let mut chan_stat = get_channel_value_stat!(nodes[0], chan.2);
+ let mut chan_stat = get_channel_value_stat!(nodes[0], nodes[1], chan.2);
let channel_reserve = chan_stat.channel_reserve_msat;
- let feerate = get_feerate!(nodes[0], chan.2);
- let opt_anchors = get_opt_anchors!(nodes[0], chan.2);
+ let feerate = get_feerate!(nodes[0], nodes[1], chan.2);
+ let opt_anchors = get_opt_anchors!(nodes[0], nodes[1], chan.2);
// 2* and +1 HTLCs on the commit tx fee calculation for the fee spike reserve.
let max_can_send = 5000000 - channel_reserve - 2*commit_tx_fee_msat(feerate, 1 + 1, opt_anchors);
// Send a payment which passes reserve checks but gets stuck in the holding cell.
nodes[0].node.send_payment(&route, our_payment_hash, &Some(our_payment_secret), PaymentId(our_payment_hash.0)).unwrap();
- chan_stat = get_channel_value_stat!(nodes[0], chan.2);
+ chan_stat = get_channel_value_stat!(nodes[0], nodes[1], chan.2);
assert_eq!(chan_stat.holding_cell_outbound_amount_msat, max_can_send);
// Flush the pending fee update.
// Upon receipt of the RAA, there will be an attempt to resend the holding cell
// HTLC, but now that the fee has been raised the payment will now fail, causing
// us to surface its failure to the user.
- chan_stat = get_channel_value_stat!(nodes[0], chan.2);
+ chan_stat = get_channel_value_stat!(nodes[0], nodes[1], chan.2);
assert_eq!(chan_stat.holding_cell_outbound_amount_msat, 0);
nodes[0].logger.assert_log("lightning::ln::channel".to_string(), format!("Freeing holding cell with 1 HTLC updates in channel {}", hex::encode(chan.2)), 1);
let failure_log = format!("Failed to send HTLC with payment_hash {} due to Cannot send value that would put our balance under counterparty-announced channel reserve value ({}) in channel {}",
nodes[1].node.handle_update_fee(&nodes[0].node.get_our_node_id(), update_msg.unwrap());
- let mut chan_stat = get_channel_value_stat!(nodes[0], chan.2);
+ let mut chan_stat = get_channel_value_stat!(nodes[0], nodes[1], chan.2);
let channel_reserve = chan_stat.channel_reserve_msat;
- let feerate = get_feerate!(nodes[0], chan.2);
- let opt_anchors = get_opt_anchors!(nodes[0], chan.2);
+ let feerate = get_feerate!(nodes[0], nodes[1], chan.2);
+ let opt_anchors = get_opt_anchors!(nodes[0], nodes[1], chan.2);
// 2* and +1 HTLCs on the commit tx fee calculation for the fee spike reserve.
let amt_1 = 20000;
// Send 2 payments which pass reserve checks but get stuck in the holding cell.
nodes[0].node.send_payment(&route_1, payment_hash_1, &Some(payment_secret_1), PaymentId(payment_hash_1.0)).unwrap();
- chan_stat = get_channel_value_stat!(nodes[0], chan.2);
+ chan_stat = get_channel_value_stat!(nodes[0], nodes[1], chan.2);
assert_eq!(chan_stat.holding_cell_outbound_amount_msat, amt_1);
let payment_id_2 = PaymentId(nodes[0].keys_manager.get_secure_random_bytes());
nodes[0].node.send_payment(&route_2, payment_hash_2, &Some(payment_secret_2), payment_id_2).unwrap();
- chan_stat = get_channel_value_stat!(nodes[0], chan.2);
+ chan_stat = get_channel_value_stat!(nodes[0], nodes[1], chan.2);
assert_eq!(chan_stat.holding_cell_outbound_amount_msat, amt_1 + amt_2);
// Flush the pending fee update.
// Upon receipt of the RAA, there will be an attempt to resend the holding cell HTLCs,
// but now that the fee has been raised the second payment will now fail, causing us
// to surface its failure to the user. The first payment should succeed.
- chan_stat = get_channel_value_stat!(nodes[0], chan.2);
+ chan_stat = get_channel_value_stat!(nodes[0], nodes[1], chan.2);
assert_eq!(chan_stat.holding_cell_outbound_amount_msat, 0);
nodes[0].logger.assert_log("lightning::ln::channel".to_string(), format!("Freeing holding cell with 2 HTLC updates in channel {}", hex::encode(chan.2)), 1);
let failure_log = format!("Failed to send HTLC with payment_hash {} due to Cannot send value that would put our balance under counterparty-announced channel reserve value ({}) in channel {}",
nodes[2].node.handle_update_fee(&nodes[1].node.get_our_node_id(), update_msg.unwrap());
- let mut chan_stat = get_channel_value_stat!(nodes[0], chan_0_1.2);
+ let mut chan_stat = get_channel_value_stat!(nodes[0], nodes[1], chan_0_1.2);
let channel_reserve = chan_stat.channel_reserve_msat;
- let feerate = get_feerate!(nodes[0], chan_0_1.2);
- let opt_anchors = get_opt_anchors!(nodes[0], chan_0_1.2);
+ let feerate = get_feerate!(nodes[0], nodes[1], chan_0_1.2);
+ let opt_anchors = get_opt_anchors!(nodes[0], nodes[1], chan_0_1.2);
// Send a payment which passes reserve checks but gets stuck in the holding cell.
let feemsat = 239;
commitment_signed_dance!(nodes[1], nodes[0], payment_event.commitment_msg, false);
expect_pending_htlcs_forwardable!(nodes[1]);
- chan_stat = get_channel_value_stat!(nodes[1], chan_1_2.2);
+ chan_stat = get_channel_value_stat!(nodes[1], nodes[2], chan_1_2.2);
assert_eq!(chan_stat.holding_cell_outbound_amount_msat, max_can_send);
// Flush the pending fee update.
let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs);
let channel_value = 100000;
let chan = create_announced_chan_between_nodes_with_value(&nodes, 0, 1, channel_value, 0, channelmanager::provided_init_features(), channelmanager::provided_init_features());
- let max_in_flight = get_channel_value_stat!(nodes[0], chan.2).counterparty_max_htlc_value_in_flight_msat;
+ let max_in_flight = get_channel_value_stat!(nodes[0], nodes[1], chan.2).counterparty_max_htlc_value_in_flight_msat;
send_payment(&nodes[0], &vec!(&nodes[1])[..], max_in_flight);
let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs);
let chan = create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 100000, 95000000, channelmanager::provided_init_features(), channelmanager::provided_init_features());
- let chan_stat = get_channel_value_stat!(nodes[0], chan.2);
+ let chan_stat = get_channel_value_stat!(nodes[0], nodes[1], chan.2);
let channel_reserve = chan_stat.channel_reserve_msat;
- let feerate = get_feerate!(nodes[0], chan.2);
- let opt_anchors = get_opt_anchors!(nodes[0], chan.2);
+ let feerate = get_feerate!(nodes[0], nodes[1], chan.2);
+ let opt_anchors = get_opt_anchors!(nodes[0], nodes[1], chan.2);
// The 2* and +1 are for the fee spike reserve.
let commit_tx_fee_outbound = 2 * commit_tx_fee_msat(feerate, 1 + 1, opt_anchors);
nodes[0].node.send_payment(&route, our_payment_hash, &Some(our_payment_secret), PaymentId(our_payment_hash.0)).unwrap();
check_added_monitors!(nodes[0], 1);
let mut updates = get_htlc_update_msgs!(nodes[0], nodes[1].node.get_our_node_id());
- updates.update_add_htlcs[0].amount_msat = get_channel_value_stat!(nodes[1], chan.2).counterparty_max_htlc_value_in_flight_msat + 1;
+ updates.update_add_htlcs[0].amount_msat = get_channel_value_stat!(nodes[1], nodes[0], chan.2).counterparty_max_htlc_value_in_flight_msat + 1;
nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &updates.update_add_htlcs[0]);
assert!(nodes[1].node.list_channels().is_empty());
let funding_outpoint = OutPoint { txid: funding_tx.txid(), index: 0 };
assert_eq!(funding_outpoint.to_channel_id(), chan_id);
- let chan_feerate = get_feerate!(nodes[0], chan_id) as u64;
- let opt_anchors = get_opt_anchors!(nodes[0], chan_id);
+ let chan_feerate = get_feerate!(nodes[0], nodes[1], chan_id) as u64;
+ let opt_anchors = get_opt_anchors!(nodes[0], nodes[1], chan_id);
assert_eq!(vec![Balance::ClaimableOnChannelClose {
claimable_amount_satoshis: 1_000_000 - 1_000 - chan_feerate * channel::commitment_tx_base_weight(opt_anchors) / 1000
let htlc_cltv_timeout = nodes[0].best_block_info().1 + TEST_FINAL_CLTV + 1; // Note ChannelManager adds one to CLTV timeouts for safety
- let chan_feerate = get_feerate!(nodes[0], chan_id) as u64;
- let opt_anchors = get_opt_anchors!(nodes[0], chan_id);
+ let chan_feerate = get_feerate!(nodes[0], nodes[1], chan_id) as u64;
+ let opt_anchors = get_opt_anchors!(nodes[0], nodes[1], chan_id);
let remote_txn = get_local_commitment_txn!(nodes[1], chan_id);
// Before B receives the payment preimage, it only suggests the push_msat value of 1_000 sats
check_added_monitors!(nodes[1], 1);
expect_payment_claimed!(nodes[1], payment_hash_2, 20_000_000);
- let chan_feerate = get_feerate!(nodes[0], chan_id) as u64;
- let opt_anchors = get_opt_anchors!(nodes[0], chan_id);
+ let chan_feerate = get_feerate!(nodes[0], nodes[1], chan_id) as u64;
+ let opt_anchors = get_opt_anchors!(nodes[0], nodes[1], chan_id);
// Get nodes[0]'s commitment transaction and HTLC-Timeout transactions
let as_txn = get_local_commitment_txn!(nodes[0], chan_id);
let to_a_failed_payment_hash = route_payment(&nodes[1], &[&nodes[0]], 20_000_000).1;
let htlc_cltv_timeout = nodes[0].best_block_info().1 + TEST_FINAL_CLTV + 1; // Note ChannelManager adds one to CLTV timeouts for safety
- let chan_feerate = get_feerate!(nodes[0], chan_id) as u64;
- let opt_anchors = get_opt_anchors!(nodes[0], chan_id);
+ let chan_feerate = get_feerate!(nodes[0], nodes[1], chan_id) as u64;
+ let opt_anchors = get_opt_anchors!(nodes[0], nodes[1], chan_id);
// Both A and B will have an HTLC that's claimable on timeout and one that's claimable if they
// receive the preimage. These will remain the same through the channel closure and until the
// Get the latest commitment transaction from A and then update the fee to revoke it
let as_revoked_txn = get_local_commitment_txn!(nodes[0], chan_id);
- let opt_anchors = get_opt_anchors!(nodes[0], chan_id);
+ let opt_anchors = get_opt_anchors!(nodes[0], nodes[1], chan_id);
- let chan_feerate = get_feerate!(nodes[0], chan_id) as u64;
+ let chan_feerate = get_feerate!(nodes[0], nodes[1], chan_id) as u64;
let missing_htlc_cltv_timeout = nodes[0].best_block_info().1 + TEST_FINAL_CLTV + 1; // Note ChannelManager adds one to CLTV timeouts for safety
let missing_htlc_payment_hash = route_payment(&nodes[1], &[&nodes[0]], 2_000_000).1;
claim_payment(&nodes[0], &[&nodes[1]], payment_preimage);
- let chan_feerate = get_feerate!(nodes[0], chan_id) as u64;
- let opt_anchors = get_opt_anchors!(nodes[0], chan_id);
+ let chan_feerate = get_feerate!(nodes[0], nodes[1], chan_id) as u64;
+ let opt_anchors = get_opt_anchors!(nodes[0], nodes[1], chan_id);
// B will generate an HTLC-Success from its revoked commitment tx
mine_transaction(&nodes[1], &revoked_local_txn[0]);
check_spends!(as_revoked_txn[0], funding_tx);
check_spends!(as_revoked_txn[1], as_revoked_txn[0]); // The HTLC-Claim transaction
- let opt_anchors = get_opt_anchors!(nodes[0], chan_id);
- let chan_feerate = get_feerate!(nodes[0], chan_id) as u64;
+ let opt_anchors = get_opt_anchors!(nodes[0], nodes[1], chan_id);
+ let chan_feerate = get_feerate!(nodes[0], nodes[1], chan_id) as u64;
{
let mut feerate = chanmon_cfgs[0].fee_estimator.sat_per_kw.lock().unwrap();