From 830220393f04a7be0418ef0d390fb51ab0215ad0 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Fri, 28 Jul 2023 06:20:43 +0000 Subject: [PATCH] Drop `claimable` from `Balance::claimable_amount_satoshis` fields In Java/TypeScript, we map enums as a base class and each variant as a class which extends the base. In Java/TypeScript, functions and fields share the same namespace, which means we cannot have functions on an enum which have the same name as any fields in any enum variants. `Balance`'s `claimable_amount_satoshis` method aliases with fields in each variant, and thus ultimately doesn't compile in TypeScript. Because `Balance::claimable_amount_satoshis` has the same name as the fields, it's also a bit confusing, as it doesn't return the field for each variant, but sometimes returns zero if we're not sure we can claim the balance. Instead, we rename the fields in each enum variant to simply `amount_satoshis`, to avoid implying that we can definitely claim the balance. --- lightning/src/chain/channelmonitor.rs | 73 ++++----- lightning/src/ln/monitor_tests.rs | 208 +++++++++++++------------- 2 files changed, 134 insertions(+), 147 deletions(-) diff --git a/lightning/src/chain/channelmonitor.rs b/lightning/src/chain/channelmonitor.rs index ce827923..a74c18e7 100644 --- a/lightning/src/chain/channelmonitor.rs +++ b/lightning/src/chain/channelmonitor.rs @@ -576,14 +576,14 @@ pub enum Balance { ClaimableOnChannelClose { /// The amount available to claim, in satoshis, excluding the on-chain fees which will be /// required to do so. - claimable_amount_satoshis: u64, + amount_satoshis: u64, }, /// The channel has been closed, and the given balance is ours but awaiting confirmations until /// we consider it spendable. ClaimableAwaitingConfirmations { /// The amount available to claim, in satoshis, possibly excluding the on-chain fees which /// were spent in broadcasting the transaction. - claimable_amount_satoshis: u64, + amount_satoshis: u64, /// The height at which an [`Event::SpendableOutputs`] event will be generated for this /// amount. confirmation_height: u32, @@ -598,7 +598,7 @@ pub enum Balance { ContentiousClaimable { /// The amount available to claim, in satoshis, excluding the on-chain fees which will be /// required to do so. - claimable_amount_satoshis: u64, + amount_satoshis: u64, /// The height at which the counterparty may be able to claim the balance if we have not /// done so. timeout_height: u32, @@ -613,7 +613,7 @@ pub enum Balance { MaybeTimeoutClaimableHTLC { /// The amount potentially available to claim, in satoshis, excluding the on-chain fees /// which will be required to do so. - claimable_amount_satoshis: u64, + amount_satoshis: u64, /// The height at which we will be able to claim the balance if our counterparty has not /// done so. claimable_height: u32, @@ -626,7 +626,7 @@ pub enum Balance { MaybePreimageClaimableHTLC { /// The amount potentially available to claim, in satoshis, excluding the on-chain fees /// which will be required to do so. - claimable_amount_satoshis: u64, + amount_satoshis: u64, /// The height at which our counterparty will be able to claim the balance if we have not /// yet received the preimage and claimed it ourselves. expiry_height: u32, @@ -643,7 +643,7 @@ pub enum Balance { /// /// Note that for outputs from HTLC balances this may be excluding some on-chain fees that /// were already spent. - claimable_amount_satoshis: u64, + amount_satoshis: u64, }, } @@ -656,27 +656,14 @@ impl Balance { /// On-chain fees required to claim the balance are not included in this amount. pub fn claimable_amount_satoshis(&self) -> u64 { match self { - Balance::ClaimableOnChannelClose { - claimable_amount_satoshis, - } => *claimable_amount_satoshis, - Balance::ClaimableAwaitingConfirmations { - claimable_amount_satoshis, - .. - } => *claimable_amount_satoshis, - Balance::ContentiousClaimable { - claimable_amount_satoshis, - .. - } => *claimable_amount_satoshis, - Balance::MaybeTimeoutClaimableHTLC { - .. - } => 0, - Balance::MaybePreimageClaimableHTLC { - .. - } => 0, - Balance::CounterpartyRevokedOutputClaimable { - claimable_amount_satoshis, - .. - } => *claimable_amount_satoshis, + Balance::ClaimableOnChannelClose { amount_satoshis, .. }| + Balance::ClaimableAwaitingConfirmations { amount_satoshis, .. }| + Balance::ContentiousClaimable { amount_satoshis, .. }| + Balance::CounterpartyRevokedOutputClaimable { amount_satoshis, .. } + => *amount_satoshis, + Balance::MaybeTimeoutClaimableHTLC { .. }| + Balance::MaybePreimageClaimableHTLC { .. } + => 0, } } } @@ -1672,7 +1659,7 @@ impl ChannelMonitorImpl { if let Some(conf_thresh) = holder_delayed_output_pending { debug_assert!(holder_commitment); return Some(Balance::ClaimableAwaitingConfirmations { - claimable_amount_satoshis: htlc.amount_msat / 1000, + amount_satoshis: htlc.amount_msat / 1000, confirmation_height: conf_thresh, }); } else if htlc_resolved.is_some() && !htlc_output_spend_pending { @@ -1710,7 +1697,7 @@ impl ChannelMonitorImpl { debug_assert!(!htlc.offered || htlc_spend_pending.is_none() || !htlc_spend_pending.unwrap().1, "We don't (currently) generate preimage claims against revoked outputs, where did you get one?!"); return Some(Balance::CounterpartyRevokedOutputClaimable { - claimable_amount_satoshis: htlc.amount_msat / 1000, + amount_satoshis: htlc.amount_msat / 1000, }); } } else if htlc.offered == holder_commitment { @@ -1719,12 +1706,12 @@ impl ChannelMonitorImpl { // and awaiting confirmations on it. if let Some(conf_thresh) = holder_timeout_spend_pending { return Some(Balance::ClaimableAwaitingConfirmations { - claimable_amount_satoshis: htlc.amount_msat / 1000, + amount_satoshis: htlc.amount_msat / 1000, confirmation_height: conf_thresh, }); } else { return Some(Balance::MaybeTimeoutClaimableHTLC { - claimable_amount_satoshis: htlc.amount_msat / 1000, + amount_satoshis: htlc.amount_msat / 1000, claimable_height: htlc.cltv_expiry, payment_hash: htlc.payment_hash, }); @@ -1738,12 +1725,12 @@ impl ChannelMonitorImpl { debug_assert!(holder_timeout_spend_pending.is_none()); if let Some((conf_thresh, true)) = htlc_spend_pending { return Some(Balance::ClaimableAwaitingConfirmations { - claimable_amount_satoshis: htlc.amount_msat / 1000, + amount_satoshis: htlc.amount_msat / 1000, confirmation_height: conf_thresh, }); } else { return Some(Balance::ContentiousClaimable { - claimable_amount_satoshis: htlc.amount_msat / 1000, + amount_satoshis: htlc.amount_msat / 1000, timeout_height: htlc.cltv_expiry, payment_hash: htlc.payment_hash, payment_preimage: *payment_preimage, @@ -1751,7 +1738,7 @@ impl ChannelMonitorImpl { } } else if htlc_resolved.is_none() { return Some(Balance::MaybePreimageClaimableHTLC { - claimable_amount_satoshis: htlc.amount_msat / 1000, + amount_satoshis: htlc.amount_msat / 1000, expiry_height: htlc.cltv_expiry, payment_hash: htlc.payment_hash, }); @@ -1824,7 +1811,7 @@ impl ChannelMonitor { } else { None } }) { res.push(Balance::ClaimableAwaitingConfirmations { - claimable_amount_satoshis: value, + amount_satoshis: value, confirmation_height: conf_thresh, }); } else { @@ -1847,7 +1834,7 @@ impl ChannelMonitor { descriptor: SpendableOutputDescriptor::StaticOutput { output, .. } } = &event.event { res.push(Balance::ClaimableAwaitingConfirmations { - claimable_amount_satoshis: output.value, + amount_satoshis: output.value, confirmation_height: event.confirmation_threshold(), }); if let Some(confirmed_to_self_idx) = confirmed_counterparty_output.map(|(idx, _)| idx) { @@ -1866,7 +1853,7 @@ impl ChannelMonitor { .is_output_spend_pending(&BitcoinOutPoint::new(txid, confirmed_to_self_idx)); if output_spendable { res.push(Balance::CounterpartyRevokedOutputClaimable { - claimable_amount_satoshis: amt, + amount_satoshis: amt, }); } } else { @@ -1879,7 +1866,7 @@ impl ChannelMonitor { walk_htlcs!(true, false, us.current_holder_commitment_tx.htlc_outputs.iter().map(|(a, _, _)| a)); if let Some(conf_thresh) = pending_commitment_tx_conf_thresh { res.push(Balance::ClaimableAwaitingConfirmations { - claimable_amount_satoshis: us.current_holder_commitment_tx.to_self_value_sat, + amount_satoshis: us.current_holder_commitment_tx.to_self_value_sat, confirmation_height: conf_thresh, }); } @@ -1889,7 +1876,7 @@ impl ChannelMonitor { walk_htlcs!(true, false, prev_commitment.htlc_outputs.iter().map(|(a, _, _)| a)); if let Some(conf_thresh) = pending_commitment_tx_conf_thresh { res.push(Balance::ClaimableAwaitingConfirmations { - claimable_amount_satoshis: prev_commitment.to_self_value_sat, + amount_satoshis: prev_commitment.to_self_value_sat, confirmation_height: conf_thresh, }); } @@ -1902,7 +1889,7 @@ impl ChannelMonitor { // neither us nor our counterparty misbehaved. At worst we've under-estimated // the amount we can claim as we'll punish a misbehaving counterparty. res.push(Balance::ClaimableAwaitingConfirmations { - claimable_amount_satoshis: us.current_holder_commitment_tx.to_self_value_sat, + amount_satoshis: us.current_holder_commitment_tx.to_self_value_sat, confirmation_height: conf_thresh, }); } @@ -1913,7 +1900,7 @@ impl ChannelMonitor { if htlc.transaction_output_index.is_none() { continue; } if htlc.offered { res.push(Balance::MaybeTimeoutClaimableHTLC { - claimable_amount_satoshis: htlc.amount_msat / 1000, + amount_satoshis: htlc.amount_msat / 1000, claimable_height: htlc.cltv_expiry, payment_hash: htlc.payment_hash, }); @@ -1923,14 +1910,14 @@ impl ChannelMonitor { // As long as the HTLC is still in our latest commitment state, treat // it as potentially claimable, even if it has long-since expired. res.push(Balance::MaybePreimageClaimableHTLC { - claimable_amount_satoshis: htlc.amount_msat / 1000, + amount_satoshis: htlc.amount_msat / 1000, expiry_height: htlc.cltv_expiry, payment_hash: htlc.payment_hash, }); } } res.push(Balance::ClaimableOnChannelClose { - claimable_amount_satoshis: us.current_holder_commitment_tx.to_self_value_sat + claimable_inbound_htlc_value_sat, + amount_satoshis: us.current_holder_commitment_tx.to_self_value_sat + claimable_inbound_htlc_value_sat, }); } diff --git a/lightning/src/ln/monitor_tests.rs b/lightning/src/ln/monitor_tests.rs index a916dbfc..47ee0939 100644 --- a/lightning/src/ln/monitor_tests.rs +++ b/lightning/src/ln/monitor_tests.rs @@ -171,10 +171,10 @@ fn chanmon_claim_value_coop_close() { let channel_type_features = get_channel_type_features!(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(&channel_type_features) / 1000 + amount_satoshis: 1_000_000 - 1_000 - chan_feerate * channel::commitment_tx_base_weight(&channel_type_features) / 1000 }], nodes[0].chain_monitor.chain_monitor.get_monitor(funding_outpoint).unwrap().get_claimable_balances()); - assert_eq!(vec![Balance::ClaimableOnChannelClose { claimable_amount_satoshis: 1_000, }], + assert_eq!(vec![Balance::ClaimableOnChannelClose { amount_satoshis: 1_000, }], nodes[1].chain_monitor.chain_monitor.get_monitor(funding_outpoint).unwrap().get_claimable_balances()); nodes[0].node.close_channel(&chan_id, &nodes[1].node.get_our_node_id()).unwrap(); @@ -206,12 +206,12 @@ fn chanmon_claim_value_coop_close() { assert!(nodes[1].chain_monitor.chain_monitor.get_and_clear_pending_events().is_empty()); assert_eq!(vec![Balance::ClaimableAwaitingConfirmations { - claimable_amount_satoshis: 1_000_000 - 1_000 - chan_feerate * channel::commitment_tx_base_weight(&channel_type_features) / 1000, + amount_satoshis: 1_000_000 - 1_000 - chan_feerate * channel::commitment_tx_base_weight(&channel_type_features) / 1000, confirmation_height: nodes[0].best_block_info().1 + ANTI_REORG_DELAY - 1, }], nodes[0].chain_monitor.chain_monitor.get_monitor(funding_outpoint).unwrap().get_claimable_balances()); assert_eq!(vec![Balance::ClaimableAwaitingConfirmations { - claimable_amount_satoshis: 1000, + amount_satoshis: 1000, confirmation_height: nodes[1].best_block_info().1 + ANTI_REORG_DELAY - 1, }], nodes[1].chain_monitor.chain_monitor.get_monitor(funding_outpoint).unwrap().get_claimable_balances()); @@ -283,33 +283,33 @@ fn do_test_claim_value_force_close(prev_commitment_tx: bool) { let remote_txn = get_local_commitment_txn!(nodes[1], chan_id); let sent_htlc_balance = Balance::MaybeTimeoutClaimableHTLC { - claimable_amount_satoshis: 3_000, + amount_satoshis: 3_000, claimable_height: htlc_cltv_timeout, payment_hash, }; let sent_htlc_timeout_balance = Balance::MaybeTimeoutClaimableHTLC { - claimable_amount_satoshis: 4_000, + amount_satoshis: 4_000, claimable_height: htlc_cltv_timeout, payment_hash: timeout_payment_hash, }; let received_htlc_balance = Balance::MaybePreimageClaimableHTLC { - claimable_amount_satoshis: 3_000, + amount_satoshis: 3_000, expiry_height: htlc_cltv_timeout, payment_hash, }; let received_htlc_timeout_balance = Balance::MaybePreimageClaimableHTLC { - claimable_amount_satoshis: 4_000, + amount_satoshis: 4_000, expiry_height: htlc_cltv_timeout, payment_hash: timeout_payment_hash, }; let received_htlc_claiming_balance = Balance::ContentiousClaimable { - claimable_amount_satoshis: 3_000, + amount_satoshis: 3_000, timeout_height: htlc_cltv_timeout, payment_hash, payment_preimage, }; let received_htlc_timeout_claiming_balance = Balance::ContentiousClaimable { - claimable_amount_satoshis: 4_000, + amount_satoshis: 4_000, timeout_height: htlc_cltv_timeout, payment_hash: timeout_payment_hash, payment_preimage: timeout_payment_preimage, @@ -318,12 +318,12 @@ fn do_test_claim_value_force_close(prev_commitment_tx: bool) { // Before B receives the payment preimage, it only suggests the push_msat value of 1_000 sats // as claimable. A lists both its to-self balance and the (possibly-claimable) HTLCs. assert_eq!(sorted_vec(vec![Balance::ClaimableOnChannelClose { - claimable_amount_satoshis: 1_000_000 - 3_000 - 4_000 - 1_000 - 3 - chan_feerate * + amount_satoshis: 1_000_000 - 3_000 - 4_000 - 1_000 - 3 - chan_feerate * (channel::commitment_tx_base_weight(&channel_type_features) + 2 * channel::COMMITMENT_TX_WEIGHT_PER_HTLC) / 1000, }, sent_htlc_balance.clone(), sent_htlc_timeout_balance.clone()]), sorted_vec(nodes[0].chain_monitor.chain_monitor.get_monitor(funding_outpoint).unwrap().get_claimable_balances())); assert_eq!(sorted_vec(vec![Balance::ClaimableOnChannelClose { - claimable_amount_satoshis: 1_000, + amount_satoshis: 1_000, }, received_htlc_balance.clone(), received_htlc_timeout_balance.clone()]), sorted_vec(nodes[1].chain_monitor.chain_monitor.get_monitor(funding_outpoint).unwrap().get_claimable_balances())); @@ -360,7 +360,7 @@ fn do_test_claim_value_force_close(prev_commitment_tx: bool) { // Once B has received the payment preimage, it includes the value of the HTLC in its // "claimable if you were to close the channel" balance. let mut a_expected_balances = vec![Balance::ClaimableOnChannelClose { - claimable_amount_satoshis: 1_000_000 - // Channel funding value in satoshis + amount_satoshis: 1_000_000 - // Channel funding value in satoshis 4_000 - // The to-be-failed HTLC value in satoshis 3_000 - // The claimed HTLC value in satoshis 1_000 - // The push_msat value in satoshis @@ -376,7 +376,7 @@ fn do_test_claim_value_force_close(prev_commitment_tx: bool) { assert_eq!(sorted_vec(a_expected_balances), sorted_vec(nodes[0].chain_monitor.chain_monitor.get_monitor(funding_outpoint).unwrap().get_claimable_balances())); assert_eq!(vec![Balance::ClaimableOnChannelClose { - claimable_amount_satoshis: 1_000 + 3_000 + 4_000, + amount_satoshis: 1_000 + 3_000 + 4_000, }], nodes[1].chain_monitor.chain_monitor.get_monitor(funding_outpoint).unwrap().get_claimable_balances()); @@ -415,7 +415,7 @@ fn do_test_claim_value_force_close(prev_commitment_tx: bool) { assert!(nodes[1].chain_monitor.chain_monitor.get_and_clear_pending_events().is_empty()); assert_eq!(sorted_vec(vec![Balance::ClaimableAwaitingConfirmations { - claimable_amount_satoshis: 1_000_000 - 3_000 - 4_000 - 1_000 - 3 - chan_feerate * + amount_satoshis: 1_000_000 - 3_000 - 4_000 - 1_000 - 3 - chan_feerate * (channel::commitment_tx_base_weight(&channel_type_features) + 2 * channel::COMMITMENT_TX_WEIGHT_PER_HTLC) / 1000, confirmation_height: nodes[0].best_block_info().1 + ANTI_REORG_DELAY - 1, }, sent_htlc_balance.clone(), sent_htlc_timeout_balance.clone()]), @@ -423,7 +423,7 @@ fn do_test_claim_value_force_close(prev_commitment_tx: bool) { // The main non-HTLC balance is just awaiting confirmations, but the claimable height is the // CSV delay, not ANTI_REORG_DELAY. assert_eq!(sorted_vec(vec![Balance::ClaimableAwaitingConfirmations { - claimable_amount_satoshis: 1_000, + amount_satoshis: 1_000, confirmation_height: node_b_commitment_claimable, }, // Both HTLC balances are "contentious" as our counterparty could claim them if we wait too @@ -440,7 +440,7 @@ fn do_test_claim_value_force_close(prev_commitment_tx: bool) { assert_eq!(sorted_vec(vec![sent_htlc_balance.clone(), sent_htlc_timeout_balance.clone()]), sorted_vec(nodes[0].chain_monitor.chain_monitor.get_monitor(funding_outpoint).unwrap().get_claimable_balances())); assert_eq!(sorted_vec(vec![Balance::ClaimableAwaitingConfirmations { - claimable_amount_satoshis: 1_000, + amount_satoshis: 1_000, confirmation_height: node_b_commitment_claimable, }, received_htlc_claiming_balance.clone(), received_htlc_timeout_claiming_balance.clone()]), sorted_vec(nodes[1].chain_monitor.chain_monitor.get_monitor(funding_outpoint).unwrap().get_claimable_balances())); @@ -481,7 +481,7 @@ fn do_test_claim_value_force_close(prev_commitment_tx: bool) { mine_transaction(&nodes[0], &a_broadcast_txn[1]); assert!(nodes[0].node.get_and_clear_pending_events().is_empty()); assert_eq!(vec![Balance::ClaimableAwaitingConfirmations { - claimable_amount_satoshis: 4_000, + amount_satoshis: 4_000, confirmation_height: nodes[0].best_block_info().1 + ANTI_REORG_DELAY - 1, }], nodes[0].chain_monitor.chain_monitor.get_monitor(funding_outpoint).unwrap().get_claimable_balances()); @@ -501,10 +501,10 @@ fn do_test_claim_value_force_close(prev_commitment_tx: bool) { mine_transaction(&nodes[1], &b_broadcast_txn[0]); assert_eq!(sorted_vec(vec![Balance::ClaimableAwaitingConfirmations { - claimable_amount_satoshis: 1_000, + amount_satoshis: 1_000, confirmation_height: node_b_commitment_claimable, }, Balance::ClaimableAwaitingConfirmations { - claimable_amount_satoshis: 3_000, + amount_satoshis: 3_000, confirmation_height: node_b_htlc_claimable, }, received_htlc_timeout_claiming_balance.clone()]), sorted_vec(nodes[1].chain_monitor.chain_monitor.get_monitor(funding_outpoint).unwrap().get_claimable_balances())); @@ -515,7 +515,7 @@ fn do_test_claim_value_force_close(prev_commitment_tx: bool) { test_spendable_output(&nodes[1], &remote_txn[0]); assert_eq!(sorted_vec(vec![Balance::ClaimableAwaitingConfirmations { - claimable_amount_satoshis: 3_000, + amount_satoshis: 3_000, confirmation_height: node_b_htlc_claimable, }, received_htlc_timeout_claiming_balance.clone()]), sorted_vec(nodes[1].chain_monitor.chain_monitor.get_monitor(funding_outpoint).unwrap().get_claimable_balances())); @@ -624,18 +624,18 @@ fn test_balances_on_local_commitment_htlcs() { check_closed_event!(nodes[0], 1, ClosureReason::CommitmentTxConfirmed); let htlc_balance_known_preimage = Balance::MaybeTimeoutClaimableHTLC { - claimable_amount_satoshis: 10_000, + amount_satoshis: 10_000, claimable_height: htlc_cltv_timeout, payment_hash, }; let htlc_balance_unknown_preimage = Balance::MaybeTimeoutClaimableHTLC { - claimable_amount_satoshis: 20_000, + amount_satoshis: 20_000, claimable_height: htlc_cltv_timeout, payment_hash: payment_hash_2, }; assert_eq!(sorted_vec(vec![Balance::ClaimableAwaitingConfirmations { - claimable_amount_satoshis: 1_000_000 - 10_000 - 20_000 - chan_feerate * + amount_satoshis: 1_000_000 - 10_000 - 20_000 - chan_feerate * (channel::commitment_tx_base_weight(&channel_type_features) + 2 * channel::COMMITMENT_TX_WEIGHT_PER_HTLC) / 1000, confirmation_height: node_a_commitment_claimable, }, htlc_balance_known_preimage.clone(), htlc_balance_unknown_preimage.clone()]), @@ -654,7 +654,7 @@ fn test_balances_on_local_commitment_htlcs() { // transaction. connect_blocks(&nodes[0], TEST_FINAL_CLTV - 1); assert_eq!(sorted_vec(vec![Balance::ClaimableAwaitingConfirmations { - claimable_amount_satoshis: 1_000_000 - 10_000 - 20_000 - chan_feerate * + amount_satoshis: 1_000_000 - 10_000 - 20_000 - chan_feerate * (channel::commitment_tx_base_weight(&channel_type_features) + 2 * channel::COMMITMENT_TX_WEIGHT_PER_HTLC) / 1000, confirmation_height: node_a_commitment_claimable, }, htlc_balance_known_preimage.clone(), htlc_balance_unknown_preimage.clone()]), @@ -669,11 +669,11 @@ fn test_balances_on_local_commitment_htlcs() { // balance) check failed. With this check removed, the code panicked in the `connect_blocks` // call, as described, two hunks down. assert_eq!(sorted_vec(vec![Balance::ClaimableAwaitingConfirmations { - claimable_amount_satoshis: 1_000_000 - 10_000 - 20_000 - chan_feerate * + amount_satoshis: 1_000_000 - 10_000 - 20_000 - chan_feerate * (channel::commitment_tx_base_weight(&channel_type_features) + 2 * channel::COMMITMENT_TX_WEIGHT_PER_HTLC) / 1000, confirmation_height: node_a_commitment_claimable, }, Balance::ClaimableAwaitingConfirmations { - claimable_amount_satoshis: 10_000, + amount_satoshis: 10_000, confirmation_height: node_a_htlc_claimable, }, htlc_balance_unknown_preimage.clone()]), sorted_vec(nodes[0].chain_monitor.chain_monitor.get_monitor(funding_outpoint).unwrap().get_claimable_balances())); @@ -683,11 +683,11 @@ fn test_balances_on_local_commitment_htlcs() { mine_transaction(&nodes[0], &bs_htlc_claim_txn[0]); expect_payment_sent!(nodes[0], payment_preimage_2); assert_eq!(sorted_vec(vec![Balance::ClaimableAwaitingConfirmations { - claimable_amount_satoshis: 1_000_000 - 10_000 - 20_000 - chan_feerate * + amount_satoshis: 1_000_000 - 10_000 - 20_000 - chan_feerate * (channel::commitment_tx_base_weight(&channel_type_features) + 2 * channel::COMMITMENT_TX_WEIGHT_PER_HTLC) / 1000, confirmation_height: node_a_commitment_claimable, }, Balance::ClaimableAwaitingConfirmations { - claimable_amount_satoshis: 10_000, + amount_satoshis: 10_000, confirmation_height: node_a_htlc_claimable, }, htlc_balance_unknown_preimage.clone()]), sorted_vec(nodes[0].chain_monitor.chain_monitor.get_monitor(funding_outpoint).unwrap().get_claimable_balances())); @@ -699,11 +699,11 @@ fn test_balances_on_local_commitment_htlcs() { expect_payment_failed!(nodes[0], payment_hash, false); assert_eq!(sorted_vec(vec![Balance::ClaimableAwaitingConfirmations { - claimable_amount_satoshis: 1_000_000 - 10_000 - 20_000 - chan_feerate * + amount_satoshis: 1_000_000 - 10_000 - 20_000 - chan_feerate * (channel::commitment_tx_base_weight(&channel_type_features) + 2 * channel::COMMITMENT_TX_WEIGHT_PER_HTLC) / 1000, confirmation_height: node_a_commitment_claimable, }, Balance::ClaimableAwaitingConfirmations { - claimable_amount_satoshis: 10_000, + amount_satoshis: 10_000, confirmation_height: node_a_htlc_claimable, }]), sorted_vec(nodes[0].chain_monitor.chain_monitor.get_monitor(funding_outpoint).unwrap().get_claimable_balances())); @@ -712,7 +712,7 @@ fn test_balances_on_local_commitment_htlcs() { // `SpendableOutputs` event and removing the claimable balance entry. connect_blocks(&nodes[0], node_a_commitment_claimable - nodes[0].best_block_info().1); assert_eq!(vec![Balance::ClaimableAwaitingConfirmations { - claimable_amount_satoshis: 10_000, + amount_satoshis: 10_000, confirmation_height: node_a_htlc_claimable, }], nodes[0].chain_monitor.chain_monitor.get_monitor(funding_outpoint).unwrap().get_claimable_balances()); @@ -754,22 +754,22 @@ fn test_no_preimage_inbound_htlc_balances() { let channel_type_features = get_channel_type_features!(nodes[0], nodes[1], chan_id); let a_sent_htlc_balance = Balance::MaybeTimeoutClaimableHTLC { - claimable_amount_satoshis: 10_000, + amount_satoshis: 10_000, claimable_height: htlc_cltv_timeout, payment_hash: to_b_failed_payment_hash, }; let a_received_htlc_balance = Balance::MaybePreimageClaimableHTLC { - claimable_amount_satoshis: 20_000, + amount_satoshis: 20_000, expiry_height: htlc_cltv_timeout, payment_hash: to_a_failed_payment_hash, }; let b_received_htlc_balance = Balance::MaybePreimageClaimableHTLC { - claimable_amount_satoshis: 10_000, + amount_satoshis: 10_000, expiry_height: htlc_cltv_timeout, payment_hash: to_b_failed_payment_hash, }; let b_sent_htlc_balance = Balance::MaybeTimeoutClaimableHTLC { - claimable_amount_satoshis: 20_000, + amount_satoshis: 20_000, claimable_height: htlc_cltv_timeout, payment_hash: to_a_failed_payment_hash, }; @@ -779,13 +779,13 @@ fn test_no_preimage_inbound_htlc_balances() { // HTLC output is spent. assert_eq!(sorted_vec(vec![Balance::ClaimableOnChannelClose { - claimable_amount_satoshis: 1_000_000 - 500_000 - 10_000 - chan_feerate * + amount_satoshis: 1_000_000 - 500_000 - 10_000 - chan_feerate * (channel::commitment_tx_base_weight(&channel_type_features) + 2 * channel::COMMITMENT_TX_WEIGHT_PER_HTLC) / 1000, }, a_received_htlc_balance.clone(), a_sent_htlc_balance.clone()]), sorted_vec(nodes[0].chain_monitor.chain_monitor.get_monitor(funding_outpoint).unwrap().get_claimable_balances())); assert_eq!(sorted_vec(vec![Balance::ClaimableOnChannelClose { - claimable_amount_satoshis: 500_000 - 20_000, + amount_satoshis: 500_000 - 20_000, }, b_received_htlc_balance.clone(), b_sent_htlc_balance.clone()]), sorted_vec(nodes[1].chain_monitor.chain_monitor.get_monitor(funding_outpoint).unwrap().get_claimable_balances())); @@ -799,7 +799,7 @@ fn test_no_preimage_inbound_htlc_balances() { // claimable balances remain the same except for the non-HTLC balance changing variant. let node_a_commitment_claimable = nodes[0].best_block_info().1 + BREAKDOWN_TIMEOUT as u32; let as_pre_spend_claims = sorted_vec(vec![Balance::ClaimableAwaitingConfirmations { - claimable_amount_satoshis: 1_000_000 - 500_000 - 10_000 - chan_feerate * + amount_satoshis: 1_000_000 - 500_000 - 10_000 - chan_feerate * (channel::commitment_tx_base_weight(&channel_type_features) + 2 * channel::COMMITMENT_TX_WEIGHT_PER_HTLC) / 1000, confirmation_height: node_a_commitment_claimable, }, a_received_htlc_balance.clone(), a_sent_htlc_balance.clone()]); @@ -820,7 +820,7 @@ fn test_no_preimage_inbound_htlc_balances() { let node_b_commitment_claimable = nodes[1].best_block_info().1 + ANTI_REORG_DELAY - 1; let mut bs_pre_spend_claims = sorted_vec(vec![Balance::ClaimableAwaitingConfirmations { - claimable_amount_satoshis: 500_000 - 20_000, + amount_satoshis: 500_000 - 20_000, confirmation_height: node_b_commitment_claimable, }, b_received_htlc_balance.clone(), b_sent_htlc_balance.clone()]); assert_eq!(bs_pre_spend_claims, @@ -871,22 +871,22 @@ fn test_no_preimage_inbound_htlc_balances() { mine_transaction(&nodes[0], &as_htlc_timeout_claim[0]); let as_timeout_claimable_height = nodes[0].best_block_info().1 + (BREAKDOWN_TIMEOUT as u32) - 1; assert_eq!(sorted_vec(vec![Balance::ClaimableAwaitingConfirmations { - claimable_amount_satoshis: 1_000_000 - 500_000 - 10_000 - chan_feerate * + amount_satoshis: 1_000_000 - 500_000 - 10_000 - chan_feerate * (channel::commitment_tx_base_weight(&channel_type_features) + 2 * channel::COMMITMENT_TX_WEIGHT_PER_HTLC) / 1000, confirmation_height: node_a_commitment_claimable, }, a_received_htlc_balance.clone(), Balance::ClaimableAwaitingConfirmations { - claimable_amount_satoshis: 10_000, + amount_satoshis: 10_000, confirmation_height: as_timeout_claimable_height, }]), sorted_vec(nodes[0].chain_monitor.chain_monitor.get_monitor(funding_outpoint).unwrap().get_claimable_balances())); mine_transaction(&nodes[0], &bs_htlc_timeout_claim[0]); assert_eq!(sorted_vec(vec![Balance::ClaimableAwaitingConfirmations { - claimable_amount_satoshis: 1_000_000 - 500_000 - 10_000 - chan_feerate * + amount_satoshis: 1_000_000 - 500_000 - 10_000 - chan_feerate * (channel::commitment_tx_base_weight(&channel_type_features) + 2 * channel::COMMITMENT_TX_WEIGHT_PER_HTLC) / 1000, confirmation_height: node_a_commitment_claimable, }, a_received_htlc_balance.clone(), Balance::ClaimableAwaitingConfirmations { - claimable_amount_satoshis: 10_000, + amount_satoshis: 10_000, confirmation_height: as_timeout_claimable_height, }]), sorted_vec(nodes[0].chain_monitor.chain_monitor.get_monitor(funding_outpoint).unwrap().get_claimable_balances())); @@ -898,18 +898,18 @@ fn test_no_preimage_inbound_htlc_balances() { connect_blocks(&nodes[0], 1); assert_eq!(sorted_vec(vec![Balance::ClaimableAwaitingConfirmations { - claimable_amount_satoshis: 1_000_000 - 500_000 - 10_000 - chan_feerate * + amount_satoshis: 1_000_000 - 500_000 - 10_000 - chan_feerate * (channel::commitment_tx_base_weight(&channel_type_features) + 2 * channel::COMMITMENT_TX_WEIGHT_PER_HTLC) / 1000, confirmation_height: node_a_commitment_claimable, }, Balance::ClaimableAwaitingConfirmations { - claimable_amount_satoshis: 10_000, + amount_satoshis: 10_000, confirmation_height: core::cmp::max(as_timeout_claimable_height, htlc_cltv_timeout), }]), sorted_vec(nodes[0].chain_monitor.chain_monitor.get_monitor(funding_outpoint).unwrap().get_claimable_balances())); connect_blocks(&nodes[0], node_a_commitment_claimable - nodes[0].best_block_info().1); assert_eq!(vec![Balance::ClaimableAwaitingConfirmations { - claimable_amount_satoshis: 10_000, + amount_satoshis: 10_000, confirmation_height: core::cmp::max(as_timeout_claimable_height, htlc_cltv_timeout), }], nodes[0].chain_monitor.chain_monitor.get_monitor(funding_outpoint).unwrap().get_claimable_balances()); @@ -924,14 +924,14 @@ fn test_no_preimage_inbound_htlc_balances() { mine_transaction(&nodes[1], &bs_htlc_timeout_claim[0]); let bs_timeout_claimable_height = nodes[1].best_block_info().1 + ANTI_REORG_DELAY - 1; assert_eq!(sorted_vec(vec![b_received_htlc_balance.clone(), Balance::ClaimableAwaitingConfirmations { - claimable_amount_satoshis: 20_000, + amount_satoshis: 20_000, confirmation_height: bs_timeout_claimable_height, }]), sorted_vec(nodes[1].chain_monitor.chain_monitor.get_monitor(funding_outpoint).unwrap().get_claimable_balances())); mine_transaction(&nodes[1], &as_htlc_timeout_claim[0]); assert_eq!(sorted_vec(vec![b_received_htlc_balance.clone(), Balance::ClaimableAwaitingConfirmations { - claimable_amount_satoshis: 20_000, + amount_satoshis: 20_000, confirmation_height: bs_timeout_claimable_height, }]), sorted_vec(nodes[1].chain_monitor.chain_monitor.get_monitor(funding_outpoint).unwrap().get_claimable_balances())); @@ -1058,17 +1058,17 @@ fn do_test_revoked_counterparty_commitment_balances(confirm_htlc_spend_first: bo // Prior to channel closure, B considers the preimage HTLC as its own, and otherwise only // lists the two on-chain timeout-able HTLCs as claimable balances. assert_eq!(sorted_vec(vec![Balance::ClaimableOnChannelClose { - claimable_amount_satoshis: 100_000 - 5_000 - 4_000 - 3 - 2_000 + 3_000, + amount_satoshis: 100_000 - 5_000 - 4_000 - 3 - 2_000 + 3_000, }, Balance::MaybeTimeoutClaimableHTLC { - claimable_amount_satoshis: 2_000, + amount_satoshis: 2_000, claimable_height: missing_htlc_cltv_timeout, payment_hash: missing_htlc_payment_hash, }, Balance::MaybeTimeoutClaimableHTLC { - claimable_amount_satoshis: 4_000, + amount_satoshis: 4_000, claimable_height: htlc_cltv_timeout, payment_hash: timeout_payment_hash, }, Balance::MaybeTimeoutClaimableHTLC { - claimable_amount_satoshis: 5_000, + amount_satoshis: 5_000, claimable_height: live_htlc_cltv_timeout, payment_hash: live_payment_hash, }]), @@ -1097,21 +1097,21 @@ fn do_test_revoked_counterparty_commitment_balances(confirm_htlc_spend_first: bo // claim balances separated out. let expected_balance = vec![Balance::ClaimableAwaitingConfirmations { // to_remote output in A's revoked commitment - claimable_amount_satoshis: 100_000 - 5_000 - 4_000 - 3, + amount_satoshis: 100_000 - 5_000 - 4_000 - 3, confirmation_height: nodes[1].best_block_info().1 + 5, }, Balance::CounterpartyRevokedOutputClaimable { - claimable_amount_satoshis: 3_000, + amount_satoshis: 3_000, }, Balance::CounterpartyRevokedOutputClaimable { - claimable_amount_satoshis: 4_000, + amount_satoshis: 4_000, }]; let to_self_unclaimed_balance = Balance::CounterpartyRevokedOutputClaimable { - claimable_amount_satoshis: 1_000_000 - 100_000 - 3_000 - chan_feerate * + amount_satoshis: 1_000_000 - 100_000 - 3_000 - chan_feerate * (channel::commitment_tx_base_weight(&channel_type_features) + 3 * channel::COMMITMENT_TX_WEIGHT_PER_HTLC) / 1000, }; let to_self_claimed_avail_height; let largest_htlc_unclaimed_balance = Balance::CounterpartyRevokedOutputClaimable { - claimable_amount_satoshis: 5_000, + amount_satoshis: 5_000, }; let largest_htlc_claimed_avail_height; @@ -1132,11 +1132,11 @@ fn do_test_revoked_counterparty_commitment_balances(confirm_htlc_spend_first: bo } let largest_htlc_claimed_balance = Balance::ClaimableAwaitingConfirmations { - claimable_amount_satoshis: 5_000 - chan_feerate * INBOUND_HTLC_CLAIM_EXP_WEIGHT as u64 / 1000, + amount_satoshis: 5_000 - chan_feerate * INBOUND_HTLC_CLAIM_EXP_WEIGHT as u64 / 1000, confirmation_height: largest_htlc_claimed_avail_height, }; let to_self_claimed_balance = Balance::ClaimableAwaitingConfirmations { - claimable_amount_satoshis: 1_000_000 - 100_000 - 3_000 - chan_feerate * + amount_satoshis: 1_000_000 - 100_000 - 3_000 - chan_feerate * (channel::commitment_tx_base_weight(&channel_type_features) + 3 * channel::COMMITMENT_TX_WEIGHT_PER_HTLC) / 1000 - chan_feerate * claim_txn[3].weight() as u64 / 1000, confirmation_height: to_self_claimed_avail_height, @@ -1165,21 +1165,21 @@ fn do_test_revoked_counterparty_commitment_balances(confirm_htlc_spend_first: bo assert_eq!(sorted_vec(vec![Balance::ClaimableAwaitingConfirmations { // to_remote output in A's revoked commitment - claimable_amount_satoshis: 100_000 - 5_000 - 4_000 - 3, + amount_satoshis: 100_000 - 5_000 - 4_000 - 3, confirmation_height: nodes[1].best_block_info().1 + 1, }, Balance::ClaimableAwaitingConfirmations { - claimable_amount_satoshis: 1_000_000 - 100_000 - 3_000 - chan_feerate * + amount_satoshis: 1_000_000 - 100_000 - 3_000 - chan_feerate * (channel::commitment_tx_base_weight(&channel_type_features) + 3 * channel::COMMITMENT_TX_WEIGHT_PER_HTLC) / 1000 - chan_feerate * claim_txn[3].weight() as u64 / 1000, confirmation_height: to_self_claimed_avail_height, }, Balance::ClaimableAwaitingConfirmations { - claimable_amount_satoshis: 3_000 - chan_feerate * OUTBOUND_HTLC_CLAIM_EXP_WEIGHT as u64 / 1000, + amount_satoshis: 3_000 - chan_feerate * OUTBOUND_HTLC_CLAIM_EXP_WEIGHT as u64 / 1000, confirmation_height: nodes[1].best_block_info().1 + 4, }, Balance::ClaimableAwaitingConfirmations { - claimable_amount_satoshis: 4_000 - chan_feerate * INBOUND_HTLC_CLAIM_EXP_WEIGHT as u64 / 1000, + amount_satoshis: 4_000 - chan_feerate * INBOUND_HTLC_CLAIM_EXP_WEIGHT as u64 / 1000, confirmation_height: nodes[1].best_block_info().1 + 5, }, Balance::ClaimableAwaitingConfirmations { - claimable_amount_satoshis: 5_000 - chan_feerate * INBOUND_HTLC_CLAIM_EXP_WEIGHT as u64 / 1000, + amount_satoshis: 5_000 - chan_feerate * INBOUND_HTLC_CLAIM_EXP_WEIGHT as u64 / 1000, confirmation_height: largest_htlc_claimed_avail_height, }]), sorted_vec(nodes[1].chain_monitor.chain_monitor.get_monitor(funding_outpoint).unwrap().get_claimable_balances())); @@ -1294,16 +1294,16 @@ fn test_revoked_counterparty_htlc_tx_balances() { // `CounterpartyRevokedOutputClaimable` entry doesn't change. let as_balances = sorted_vec(vec![Balance::ClaimableAwaitingConfirmations { // to_remote output in B's revoked commitment - claimable_amount_satoshis: 1_000_000 - 11_000 - 3_000 - chan_feerate * + amount_satoshis: 1_000_000 - 11_000 - 3_000 - chan_feerate * (channel::commitment_tx_base_weight(&channel_type_features) + 2 * channel::COMMITMENT_TX_WEIGHT_PER_HTLC) / 1000, confirmation_height: to_remote_conf_height, }, Balance::CounterpartyRevokedOutputClaimable { // to_self output in B's revoked commitment - claimable_amount_satoshis: 10_000, + amount_satoshis: 10_000, }, Balance::CounterpartyRevokedOutputClaimable { // HTLC 1 - claimable_amount_satoshis: 3_000, + amount_satoshis: 3_000, }, Balance::CounterpartyRevokedOutputClaimable { // HTLC 2 - claimable_amount_satoshis: 1_000, + amount_satoshis: 1_000, }]); assert_eq!(as_balances, sorted_vec(nodes[0].chain_monitor.chain_monitor.get_monitor(funding_outpoint).unwrap().get_claimable_balances())); @@ -1325,16 +1325,16 @@ fn test_revoked_counterparty_htlc_tx_balances() { mine_transaction(&nodes[0], &as_htlc_claim_tx[0]); assert_eq!(sorted_vec(vec![Balance::ClaimableAwaitingConfirmations { // to_remote output in B's revoked commitment - claimable_amount_satoshis: 1_000_000 - 11_000 - 3_000 - chan_feerate * + amount_satoshis: 1_000_000 - 11_000 - 3_000 - chan_feerate * (channel::commitment_tx_base_weight(&channel_type_features) + 2 * channel::COMMITMENT_TX_WEIGHT_PER_HTLC) / 1000, confirmation_height: to_remote_conf_height, }, Balance::CounterpartyRevokedOutputClaimable { // to_self output in B's revoked commitment - claimable_amount_satoshis: 10_000, + amount_satoshis: 10_000, }, Balance::CounterpartyRevokedOutputClaimable { // HTLC 2 - claimable_amount_satoshis: 1_000, + amount_satoshis: 1_000, }, Balance::ClaimableAwaitingConfirmations { - claimable_amount_satoshis: as_htlc_claim_tx[0].output[0].value, + amount_satoshis: as_htlc_claim_tx[0].output[0].value, confirmation_height: nodes[0].best_block_info().1 + ANTI_REORG_DELAY - 1, }]), sorted_vec(nodes[0].chain_monitor.chain_monitor.get_monitor(funding_outpoint).unwrap().get_claimable_balances())); @@ -1343,11 +1343,11 @@ fn test_revoked_counterparty_htlc_tx_balances() { test_spendable_output(&nodes[0], &revoked_local_txn[0]); assert_eq!(sorted_vec(vec![Balance::CounterpartyRevokedOutputClaimable { // to_self output to B - claimable_amount_satoshis: 10_000, + amount_satoshis: 10_000, }, Balance::CounterpartyRevokedOutputClaimable { // HTLC 2 - claimable_amount_satoshis: 1_000, + amount_satoshis: 1_000, }, Balance::ClaimableAwaitingConfirmations { - claimable_amount_satoshis: as_htlc_claim_tx[0].output[0].value, + amount_satoshis: as_htlc_claim_tx[0].output[0].value, confirmation_height: nodes[0].best_block_info().1 + 2, }]), sorted_vec(nodes[0].chain_monitor.chain_monitor.get_monitor(funding_outpoint).unwrap().get_claimable_balances())); @@ -1356,9 +1356,9 @@ fn test_revoked_counterparty_htlc_tx_balances() { test_spendable_output(&nodes[0], &as_htlc_claim_tx[0]); assert_eq!(sorted_vec(vec![Balance::CounterpartyRevokedOutputClaimable { // to_self output in B's revoked commitment - claimable_amount_satoshis: 10_000, + amount_satoshis: 10_000, }, Balance::CounterpartyRevokedOutputClaimable { // HTLC 2 - claimable_amount_satoshis: 1_000, + amount_satoshis: 1_000, }]), sorted_vec(nodes[0].chain_monitor.chain_monitor.get_monitor(funding_outpoint).unwrap().get_claimable_balances())); @@ -1392,18 +1392,18 @@ fn test_revoked_counterparty_htlc_tx_balances() { connect_blocks(&nodes[0], ANTI_REORG_DELAY - 1); assert_eq!(sorted_vec(vec![Balance::CounterpartyRevokedOutputClaimable { // to_self output in B's revoked commitment - claimable_amount_satoshis: 10_000, + amount_satoshis: 10_000, }, Balance::CounterpartyRevokedOutputClaimable { // HTLC 2 - claimable_amount_satoshis: 1_000, + amount_satoshis: 1_000, }]), sorted_vec(nodes[0].chain_monitor.chain_monitor.get_monitor(funding_outpoint).unwrap().get_claimable_balances())); mine_transaction(&nodes[0], &as_second_htlc_claim_tx[0]); assert_eq!(sorted_vec(vec![Balance::CounterpartyRevokedOutputClaimable { // to_self output in B's revoked commitment - claimable_amount_satoshis: 10_000, + amount_satoshis: 10_000, }, Balance::ClaimableAwaitingConfirmations { - claimable_amount_satoshis: as_second_htlc_claim_tx[0].output[0].value, + amount_satoshis: as_second_htlc_claim_tx[0].output[0].value, confirmation_height: nodes[0].best_block_info().1 + ANTI_REORG_DELAY - 1, }]), sorted_vec(nodes[0].chain_monitor.chain_monitor.get_monitor(funding_outpoint).unwrap().get_claimable_balances())); @@ -1411,10 +1411,10 @@ fn test_revoked_counterparty_htlc_tx_balances() { mine_transaction(&nodes[0], &as_second_htlc_claim_tx[1]); assert_eq!(sorted_vec(vec![Balance::ClaimableAwaitingConfirmations { // to_self output in B's revoked commitment - claimable_amount_satoshis: as_second_htlc_claim_tx[1].output[0].value, + amount_satoshis: as_second_htlc_claim_tx[1].output[0].value, confirmation_height: nodes[0].best_block_info().1 + ANTI_REORG_DELAY - 1, }, Balance::ClaimableAwaitingConfirmations { - claimable_amount_satoshis: as_second_htlc_claim_tx[0].output[0].value, + amount_satoshis: as_second_htlc_claim_tx[0].output[0].value, confirmation_height: nodes[0].best_block_info().1 + ANTI_REORG_DELAY - 2, }]), sorted_vec(nodes[0].chain_monitor.chain_monitor.get_monitor(funding_outpoint).unwrap().get_claimable_balances())); @@ -1495,13 +1495,13 @@ fn test_revoked_counterparty_aggregated_claims() { let _a_htlc_msgs = get_htlc_update_msgs!(&nodes[0], nodes[1].node.get_our_node_id()); assert_eq!(sorted_vec(vec![Balance::ClaimableOnChannelClose { - claimable_amount_satoshis: 100_000 - 4_000 - 3_000, + amount_satoshis: 100_000 - 4_000 - 3_000, }, Balance::MaybeTimeoutClaimableHTLC { - claimable_amount_satoshis: 4_000, + amount_satoshis: 4_000, claimable_height: htlc_cltv_timeout, payment_hash: revoked_payment_hash, }, Balance::MaybeTimeoutClaimableHTLC { - claimable_amount_satoshis: 3_000, + amount_satoshis: 3_000, claimable_height: htlc_cltv_timeout, payment_hash: claimed_payment_hash, }]), @@ -1522,16 +1522,16 @@ fn test_revoked_counterparty_aggregated_claims() { assert_eq!(sorted_vec(vec![Balance::ClaimableAwaitingConfirmations { // to_remote output in A's revoked commitment - claimable_amount_satoshis: 100_000 - 4_000 - 3_000, + amount_satoshis: 100_000 - 4_000 - 3_000, confirmation_height: to_remote_maturity, }, Balance::CounterpartyRevokedOutputClaimable { // to_self output in A's revoked commitment - claimable_amount_satoshis: 1_000_000 - 100_000 - chan_feerate * + amount_satoshis: 1_000_000 - 100_000 - chan_feerate * (channel::commitment_tx_base_weight(&channel_type_features) + 2 * channel::COMMITMENT_TX_WEIGHT_PER_HTLC) / 1000, }, Balance::CounterpartyRevokedOutputClaimable { // HTLC 1 - claimable_amount_satoshis: 4_000, + amount_satoshis: 4_000, }, Balance::CounterpartyRevokedOutputClaimable { // HTLC 2 - claimable_amount_satoshis: 3_000, + amount_satoshis: 3_000, }]), sorted_vec(nodes[1].chain_monitor.chain_monitor.get_monitor(funding_outpoint).unwrap().get_claimable_balances())); @@ -1551,19 +1551,19 @@ fn test_revoked_counterparty_aggregated_claims() { assert_eq!(sorted_vec(vec![Balance::ClaimableAwaitingConfirmations { // to_remote output in A's revoked commitment - claimable_amount_satoshis: 100_000 - 4_000 - 3_000, + amount_satoshis: 100_000 - 4_000 - 3_000, confirmation_height: to_remote_maturity, }, Balance::CounterpartyRevokedOutputClaimable { // to_self output in A's revoked commitment - claimable_amount_satoshis: 1_000_000 - 100_000 - chan_feerate * + amount_satoshis: 1_000_000 - 100_000 - chan_feerate * (channel::commitment_tx_base_weight(&channel_type_features) + 2 * channel::COMMITMENT_TX_WEIGHT_PER_HTLC) / 1000, }, Balance::CounterpartyRevokedOutputClaimable { // HTLC 1 - claimable_amount_satoshis: 4_000, + amount_satoshis: 4_000, }, Balance::CounterpartyRevokedOutputClaimable { // HTLC 2 // The amount here is a bit of a misnomer, really its been reduced by the HTLC // transaction fee, but the claimable amount is always a bit of an overshoot for HTLCs // anyway, so its not a big change. - claimable_amount_satoshis: 3_000, + amount_satoshis: 3_000, }]), sorted_vec(nodes[1].chain_monitor.chain_monitor.get_monitor(funding_outpoint).unwrap().get_claimable_balances())); @@ -1572,15 +1572,15 @@ fn test_revoked_counterparty_aggregated_claims() { assert_eq!(sorted_vec(vec![Balance::CounterpartyRevokedOutputClaimable { // to_self output in A's revoked commitment - claimable_amount_satoshis: 1_000_000 - 100_000 - chan_feerate * + amount_satoshis: 1_000_000 - 100_000 - chan_feerate * (channel::commitment_tx_base_weight(&channel_type_features) + 2 * channel::COMMITMENT_TX_WEIGHT_PER_HTLC) / 1000, }, Balance::CounterpartyRevokedOutputClaimable { // HTLC 1 - claimable_amount_satoshis: 4_000, + amount_satoshis: 4_000, }, Balance::CounterpartyRevokedOutputClaimable { // HTLC 2 // The amount here is a bit of a misnomer, really its been reduced by the HTLC // transaction fee, but the claimable amount is always a bit of an overshoot for HTLCs // anyway, so its not a big change. - claimable_amount_satoshis: 3_000, + amount_satoshis: 3_000, }]), sorted_vec(nodes[1].chain_monitor.chain_monitor.get_monitor(funding_outpoint).unwrap().get_claimable_balances())); @@ -1589,12 +1589,12 @@ fn test_revoked_counterparty_aggregated_claims() { assert_eq!(sorted_vec(vec![Balance::CounterpartyRevokedOutputClaimable { // to_self output in A's revoked commitment - claimable_amount_satoshis: 1_000_000 - 100_000 - chan_feerate * + amount_satoshis: 1_000_000 - 100_000 - chan_feerate * (channel::commitment_tx_base_weight(&channel_type_features) + 2 * channel::COMMITMENT_TX_WEIGHT_PER_HTLC) / 1000, }, Balance::CounterpartyRevokedOutputClaimable { // HTLC 1 - claimable_amount_satoshis: 4_000, + amount_satoshis: 4_000, }, Balance::ClaimableAwaitingConfirmations { // HTLC 2 - claimable_amount_satoshis: claim_txn_2[1].output[0].value, + amount_satoshis: claim_txn_2[1].output[0].value, confirmation_height: htlc_2_claim_maturity, }]), sorted_vec(nodes[1].chain_monitor.chain_monitor.get_monitor(funding_outpoint).unwrap().get_claimable_balances())); @@ -1604,10 +1604,10 @@ fn test_revoked_counterparty_aggregated_claims() { assert_eq!(sorted_vec(vec![Balance::CounterpartyRevokedOutputClaimable { // to_self output in A's revoked commitment - claimable_amount_satoshis: 1_000_000 - 100_000 - chan_feerate * + amount_satoshis: 1_000_000 - 100_000 - chan_feerate * (channel::commitment_tx_base_weight(&channel_type_features) + 2 * channel::COMMITMENT_TX_WEIGHT_PER_HTLC) / 1000, }, Balance::CounterpartyRevokedOutputClaimable { // HTLC 1 - claimable_amount_satoshis: 4_000, + amount_satoshis: 4_000, }]), sorted_vec(nodes[1].chain_monitor.chain_monitor.get_monitor(funding_outpoint).unwrap().get_claimable_balances())); @@ -1615,7 +1615,7 @@ fn test_revoked_counterparty_aggregated_claims() { let rest_claim_maturity = nodes[1].best_block_info().1 + ANTI_REORG_DELAY - 1; assert_eq!(vec![Balance::ClaimableAwaitingConfirmations { - claimable_amount_satoshis: claim_txn_2[0].output[0].value, + amount_satoshis: claim_txn_2[0].output[0].value, confirmation_height: rest_claim_maturity, }], nodes[1].chain_monitor.chain_monitor.get_monitor(funding_outpoint).unwrap().get_claimable_balances()); -- 2.30.2