From: Alec Chen Date: Sun, 23 Apr 2023 04:21:40 +0000 (-0500) Subject: Add payment hash to `MaybePreimageClaimableHTLC` X-Git-Tag: v0.0.116-alpha1~61^2 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=29b9eb3936fa9de3cafffe05506e537d44d2a862;p=rust-lightning Add payment hash to `MaybePreimageClaimableHTLC` --- diff --git a/lightning/src/chain/channelmonitor.rs b/lightning/src/chain/channelmonitor.rs index 865b2c55c..9b2b1a766 100644 --- a/lightning/src/chain/channelmonitor.rs +++ b/lightning/src/chain/channelmonitor.rs @@ -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 ChannelMonitorImpl { 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 ChannelMonitor { res.push(Balance::MaybePreimageClaimableHTLC { claimable_amount_satoshis: htlc.amount_msat / 1000, expiry_height: htlc.cltv_expiry, + payment_hash: htlc.payment_hash, }); } } diff --git a/lightning/src/ln/monitor_tests.rs b/lightning/src/ln/monitor_tests.rs index 9b5dc10da..9c80d566e 100644 --- a/lightning/src/ln/monitor_tests.rs +++ b/lightning/src/ln/monitor_tests.rs @@ -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,