diff options
| author | Adam Soltys <[email protected]> | 2026-05-17 23:22:51 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-05-17 23:22:51 -0700 |
| commit | 0e368dab0943067c060ad45578a4c4cbdc3434a6 (patch) | |
| tree | bdca246458c0f80ed1e60a369069d50a72e0c217 /lib/utils.js.map | |
| parent | 3b7a1efaa1040de29d97640b371f24b41a6562a0 (diff) | |
| download | coinos-server-0e368dab0943067c060ad45578a4c4cbdc3434a6.tar.gz coinos-server-0e368dab0943067c060ad45578a4c4cbdc3434a6.zip | |
mirror payment records to arc + atomic /confirm lock to prevent double-credits
Follows up the Apr 29 double-credit incident. Two parallel callers of
/confirm (walletnotify, catchUp, bulk sweeps) could each read
p.confirmed=false and each run the multi() that increments balance —
because main-db pointers were sometimes missing while arc still had them,
gf()'s arc fallback returned stale state. Three pieces here:
- routes/payments.ts: SET NX EX 60 lock around the /confirm credit block
keyed by `confirmlock:${txid}:${vout}`. Concurrent callers short-circuit
cleanly. The lock is released on success and on every early-return.
- lib/payments.ts credit() + routes/payments.ts /confirm: mirror the
payment/invoice records and the `payment:<txid>:<vout>` / `payment:<hash>`
pointer keys into arc as soon as they're written. gf() will then find
the prior credit via arc fallback even if the main-db copy is wiped by
a future data-loss event.
- routes/payments.ts hide `revertedDuplicate` payments from the user's
payment list — matches the same filter added to lib/nwc.ts list_transactions
so reverted records never surface in either rendering path.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Diffstat (limited to 'lib/utils.js.map')
0 files changed, 0 insertions, 0 deletions
