aboutsummaryrefslogtreecommitdiffstats
path: root/src/nostr-login.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-08-28 07:57:09 -0700
committerAdam Soltys <[email protected]>2026-08-28 07:57:09 -0700
commit274130edd7d11a0643d9b1f7469022207e5f5563 (patch)
tree46a0e288bebd4669a0bbe3d8850138d8932d90a8 /src/nostr-login.js
parent92dd80a816c3efdabfd9aaabb3461d9078b39b5e (diff)
downloadcoinosv3-274130edd7d11a0643d9b1f7469022207e5f5563.tar.gz
coinosv3-274130edd7d11a0643d9b1f7469022207e5f5563.zip
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
Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_019eA8JRq9Wr7z2fRQk99HLi
Diffstat (limited to 'src/nostr-login.js')
-rw-r--r--src/nostr-login.js9
1 files changed, 6 insertions, 3 deletions
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