From 51b9f1a267a682a86e528bef424b245c63e5cb19 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Mon, 17 Aug 2026 22:32:03 -0700 Subject: nostr: resolve NIP-05 via the v3 registrar first; empty (not 500) on unknown name A claimed name's NIP-05 belongs to its wallet key in the registrar, so query NAMES_URL/.well-known/nostr.json first and fall back to the local lookup for legacy accounts. Return an empty names object for an unknown name per NIP-05 instead of throwing a 500. Co-Authored-By: Claude Opus 4.8 --- routes/nostr.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/routes/nostr.ts b/routes/nostr.ts index 4a7ce069..3b28076a 100644 --- a/routes/nostr.ts +++ b/routes/nostr.ts @@ -348,7 +348,21 @@ export default { } = req; let names = {}; if (name) { - names = { [name]: (await getUser(name, fields)).pubkey }; + // v3 registrar first: a claimed name's NIP-05 belongs to its wallet key. + // Legacy accounts answer as before when the registrar doesn't know it. + try { + const r = await fetch( + `${process.env.NAMES_URL || "https://names.coinos.io"}/.well-known/nostr.json?name=${encodeURIComponent(name)}`, + { signal: AbortSignal.timeout(3000) }, + ); + if (r.ok) { + const j = await r.json(); + if (j?.names?.[name]) return res.send({ names: { [name]: j.names[name] } }); + } + } catch {} + const u = await getUser(name, fields); + if (!u) return res.send({ names: {} }); // unknown name: empty per NIP-05, not a 500 + names = { [name]: u.pubkey }; } else { const records = await db.sMembers("nip5"); for (const s of records) { -- cgit v1.2.3