]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Simplify claimable balance trivially with consistent accessors
authorMatt Corallo <git@bluematt.me>
Wed, 13 Jul 2022 01:20:09 +0000 (01:20 +0000)
committerMatt Corallo <git@bluematt.me>
Mon, 15 Aug 2022 23:18:12 +0000 (23:18 +0000)
lightning/src/chain/channelmonitor.rs

index f08895718f18f9ca8b4774d353e8b3e47156e172..863ce4759e6e302e818cf7d45243293627584fd2 100644 (file)
@@ -1457,8 +1457,8 @@ impl<Signer: Sign> ChannelMonitor<Signer> {
                                                                OnchainEvent::HTLCUpdate { commitment_tx_output_idx, htlc_value_satoshis, .. }
                                                                if commitment_tx_output_idx == Some(htlc_commitment_tx_output_idx) => {
                                                                        debug_assert!(htlc_update_pending.is_none());
-                                                                       htlc_update_pending =
-                                                                               Some((htlc_value_satoshis.unwrap(), event.confirmation_threshold()));
+                                                                       debug_assert_eq!(htlc_value_satoshis.unwrap(), htlc.amount_msat / 1000);
+                                                                       htlc_update_pending = Some(event.confirmation_threshold());
                                                                },
                                                                OnchainEvent::HTLCSpendConfirmation { commitment_tx_output_idx, preimage, .. }
                                                                if commitment_tx_output_idx == htlc_commitment_tx_output_idx => {
@@ -1496,9 +1496,9 @@ impl<Signer: Sign> ChannelMonitor<Signer> {
                                                                // If the payment was outbound, check if there's an HTLCUpdate
                                                                // indicating we have spent this HTLC with a timeout, claiming it back
                                                                // and awaiting confirmations on it.
-                                                               if let Some((value, conf_thresh)) = htlc_update_pending {
+                                                               if let Some(conf_thresh) = htlc_update_pending {
                                                                        res.push(Balance::ClaimableAwaitingConfirmations {
-                                                                               claimable_amount_satoshis: value,
+                                                                               claimable_amount_satoshis: htlc.amount_msat / 1000,
                                                                                confirmation_height: conf_thresh,
                                                                        });
                                                                } else {