Page MenuHomePhabricator

rpc: Allow named and positional arguments to be used together
ClosedPublic

Authored by Fabien on May 29 2024, 09:18.

Details

Summary
It's nice to be able to use named options and positional arguments together.

Most shell tools accept both, and python functions combine options and
arguments allowing them to be passed with even more flexibility. This change
adds support for python's approach so as a motivating example:

    bitcoin-cli -named createwallet wallet_name=mywallet load_on_startup=1

Can be shortened to:

    bitcoin-cli -named createwallet mywallet load_on_startup=1

JSON-RPC standard doesn't have a convention for passing named and positional
parameters together, so this implementation makes one up and interprets any
unused "args" named parameter as a positional parameter array.

Backport of core#19762.

Depends on D16240.

Test Plan
ninja all check-all

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Fabien requested review of this revision.May 29 2024, 09:18
src/test/rpc_tests.cpp
74 ↗(On Diff #48013)

This change (and the related header removal) is not from this PR but this seems to be a leftover from another backport, so I'm doing it.

This revision is now accepted and ready to land.May 29 2024, 09:43