rpc, wallet: Convert walletprocesspsbt to use options parameter

bitcoin/bitcoin: PR #36986

4 suggestions

Optional improvements

Link

[suggestion] · The null finalize test cannot distinguish the default from false

The new finalize=None assertion uses an unsigned PSBT with sign=False, so treating null as false would leave the assertion passing.

Location: test/functional/rpc_psbt.py:1519 (head).

Details and suggested fix

The PSBT comes from createpsbt, and the subsequent assertions confirm that it still needs a signer. Finalization cannot change this result. In --usecli mode, send_cli also omits the top-level finalize=None keyword entirely. Add walletprocesspsbt(psbtx, {"finalize": None}) to the earlier fixture that already distinguishes finalize=False without hex from finalize=True with hex. Compare the full result with processed_finalized_psbt and check that hex is present. Nesting the null inside the options object also ensures that the CLI variant sends it.


Link

[suggestion] · The OpenRPC schema permits a boolean under options

An OpenRPC client using named arguments can validate options=true against the published schema even though walletprocesspsbt rejects it.

Location: src/rpc/server.cpp:359 (head).

Details and suggested fix

OpenRPCArgSchema unions every type in m_type_per_name, while buildOpenRPCDoc publishes that schema under the first name, options. The sign alias appears only in x-bitcoin-aliases, without its separate type constraint. The server accepts a boolean by position or as sign, but checks named options against the object type only. Publish the object schema for options and describe the legacy positional boolean and per-alias types in an extension. Update rpc_openrpc_type_per_name to check that distinction instead of fixing the unrestricted union in place.


Link

[suggestion] · The walletprocesspsbt interface change lacks a release note

walletprocesspsbt now documents an options object and hides the legacy positional settings, but no release-note entry explains the change.

Location: src/wallet/rpc/spend.cpp:1640 (head).

Details and suggested fix

Help now shows walletprocesspsbt "psbt" ( options ), while sighashtype, bip32derivs and finalize remain as hidden compatibility parameters. Add a uniquely named doc/release-notes-<PR>.md entry, as requested for API changes in doc/developer-notes.md. Explain the new options-object form, that legacy positional and named forms remain supported despite the help change, and that an options object cannot be followed by additional positional settings.


Link

[suggestion] · The conversion commit precedes its by-name type enforcement

The final tree rejects options=<bool>, but the conversion commit temporarily accepts it as sign; moving the framework check earlier would make the conversion independently reviewable with its intended contract.

Location: src/wallet/rpc/spend.cpp:1640 at d24c8ea83d87 (commit) (commit).

Details and suggested fix

At d24c8ea83d8764e798c49edc61fdc828fd9a0205 (the conversion, inspected with parent=null), MatchesType accepts either declared type regardless of the supplied name, so options=true becomes sign=true. The by-name rule arrives in 54023e9325acb554fec8b1a8a02d19045e215d7b, and its wallet rejection test arrives in 348688bb8fd2179ccaa7637f11fd044d60a5a4c1. This makes a reviewer defer validation of the conversion's contract to later commits; it is not a head defect.

Move 54023e9325acb554fec8b1a8a02d19045e215d7b after the mixed-call framework prerequisite c3db835afd323e321a597419a732696e9f029928 and before the conversion. Its framework changes and dummy-RPC tests do not depend on the wallet conversion. Move the options=True/False rejection test from 348688bb8fd2179ccaa7637f11fd044d60a5a4c1 into the conversion as well. This keeps the final tree unchanged while letting the conversion demonstrate the complete by-name rule.


Coverage details

Background

Ralph's summary of historical context for the behaviour affected by this change. The historical record reviewed here is incomplete.

Documented decisions

The predecessor proposed an options object to improve the positional API, not to change signing behavior: it described walletprocesspsbt as having one logical positional argument and settings that make sense as named options, while explicitly retaining backward compatibility 'for now'.

This establishes the migration's historical intent: reorganizing settings should not require existing callers to rewrite valid calls. The pinned head reflects that intent by retaining the sign boolean in the second position and the remaining legacy positional parameters. The source does not define compatibility as permanent or specify byte-for-byte preservation of errors.

Source 1

Ralph's inferences

Mixed positional/named calls are an established supported interface, not merely an accidental parser behavior. Base tests explicitly require positional arguments supplied through args to combine with later named arguments, with nulls inserted for intervening omissions.

Before migration, walletprocesspsbt declares psbt, sign, sighashtype, bip32derivs and finalize as separate parameters. Thus a positional prefix followed by a non-overlapping named setting belongs to the existing interface. Preserving only wholly positional and wholly named calls would be narrower than the tested compatibility semantics. The options-object migration needs to preserve how such legacy calls select their settings, rather than reinterpret a later named setting as a second supply of the options position.

Null is part of the argument-omission mechanism, and must be distinguished from an explicit false setting. Base tests require null-filled holes; walletprocesspsbt declares sign, bip32derivs and finalize to default to true, with a context-dependent sighash default.

Named calls can omit earlier settings while supplying later ones, so migration must retain the meaning of those omissions. At the pinned head, null options explicitly leave defaults unchanged, while false changes the corresponding boolean. This supports default-equivalence as the relevant compatibility objective, although the legacy helper's treatment of every explicitly supplied null was not independently inspected.

The established framework rejects duplicate or conflicting supplies rather than resolving them by precedence. Base tests reject repeated named keys and positional/named overlap, including overlap where the supplied values agree.

Compatibility therefore includes preserving the distinction between a valid mixed call and supplying the same legacy parameter twice; allowing mixed arguments does not imply permitting an override. Separate base options-framework tests also reject an explicit options object combined with flattened named options, even when a positional object and a named option contain different fields. Those object-conflict tests are framework precedent, not evidence that legacy walletprocesspsbt already accepted an options object. They support an ambiguity-avoidance interpretation, but the inspected record does not establish the historical authors' rationale or a permanent guarantee for exact error text.