Skip to content

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

Open
marcopeereboom wants to merge 3 commits intoMetaMask:mainfrom
marcopeereboom:feat/btc-provider-p2tr-testnet4
Open

feat(btc-provider): accept P2TR accounts and add testnet4#8548
marcopeereboom wants to merge 3 commits 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
Changes which Bitcoin accounts/scopes are considered compatible and discoverable, which could alter onboarding/discovery results for some users (especially on testnets). Limited surface area and covered by a targeted unit test.

Overview
BtcAccountProvider now accepts Taproot P2TR accounts in isAccountCompatible, allowing the provider to manage/discover those accounts alongside existing P2WPKH accounts.

The provider’s advertised Bitcoin capabilities and discovery logic are updated to include BtcScope.Testnet4, and tests/changelog are updated accordingly.

Reviewed by Cursor Bugbot for commit 8878c33. 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