Commit ac78da8
Merge sync-created duplicates when recording a funding round
Wallet sync can observe a funding round before it is recorded as a
candidate: the counterparty broadcasts a round this node did not
contribute to, which nothing records until this node signs a later
round of the same splice and records the channel's history with it. The
funding-status gate rightly reports such a round foreign, and sync
re-keys the event to the round's txid-derived id, creating an untyped
duplicate record whose pending entry from then on shadows the funding
record in txid resolution: even after the round is recorded as a
candidate, every later event routes to the duplicate, the confirmation
strands there, and the funding record never confirms or graduates.
Fold the duplicate back in when its round becomes a recorded candidate:
adopt its confirmation onto the funding record -- through the same
status-update path wallet sync uses, so the confirmed candidate's
figures land -- and remove the duplicate along with its pending entry. A
duplicate for a round that never confirmed is dropped without adopting
anything; the actively-broadcast candidate stays the record's current
txid. The merge runs when this node signs a round and records the
channel's history with it, and again when LDK reports the round
negotiated, under the writer's cross-store lock acquisition, so sync
cannot interleave, and is idempotent, so a replayed SpliceNegotiated
event can re-run it after a partial failure. At signing time the merge
is a courtesy and a failure is only logged: the signed round can have no
duplicate yet, as our signatures have not left the node, the round's
SpliceNegotiated event re-runs the merge and replays on failure, and
failing the signing would replay it against a record whose two-store
write already completed, which the write's rollback does not cover. The
pending entry is removed before the payment record: a replay
rediscovers the duplicate through the record, so a failure between the
two removals can still be cleaned up, instead of orphaning a pending
entry that would shadow txid resolution all over again.
Generated with assistance from Claude Code.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>1 parent 80869b5 commit ac78da8
1 file changed
Lines changed: 673 additions & 18 deletions
0 commit comments