-
Notifications
You must be signed in to change notification settings - Fork 84
Description
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.