From 17a4461d8497f4f0f89871bb80604d449487a4c3 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Sun, 14 Jun 2026 12:33:29 -0700 Subject: 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 = 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 --- index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'index.ts') 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({}); }); -- cgit v1.2.3