Skip to content

fix(btc-only): purge phantom multi-chain balances on connect#351

Merged
BitHighlander merged 1 commit into
developfrom
fix/btc-only-purge-stale-balances
Jul 12, 2026
Merged

fix(btc-only): purge phantom multi-chain balances on connect#351
BitHighlander merged 1 commit into
developfrom
fix/btc-only-purge-stale-balances

Conversation

@BitHighlander

Copy link
Copy Markdown
Collaborator

Diagnosis (live btc-only testing): dashboard showed All Chains $101.17 but Bitcoin No balance. The balance cache is keyed by hardware deviceId alone (getCachedBalances(deviceId) returns every chain row), and deviceId is stable across firmware variants. A device reflashed multi-chain → btc-only keeps its old rows, so the dashboard sums phantom balances — including ETH $91.36 at 0x9f5f2e60…, an address btc-only firmware can't derive — into the total. (Rows dated 2026-07-08, 4 days pre-flash — stale table, not a live refetch.)

The intuition that the cache needs an ETH address in its identifier is inverted: it's keyed by deviceId, so nothing gates the stale data.

Fix: a btc-only seed is locked to BTC (storage band 10017) and can never hold another chain, so on connect purge every non-bitcoin cached balance for the device. Source-level fix → dashboard, audit, ledger, and swap all read correct. Verified on the live DB: 16 phantom rows removed, 1 BTC row kept, total → $0.00.

Diagnosis: the balance cache is keyed by hardware deviceId alone
(getCachedBalances(deviceId) → all chain rows), and deviceId is stable across
firmware variants. A device reflashed from multi-chain to bitcoin-only keeps
its old multi-chain balance rows, so the dashboard sums phantom balances — incl.
an ETH balance at an address the btc-only firmware physically cannot derive —
into 'All Chains'. (Reproduced: device 343737340F...3B00, ETH $91.36 at
0x9f5f2e60…, Bitcoin $0.00, total $101.17; rows dated 4 days pre-flash.)

The user's assumption that the cache is keyed by an ETH address is inverted —
it's keyed by deviceId, which has no address in it, so nothing stops the stale
multi-chain data from loading.

Fix: a btc-only seed is locked to BTC (storage band 10017) and can never hold
another chain, so on connect purge every non-'bitcoin' cached balance for the
device (clearNonBitcoinBalances). Removes the phantom at the source, so every
read path (dashboard, audit, ledger, swap) is correct.
@BitHighlander BitHighlander merged commit 150df7b into develop Jul 12, 2026
@BitHighlander BitHighlander deleted the fix/btc-only-purge-stale-balances branch July 12, 2026 15:31
@BitHighlander

Copy link
Copy Markdown
Collaborator Author

Backed out of develop and consolidated into a single reviewable PR: #353 (branch btc-only). The change itself is unchanged — this was a history cleanup so btc-only ships as one PR. Nothing to do here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant