aboutsummaryrefslogtreecommitdiffstats
path: root/index.ts
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-06-14 12:33:29 -0700
committerAdam Soltys <[email protected]>2026-06-17 07:47:45 -0700
commit17a4461d8497f4f0f89871bb80604d449487a4c3 (patch)
tree1a66a54249afad5f5ec774b3912f1e0657df7bf1 /index.ts
parent9595de876df5264846227f6f80a7306df9154278 (diff)
downloadcoinos-server-17a4461d8497f4f0f89871bb80604d449487a4c3.tar.gz
coinos-server-17a4461d8497f4f0f89871bb80604d449487a4c3.zip
payments: guard /replay double-credit race with SET NX idempotency
Port of master ca28c19f to the staging stack. The getPayment() pre-check in the lightning listener/replay isn't atomic, so concurrent re-credits of the same settlement each ran the credit path. Claim each lightning/bolt12 settlement with an atomic SET NX on credited:<ref> (ref = preimage) and bail if already claimed. Guard sits before tbCredit and the pointer writes so a duplicate bails cleanly. Also disable the /replay route that triggered it. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Diffstat (limited to 'index.ts')
-rw-r--r--index.ts2
1 files changed, 1 insertions, 1 deletions
diff --git a/index.ts b/index.ts
index 98a9668e..bb944f41 100644
--- a/index.ts
+++ b/index.ts
@@ -241,7 +241,7 @@ app.post("/melt", auth, ecash.melt);
app.post("/ecash/:id", ecash.receive);
app.get("/replay/:index", (c) => {
- replay(c.req.param("index"));
+ // replay(c.req.param("index"));
return c.json({});
});