fix: clear registered tokens and nano contracts when exiting a hardware wallet - #884
Draft
raul-oliveira wants to merge 1 commit into
Draft
fix: clear registered tokens and nano contracts when exiting a hardware wallet#884raul-oliveira wants to merge 1 commit into
raul-oliveira wants to merge 1 commit into
Conversation
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
raul-oliveira
marked this pull request as draft
July 9, 2026 16:00
…re wallet Root cause: the hardware-wallet exit path (locked screen for a hardware wallet, in App.js) calls LOCAL_STORE.cleanWallet(), which removed only the wallet identity keys and left REGISTERED_TOKENS_KEY, REGISTERED_NANOCONTRACTS_KEY and TOKEN_SIGNATURES_KEY in localStorage. This path skips resetStorage (used by the software reset-all-data flow), so importing a software wallet in the same session re-read the previous hardware wallet's registered tokens and nano contracts. The stale nano contract entry also carried over its old caller address. Add an opt-in cleanRegisteredData flag to cleanWallet and set it on the hardware-exit branch, so those wallet-scoped keys are cleared at the wallet switch. Other cleanWallet callers keep the previous behavior.
raul-oliveira
force-pushed
the
raul-oliveira/fix/hardware-wallet-data-leak-on-switch
branch
from
July 10, 2026 14:51
d2c24a0 to
ddd8bd2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Acceptance Criteria
Root cause (from the QA flow)
Repro: open a hardware (Ledger) wallet → quit the Hathor app on the device → without closing the desktop app, import a software wallet. The hardware wallet's custom tokens are still shown, and a nano contract tx keeps the old caller address.
When a hardware wallet is locked,
App.jssends it to the Wallet Type screen viaLOCAL_STORE.cleanWallet(). That method cleared only the wallet-identity keys (IS_HARDWARE_KEY,CLOSED_KEY,ACCESS_DATA_KEY) and left the wallet-scopedREGISTERED_TOKENS_KEY,REGISTERED_NANOCONTRACTS_KEYandTOKEN_SIGNATURES_KEYin localStorage. Unlike the software "reset all data" flow (which callsresetStorageand clears every key), this hardware path skipsresetStorage, so the next wallet re-reads the stale registered data. The stuck caller address is the leftover registered nano contract's storedaddress.Proposed solution
Add an opt-in
cleanRegisteredDataflag tocleanWalletand set it on the hardware-exit branch, clearing those three wallet-scoped keys at the wallet switch. The redux token/nano-contract state is repopulated from the now-empty keys when the next wallet loads. OthercleanWalletcallers keep their current behavior (the flag defaults tofalse), so the passphrase and logout flows are unchanged.No new dependencies.
Security Checklist