aboutsummaryrefslogtreecommitdiffstats
path: root/nwcpush
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-11-10 15:09:20 -0700
committerAdam Soltys <[email protected]>2026-11-10 15:09:20 -0700
commitf8c9efa8d1fab36ded9fa525c0ed56cd16ae5345 (patch)
tree05aef10cbbbccc8bb4d71e536a9860d3d114d402 /nwcpush
parent3c5e9c347a4b1a48d19d1a20ab4ace6f19852770 (diff)
downloadcoinosv3-server-f8c9efa8d1fab36ded9fa525c0ed56cd16ae5345.tar.gz
coinosv3-server-f8c9efa8d1fab36ded9fa525c0ed56cd16ae5345.zip
names: delete my account. "someone's asking for a way to delete their v3 account. we allowed that in v2. i guess we'd want to free up the name once the deletion is done and remove any records we have on them on the server" (Adam, 2026-11-10). POST /account/delete, NIP-98 signed: the signer's account is its key, the names it owns or manages, and those names' other key (a login identity's name is kept by its wallet's key). Everything filed under them goes: the names (DNS record, node offer), custom offers, POS tokens and sales, hats and hat invoices, the welcome mark, Lightning receipts, migration grants (which would otherwise keep the name reserved for the key that left), queued webhooks, closed and never-funded withdraw links. Then the notifier is told (POST /forget with the shared notify token): the devices registered to be told about those keys lose their registrations, NWC wakes included, and the keys' scheduled posts are dropped. Money is never deleted: while sats are queued, parked or in flight to them, or an open withdraw link of theirs still holds some, the answer is 409 "funds" with the amounts; { check: true } asks without doing. Kept: what stops a payment being made twice (delivered, withdrawPaid, inflight) and the unpaid-invoice map, which ages out in a week. names/forget.js + forget.test.js; run against both real services on throwaway state
Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_01VMan6V74NSFWZtNtgCfokN
Diffstat (limited to 'nwcpush')
-rw-r--r--nwcpush/server.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/nwcpush/server.js b/nwcpush/server.js
index bdf30aa..7873a4e 100644
--- a/nwcpush/server.js
+++ b/nwcpush/server.js
@@ -694,6 +694,28 @@ const server = Bun.serve({
return json({ ok: true, devices: n });
}
+ // Server-to-server: an account was deleted at the registrar. Its devices'
+ // registrations go (found by the keys they asked to be told about, then
+ // the same devices' NWC wakes), and its scheduled posts.
+ if (url.pathname === '/forget' && req.method === 'POST') {
+ const body = await req.json().catch(() => null);
+ if (!CFG.notifyToken || body?.token !== CFG.notifyToken) return json({ error: 'forbidden' }, 403);
+ const pks = new Set((Array.isArray(body.pubkeys) ? body.pubkeys : []).filter((k) => /^[0-9a-f]{64}$/.test(k || '')));
+ if (!pks.size) return json({ error: 'pubkeys required' }, 400);
+ const ids = new Set();
+ for (const [id, r] of Object.entries(notifyRegs)) if ((r.ptags || []).some((k) => pks.has(k))) { ids.add(id); delete notifyRegs[id]; }
+ for (const pk of Object.keys(regs)) {
+ regs[pk] = regs[pk].filter((r) => !ids.has(r.id));
+ if (!regs[pk].length) delete regs[pk];
+ }
+ let posts = 0;
+ for (const [id, s2] of Object.entries(scheduled)) if (pks.has(s2.ev?.pubkey)) { delete scheduled[id]; posts++; }
+ if (ids.size) { persist(); resubscribe(); }
+ if (posts) persistScheduled();
+ log(`forgot ${ids.size} device(s), ${posts} scheduled post(s)`);
+ return json({ ok: true, devices: ids.size, scheduled: posts });
+ }
+
// Claim a pay request before spending on it. The first claimant (or the
// same one again) gets ok:true; anyone else ok:false and stands down.
if (url.pathname === '/claim' && req.method === 'POST') {