diff options
| author | Adam Soltys <[email protected]> | 2026-05-17 23:49:55 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-05-17 23:49:55 -0700 |
| commit | 0d40e407f4c1a14a7da9466e38ade97adbdeeaee (patch) | |
| tree | bd4c94e2b722ef4181a78c82c029b9a109c03194 /lib | |
| parent | d5395a81e5475af3a41c2715f58cab6b487a5795 (diff) | |
| download | coinos-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]>
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/nwc.ts | 2 |
1 files changed, 2 insertions, 0 deletions
@@ -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; |
