diff options
| author | Adam Soltys <[email protected]> | 2026-08-03 13:04:37 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-08-03 13:04:37 -0700 |
| commit | efa4a719786633ba905798cdc46e6f35ada51372 (patch) | |
| tree | 8afcbd56cf87683c9656d81c6cc95bccd5eee1cf /src/routes | |
| parent | 2c9ab7a73c662e15229c340ba471fb3aeec41b70 (diff) | |
| download | coinos-ui-efa4a719786633ba905798cdc46e6f35ada51372.tar.gz coinos-ui-efa4a719786633ba905798cdc46e6f35ada51372.zip | |
migrate: flag the account instead of renaming it
Renaming to <name>v2 was a hack for freeing the username, and v3/v4/v9
fallbacks made it worse. The page now sweeps the balance and sets the
new `migrated` flag: the registrar takes over receiving for the name
while the old account keeps working here, unchanged.
Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Wvj4aoeMZwA7VUGdJP9Swi
Diffstat (limited to 'src/routes')
| -rw-r--r-- | src/routes/(app)/migrate/+page.server.ts | 36 | ||||
| -rw-r--r-- | src/routes/(app)/migrate/+page.svelte | 14 |
2 files changed, 12 insertions, 38 deletions
diff --git a/src/routes/(app)/migrate/+page.server.ts b/src/routes/(app)/migrate/+page.server.ts index 5182e8a0..f1964d1b 100644 --- a/src/routes/(app)/migrate/+page.server.ts +++ b/src/routes/(app)/migrate/+page.server.ts @@ -20,26 +20,12 @@ async function invoiceFor(address: string, sats: number) { return inv.pr as string; } -// The server only accepts letters and numbers, 2–24 of them, so the retired -// name can't carry a separator. Candidates are <name>v2, <name>v3, … each -// trimmed to fit, so a long username still lands inside the limit. -function retiredNames(username: string) { - const base = String(username).replace(/[^\p{L}\p{N}]/gu, ""); - const out: string[] = []; - for (let n = 2; n <= 9; n++) { - const suffix = `v${n}`; - out.push(base.slice(0, 24 - suffix.length) + suffix); - } - return out; -} - export async function load({ parent, url }) { const { user } = await parent(); if (!user) redirect(307, `/login?redirect=${encodeURIComponent(url.pathname + url.search)}`); return { to: url.searchParams.get("to") || "", back: url.searchParams.get("back") || "", - newName: retiredNames(user.username)[0], }; } @@ -76,23 +62,11 @@ export const actions = { } if (!sent) throw lastErr; } - // Releasing the username is what lets them keep it on v3. If the - // retired name is itself taken, step to the next candidate. - let renamed = ""; - let renameErr; - for (const candidate of retiredNames(username)) { - try { - await post("/user", { username: candidate, ...(pin ? { pin } : {}) }, auth(cookies)); - renamed = candidate; - break; - } catch (e) { - renameErr = e; - const msg = String((e as any)?.message || e); - if (!/taken/i.test(msg)) throw e; - } - } - if (!renamed) throw renameErr; - return { ok: true, sent, released: username, renamed }; + // Hand the name over for receiving. The account itself stays exactly + // as it is — same username, same history, still usable here; the + // registrar just becomes the answer for incoming payments. + await post("/user", { migrated: true, ...(pin ? { pin } : {}) }, auth(cookies)); + return { ok: true, sent, released: username }; } catch (e) { const msg = e && typeof e === "object" && "message" in e ? String(e.message) : String(e); return { error: msg, sent }; diff --git a/src/routes/(app)/migrate/+page.svelte b/src/routes/(app)/migrate/+page.svelte index e1e4a79d..0853c15b 100644 --- a/src/routes/(app)/migrate/+page.svelte +++ b/src/routes/(app)/migrate/+page.svelte @@ -9,7 +9,7 @@ import { enhance } from "$app/forms"; let { data, form } = $props(); - let { user, to, back, newName } = $derived(data); + let { user, to, back } = $derived(data); let working = $state(false); let balance = $derived(user?.balance || 0); @@ -36,16 +36,16 @@ <p>{form.sent.toLocaleString()} sats are on their way to your new wallet.</p> {/if} <p> - Your username was released, so <strong>{form.released}</strong> can be yours again on - coinos v3. + <strong>{form.released}@coinos.io</strong> now receives into your coinos v3 wallet. </p> <a class="btn btn-primary w-full" href={backUrl}>Back to coinos v3</a> </div> {:else} <p> - This sends your balance to your new wallet and frees up your username so you can keep - it there. Your old account stays, renamed to <strong>{newName}</strong>, and stops - receiving payments. + This sends your balance to your new wallet and points + <strong>{user.username}@coinos.io</strong> at it, so payments to your address arrive + there from now on. This account stays exactly as it is — same name, same history — + you just receive on coinos v3. </p> <div class="rounded-xl border p-3 space-y-1"> @@ -76,7 +76,7 @@ name="pin" placeholder="Your PIN" /> {/if} <button class="btn btn-primary w-full" disabled={working}> - {#if working}Moving…{:else}Move {balance.toLocaleString()} sats and release {user.username}{/if} + {#if working}Moving…{:else}Move my balance and address to coinos v3{/if} </button> </form> |
