diff options
| author | Adam Soltys <[email protected]> | 2026-09-10 21:05:58 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-09-10 21:05:58 -0700 |
| commit | 3cda220c2432181b5f2dfc0c47e28c3e3cb54f18 (patch) | |
| tree | e727d022556f63d2a6383360fb59a466e58de537 /src/nostr.js | |
| parent | 1c34bb343c47f6e200575bac967959656ae7becb (diff) | |
| download | coinosv3-3cda220c2432181b5f2dfc0c47e28c3e3cb54f18.tar.gz coinosv3-3cda220c2432181b5f2dfc0c47e28c3e3cb54f18.zip | |
Each account in the switcher wears its own face, and its own renewal warning.
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) <[email protected]>
Claude-Session: https://claude.ai/code/session_019mrt228Upn9nNCwGixzSLx
Diffstat (limited to 'src/nostr.js')
| -rw-r--r-- | src/nostr.js | 13 |
1 files changed, 13 insertions, 0 deletions
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(); |
