aboutsummaryrefslogtreecommitdiffstats
path: root/src/wallet.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-06-26 11:56:37 -0700
committerAdam Soltys <[email protected]>2026-06-26 11:56:37 -0700
commit634ed2c91f64e478e6dfff676d402eb15d97af21 (patch)
tree5d39b8ce6a10051537b5c22dfa6269299eab09d9 /src/wallet.js
parentd7d93f6e0cb5db140a842228eb42a25d2b789bd3 (diff)
downloadcoinosv3-634ed2c91f64e478e6dfff676d402eb15d97af21.tar.gz
coinosv3-634ed2c91f64e478e6dfff676d402eb15d97af21.zip
Make auto log-out per-wallet — only signs out the wallet it's set for
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) <[email protected]>
Diffstat (limited to 'src/wallet.js')
-rw-r--r--src/wallet.js7
1 files changed, 7 insertions, 0 deletions
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.