Skip to content

rpc, wallet: Convert walletprocesspsbt to use options parameter - #36986

Open
jeanpablojp wants to merge 6 commits into
bitcoin:masterfrom
jeanpablojp:walletprocesspsbt-options
Open

jeanpablojp wants to merge 6 commits into
bitcoin:masterfrom
jeanpablojp:walletprocesspsbt-options

Conversation

@jeanpablojp

Copy link
Copy Markdown
Contributor

This picks up #24963.

walletprocesspsbt takes four settings after the PSBT, three of them booleans, so a positional call reads walletprocesspsbt "psbt" true "ALL" true false, and each new setting becomes one more positional parameter (#32857 would add a sixth). This moves the four settings into an options object as the second parameter. Calls that work today, by position or by name, keep working.

For the old positional form, the second position accepts either the options object or the old sign boolean, which needs a parameter to declare one type per alias. The other three settings stay as hidden positional parameters. A parameter passed by name must have the type declared for that name, so options=true is rejected instead of being read as sign=true.

Changes compared to #24963, besides the rebase on the current RPC framework.

  • getopenrpcinfo describes the second parameter as an object or a boolean.
  • A call mixing positional and named arguments, such as walletprocesspsbt <psbt> true finalize=false with -named, works as on master instead of failing with "specified twice".
  • The type check by name no longer reads the wrong name after an options object built from named options, which made walletcreatefundedpsbt outputs=... add_inputs=true bip32derivs=false fail with "JSON value of type object is not of expected type object".
  • A null option means the default, as a null named argument does on master.
  • From review on RPC/Wallet: Convert walletprocesspsbt to use options parameter #24963, the options are checked before the wallet sync and the PSBT decode, and a test mixes positional and named arguments.
  • Unit tests for the framework changes.

descriptorprocesspsbt and createwallet I will do as follow-ups if this is accepted first.

luke-jr and others added 6 commits November 25, 2026 17:24
An RPC parameter can have aliases but only one type. Let it declare a
type per alias, so that one position can take a new options object
under one name and the old boolean under another. Replacing positional
parameters with an options object without breaking existing callers
needs this.

MatchesType accepts any of the declared types, and GetArgMap lists each
alias with its own type, so the client conversion table is checked per
name.

Co-authored-by: jeanpablojp <[email protected]>
getopenrpcinfo builds the schema of a parameter from its first type
only, so a parameter that takes an options object or a boolean would be
described as an object. Describe it with a oneOf holding one schema per
declared type.
A named-only option that a positional parameter also accepts by name
(also_positional) always goes into the options object. When positional
arguments passed in "args" already take the position of that object,
the call fails with "specified twice", although the option could go to
the positional parameter of the same name. Pass it there instead.

No RPC has this layout yet. The next commit gives walletprocesspsbt
one, and without this change a call such as
`walletprocesspsbt <psbt> true finalize=false` with -named, which works
today, would start to fail.
Move sign, sighashtype, bip32derivs and finalize into an options object
as the second parameter, so that new settings do not have to become
more positional parameters.

Existing calls keep working. The second position still accepts the sign
boolean, sighashtype, bip32derivs and finalize stay as hidden positional
parameters, and all four can still be passed by name. A null option
means the default, as a null named argument did before.

The options are read before waiting for the wallet to sync and decoding
the PSBT, so invalid options are reported first. The conversion check
in rpc_help.py compares sets now, because sign is listed at position 1
both as an option and as an alias.

Co-authored-by: jeanpablojp <[email protected]>
A parameter passed by name must have the type declared for that name,
so walletprocesspsbt rejects options=true instead of reading it as
sign=true. A parameter passed by position can still have any of its
declared types.

transformNamedArguments records the name each parameter was passed
under. Holes and an options object built from named options get no
name, so the parameters after them keep their own.

Co-authored-by: jeanpablojp <[email protected]>
Cover options passed by name with the wrong type, an options field with
the wrong type, an unknown option, and an options object followed by
more positional parameters.

Co-authored-by: jeanpablojp <[email protected]>
@DrahtBot

DrahtBot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

External sites

Reviews

See the guideline and AI policy for information on the review process.
A summary of reviews will appear here.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #37016 (rpc: fail scanblocks instead of silently skipping missing filters by shivansh023023)
  • #36154 (wallet: fill PSBT_GLOBAL_XPUB by jeanpablojp)
  • #36122 (BIP460: CISA for Taproot key path spends by fjahr)
  • #32857 (wallet: allow skipping script paths by Sjors)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

LLM Linter (✨ experimental)

Possible places where comparison-specific test macros should replace generic comparisons:

  • src/test/rpc_tests.cpp: BOOST_CHECK_THROW((RPCArg{"options", ...}), NonFatalCheckError) → Prefer BOOST_CHECK_EXCEPTION with a predicate checking the specific failure message.
  • src/test/rpc_tests.cpp: BOOST_CHECK_THROW((RPCArg{"flag|options", ...}), NonFatalCheckError) → Prefer BOOST_CHECK_EXCEPTION with a predicate checking the specific failure message.

2026-11-25 21:19:36

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.

5 participants