From 3cda220c2432181b5f2dfc0c47e28c3e3cb54f18 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Thu, 10 Sep 2026 21:05:58 -0700 Subject: Each account in the switcher wears its own face, and its own renewal warning. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two accounts could show the same name and avatar: the identity list read a key stamped onto the account record, and the stamp was taken during the gap in a wallet switch where the new account is already loaded and saved but the features haven't re-inited — so the PREVIOUS account's signer was still answering "who are you". The live signer now re-checks on every read that it still belongs to the open wallet, not just at init(); and the switcher reads each account's own persisted login (or its seed's nostr key) instead of the stamped mirror, so a record stamped wrong before this still lists right. The Spending renewal warning belonged to the wallet that computed it and stayed on screen after switching — the old wallet's amount and deadline over the new wallet's balance, with a 30-minute throttle keeping it there. It now resets with the ark manager, and the next connect re-decides. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_019mrt228Upn9nNCwGixzSLx --- src/nostr.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/nostr.js') diff --git a/src/nostr.js b/src/nostr.js index fdc797c..50ed1f4 100644 --- a/src/nostr.js +++ b/src/nostr.js @@ -188,6 +188,19 @@ export async function publishOn(relays, evt) { export { nip04, nip44 }; export { getPublicKey, finalizeEvent, generateSecretKey }; +// The nostr identity a seed carries (NostrSync#load's key, without the +// wallet) — so the account switcher can put a face on every account on the +// device, not just the one that's open. Memoized: nip06 stretches the seed. +const _seedPks = new Map(); +export function seedPubkey(mnemonic, passphrase = '', accountIndex = 0) { + const k = `${mnemonic}\n${passphrase}\n${accountIndex}`; + if (_seedPks.has(k)) return _seedPks.get(k); + let pk = null; + try { pk = getPublicKey(nip06.privateKeyFromSeedWords(mnemonic, passphrase || undefined, accountIndex || 0)); } catch {} + _seedPks.set(k, pk); + return pk; +} + export function parseNostrPubkey(input) { const s = (input || '').trim(); if (/^[0-9a-f]{64}$/i.test(s)) return s.toLowerCase(); -- cgit v1.2.3