feat(keyring): enable P2TR taproot account creation#598
Open
marcopeereboom wants to merge 1 commit intoMetaMask:mainfrom
Open
feat(keyring): enable P2TR taproot account creation#598marcopeereboom wants to merge 1 commit intoMetaMask:mainfrom
marcopeereboom wants to merge 1 commit intoMetaMask:mainfrom
Conversation
Remove v1 P2WPKH-only guards from createAccount, extractAddressType, and discoverAccounts. The full P2TR pipeline (BDK descriptors, CAIP type mappings, BIP-86 derivation paths, extension UI) already exists; only the whitelist checks blocked taproot. Widen address type validation to accept P2TR alongside P2WPKH. Accept BIP-86 (purpose 86) derivation paths. Include P2TR in account discovery so existing taproot UTXOs are found during wallet setup. Test coverage: unskip existing BIP-86 vector, add P2TR derivation path extraction, P2TR-only creation, P2TR+path combined validation, and P2TR account discovery with history filtering.
This was referenced Apr 22, 2026
|
I would Love to see this. This is Massive TBH P2TR taproot account creation system on MetaMask is personally needed... |
Nabilislam722
approved these changes
Apr 22, 2026
Nabilislam722
left a comment
There was a problem hiding this comment.
Utilizing it.each for the derivation path tests is a great way to handle the matrix of Bitcoin address types BIP-84 for p2wpkh
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
The snap currently restricts account creation to P2WPKH only, enforced
by three guards in
KeyringHandlerdocumented as v1 restrictions. Thefull P2TR pipeline already exists:
@metamask/bitcoindevkithandlestaproot natively,
caipToAddressTypemapsP2tr → 'p2tr',Purpose.Taproot = 86andpurposeToAddressTypeare defined inentities/account.ts, and the extension UI mapsP2trto 'Taproot'.Only the whitelist checks block taproot.
This PR widens the whitelist to accept P2TR alongside P2WPKH:
createAccount: acceptBtcAccountType.P2trin address type validation#extractAddressType: accept BIP-86 (purpose 86) derivation pathsdiscoverAccounts: include P2TR in the address type discovery listNo new dependencies. No changes to BDK integration, CAIP mappings, or
account infrastructure. Existing P2WPKH behavior is unchanged.
References
Checklist
Note
Medium Risk
Expands supported account types/derivation paths in keyring account creation and discovery, which can affect address derivation and account selection flows. Changes are scoped to whitelisting/validation and test coverage is updated, but incorrect mappings could lead to wrong accounts being created or discovered.
Overview
Adds taproot support by allowing
BtcAccountType.P2tralongsideP2wpkhwhen creating accounts inKeyringHandler, including validating defaults andaddressType/derivation-path consistency.Updates derivation-path parsing to accept BIP-86 (purpose
86) in addition to BIP-84, and expandsdiscoverAccountsto scan both P2WPKH and P2TR across all scopes (with corresponding unit test updates).Documents the new P2TR creation/discovery behavior in the snap package changelog.
Reviewed by Cursor Bugbot for commit 7bd736b. Bugbot is set up for automated code reviews on this repo. Configure here.