diff options
| author | Adam Soltys <[email protected]> | 2026-08-17 22:32:03 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-08-17 22:32:03 -0700 |
| commit | 51b9f1a267a682a86e528bef424b245c63e5cb19 (patch) | |
| tree | 41c199950490e6ab36a8fe22347e231ef12b99a2 /routes | |
| parent | f385ae87f7b65ef2e2cc7caaedc78170c6c99392 (diff) | |
| download | coinos-server-51b9f1a267a682a86e528bef424b245c63e5cb19.tar.gz coinos-server-51b9f1a267a682a86e528bef424b245c63e5cb19.zip | |
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 <[email protected]>
Diffstat (limited to 'routes')
| -rw-r--r-- | routes/nostr.ts | 16 |
1 files changed, 15 insertions, 1 deletions
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) { |
