aboutsummaryrefslogtreecommitdiffstats
path: root/src/features/names.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-08-04 02:13:14 -0700
committerAdam Soltys <[email protected]>2026-08-04 02:13:14 -0700
commit06b4a10a8bf585378dfb2b40842385aeab44ec30 (patch)
treea02e29dc15a34112f6caa39b9bd47be71628c2f3 /src/features/names.js
parentc124a845ea1ed2d755032eb4de09eccace88cd12 (diff)
downloadcoinosv3-06b4a10a8bf585378dfb2b40842385aeab44ec30.tar.gz
coinosv3-06b4a10a8bf585378dfb2b40842385aeab44ec30.zip
The npub default never displaces a custom name
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 <[email protected]>
Diffstat (limited to 'src/features/names.js')
-rw-r--r--src/features/names.js10
1 files changed, 9 insertions, 1 deletions
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;