From 06b4a10a8bf585378dfb2b40842385aeab44ec30 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Tue, 4 Aug 2026 02:13:14 -0700 Subject: The npub default never displaces a custom name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit adoptIdentity claimed the identity npub whenever the local name differed — and claim() releases the previous name, so a nostr login could delete the user's custom address from the registrar (it did). It now asks the registrar first and yields to any custom name. The registrar's /pubkey lookup also matches manager keys now and prefers real names over npub defaults, so restored wallets find their name again. Co-Authored-By: Claude Fable 5 --- src/features/names.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/features') diff --git a/src/features/names.js b/src/features/names.js index 3cff89b..862511f 100644 --- a/src/features/names.js +++ b/src/features/names.js @@ -169,7 +169,15 @@ export function namesFeature(ctx) { async function adoptIdentity(signer, npub) { if (!signer || !npub || !available()) return null; const name = npub.slice(0, 12); - if (load().name === name) return name; + let st = load(); + // A restored wallet may not know its name yet — ask the registrar before + // assuming there is none. + if (!st.name) { await lookupMine(); st = load(); } + // The npub default is a placeholder for wallets with no name. Adopting it + // must never displace a custom name — claim() releases the previous name, + // so getting this wrong deletes the user's address from the registrar. + if (st.name && !/^npub1/.test(st.name)) return st.name; + if (st.name === name) return name; await claim(name, { signer, manager: wallet.nostrPubkey() }); render(); return name; -- cgit v1.2.3