Repository navigation
fix(bitcoin): sync and amount formatting - #543
Merged
Merged
Conversation
taran-a
force-pushed
the
fix/bitcoin-sync-and-amount-formatting
branch
from
November 2, 2026 08:28
3b78067 to
89e16e5
Compare
Contributor
Author
|
@metamaskbot publish-preview |
Contributor
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
Battambang
reviewed
Nov 2, 2026
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Repair and regular sync runs can overlap for the same account, allowing stale balances and transaction statuses to overwrite newer published data.
1 open issue
What changed in this PR
This PR separates Bitcoin repair scans from regular synchronization and uses exact decimal formatting for balances, transaction amounts, fees, and UI displays.
Changes:
- Schedules repairs independently while preserving retry behavior and sync coalescing.
- Replaces floating-point BTC formatting with a shared integer-based formatter.
- Adds regression tests and changelog entries for synchronization and amount formatting.
| File | Description |
|---|---|
packages/bitcoin-wallet-snap/src/utils/format-btc.ts |
Adds exact satoshi-to-BTC decimal formatting. |
packages/bitcoin-wallet-snap/src/utils/format-btc.test.ts |
Tests small amounts, precision boundaries, and balance validation. |
packages/bitcoin-wallet-snap/src/infra/SnapClientAdapter.ts |
Formats emitted balances with the shared helper. |
packages/bitcoin-wallet-snap/src/infra/SnapClientAdapter.test.ts |
Tests small-balance event formatting. |
packages/bitcoin-wallet-snap/src/infra/jsx/format.ts |
Uses exact formatting for displayed BTC amounts. |
packages/bitcoin-wallet-snap/src/infra/jsx/format.test.ts |
Tests decimal display and currency suffixes. |
packages/bitcoin-wallet-snap/src/handlers/RpcHandler.test.ts |
Updates the fee mock to provide satoshis. |
packages/bitcoin-wallet-snap/src/handlers/mappings.ts |
Formats transaction amounts and fees exactly. |
packages/bitcoin-wallet-snap/src/handlers/mappings.test.ts |
Adds precision and transaction-validation coverage. |
packages/bitcoin-wallet-snap/src/handlers/KeyringHandler.ts |
Returns exact decimal account balances. |
packages/bitcoin-wallet-snap/src/handlers/KeyringHandler.test.ts |
Tests small balances and updates amount mocks. |
packages/bitcoin-wallet-snap/src/handlers/CronHandler.ts |
Separates repair execution from regular synchronization. |
packages/bitcoin-wallet-snap/src/handlers/CronHandler.test.ts |
Tests repair scheduling, overlap, retries, and client-state checks. |
packages/bitcoin-wallet-snap/snap.manifest.json |
Adds a dedicated 45-second repair schedule. |
packages/bitcoin-wallet-snap/CHANGELOG.md |
Documents independent repairs and formatting fixes. |
Review effort: Balanced
taran-a
force-pushed
the
fix/bitcoin-sync-and-amount-formatting
branch
from
November 2, 2026 16:55
a8f5dea to
2a031d5
Compare
stanleyyconsensys
previously approved these changes
Nov 3, 2026
stanleyyconsensys
left a comment
Contributor
There was a problem hiding this comment.
LGTM, Approved with a small comment on accountUseCases
taran-a
force-pushed
the
fix/bitcoin-sync-and-amount-formatting
branch
from
November 3, 2026 12:26
6fc6f74 to
e1da187
Compare
taran-a
enabled stacked auto-merge
November 3, 2026 12:32
|
taran-a
disabled stacked auto-merge
November 3, 2026 12:36
stanleyyconsensys
approved these changes
Nov 3, 2026
This was referenced Nov 4, 2026
Merged
n3ps
pushed a commit
to n3ps/metamask-extension
that referenced
this pull request
Nov 4, 2026
…aMask#47621) <!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** # Bitcoin [3.3.0] ### Changed - Retry transient Bitcoin indexer, price API, and signed transaction broadcast failures with the shared fetch policy, and treat duplicate broadcasts as successful. ([MetaMask#530](MetaMask/internal-snaps#530)) ### Fixed - Fix formatting of small Bitcoin balances to avoid scientific notation. ([MetaMask#543](MetaMask/internal-snaps#543)) # Tron [4.3.1] ### Fixed - Allow transaction confirmation after remote simulation failures while retaining security warnings and checks for locally invalid transactions. ([MetaMask#552](MetaMask/internal-snaps#552)) <!-- Write a short description of the changes included in this pull request, also include relevant motivation and context. Have in mind the following questions: 1. What is the reason for the change? 2. What is the improvement/solution? --> ## **Changelog** <!-- If this PR is not End-User-Facing and should not show up in the CHANGELOG, you can choose to either: 1. Write `CHANGELOG entry: null` 2. Label with `no-changelog` If this PR is End-User-Facing, please write a short User-Facing description in the past tense like: `CHANGELOG entry: Added a new tab for users to see their NFTs` `CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker` (This helps the Release Engineer do their job more quickly and accurately) --> CHANGELOG entry: null ## **Related issues** n/a ## **Manual testing steps** n/a ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** <!-- [screenshots/recordings] --> ## **Pre-merge author checklist** - [X] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [X] I've completed the PR template to the best of my ability - [X] I’ve included tests if applicable - [X] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [X] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Patch bumps change Bitcoin broadcast/retry behavior and Tron confirmation when remote simulation fails, both on transaction-critical paths. > > **Overview** > Bumps **`@metamask/bitcoin-wallet-snap`** to **3.3.0** and **`@metamask/tron-wallet-snap`** to **4.3.1** in `package.json`, with matching **`yarn.lock`** resolutions. No extension source changes—behavior comes from the new snap builds. > > With **Bitcoin 3.3.0**, users get more resilient indexer/price/broadcast calls (shared fetch retries, duplicate broadcasts treated as success) and corrected display of very small balances (no scientific notation). > > With **Tron 4.3.1**, confirmation can proceed when **remote** simulation fails, while locally invalid transactions still block approval and security warnings remain. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 4bd1b01. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
5 of 10 tasks
Merged
8 of 10 tasks
anxolin
pushed a commit
to anxolin/internal-snaps
that referenced
this pull request
Nov 7, 2026
## Explanation # Bitcoin [3.3.0] ### Changed - Retry transient Bitcoin indexer, price API, and signed transaction broadcast failures with the shared fetch policy, and treat duplicate broadcasts as successful. ([MetaMask#530](MetaMask#530)) ### Fixed - Fix formatting of small Bitcoin balances to avoid scientific notation. ([MetaMask#543](MetaMask#543)) # Tron [4.3.1] ### Fixed - Allow transaction confirmation after remote simulation failures while retaining security warnings and checks for locally invalid transactions. ([MetaMask#552](MetaMask#552)) <!-- Thanks for your contribution! Take a moment to answer these questions so that reviewers have the information they need to properly understand your changes: * What is the current state of things and why does it need to change? * What is the solution your changes offer and how does it work? * Are there any changes whose purpose might not obvious to those unfamiliar with the domain? * If your primary goal was to update one package but you found you had to update another one along the way, why did you do so? * If you had to upgrade a dependency, why did you do so? --> ## References <!-- Are there any issues that this pull request is tied to? Are there other links that reviewers should consult to understand these changes better? Are there client or consumer pull requests to adopt any breaking changes? For example: * Fixes #12345 * Related to #67890 --> ## Checklist - [ ] I've updated the test suite for new or updated code as appropriate - [ ] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate - [ ] I've communicated my changes to consumers by [updating changelogs for packages I've changed](https://github.com/MetaMask/internal-snaps/tree/main/docs/processes/updating-changelogs.md) - [ ] I've introduced [breaking changes](https://github.com/MetaMask/internal-snaps/tree/main/docs/processes/breaking-changes.md) in this PR and have prepared draft pull requests for clients and consumer packages to resolve them
cursor Bot
pushed a commit
that referenced
this pull request
Nov 9, 2026
Resolve CronHandler conflicts: keep #543 publish-before-repair flow and rescanV1 repair; retain PR full-scan queue reliability after regular sync. Adapt createMany to main repository API; migrate affected tests to Vitest. Co-authored-by: Raul Velaz <rvelaz@users.noreply.github.com>
weitingsun
pushed a commit
to Poovarasan-Sandhanam/metamask-mobile
that referenced
this pull request
Nov 10, 2026
…taMask#39134) <!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until this PR meets the canonical Definition of Ready For Review in `docs/readme/ready-for-review.md`. --> ## **Description** Bumps the Bitcoin, Solana, Stellar, and Tron wallet snaps to their latest published versions: - `@metamask/bitcoin-wallet-snap`: `^3.2.0` → `^3.3.0` - `@metamask/solana-wallet-snap`: `^7.2.0` → `^7.3.0` - `@metamask/stellar-wallet-snap`: `^2.0.0` → `^2.1.0` - `@metamask/tron-wallet-snap`: `^4.3.0` → `^4.4.0` All are backwards-compatible minor updates; no application code changes are required. ### @metamask/bitcoin-wallet-snap 3.3.0 - Retry transient Bitcoin indexer, price API, and signed transaction broadcast failures with the shared fetch policy, and treat duplicate broadcasts as successful ([MetaMask#530](MetaMask/internal-snaps#530)). - Fix formatting of small Bitcoin balances to avoid scientific notation ([MetaMask#543](MetaMask/internal-snaps#543)). ### @metamask/solana-wallet-snap 7.3.0 - Remove the temporary fallback that injected `https://metamask.io` as the request origin when `keyring_submitRequest` was called without one ([MetaMask#533](MetaMask/internal-snaps#533)). ### @metamask/stellar-wallet-snap 2.1.0 - `confirmSend` now throws when signing or submission fails after the user confirms, instead of returning a JSON error response ([MetaMask#550](MetaMask/internal-snaps#550)). - Bump `@stellar/stellar-sdk` from `^17.2.1` to `^17.4.0` ([MetaMask#545](MetaMask/internal-snaps#545)). - Retry transient Token API, Price API, Security Alerts API, RPC, and Horizon failures with bounded timeouts and circuit breaking ([MetaMask#534](MetaMask/internal-snaps#534), [MetaMask#551](MetaMask/internal-snaps#551)). - Fix `onAmountInput` to accept the optional destination as `toAddress` instead of `to` ([MetaMask#558](MetaMask/internal-snaps#558)). ### @metamask/tron-wallet-snap 4.4.0 - Support `VoteWitnessContract` and `AccountPermissionUpdateContract` transactions by upgrading TronWeb to 6.5.1 ([MetaMask#561](MetaMask/internal-snaps#561)). - Align transaction security warning copy and scan-loading behavior with user preferences ([MetaMask#557](MetaMask/internal-snaps#557)). ## **Changelog** CHANGELOG entry: Updated the Solana, Stellar, and Tron wallet snaps to their latest versions. ## **Related issues** Fixes: N/A ## **Manual testing steps** ```gherkin Feature: Bitcoin and non-EVM wallet flows Scenario: user views account assets Given the user has Bitcoin, Solana, Stellar, and Tron accounts with assets When user opens the wallet and switches between those networks Then the assets and balances load successfully Scenario: user sends funds on each network Given the user has funds on Bitcoin, Solana, Stellar, and Tron When user sends funds on each network Then the fee estimate and confirmation are displayed correctly And the transaction is broadcast and completes successfully ``` ## **Screenshots/Recordings** ### **Before** N/A ### **After** N/A ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I've included tests if applicable - [x] I've documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I've applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. #### Performance checks (if applicable) - [x] I've tested on Android - Ideally on a mid-range device; emulator is acceptable - [x] I've tested with a power user scenario - Use these [power-user SRPs](https://consensyssoftware.atlassian.net/wiki/spaces/TL1/pages/edit-v2/401401446401?draftShareId=9d77e1e1-4bdc-4be1-9ebb-ccd916988d93) to import wallets with many accounts and tokens - [x] I've instrumented key operations with Sentry traces for production performance metrics - See [`trace()`](/app/util/trace.ts) for usage and [`addToken`](/app/components/Views/AddAsset/components/AddCustomToken/AddCustomToken.tsx#L274) for an example For performance guidelines and tooling, see the [Performance Guide](https://consensyssoftware.atlassian.net/wiki/spaces/TL1/pages/400085549067/Performance+Guide+for+Engineers). ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.
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.




Explanation
Run normal synchronization and publish balance/activity updates before repair scans, preventing slow repairs from delaying those updates. Preserve repair retries and sync coalescing.
References
Checklist