Skip to content

Commit ff48f5d

Browse files
committed
Avoid redundant broadcast of local commitment transaction
This change follows the rationale of commit 62236c7 and addresses the last remaining redundant local commitment broadcast. There's no need to broadcast our local commitment transaction if we've already seen a confirmed one as it'll be immediately rejected as a duplicate/conflict. This will also help prevent dispatching spurious events for bumping commitment and HTLC transactions through anchor outputs since the dispatch for said events follows the same flow as our usual commitment broadcast.
1 parent 56afbf5 commit ff48f5d

File tree

5 files changed

+189
-280
lines changed

5 files changed

+189
-280
lines changed

lightning/src/chain/channelmonitor.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2325,6 +2325,17 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
23252325
log_trace!(logger, "Updating ChannelMonitor: channel force closed, should broadcast: {}", should_broadcast);
23262326
self.lockdown_from_offchain = true;
23272327
if *should_broadcast {
2328+
// There's no need to broadcast our commitment transaction if we've seen one
2329+
// confirmed (even with 1 confirmation) as it'll be rejected as
2330+
// duplicate/conflicting.
2331+
let detected_funding_spend = self.funding_spend_confirmed.is_some() ||
2332+
self.onchain_events_awaiting_threshold_conf.iter().find(|event| match event.event {
2333+
OnchainEvent::FundingSpendConfirmation { .. } => true,
2334+
_ => false,
2335+
}).is_some();
2336+
if detected_funding_spend {
2337+
continue;
2338+
}
23282339
self.broadcast_latest_holder_commitment_txn(broadcaster, logger);
23292340
// If the channel supports anchor outputs, we'll need to emit an external
23302341
// event to be consumed such that a child transaction is broadcast with a

0 commit comments

Comments
 (0)