aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-05-17 23:49:55 -0700
committerAdam Soltys <[email protected]>2026-05-17 23:49:55 -0700
commit0d40e407f4c1a14a7da9466e38ade97adbdeeaee (patch)
treebd4c94e2b722ef4181a78c82c029b9a109c03194
parentd5395a81e5475af3a41c2715f58cab6b487a5795 (diff)
downloadcoinos-server-0d40e407f4c1a14a7da9466e38ade97adbdeeaee.tar.gz
coinos-server-0d40e407f4c1a14a7da9466e38ade97adbdeeaee.zip
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) <[email protected]>
-rw-r--r--lib/nwc.ts2
1 files changed, 2 insertions, 0 deletions
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;