Skip to content

Commit 0f933ef

Browse files
committed
Add payment preimage and hash to ContentiousClaimable
1 parent 84da915 commit 0f933ef

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

lightning/src/chain/channelmonitor.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,10 @@ pub enum Balance {
606606
/// The height at which the counterparty may be able to claim the balance if we have not
607607
/// done so.
608608
timeout_height: u32,
609+
/// The payment hash that locks this HTLC.
610+
payment_hash: PaymentHash,
611+
/// The preimage that can be used to claim this HTLC.
612+
payment_preimage: PaymentPreimage,
609613
},
610614
/// HTLCs which we sent to our counterparty which are claimable after a timeout (less on-chain
611615
/// fees) if the counterparty does not know the preimage for the HTLCs. These are somewhat
@@ -1604,7 +1608,7 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
16041608
claimable_height: htlc.cltv_expiry,
16051609
});
16061610
}
1607-
} else if self.payment_preimages.get(&htlc.payment_hash).is_some() {
1611+
} else if let Some(payment_preimage) = self.payment_preimages.get(&htlc.payment_hash) {
16081612
// Otherwise (the payment was inbound), only expose it as claimable if
16091613
// we know the preimage.
16101614
// Note that if there is a pending claim, but it did not use the
@@ -1620,6 +1624,8 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
16201624
return Some(Balance::ContentiousClaimable {
16211625
claimable_amount_satoshis: htlc.amount_msat / 1000,
16221626
timeout_height: htlc.cltv_expiry,
1627+
payment_hash: htlc.payment_hash,
1628+
payment_preimage: *payment_preimage,
16231629
});
16241630
}
16251631
} else if htlc_resolved.is_none() {

lightning/src/ln/monitor_tests.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,10 +317,14 @@ fn do_test_claim_value_force_close(prev_commitment_tx: bool) {
317317
let received_htlc_claiming_balance = Balance::ContentiousClaimable {
318318
claimable_amount_satoshis: 3_000,
319319
timeout_height: htlc_cltv_timeout,
320+
payment_hash,
321+
payment_preimage,
320322
};
321323
let received_htlc_timeout_claiming_balance = Balance::ContentiousClaimable {
322324
claimable_amount_satoshis: 4_000,
323325
timeout_height: htlc_cltv_timeout,
326+
payment_hash: timeout_payment_hash,
327+
payment_preimage: timeout_payment_preimage,
324328
};
325329

326330
// Before B receives the payment preimage, it only suggests the push_msat value of 1_000 sats

0 commit comments

Comments
 (0)