aboutsummaryrefslogtreecommitdiffstats
path: root/names/server.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-08-01 21:36:27 -0700
committerAdam Soltys <[email protected]>2026-08-01 21:36:27 -0700
commitc41081838b87ffaa0ac95694a9c3167fa1ec3749 (patch)
tree750cd53750ef2b652888ff1c8a20cf56cf4c12d9 /names/server.js
parentc17f3fb4dcaf8037eafdbd8d85c655da75d0c7d5 (diff)
downloadcoinosv3-c41081838b87ffaa0ac95694a9c3167fa1ec3749.tar.gz
coinosv3-c41081838b87ffaa0ac95694a9c3167fa1ec3749.zip
Username onboarding + the payment address leads Receive
New wallets must pick a username before entering the wallet: the onboarding gate renders a claim screen until a name exists. Imported seeds skip it — the registrar's new /pubkey lookup recovers the name owned by the wallet's key, so nothing is retyped. If claiming errors (registrar or ark unreachable) a do-it-later escape appears rather than locking anyone away from funds; the prompt returns next open. The Receive tab now defaults to the payment address — name QR + copy — with the on-chain address and other modes behind it, and the claim form inline for wallets that skipped onboarding. Co-Authored-By: Claude Fable 5 <[email protected]>
Diffstat (limited to 'names/server.js')
-rw-r--r--names/server.js13
1 files changed, 13 insertions, 0 deletions
diff --git a/names/server.js b/names/server.js
index 383a9ce..a43191e 100644
--- a/names/server.js
+++ b/names/server.js
@@ -256,6 +256,19 @@ Bun.serve({
return json({ name: m[1], domain, taken: reserved, reserved });
}
+ // Which name(s) does a wallet key own? Lets an imported seed find its
+ // username again without the user retyping it. Public data (DNS is public).
+ const pm = url.pathname.match(/^\/pubkey\/([0-9a-f]{64})$/);
+ if (pm && req.method === 'GET') {
+ const mine = Object.entries(state.names)
+ .filter(([, r]) => r.pubkey === pm[1])
+ .sort((a, b) => (b[1].updated || 0) - (a[1].updated || 0));
+ if (!mine.length) return json({});
+ const [key, r] = mine[0];
+ const [name, domain] = key.split('@');
+ return json({ name, domain, uri: r.uri });
+ }
+
if (url.pathname === '/register' && req.method === 'POST') {
if (!rateOk(ip)) return json({ error: 'rate limited' }, 429);
const body = await req.json().catch(() => null);