Skip to content

feat(btc-provider): accept P2TR accounts and add testnet4#8548

Open
marcopeereboom wants to merge 1 commit intoMetaMask:mainfrom
marcopeereboom:feat/btc-provider-p2tr-testnet4
Open

feat(btc-provider): accept P2TR accounts and add testnet4#8548
marcopeereboom wants to merge 1 commit intoMetaMask:mainfrom
marcopeereboom:feat/btc-provider-p2tr-testnet4

Conversation

@marcopeereboom
Copy link
Copy Markdown

@marcopeereboom marcopeereboom commented Apr 22, 2026

Explanation

BtcAccountProvider currently restricts Bitcoin account compatibility
to P2WPKH only and limits capabilities and discovery to mainnet and
testnet3. This blocks taproot (P2TR) accounts from being tracked by
the provider and prevents testnet4 usage.

This PR makes three changes to BtcAccountProvider:

  • isAccountCompatible: accept P2TR accounts alongside P2WPKH so that
    taproot accounts created through discovery or future UI options are
    correctly managed by the provider
  • capabilities.scopes: add BtcScope.Testnet4 so the provider
    advertises testnet4 support
  • discoverAccounts: include BtcScope.Testnet4 in discovery scopes
    so existing testnet4 accounts are found during wallet setup

Default account creation via createAccountV1 remains P2WPKH — no
behavioral change for existing callers. The snap already has full P2TR
and testnet4 support; this change enables the provider to work with
accounts the snap can now create.

References

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
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

Medium Risk
Expands Bitcoin account compatibility and discovery scopes, which can change which accounts are surfaced/managed and may impact users with existing BTC snap accounts. Limited scope change with added test coverage, but touches account discovery/compatibility logic.

Overview
Updates BtcAccountProvider to treat Taproot (BtcAccountType.P2tr) accounts as compatible alongside P2wpkh, and adds BtcScope.Testnet4 to the provider’s declared capabilities.

Bitcoin account discovery is widened to query the snap for both Mainnet and Testnet4 scopes, and tests/changelog are updated to cover the new compatibility behavior.

Reviewed by Cursor Bugbot for commit 6efa1f0. Bugbot is set up for automated code reviews on this repo. Configure here.

Widen BtcAccountProvider to recognize P2TR (taproot) accounts as
compatible Bitcoin accounts alongside P2WPKH. Add BtcScope.Testnet4
to the provider capabilities and account discovery scopes.

Default account creation remains P2WPKH — no behavioral change for
existing callers. P2TR accounts created through discovery or future
UI options are now correctly tracked by the provider.

Depends on MetaMask/snap-bitcoin-wallet P2TR support for the snap
to serve P2TR accounts via keyring_createAccount.
@marcopeereboom marcopeereboom requested review from a team as code owners April 22, 2026 12:35
@marcopeereboom
Copy link
Copy Markdown
Author

FWIW, I tested all of this code using metamask flask and I was able to send and move ordinals.

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