From 89a87b6b7866240a9289aefb3975a607d61bf371 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Sun, 5 Jul 2026 18:07:14 -0700 Subject: Never apply legacy netName-less nostr snapshots MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A pre-per-network-dtag event can hold ANY network's state; applying one put regtest coins into a mainnet wallet (and its board tx was then rightly rejected by the network). Unstamped snapshots are now skipped — a full scan is safer than a wrong snapshot. Co-Authored-By: Claude Fable 5 --- src/features/sync.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/features/sync.js') diff --git a/src/features/sync.js b/src/features/sync.js index 41d772e..f927aef 100644 --- a/src/features/sync.js +++ b/src/features/sync.js @@ -36,9 +36,12 @@ export function installSyncWallet(wallet) { return false; } if (!remote) return false; - // A snapshot for another network must never apply here (events published - // before per-network d-tags all live under the mainnet tag). - if (remote.netName && remote.netName !== this.netName) return false; + // A snapshot for another network must never apply here. Legacy events + // (published before snapshots carried netName) are ambiguous — they can + // hold ANY network's state under the shared d-tag, and applying one + // poisoned a mainnet wallet with regtest coins — so they are never + // applied either; a full scan is safer than a wrong snapshot. + if (remote.netName !== this.netName) return false; if ((remote.savedAt || 0) > (this._savedAt || 0)) { this._applySnapshot(remote); this.saveCache(); // mirror into localStorage -- cgit v1.2.3