From 634ed2c91f64e478e6dfff676d402eb15d97af21 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Fri, 26 Jun 2026 11:56:37 -0700 Subject: Make auto log-out per-wallet — only signs out the wallet it's set for MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The logout timer is now an account setting (stored per account in the session and the durable directory), not a global one, and it removes only that wallet from the device — its session entry, directory entry, cached state (xpub + seed keys), and its vault entry — leaving other wallets untouched. - wipeAccount(id) surgically removes one wallet; the active one falls back to the next account (or the unlock screen). - Background-away timestamp drives per-account evaluation on resume/boot; an armed timer fires for the soonest-due wallet so a blurred-but-visible window still signs out on time. Overdue saved wallets are removed from the vault when it's unlocked (the only point we can re-encrypt it). - New cacheKeyFor() export lets app code target one wallet's cache keys exactly (verified against the wallet's seed/xpub/watch keys). Co-Authored-By: Claude Opus 4.8 (1M context) --- src/wallet.js | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/wallet.js') diff --git a/src/wallet.js b/src/wallet.js index 44694bc..b4aff8b 100644 --- a/src/wallet.js +++ b/src/wallet.js @@ -47,6 +47,13 @@ export function newMnemonic(strengthBits = 128) { return generateMnemonic(wordlist, strengthBits); } +// The base localStorage cache key for a wallet identity (xpub, xprv, or +// seed-id) — mirrors Wallet#_cacheKey, so app code can target a specific +// account's cached state (e.g. to wipe it on log-out). +export function cacheKeyFor(id) { + return 'btc-wallet-cache:' + hex.encode(sha256(new TextEncoder().encode(id))).slice(0, 32); +} + // Account-level xpub for a seed/key without constructing a Wallet — used to // verify an entered recovery phrase matches a watch-only account before // upgrading it to spendable. -- cgit v1.2.3