feat(btc-provider): accept P2TR accounts and add testnet4#8548
Open
marcopeereboom wants to merge 1 commit intoMetaMask:mainfrom
Open
feat(btc-provider): accept P2TR accounts and add testnet4#8548marcopeereboom wants to merge 1 commit intoMetaMask:mainfrom
marcopeereboom wants to merge 1 commit intoMetaMask:mainfrom
Conversation
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.
Author
|
FWIW, I tested all of this code using metamask flask and I was able to send and move ordinals. |
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
BtcAccountProvidercurrently restricts Bitcoin account compatibilityto 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 thattaproot accounts created through discovery or future UI options are
correctly managed by the provider
capabilities.scopes: addBtcScope.Testnet4so the provideradvertises testnet4 support
discoverAccounts: includeBtcScope.Testnet4in discovery scopesso existing testnet4 accounts are found during wallet setup
Default account creation via
createAccountV1remains P2WPKH — nobehavioral 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
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
BtcAccountProviderto treat Taproot (BtcAccountType.P2tr) accounts as compatible alongsideP2wpkh, and addsBtcScope.Testnet4to the provider’s declared capabilities.Bitcoin account discovery is widened to query the snap for both
MainnetandTestnet4scopes, 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.