Skip to content

Sweep recovery: detect replaced/conflicting broadcast tx and auto-resync instead of stalling #1022

@parrth20

Description

@parrth20

Even though #996 exists but this is a follow-up implementation issue that generalizes the fix and avoids being a duplicate by focusing on recovery + correctness guarantees.

Problem
Sweep can stall forever when a broadcast collaborative transaction (TX1) is replaced by another tx (TX2) spending the same inputs. Jam continues waiting for TX1 confirmation, while TX2 confirms. The user then sees confusing jar balances / 0-conf states and may hit bad-txns-inputs-missingorspent.

Goal
Make Sweep robust to tx replacement/conflicts: if TX1 is replaced/evicted and inputs are spent by another tx, Sweep should auto-resync state and either:

continue with the confirmed replacement outcome, or
fail fast with a clear recoverable error + guided action (rescan / refresh / lock-unlock).

Acceptance criteria
If TX1 is replaced by TX2 (same inputs), Sweep does not stall indefinitely.
UI shows a clear state transition: “Detected conflicting/replaced tx → resyncing wallet state…”
After resync, jars/UTXOs reflect the chain result (TX2) without requiring a full service restart.
Logs include a structured event: SWEEP_TX_REPLACED (or similar) with txids + input outpoints.

Repro (regtest/signet)
Start Sweep with collaborative transaction enabled.
Capture TX1 before it confirms.
Broadcast a replacement TX2 spending the same inputs (RBF/conflict path).
Mine blocks confirming TX2.
Observe that Sweep currently waits forever; expected behavior is recovery/resync.

Notes
Jam docs mention scheduled sweeps can take long, but “stuck forever due to confirmed replacement” is distinct and should be detectable.

Ping
@theborakompanioni — I’d like to take this on and submit a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions