Skip to content

fix(send): fix Taproot balance showing 0 in address type selector (OK-52631)#11085

Open
PatrickChoo wants to merge 3 commits intoOneKeyHQ:xfrom
PatrickChoo:fix/address-type-taproot-balance
Open

fix(send): fix Taproot balance showing 0 in address type selector (OK-52631)#11085
PatrickChoo wants to merge 3 commits intoOneKeyHQ:xfrom
PatrickChoo:fix/address-type-taproot-balance

Conversation

@PatrickChoo
Copy link
Copy Markdown
Collaborator

@PatrickChoo PatrickChoo commented Apr 7, 2026

Summary

  • Simplify tokenMap key matching in AddressTypeFiat to use includes() instead of split('_') + slice
  • The previous approach failed for UTXO xpub-based keys where the key format didn't split cleanly into the expected networkId_accountKey_tokenAddress segments

Root cause: PR #10931 changed the matching from simple key.includes(xpub) to a structured split('_').slice(1, -1) extraction. This broke for BTC/LTC where the tokenMap key contains xpub as the account identifier — the structured extraction couldn't reliably parse it back out.

Jira

OK-52631

Test plan

  • BTC send → open address type selector → verify Taproot balance shows correctly
  • Verify Nested SegWit, Native SegWit, Legacy balances also show correctly
  • LTC send → verify all derive type balances show correctly
  • EVM send (no address type selector) → verify no regression

Open with Devin

@revan-zhang
Copy link
Copy Markdown
Contributor

revan-zhang commented Apr 7, 2026

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

devin-ai-integration[bot]

This comment was marked as resolved.

…-52631)

The tokenMap key matching used split('_') + slice to extract the account
key segment, which failed for UTXO xpub-based keys where the format
didn't split cleanly. Replace with includes() matching against all
account key candidates (xpub, address, displayAddress, etc.), which is
the same approach the original implementation used reliably.
… lookup (OK-52631)

Root cause: BTC Taproot accounts use xpubSegwit (native descriptor) as the
account identifier in token map keys, but the candidate set only included
xpub. Restore exact segment matching (slice) instead of loose substring
matching (includes) and add xpubSegwit to candidates.
@PatrickChoo PatrickChoo force-pushed the fix/address-type-taproot-balance branch from d340934 to e7412af Compare April 7, 2026 16:10
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.

3 participants