fix: deleting the last wallet leaves hasWallet true, resets selection unconditionally, and skips the active-address broadcast #156
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
Delete wallet is implemented and reachable (Home gear -> Settings -> per-wallet
[x]-> password-gated confirm atsrc/popup/views/deleteWallet.js:52), butit has three defects.
1. Deleting the last wallet leaves
state.hasWallet === true.deleteWallet.js:75-82nullsselectedWallet,selectedAddressandactiveAddressand callsshowView("welcome"), but never setsstate.hasWallet = false. On the next popup open,src/popup/index.js:265(
if (!state.hasWallet)) is false, so the user lands on Home rendering "Nowallets yet. Add one to get started." (
src/popup/views/home.js:219-220)instead of the Welcome screen.
README.md:270-276specifies Welcome is theroot screen when no wallets exist.
2. Selection is reset unconditionally.
deleteWallet.js:85-88forcesselectedWallet = 0; selectedAddress = 0and movesactiveAddressto wallet0 even when the deleted wallet was not the active one. Deleting an unrelated
wallet silently moves the user's active address.
3. No
AUTISTMASK_ACTIVE_CHANGEDbroadcast after the active addresschanges on delete. Compare
home.js:277, which does broadcast on addressswitch. Connected dApps keep seeing a deleted address until some other event
triggers a broadcast — the site believes it is still connected to an account
whose key no longer exists in the wallet.
Implementation requirements
state.hasWallet = falsewhen the last wallet is removed, and persistbefore navigating. Verify the Welcome screen is what actually renders on a
fresh popup open afterwards, not just immediately after the delete.
selectedWallet/selectedAddress/activeAddresswhen thedeleted wallet actually contained the current selection. When it did,
fall back deterministically (e.g. to the first remaining wallet's first
address) and say what the rule is in the PR. When it did not, leave the
user's selection exactly where it was, accounting for the index shift caused
by the
spliceatdeleteWallet.js:65.AUTISTMASK_ACTIVE_CHANGEDwhenever the active address changes as aresult of the delete, matching the existing call shape at
home.js:277.Also consider whether
accountsChangedneeds to reach connected dApps viabroadcastAccountsChanged(src/background/index.js:567-590) — a deletedaddress should not remain an authorized account.
allowedSites/deniedSitescleanup atdeleteWallet.js:67-71looks correct; keep it and confirm it covers every address of an HD wallet,
not just the first.
Definition of done
the Welcome screen.
the selection still points at the same wallet it did before (correct
index after the splice).
broadcasts
AUTISTMASK_ACTIVE_CHANGED.see a deleted address.
from both
allowedSitesanddeniedSites.active wallet, non-active wallet).
TODO.mdupdated in the same commit; the README TODO checkbox for"Delete wallet (with confirmation)" is ticked, since the feature exists.
make checkpasses.clawbot referenced this issue2026-08-11 14:24:20 +02:00