Skip to content

Commit e38ab09

Browse files
authored
Merge pull request #1922 from wpaulino/avoid-remaining-redundant-commitment-broadcasts
Avoid redundant broadcast of local commitment transaction
2 parents 45eb0f3 + ff48f5d commit e38ab09

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)