]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Add payment hash to `MaybePreimageClaimableHTLC`
authorAlec Chen <alecchendev@gmail.com>
Sun, 23 Apr 2023 04:21:40 +0000 (23:21 -0500)
committerAlec Chen <alecchendev@gmail.com>
Sun, 23 Apr 2023 07:04:31 +0000 (02:04 -0500)
lightning/src/chain/channelmonitor.rs
lightning/src/ln/monitor_tests.rs

index 865b2c55cb12d89cc8b7b756a52e0264cdb007bc..9b2b1a766bc4c1b88257805f5a9b6bbff54ca8ea 100644 (file)
@@ -634,6 +634,8 @@ pub enum Balance {
                /// 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,
+               /// The payment hash whose preimage we need to claim this HTLC.
+               payment_hash: PaymentHash,
        },
        /// The channel has been closed, and our counterparty broadcasted a revoked commitment
        /// transaction.
@@ -1635,6 +1637,7 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
                        return Some(Balance::MaybePreimageClaimableHTLC {
                                claimable_amount_satoshis: htlc.amount_msat / 1000,
                                expiry_height: htlc.cltv_expiry,
+                               payment_hash: htlc.payment_hash,
                        });
                }
                None
@@ -1806,6 +1809,7 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitor<Signer> {
                                        res.push(Balance::MaybePreimageClaimableHTLC {
                                                claimable_amount_satoshis: htlc.amount_msat / 1000,
                                                expiry_height: htlc.cltv_expiry,
+                                               payment_hash: htlc.payment_hash,
                                        });
                                }
                        }
index 9b5dc10da687a6fa21f8f9e95c1aa50664c88d95..9c80d566e009af0fc759d63dfa037d0e1dcf026f 100644 (file)
@@ -311,10 +311,12 @@ fn do_test_claim_value_force_close(prev_commitment_tx: bool) {
        let received_htlc_balance = Balance::MaybePreimageClaimableHTLC {
                claimable_amount_satoshis: 3_000,
                expiry_height: htlc_cltv_timeout,
+               payment_hash,
        };
        let received_htlc_timeout_balance = Balance::MaybePreimageClaimableHTLC {
                claimable_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,
@@ -775,10 +777,12 @@ fn test_no_preimage_inbound_htlc_balances() {
        let a_received_htlc_balance = Balance::MaybePreimageClaimableHTLC {
                claimable_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,
                expiry_height: htlc_cltv_timeout,
+               payment_hash: to_b_failed_payment_hash,
        };
        let b_sent_htlc_balance = Balance::MaybeTimeoutClaimableHTLC {
                claimable_amount_satoshis: 20_000,