Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions lightning/src/chain/channelmonitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4867,13 +4867,16 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
} else if let Some(per_commitment_claimable_data) = per_commitment_option {
assert_eq!(funding_spent.funding_txid(), funding_txid_spent);

// While this isn't useful yet, there is a potential race where if a counterparty
// revokes a state at the same time as the commitment transaction for that state is
// confirmed, and the watchtower receives the block before the user, the user could
// upload a new ChannelMonitor with the revocation secret but the watchtower has
// already processed the block, resulting in the counterparty_commitment_txn_on_chain entry
// not being generated by the above conditional. Thus, to be safe, we go ahead and
// insert it here.
// Track that this counterparty commitment tx appeared on-chain. This is
// used by `provide_payment_preimage` to look up the commitment number
// when a preimage arrives after the commitment tx is already confirmed.
// It also handles a race where a counterparty revokes a state at the
// same time as the commitment transaction for that state is confirmed,
// and the watchtower receives the block before the user. The user could
// upload a new ChannelMonitor with the revocation secret but the
// watchtower has already processed the block, resulting in the
// counterparty_commitment_txn_on_chain entry not being generated by
// the above conditional.
self.counterparty_commitment_txn_on_chain.insert(commitment_txid, commitment_number);

log_info!(logger, "Got broadcast of non-revoked counterparty commitment transaction {}", commitment_txid);
Expand Down
Loading