aboutsummaryrefslogtreecommitdiffstats
path: root/src/features
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-08-01 21:40:00 -0700
committerAdam Soltys <[email protected]>2026-08-01 21:40:00 -0700
commit5c472442a4abf8768b25c544c73328467422538a (patch)
tree12350db16c282b1d2255207b75014324198e90f6 /src/features
parentc41081838b87ffaa0ac95694a9c3167fa1ec3749 (diff)
downloadcoinosv3-5c472442a4abf8768b25c544c73328467422538a.tar.gz
coinosv3-5c472442a4abf8768b25c544c73328467422538a.zip
Default usernames from the npub — no onboarding prompt
Every wallet silently claims the first 20 characters of its npub as its payment address the first time it opens: unique, free, and nothing to decide. The pick-a-username gate is gone (the generic onboardingView hook stays as an extension point). A custom name is an optional change tucked into the payment-address card — and swapping to one releases the old name so the registrar and DNS stay tidy. Custom names may become paid later to deter squatting; the default tier keeps working regardless. Co-Authored-By: Claude Fable 5 <[email protected]>
Diffstat (limited to 'src/features')
-rw-r--r--src/features/names.js37
1 files changed, 23 insertions, 14 deletions
diff --git a/src/features/names.js b/src/features/names.js
index a8d762e..970a690 100644
--- a/src/features/names.js
+++ b/src/features/names.js
@@ -49,7 +49,18 @@ export function namesFeature(ctx) {
});
const j = await r.json();
if (!r.ok || j.error) throw new Error(j.error || `registrar refused (${r.status})`);
+ const prev = load().name;
save({ name, domain: DOMAIN, uri, updated: Date.now() });
+ if (prev && prev !== name) {
+ const bye = wallet.nostrSign({
+ kind: AUTH_KIND, created_at: Math.floor(Date.now() / 1000), tags: [],
+ content: JSON.stringify({ action: 'delete', name: prev, domain: DOMAIN }),
+ });
+ fetch(`${REGISTRAR}/register`, {
+ method: 'DELETE', headers: { 'content-type': 'application/json' },
+ body: JSON.stringify({ auth: bye }),
+ }).catch(() => {});
+ }
return j;
}
@@ -80,12 +91,19 @@ export function namesFeature(ctx) {
} catch {}
}
- // The record must track the wallet: re-register when the ark address moved.
+ // Everyone gets an address without being asked: the default username is a
+ // prefix of the wallet's npub — unique, boring, and free. Custom names are
+ // an optional change (and may cost something one day, to keep squatters
+ // out), so nothing here ever blocks the wallet.
async function refresh() {
try {
if (!available()) { checked = true; render(); return; }
let st = load();
if (!st.name) { await lookupMine(); st = load(); }
+ if (!st.name) {
+ const npub = wallet.nostrNpub && wallet.nostrNpub();
+ if (npub) { await claim(npub.slice(0, 20)); st = load(); }
+ }
checked = true;
render();
if (!st.name) return;
@@ -177,6 +195,10 @@ export function namesFeature(ctx) {
h('button', { class: 'btn-ghost btn-sm', onClick: async () => {
await release(); toast(t('namesReleased')); render();
} }, t('namesRelease'))),
+ h('details', { class: 'small faint' },
+ h('summary', {}, t('namesCustom')),
+ h('p', { style: 'margin:4px 0' }, t('namesCustomHow')),
+ claimForm(false)),
(() => {
const code = hook('nwcOfferString');
return code ? h('details', { class: 'small faint' },
@@ -225,19 +247,6 @@ export function namesFeature(ctx) {
render: (seg) => namePane(seg),
}];
},
- // New wallets must pick a username before using the wallet; imported
- // seeds recover theirs from the registrar and skip straight through.
- onboardingView() {
- if (!available() || !checked) return null;
- if (load().name || ui.namesLater) return null;
- return h('div', { class: 'card col', style: 'gap:12px' },
- h('h2', { style: 'margin:0' }, t('namesOnboardTitle')),
- h('p', { class: 'muted', style: 'margin:0' }, t('namesOnboardDesc')),
- claimForm(true),
- ui.nameClaimError
- ? h('button', { class: 'linklike small', onClick: () => { ui.namesLater = true; render(); } }, t('namesOnboardLater'))
- : null);
- },
// BEFORE zaps in the registry: a pasted user@domain tries DNS first.
matchSendText(text, typed) {
if (typed) return false; // don't yank the form away mid-keystroke