From 274130edd7d11a0643d9b1f7469022207e5f5563 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Fri, 28 Aug 2026 07:57:09 -0700 Subject: The wallet remembers it has a spending side: the relay backup carries the hint, stamped the moment spending becomes real, so a restore paints Spending from its first frame instead of reflowing when the name lookup catches up — and the sign-in toasts are gone, since a wallet appearing announces itself MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_019eA8JRq9Wr7z2fRQk99HLi --- src/nostr-login.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/nostr-login.js') diff --git a/src/nostr-login.js b/src/nostr-login.js index b032c73..514c36b 100644 --- a/src/nostr-login.js +++ b/src/nostr-login.js @@ -233,8 +233,11 @@ export async function fetchWalletBackup(signer, relays = BACKUP_RELAYS) { } // Publish (or replace) the encrypted wallet association for this account. -export async function publishWalletBackup(signer, { mnemonic, passphrase }, relays = BACKUP_RELAYS) { - const content = await signer.encryptSelf(JSON.stringify({ mnemonic, passphrase: passphrase || '' })); +// `spending` rides along as a hint: a restored wallet paints its Spending +// side from the first frame instead of reflowing when the name lookup proves +// it seconds later. +export async function publishWalletBackup(signer, { mnemonic, passphrase, spending }, relays = BACKUP_RELAYS) { + const content = await signer.encryptSelf(JSON.stringify({ mnemonic, passphrase: passphrase || '', ...(spending ? { spending: true } : {}) })); const evt = await signer.signEvent({ kind: BACKUP_KIND, created_at: Math.floor(Date.now() / 1000), tags: [['d', SEED_DTAG]], content, @@ -256,7 +259,7 @@ export async function publishWalletBackup(signer, { mnemonic, passphrase }, rela // deriving (key in hand) or generating (signer only). export async function walletForSigner(signer) { const found = await fetchWalletBackup(signer); - if (found) return { mnemonic: found.mnemonic, passphrase: found.passphrase, mode: 'restored' }; + if (found) return { mnemonic: found.mnemonic, passphrase: found.passphrase, spending: !!found.spending, mode: 'restored' }; if (signer.secret) { // Publishing the derived seed costs nothing: the derivation is public, // so anyone holding this key could compute it anyway. It buys the thing -- cgit v1.2.3