Skip to content

Commit 4998b17

Browse files
Defer claimable tracking until manual funding is seen
1 parent 0b7fa8b commit 4998b17

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

lightning/src/chain/channelmonitor.rs

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5497,8 +5497,10 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
54975497
if should_broadcast_commitment {
54985498
let (mut claimables, mut outputs) =
54995499
self.generate_claimable_outpoints_and_watch_outputs(None);
5500-
claimable_outpoints.append(&mut claimables);
5501-
watch_outputs.append(&mut outputs);
5500+
if !self.is_manual_broadcast || self.funding_seen_onchain {
5501+
claimable_outpoints.append(&mut claimables);
5502+
watch_outputs.append(&mut outputs);
5503+
}
55025504
}
55035505

55045506
self.block_confirmed(height, block_hash, txn_matched, watch_outputs, claimable_outpoints, &broadcaster, &fee_estimator, logger)
@@ -5532,13 +5534,18 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
55325534
log_trace!(logger, "Processing {} matched transactions for block at height {}.", txn_matched.len(), conf_height);
55335535
debug_assert!(self.best_block.height >= conf_height);
55345536

5535-
let should_broadcast = self.should_broadcast_holder_commitment_txn(logger);
5536-
if let Some(payment_hash) = should_broadcast {
5537-
let reason = ClosureReason::HTLCsTimedOut { payment_hash: Some(payment_hash) };
5538-
let (mut new_outpoints, mut new_outputs) =
5539-
self.generate_claimable_outpoints_and_watch_outputs(Some(reason));
5540-
claimable_outpoints.append(&mut new_outpoints);
5541-
watch_outputs.append(&mut new_outputs);
5537+
// Only generate claims if we haven't already done so (e.g., in transactions_confirmed).
5538+
if claimable_outpoints.is_empty() && watch_outputs.is_empty() {
5539+
let should_broadcast = self.should_broadcast_holder_commitment_txn(logger);
5540+
if let Some(payment_hash) = should_broadcast {
5541+
let reason = ClosureReason::HTLCsTimedOut { payment_hash: Some(payment_hash) };
5542+
let (mut new_outpoints, mut new_outputs) =
5543+
self.generate_claimable_outpoints_and_watch_outputs(Some(reason));
5544+
if !self.is_manual_broadcast || self.funding_seen_onchain {
5545+
claimable_outpoints.append(&mut new_outpoints);
5546+
watch_outputs.append(&mut new_outputs);
5547+
}
5548+
}
55425549
}
55435550

55445551
// Find which on-chain events have reached their confirmation threshold.

0 commit comments

Comments
 (0)