aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/api.js11
-rw-r--r--src/wallet.js7
2 files changed, 17 insertions, 1 deletions
diff --git a/src/api.js b/src/api.js
index c020a0c..5917234 100644
--- a/src/api.js
+++ b/src/api.js
@@ -31,6 +31,17 @@ export function setExplorerConfig({ server, url }, net = getNetwork()) {
// blocks) for testing — same address format as testnet, its own explorer at
// mutinynet.com. Data-source choices are stored per network (see nk()).
const NETWORK_KEY = 'btc-wallet-network';
+// Staging's default is mutinynet, but a "mainnet" stored BEFORE the staging
+// flag existed would pin early testers to mainnet forever. Clear it once —
+// anyone who picks mainnet on staging after this keeps their choice.
+if (STAGING) {
+ try {
+ if (!localStorage.getItem(NETWORK_KEY + '-staged')) {
+ localStorage.setItem(NETWORK_KEY + '-staged', '1');
+ if (localStorage.getItem(NETWORK_KEY) === 'mainnet') localStorage.removeItem(NETWORK_KEY);
+ }
+ } catch {}
+}
export const NETWORKS = [
{ id: 'mainnet', label: 'Mainnet' },
{ id: 'testnet', label: 'Testnet' },
diff --git a/src/wallet.js b/src/wallet.js
index cdae1ff..cce0a45 100644
--- a/src/wallet.js
+++ b/src/wallet.js
@@ -1871,7 +1871,12 @@ export class Wallet {
// cache yet — fall back to the xpub mirror so it shows instantly.
if (!raw && !this.watchOnly) raw = localStorage.getItem(this._xpubCacheKey());
if (!raw) return false;
- this._applySnapshot(JSON.parse(raw));
+ const snap = JSON.parse(raw);
+ // The seed-keyed cache slot is shared across networks (the key hashes
+ // only the seed), so a wallet switched to mutinynet would restore — and
+ // show — its mainnet balance. A snapshot only counts on its own network.
+ if (snap.netName && snap.netName !== this.netName) return false;
+ this._applySnapshot(snap);
this.emit();
return true;
} catch {