From 0d40e407f4c1a14a7da9466e38ade97adbdeeaee Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Sun, 17 May 2026 23:49:55 -0700 Subject: nwc: handle stale user record and skip reverted-duplicate records - fail loudly when an NWC request references an app whose user record no longer exists (migrated/deleted account); previously crashed inside handle() on `user.id` - filter `revertedDuplicate` payments out of list_transactions so clients never see the doubled records that were later reverted Co-Authored-By: Claude Opus 4.7 (1M context) --- lib/nwc.ts | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib') diff --git a/lib/nwc.ts b/lib/nwc.ts index 0d18f744..2053ccb5 100644 --- a/lib/nwc.ts +++ b/lib/nwc.ts @@ -121,6 +121,7 @@ export default () => { const app = await g(`app:${pubkey}`); if (!app) fail("pubkey not found"); const user = await g(`user:${app.uid}`); + if (!user) fail("user not found"); const result = await handle(method, params, ev, app, user); const payload = JSON.stringify({ result_type: method, ...result }); @@ -429,6 +430,7 @@ const handle = (method, params, ev, app, user) => for (const pid of payments) { const p = await gf(`payment:${pid}`); if (!p) continue; + if (p.revertedDuplicate) continue; const created_at = Math.floor(p.created / 1000); if (created_at < from || created_at > until) continue; if (p.amount < 0 && type === "incoming") continue; -- cgit v1.2.3