Merge pull request #2366 from valentinewallace/2023-05-blinded-pathfinding-fuzz
authorvalentinewallace <valentinewallace@users.noreply.github.com>
Mon, 31 Jul 2023 22:27:47 +0000 (15:27 -0700)
committerGitHub <noreply@github.com>
Mon, 31 Jul 2023 22:27:47 +0000 (15:27 -0700)
Blinded pathfinding fuzzing

12 files changed:
lightning/src/chain/channelmonitor.rs
lightning/src/events/bump_transaction.rs
lightning/src/ln/chanmon_update_fail_tests.rs
lightning/src/ln/channel.rs
lightning/src/ln/channelmanager.rs
lightning/src/ln/functional_test_utils.rs
lightning/src/ln/functional_tests.rs
lightning/src/ln/monitor_tests.rs
lightning/src/ln/onion_route_tests.rs
lightning/src/ln/payment_tests.rs
lightning/src/ln/reload_tests.rs
lightning/src/routing/scoring.rs

index ce8279234a54f71a201521e9a19545b29e319941..a74c18e725d2bc0a5ec58614bf3cdcf622bed2b0 100644 (file)
@@ -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<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
                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<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
                                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<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
                        // 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<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
                        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<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
                        }
                } 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<Signer: WriteableEcdsaChannelSigner> ChannelMonitor<Signer> {
                                                } else { None }
                                        }) {
                                                res.push(Balance::ClaimableAwaitingConfirmations {
-                                                       claimable_amount_satoshis: value,
+                                                       amount_satoshis: value,
                                                        confirmation_height: conf_thresh,
                                                });
                                        } else {
@@ -1847,7 +1834,7 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitor<Signer> {
                                                        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<Signer: WriteableEcdsaChannelSigner> ChannelMonitor<Signer> {
                                                        .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<Signer: WriteableEcdsaChannelSigner> ChannelMonitor<Signer> {
                                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<Signer: WriteableEcdsaChannelSigner> ChannelMonitor<Signer> {
                                        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<Signer: WriteableEcdsaChannelSigner> ChannelMonitor<Signer> {
                                        // 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<Signer: WriteableEcdsaChannelSigner> ChannelMonitor<Signer> {
                                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<Signer: WriteableEcdsaChannelSigner> ChannelMonitor<Signer> {
                                        // 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,
                        });
                }
 
index 5963da8e9f213efd023a21f6570369b8775ee2a5..4e7c3a224c29204d57d43220527ea9ba423b9620 100644 (file)
@@ -26,7 +26,7 @@ use crate::ln::chan_utils::{
 use crate::ln::features::ChannelTypeFeatures;
 use crate::ln::PaymentPreimage;
 use crate::prelude::*;
-use crate::sign::{ChannelSigner, EcdsaChannelSigner, SignerProvider, WriteableEcdsaChannelSigner};
+use crate::sign::{EcdsaChannelSigner, SignerProvider, WriteableEcdsaChannelSigner};
 use crate::sync::Mutex;
 use crate::util::logger::Logger;
 
index 8d4c40b64d06b303c7aab3b183adbc98dcf8829d..c2ddbfa41b5f7896e8b4a92059b1c232ce44c7f1 100644 (file)
@@ -178,7 +178,9 @@ fn do_test_simple_monitor_temporary_update_fail(disconnect: bool) {
        if disconnect {
                nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id());
                nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id());
-               reconnect_nodes(&nodes[0], &nodes[1], (true, true), (0, 0), (0, 0), (0, 0), (0, 0), (0, 0), (false, false));
+               let mut reconnect_args = ReconnectArgs::new(&nodes[0], &nodes[1]);
+               reconnect_args.send_channel_ready = (true, true);
+               reconnect_nodes(reconnect_args);
        }
 
        chanmon_cfgs[0].persister.set_update_ret(ChannelMonitorUpdateStatus::Completed);
@@ -233,7 +235,7 @@ fn do_test_simple_monitor_temporary_update_fail(disconnect: bool) {
        if disconnect {
                nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id());
                nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id());
-               reconnect_nodes(&nodes[0], &nodes[1], (false, false), (0, 0), (0, 0), (0, 0), (0, 0), (0, 0), (false, false));
+               reconnect_nodes(ReconnectArgs::new(&nodes[0], &nodes[1]));
        }
 
        // ...and make sure we can force-close a frozen channel
@@ -1925,7 +1927,9 @@ fn do_during_funding_monitor_fail(confirm_a_first: bool, restore_b_before_conf:
        // Make sure nodes[1] isn't stupid enough to re-send the ChannelReady on reconnect
        nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id());
        nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id());
-       reconnect_nodes(&nodes[0], &nodes[1], (false, confirm_a_first), (0, 0), (0, 0), (0, 0), (0, 0), (0, 0), (false, false));
+       let mut reconnect_args = ReconnectArgs::new(&nodes[0], &nodes[1]);
+       reconnect_args.send_channel_ready.1 = confirm_a_first;
+       reconnect_nodes(reconnect_args);
 
        // But we want to re-emit ChannelPending
        expect_channel_pending_event(&nodes[1], &nodes[0].node.get_our_node_id());
@@ -2575,10 +2579,14 @@ fn do_test_reconnect_dup_htlc_claims(htlc_status: HTLCStatusAtDupClaim, second_f
        nodes[2].node.peer_disconnected(&nodes[1].node.get_our_node_id());
 
        if second_fails {
-               reconnect_nodes(&nodes[1], &nodes[2], (false, false), (0, 0), (0, 0), (1, 0), (0, 0), (0, 0), (false, false));
+               let mut reconnect_args = ReconnectArgs::new(&nodes[1], &nodes[2]);
+               reconnect_args.pending_htlc_fails.0 = 1;
+               reconnect_nodes(reconnect_args);
                expect_pending_htlcs_forwardable_and_htlc_handling_failed!(nodes[1], vec![HTLCDestination::NextHopChannel { node_id: Some(nodes[2].node.get_our_node_id()), channel_id: chan_id_2 }]);
        } else {
-               reconnect_nodes(&nodes[1], &nodes[2], (false, false), (0, 0), (1, 0), (0, 0), (0, 0), (0, 0), (false, false));
+               let mut reconnect_args = ReconnectArgs::new(&nodes[1], &nodes[2]);
+               reconnect_args.pending_htlc_claims.0 = 1;
+               reconnect_nodes(reconnect_args);
        }
 
        if htlc_status == HTLCStatusAtDupClaim::HoldingCell {
index e559ac3355007808a18abe58acb562cf8e2c112f..fd0d94d3eb6381fb97dadcd49184d554c42aa94a 100644 (file)
@@ -250,38 +250,38 @@ enum HTLCUpdateAwaitingACK {
 }
 
 /// There are a few "states" and then a number of flags which can be applied:
-/// We first move through init with OurInitSent -> TheirInitSent -> FundingCreated -> FundingSent.
-/// TheirChannelReady and OurChannelReady then get set on FundingSent, and when both are set we
-/// move on to ChannelReady.
-/// Note that PeerDisconnected can be set on both ChannelReady and FundingSent.
-/// ChannelReady can then get all remaining flags set on it, until we finish shutdown, then we
-/// move on to ShutdownComplete, at which point most calls into this channel are disallowed.
+/// We first move through init with `OurInitSent` -> `TheirInitSent` -> `FundingCreated` -> `FundingSent`.
+/// `TheirChannelReady` and `OurChannelReady` then get set on `FundingSent`, and when both are set we
+/// move on to `ChannelReady`.
+/// Note that `PeerDisconnected` can be set on both `ChannelReady` and `FundingSent`.
+/// `ChannelReady` can then get all remaining flags set on it, until we finish shutdown, then we
+/// move on to `ShutdownComplete`, at which point most calls into this channel are disallowed.
 enum ChannelState {
        /// Implies we have (or are prepared to) send our open_channel/accept_channel message
        OurInitSent = 1 << 0,
-       /// Implies we have received their open_channel/accept_channel message
+       /// Implies we have received their `open_channel`/`accept_channel` message
        TheirInitSent = 1 << 1,
-       /// We have sent funding_created and are awaiting a funding_signed to advance to FundingSent.
-       /// Note that this is nonsense for an inbound channel as we immediately generate funding_signed
-       /// upon receipt of funding_created, so simply skip this state.
+       /// We have sent `funding_created` and are awaiting a `funding_signed` to advance to `FundingSent`.
+       /// Note that this is nonsense for an inbound channel as we immediately generate `funding_signed`
+       /// upon receipt of `funding_created`, so simply skip this state.
        FundingCreated = 4,
-       /// Set when we have received/sent funding_created and funding_signed and are thus now waiting
-       /// on the funding transaction to confirm. The ChannelReady flags are set to indicate when we
+       /// Set when we have received/sent `funding_created` and `funding_signed` and are thus now waiting
+       /// on the funding transaction to confirm. The `ChannelReady` flags are set to indicate when we
        /// and our counterparty consider the funding transaction confirmed.
        FundingSent = 8,
-       /// Flag which can be set on FundingSent to indicate they sent us a channel_ready message.
-       /// Once both TheirChannelReady and OurChannelReady are set, state moves on to ChannelReady.
+       /// Flag which can be set on `FundingSent` to indicate they sent us a `channel_ready` message.
+       /// Once both `TheirChannelReady` and `OurChannelReady` are set, state moves on to `ChannelReady`.
        TheirChannelReady = 1 << 4,
-       /// Flag which can be set on FundingSent to indicate we sent them a channel_ready message.
-       /// Once both TheirChannelReady and OurChannelReady are set, state moves on to ChannelReady.
+       /// Flag which can be set on `FundingSent` to indicate we sent them a `channel_ready` message.
+       /// Once both `TheirChannelReady` and `OurChannelReady` are set, state moves on to `ChannelReady`.
        OurChannelReady = 1 << 5,
        ChannelReady = 64,
-       /// Flag which is set on ChannelReady and FundingSent indicating remote side is considered
-       /// "disconnected" and no updates are allowed until after we've done a channel_reestablish
+       /// Flag which is set on `ChannelReady` and `FundingSent` indicating remote side is considered
+       /// "disconnected" and no updates are allowed until after we've done a `channel_reestablish`
        /// dance.
        PeerDisconnected = 1 << 7,
-       /// Flag which is set on ChannelReady, FundingCreated, and FundingSent indicating the user has
-       /// told us a ChannelMonitor update is pending async persistence somewhere and we should pause
+       /// Flag which is set on `ChannelReady`, FundingCreated, and `FundingSent` indicating the user has
+       /// told us a `ChannelMonitor` update is pending async persistence somewhere and we should pause
        /// sending any outbound messages until they've managed to finish.
        MonitorUpdateInProgress = 1 << 8,
        /// Flag which implies that we have sent a commitment_signed but are awaiting the responding
@@ -289,13 +289,13 @@ enum ChannelState {
        /// messages as then we will be unable to determine which HTLCs they included in their
        /// revoke_and_ack implicit ACK, so instead we have to hold them away temporarily to be sent
        /// later.
-       /// Flag is set on ChannelReady.
+       /// Flag is set on `ChannelReady`.
        AwaitingRemoteRevoke = 1 << 9,
-       /// Flag which is set on ChannelReady or FundingSent after receiving a shutdown message from
+       /// Flag which is set on `ChannelReady` or `FundingSent` after receiving a shutdown message from
        /// the remote end. If set, they may not add any new HTLCs to the channel, and we are expected
        /// to respond with our own shutdown message when possible.
        RemoteShutdownSent = 1 << 10,
-       /// Flag which is set on ChannelReady or FundingSent after sending a shutdown message. At this
+       /// Flag which is set on `ChannelReady` or `FundingSent` after sending a shutdown message. At this
        /// point, we may not add any new HTLCs to the channel.
        LocalShutdownSent = 1 << 11,
        /// We've successfully negotiated a closing_signed dance. At this point ChannelManager is about
@@ -4869,7 +4869,7 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
        // something in the handler for the message that prompted this message):
 
        /// Gets an UnsignedChannelAnnouncement for this channel. The channel must be publicly
-       /// announceable and available for use (have exchanged ChannelReady messages in both
+       /// announceable and available for use (have exchanged [`ChannelReady`] messages in both
        /// directions). Should be used for both broadcasted announcements and in response to an
        /// AnnouncementSignatures message from the remote peer.
        ///
@@ -4877,6 +4877,8 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
        /// closing).
        ///
        /// This will only return ChannelError::Ignore upon failure.
+       ///
+       /// [`ChannelReady`]: crate::ln::msgs::ChannelReady
        fn get_channel_announcement<NS: Deref>(
                &self, node_signer: &NS, chain_hash: BlockHash, user_config: &UserConfig,
        ) -> Result<msgs::UnsignedChannelAnnouncement, ChannelError> where NS::Target: NodeSigner {
index c7fc70a4593d66601b7d0d0e2acf8759196e5ffd..6cd4799ff3cf77063e5b313e8a6d6a70631373a7 100644 (file)
@@ -7426,7 +7426,9 @@ where
 /// Fetches the set of [`NodeFeatures`] flags which are provided by or required by
 /// [`ChannelManager`].
 pub(crate) fn provided_node_features(config: &UserConfig) -> NodeFeatures {
-       provided_init_features(config).to_context()
+       let mut node_features = provided_init_features(config).to_context();
+       node_features.set_keysend_optional();
+       node_features
 }
 
 /// Fetches the set of [`Bolt11InvoiceFeatures`] flags which are provided by or required by
index 84bc1a1b3f0656476aa1d00771f0368d97003cd0..39396685f005abf2e9bf795ad7428724c02186dc 100644 (file)
@@ -2945,9 +2945,41 @@ macro_rules! handle_chan_reestablish_msgs {
        }
 }
 
+pub struct ReconnectArgs<'a, 'b, 'c, 'd> {
+       pub node_a: &'a Node<'b, 'c, 'd>,
+       pub node_b: &'a Node<'b, 'c, 'd>,
+       pub send_channel_ready: (bool, bool),
+       pub pending_htlc_adds: (i64, i64),
+       pub pending_htlc_claims: (usize, usize),
+       pub pending_htlc_fails: (usize, usize),
+       pub pending_cell_htlc_claims: (usize, usize),
+       pub pending_cell_htlc_fails: (usize, usize),
+       pub pending_raa: (bool, bool),
+}
+
+impl<'a, 'b, 'c, 'd> ReconnectArgs<'a, 'b, 'c, 'd> {
+       pub fn new(node_a: &'a Node<'b, 'c, 'd>, node_b: &'a Node<'b, 'c, 'd>) -> Self {
+               Self {
+                       node_a,
+                       node_b,
+                       send_channel_ready: (false, false),
+                       pending_htlc_adds: (0, 0),
+                       pending_htlc_claims: (0, 0),
+                       pending_htlc_fails: (0, 0),
+                       pending_cell_htlc_claims: (0, 0),
+                       pending_cell_htlc_fails: (0, 0),
+                       pending_raa: (false, false),
+               }
+       }
+}
+
 /// pending_htlc_adds includes both the holding cell and in-flight update_add_htlcs, whereas
 /// for claims/fails they are separated out.
-pub fn reconnect_nodes<'a, 'b, 'c>(node_a: &Node<'a, 'b, 'c>, node_b: &Node<'a, 'b, 'c>, send_channel_ready: (bool, bool), pending_htlc_adds: (i64, i64), pending_htlc_claims: (usize, usize), pending_htlc_fails: (usize, usize), pending_cell_htlc_claims: (usize, usize), pending_cell_htlc_fails: (usize, usize), pending_raa: (bool, bool))  {
+pub fn reconnect_nodes<'a, 'b, 'c, 'd>(args: ReconnectArgs<'a, 'b, 'c, 'd>) {
+       let ReconnectArgs {
+               node_a, node_b, send_channel_ready, pending_htlc_adds, pending_htlc_claims, pending_htlc_fails,
+               pending_cell_htlc_claims, pending_cell_htlc_fails, pending_raa
+       } = args;
        node_a.node.peer_connected(&node_b.node.get_our_node_id(), &msgs::Init {
                features: node_b.node.init_features(), networks: None, remote_network_address: None
        }, true).unwrap();
index 8de2e9f631a53325ba5b6ba6b384392762017967..ed54522526d06e1dfd51e462070b314b0777cf0b 100644 (file)
@@ -3585,7 +3585,9 @@ fn test_dup_events_on_peer_disconnect() {
        nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id());
        nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id());
 
-       reconnect_nodes(&nodes[0], &nodes[1], (false, false), (0, 0), (1, 0), (0, 0), (0, 0), (0, 0), (false, false));
+       let mut reconnect_args = ReconnectArgs::new(&nodes[0], &nodes[1]);
+       reconnect_args.pending_htlc_claims.0 = 1;
+       reconnect_nodes(reconnect_args);
        expect_payment_path_successful!(nodes[0]);
 }
 
@@ -3642,7 +3644,9 @@ fn test_simple_peer_disconnect() {
 
        nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id());
        nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id());
-       reconnect_nodes(&nodes[0], &nodes[1], (true, true), (0, 0), (0, 0), (0, 0), (0, 0), (0, 0), (false, false));
+       let mut reconnect_args = ReconnectArgs::new(&nodes[0], &nodes[1]);
+       reconnect_args.send_channel_ready = (true, true);
+       reconnect_nodes(reconnect_args);
 
        let payment_preimage_1 = route_payment(&nodes[0], &vec!(&nodes[1], &nodes[2])[..], 1000000).0;
        let payment_hash_2 = route_payment(&nodes[0], &vec!(&nodes[1], &nodes[2])[..], 1000000).1;
@@ -3651,7 +3655,7 @@ fn test_simple_peer_disconnect() {
 
        nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id());
        nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id());
-       reconnect_nodes(&nodes[0], &nodes[1], (false, false), (0, 0), (0, 0), (0, 0), (0, 0), (0, 0), (false, false));
+       reconnect_nodes(ReconnectArgs::new(&nodes[0], &nodes[1]));
 
        let (payment_preimage_3, payment_hash_3, _) = route_payment(&nodes[0], &vec!(&nodes[1], &nodes[2])[..], 1000000);
        let payment_preimage_4 = route_payment(&nodes[0], &vec!(&nodes[1], &nodes[2])[..], 1000000).0;
@@ -3664,7 +3668,10 @@ fn test_simple_peer_disconnect() {
        claim_payment_along_route(&nodes[0], &[&[&nodes[1], &nodes[2]]], true, payment_preimage_3);
        fail_payment_along_route(&nodes[0], &[&[&nodes[1], &nodes[2]]], true, payment_hash_5);
 
-       reconnect_nodes(&nodes[0], &nodes[1], (false, false), (0, 0), (0, 0), (0, 0), (1, 0), (1, 0), (false, false));
+       let mut reconnect_args = ReconnectArgs::new(&nodes[0], &nodes[1]);
+       reconnect_args.pending_cell_htlc_fails.0 = 1;
+       reconnect_args.pending_cell_htlc_claims.0 = 1;
+       reconnect_nodes(reconnect_args);
        {
                let events = nodes[0].node.get_and_clear_pending_events();
                assert_eq!(events.len(), 4);
@@ -3776,19 +3783,29 @@ fn do_test_drop_messages_peer_disconnect(messages_delivered: u8, simulate_broken
                }
                // Even if the channel_ready messages get exchanged, as long as nothing further was
                // received on either side, both sides will need to resend them.
-               reconnect_nodes(&nodes[0], &nodes[1], (true, true), (0, 1), (0, 0), (0, 0), (0, 0), (0, 0), (false, false));
+               let mut reconnect_args = ReconnectArgs::new(&nodes[0], &nodes[1]);
+               reconnect_args.send_channel_ready = (true, true);
+               reconnect_args.pending_htlc_adds.1 = 1;
+               reconnect_nodes(reconnect_args);
        } else if messages_delivered == 3 {
                // nodes[0] still wants its RAA + commitment_signed
-               reconnect_nodes(&nodes[0], &nodes[1], (false, false), (-1, 0), (0, 0), (0, 0), (0, 0), (0, 0), (true, false));
+               let mut reconnect_args = ReconnectArgs::new(&nodes[0], &nodes[1]);
+               reconnect_args.pending_htlc_adds.0 = -1;
+               reconnect_args.pending_raa.0 = true;
+               reconnect_nodes(reconnect_args);
        } else if messages_delivered == 4 {
                // nodes[0] still wants its commitment_signed
-               reconnect_nodes(&nodes[0], &nodes[1], (false, false), (-1, 0), (0, 0), (0, 0), (0, 0), (0, 0), (false, false));
+               let mut reconnect_args = ReconnectArgs::new(&nodes[0], &nodes[1]);
+               reconnect_args.pending_htlc_adds.0 = -1;
+               reconnect_nodes(reconnect_args);
        } else if messages_delivered == 5 {
                // nodes[1] still wants its final RAA
-               reconnect_nodes(&nodes[0], &nodes[1], (false, false), (0, 0), (0, 0), (0, 0), (0, 0), (0, 0), (false, true));
+               let mut reconnect_args = ReconnectArgs::new(&nodes[0], &nodes[1]);
+               reconnect_args.pending_raa.1 = true;
+               reconnect_nodes(reconnect_args);
        } else if messages_delivered == 6 {
                // Everything was delivered...
-               reconnect_nodes(&nodes[0], &nodes[1], (false, false), (0, 0), (0, 0), (0, 0), (0, 0), (0, 0), (false, false));
+               reconnect_nodes(ReconnectArgs::new(&nodes[0], &nodes[1]));
        }
 
        let events_1 = nodes[1].node.get_and_clear_pending_events();
@@ -3812,7 +3829,7 @@ fn do_test_drop_messages_peer_disconnect(messages_delivered: u8, simulate_broken
 
        nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id());
        nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id());
-       reconnect_nodes(&nodes[0], &nodes[1], (false, false), (0, 0), (0, 0), (0, 0), (0, 0), (0, 0), (false, false));
+       reconnect_nodes(ReconnectArgs::new(&nodes[0], &nodes[1]));
 
        nodes[1].node.process_pending_htlc_forwards();
 
@@ -3896,7 +3913,9 @@ fn do_test_drop_messages_peer_disconnect(messages_delivered: u8, simulate_broken
        nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id());
        nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id());
        if messages_delivered < 2 {
-               reconnect_nodes(&nodes[0], &nodes[1], (false, false), (0, 0), (1, 0), (0, 0), (0, 0), (0, 0), (false, false));
+               let mut reconnect_args = ReconnectArgs::new(&nodes[0], &nodes[1]);
+               reconnect_args.pending_htlc_claims.0 = 1;
+               reconnect_nodes(reconnect_args);
                if messages_delivered < 1 {
                        expect_payment_sent!(nodes[0], payment_preimage_1);
                } else {
@@ -3904,16 +3923,23 @@ fn do_test_drop_messages_peer_disconnect(messages_delivered: u8, simulate_broken
                }
        } else if messages_delivered == 2 {
                // nodes[0] still wants its RAA + commitment_signed
-               reconnect_nodes(&nodes[0], &nodes[1], (false, false), (0, -1), (0, 0), (0, 0), (0, 0), (0, 0), (false, true));
+               let mut reconnect_args = ReconnectArgs::new(&nodes[0], &nodes[1]);
+               reconnect_args.pending_htlc_adds.1 = -1;
+               reconnect_args.pending_raa.1 = true;
+               reconnect_nodes(reconnect_args);
        } else if messages_delivered == 3 {
                // nodes[0] still wants its commitment_signed
-               reconnect_nodes(&nodes[0], &nodes[1], (false, false), (0, -1), (0, 0), (0, 0), (0, 0), (0, 0), (false, false));
+               let mut reconnect_args = ReconnectArgs::new(&nodes[0], &nodes[1]);
+               reconnect_args.pending_htlc_adds.1 = -1;
+               reconnect_nodes(reconnect_args);
        } else if messages_delivered == 4 {
                // nodes[1] still wants its final RAA
-               reconnect_nodes(&nodes[0], &nodes[1], (false, false), (0, 0), (0, 0), (0, 0), (0, 0), (0, 0), (true, false));
+               let mut reconnect_args = ReconnectArgs::new(&nodes[0], &nodes[1]);
+               reconnect_args.pending_raa.0 = true;
+               reconnect_nodes(reconnect_args);
        } else if messages_delivered == 5 {
                // Everything was delivered...
-               reconnect_nodes(&nodes[0], &nodes[1], (false, false), (0, 0), (0, 0), (0, 0), (0, 0), (0, 0), (false, false));
+               reconnect_nodes(ReconnectArgs::new(&nodes[0], &nodes[1]));
        }
 
        if messages_delivered == 1 || messages_delivered == 2 {
@@ -3923,7 +3949,7 @@ fn do_test_drop_messages_peer_disconnect(messages_delivered: u8, simulate_broken
                nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id());
                nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id());
        }
-       reconnect_nodes(&nodes[0], &nodes[1], (false, false), (0, 0), (0, 0), (0, 0), (0, 0), (0, 0), (false, false));
+       reconnect_nodes(ReconnectArgs::new(&nodes[0], &nodes[1]));
 
        if messages_delivered > 2 {
                expect_payment_path_successful!(nodes[0]);
index a916dbfc9e26d13cdd12e7d29ec667772d8e7dd7..47ee09396368eea64ec1d2b7f51ad95eb5ebe39c 100644 (file)
@@ -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());
index 1230d48ba1ed6d37df3a7f73f1737dc5b873c733..01dac68432bd17c089321622bde44e05c421a48c 100644 (file)
@@ -597,7 +597,7 @@ fn test_onion_failure() {
                nodes[1].node.get_and_clear_pending_msg_events();
                nodes[2].node.get_and_clear_pending_msg_events();
        }, true, Some(UPDATE|20), Some(NetworkUpdate::ChannelUpdateMessage{msg: ChannelUpdate::dummy(short_channel_id)}), Some(short_channel_id));
-       reconnect_nodes(&nodes[1], &nodes[2], (false, false), (0, 0), (0, 0), (0, 0), (0, 0), (0, 0), (false, false));
+       reconnect_nodes(ReconnectArgs::new(&nodes[1], &nodes[2]));
 
        run_onion_failure_test("expiry_too_far", 0, &nodes, &route, &payment_hash, &payment_secret, |msg| {
                let session_priv = SecretKey::from_slice(&[3; 32]).unwrap();
index 2ae606106c92a7591be57770bf6627a3bac9dc95..cd75d48ebcbf29dbd758039b4448b2012696d28a 100644 (file)
@@ -490,7 +490,7 @@ fn do_retry_with_no_persist(confirm_before_reload: bool) {
        // nodes[1] now immediately fails the HTLC as the next-hop channel is disconnected
        let _ = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
 
-       reconnect_nodes(&nodes[1], &nodes[2], (false, false), (0, 0), (0, 0), (0, 0), (0, 0), (0, 0), (false, false));
+       reconnect_nodes(ReconnectArgs::new(&nodes[1], &nodes[2]));
 
        let as_commitment_tx = get_local_commitment_txn!(nodes[0], chan_id)[0].clone();
        if confirm_before_reload {
@@ -789,7 +789,9 @@ fn do_test_completed_payment_not_retryable_on_reload(use_dust: bool) {
        nodes[0].node.test_process_background_events();
        check_added_monitors(&nodes[0], 1);
 
-       reconnect_nodes(&nodes[0], &nodes[1], (true, true), (0, 0), (0, 0), (0, 0), (0, 0), (0, 0), (false, false));
+       let mut reconnect_args = ReconnectArgs::new(&nodes[0], &nodes[1]);
+       reconnect_args.send_channel_ready = (true, true);
+       reconnect_nodes(reconnect_args);
 
        // Now resend the payment, delivering the HTLC and actually claiming it this time. This ensures
        // the payment is not (spuriously) listed as still pending.
@@ -817,7 +819,7 @@ fn do_test_completed_payment_not_retryable_on_reload(use_dust: bool) {
        nodes[0].node.test_process_background_events();
        check_added_monitors(&nodes[0], 1);
 
-       reconnect_nodes(&nodes[0], &nodes[1], (false, false), (0, 0), (0, 0), (0, 0), (0, 0), (0, 0), (false, false));
+       reconnect_nodes(ReconnectArgs::new(&nodes[0], &nodes[1]));
 
        match nodes[0].node.send_payment_with_route(&new_route, payment_hash, RecipientOnionFields::secret_only(payment_secret), payment_id) {
                Err(PaymentSendFailure::DuplicatePayment) => {},
@@ -1011,7 +1013,7 @@ fn test_fulfill_restart_failure() {
        reload_node!(nodes[1], &chan_manager_serialized, &[&chan_0_monitor_serialized], persister, new_chain_monitor, nodes_1_deserialized);
 
        nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id());
-       reconnect_nodes(&nodes[0], &nodes[1], (false, false), (0, 0), (0, 0), (0, 0), (0, 0), (0, 0), (false, false));
+       reconnect_nodes(ReconnectArgs::new(&nodes[0], &nodes[1]));
 
        nodes[1].node.fail_htlc_backwards(&payment_hash);
        expect_pending_htlcs_forwardable_and_htlc_handling_failed!(nodes[1], vec![HTLCDestination::FailedPayment { payment_hash }]);
@@ -3422,9 +3424,11 @@ fn do_test_payment_metadata_consistency(do_reload: bool, do_modify: bool) {
                reload_node!(nodes[3], config, &nodes[3].node.encode(), &[&mon_bd, &mon_cd],
                        persister, new_chain_monitor, nodes_0_deserialized);
                nodes[1].node.peer_disconnected(&nodes[3].node.get_our_node_id());
-               reconnect_nodes(&nodes[1], &nodes[3], (false, false), (0, 0), (0, 0), (0, 0), (0, 0), (0, 0), (false, false));
+               reconnect_nodes(ReconnectArgs::new(&nodes[1], &nodes[3]));
        }
-       reconnect_nodes(&nodes[2], &nodes[3], (true, true), (0, 0), (0, 0), (0, 0), (0, 0), (0, 0), (false, false));
+       let mut reconnect_args = ReconnectArgs::new(&nodes[2], &nodes[3]);
+       reconnect_args.send_channel_ready = (true, true);
+       reconnect_nodes(reconnect_args);
 
        // Create a new channel between C and D as A will refuse to retry on the existing one because
        // it just failed.
index b53c617916a16deb8efc52b0197dacd61f5af780..141a7d53663613be4142e1c91a39d70a5b91bb8c 100644 (file)
@@ -52,7 +52,9 @@ fn test_funding_peer_disconnect() {
        let events_1 = nodes[0].node.get_and_clear_pending_msg_events();
        assert!(events_1.is_empty());
 
-       reconnect_nodes(&nodes[0], &nodes[1], (false, true), (0, 0), (0, 0), (0, 0), (0, 0), (0, 0), (false, false));
+       let mut reconnect_args = ReconnectArgs::new(&nodes[0], &nodes[1]);
+       reconnect_args.send_channel_ready.1 = true;
+       reconnect_nodes(reconnect_args);
 
        nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id());
        nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id());
@@ -180,7 +182,7 @@ fn test_funding_peer_disconnect() {
 
        reload_node!(nodes[0], &nodes[0].node.encode(), &[&chan_0_monitor_serialized], persister, new_chain_monitor, nodes_0_deserialized);
 
-       reconnect_nodes(&nodes[0], &nodes[1], (false, false), (0, 0), (0, 0), (0, 0), (0, 0), (0, 0), (false, false));
+       reconnect_nodes(ReconnectArgs::new(&nodes[0], &nodes[1]));
 }
 
 #[test]
@@ -334,7 +336,7 @@ fn test_simple_manager_serialize_deserialize() {
        let chan_0_monitor_serialized = get_monitor!(nodes[0], chan_id).encode();
        reload_node!(nodes[0], nodes[0].node.encode(), &[&chan_0_monitor_serialized], persister, new_chain_monitor, nodes_0_deserialized);
 
-       reconnect_nodes(&nodes[0], &nodes[1], (false, false), (0, 0), (0, 0), (0, 0), (0, 0), (0, 0), (false, false));
+       reconnect_nodes(ReconnectArgs::new(&nodes[0], &nodes[1]));
 
        fail_payment(&nodes[0], &[&nodes[1]], our_payment_hash);
        claim_payment(&nodes[0], &[&nodes[1]], our_payment_preimage);
@@ -456,8 +458,8 @@ fn test_manager_serialize_deserialize_inconsistent_monitor() {
        check_added_monitors!(nodes[0], 1);
 
        // nodes[1] and nodes[2] have no lost state with nodes[0]...
-       reconnect_nodes(&nodes[0], &nodes[1], (false, false), (0, 0), (0, 0), (0, 0), (0, 0), (0, 0), (false, false));
-       reconnect_nodes(&nodes[0], &nodes[2], (false, false), (0, 0), (0, 0), (0, 0), (0, 0), (0, 0), (false, false));
+       reconnect_nodes(ReconnectArgs::new(&nodes[0], &nodes[1]));
+       reconnect_nodes(ReconnectArgs::new(&nodes[0], &nodes[2]));
        //... and we can even still claim the payment!
        claim_payment(&nodes[2], &[&nodes[0], &nodes[1]], our_payment_preimage);
 
@@ -666,10 +668,12 @@ fn test_forwardable_regen() {
        let chan_1_monitor_serialized = get_monitor!(nodes[1], chan_id_2).encode();
        reload_node!(nodes[1], nodes[1].node.encode(), &[&chan_0_monitor_serialized, &chan_1_monitor_serialized], persister, new_chain_monitor, nodes_1_deserialized);
 
-       reconnect_nodes(&nodes[0], &nodes[1], (false, false), (0, 0), (0, 0), (0, 0), (0, 0), (0, 0), (false, false));
+       reconnect_nodes(ReconnectArgs::new(&nodes[0], &nodes[1]));
        // Note that nodes[1] and nodes[2] resend their channel_ready here since they haven't updated
        // the commitment state.
-       reconnect_nodes(&nodes[1], &nodes[2], (true, true), (0, 0), (0, 0), (0, 0), (0, 0), (0, 0), (false, false));
+       let mut reconnect_args = ReconnectArgs::new(&nodes[1], &nodes[2]);
+       reconnect_args.send_channel_ready = (true, true);
+       reconnect_nodes(reconnect_args);
 
        assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
 
@@ -967,7 +971,7 @@ fn do_forwarded_payment_no_manager_persistence(use_cs_commitment: bool, claim_ht
        check_added_monitors!(nodes[1], 1);
 
        nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id());
-       reconnect_nodes(&nodes[0], &nodes[1], (false, false), (0, 0), (0, 0), (0, 0), (0, 0), (0, 0), (false, false));
+       reconnect_nodes(ReconnectArgs::new(&nodes[0], &nodes[1]));
 
        if use_cs_commitment {
                // If we confirm a commitment transaction that has the HTLC on-chain, nodes[1] should wait
@@ -1085,7 +1089,7 @@ fn removed_payment_no_manager_persistence() {
        // now forgotten everywhere. The ChannelManager should have, as a side-effect of reload,
        // learned that the HTLC is gone from the ChannelMonitor and added it to the to-fail-back set.
        nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id());
-       reconnect_nodes(&nodes[0], &nodes[1], (false, false), (0, 0), (0, 0), (0, 0), (0, 0), (0, 0), (false, false));
+       reconnect_nodes(ReconnectArgs::new(&nodes[0], &nodes[1]));
 
        expect_pending_htlcs_forwardable_and_htlc_handling_failed!(nodes[1], [HTLCDestination::NextHopChannel { node_id: Some(nodes[2].node.get_our_node_id()), channel_id: chan_id_2 }]);
        check_added_monitors!(nodes[1], 1);
index 615cc1a19eb0ef4d52aac39b71a13aa7776793ee..9e5e3e45b27eabdb485c578c3721e1d8477cf139 100644 (file)
@@ -483,7 +483,7 @@ pub struct ProbabilisticScoringFeeParameters {
        pub manual_node_penalties: HashMap<NodeId, u64>,
 
        /// This penalty is applied when `htlc_maximum_msat` is equal to or larger than half of the
-       /// channel's capacity, (ie. htlc_maximum_msat  0.5 * channel_capacity) which makes us
+       /// channel's capacity, (ie. htlc_maximum_msat >= 0.5 * channel_capacity) which makes us
        /// prefer nodes with a smaller `htlc_maximum_msat`. We treat such nodes preferentially
        /// as this makes balance discovery attacks harder to execute, thereby creating an incentive
        /// to restrict `htlc_maximum_msat` and improve privacy.