Skip to content

refactor: move validation structs and add account field#589

Open
Battambang wants to merge 3 commits intomainfrom
refactor/validation-structs-account-field
Open

refactor: move validation structs and add account field#589
Battambang wants to merge 3 commits intomainfrom
refactor/validation-structs-account-field

Conversation

@Battambang
Copy link
Contributor

@Battambang Battambang commented Mar 12, 2026

Explanation

This PR contributes to supporting the Bitcoin dApp connectivity.
It's refactoring the current code to prepare the integration of the resolve account address Keyring method.

It is part from the initial PR #564 feat: enable account address resolution to support dApps connectivity to split the work into 3 smaller PRs:
#589 refactor: move validation structs and add account field
#590 feat: add resolveAccountAddress method to KeyringHandler for dApp connectivity routing
#591 feat: add confirmation dialog before sendTransfer and before signing a PSBT from the keyring handler

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 the validated shape of keyring request params by requiring an embedded account object (with address) across multiple Bitcoin RPC methods, which can break callers if they don’t update. Logic changes are mostly structural (validation refactor), but they gate core signing/broadcast/transfer flows.

Overview
Keyring request validation was refactored and tightened. Request superstruct schemas for SignPsbt, FillPsbt, ComputeFee, BroadcastPsbt, SendTransfer, GetUtxo, and SignMessage were moved out of KeyringRequestHandler into handlers/validation.ts and updated to require params.account (currently { address }).

Keyring method typing/validation was expanded. validation.ts now defines per-method keyring request structs keyed by BtcMethod (via literal(...)) and a BtcWalletRequestStruct union for validating supported Bitcoin wallet requests.

Tests were updated accordingly (unit + integration) to pass the new account param shape, caip.ts adds NetworkStruct for validating BtcScope values, and snap.manifest.json shasum was updated to match the rebuilt bundle.

Written by Cursor Bugbot for commit bee05b0. This will update automatically on new commits. Configure here.

@Battambang Battambang requested a review from a team as a code owner March 12, 2026 22:56
@Battambang Battambang changed the title Refactor/validation structs account field Refactor validation structs and add account field Mar 12, 2026
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

@Battambang
Copy link
Contributor Author

@metamaskbot publish-preview

@github-actions
Copy link
Contributor

Preview builds have been published. See these instructions for more information about preview builds.

Expand for full list of packages and versions.
{
  "@metamask-previews/bitcoin-wallet-snap": "1.10.0-preview-bee05b0"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant