diff options
author | Ryan Ofsky <ryan@ofsky.org> | 2022-12-02 17:53:58 -0500 |
---|---|---|
committer | Ryan Ofsky <ryan@ofsky.org> | 2022-12-02 17:53:58 -0500 |
commit | d1ca56382512df3084fce7353bf1e8b66cae61bc (patch) | |
tree | e5884bb502558af0a4ce26989f31fa5f6a2d3461 /src | |
parent | 6bd1d20b8cf27aa72ec2907342787e6fc9f94c50 (diff) |
bitcoin-cli: Make it an error to specify the "args" parameter two different ways
MarcoFalke reported the case of positional arguments silently overwriting the
named "args" parameter in bitcoin-cli
https://github.com/bitcoin/bitcoin/pull/19762#discussion_r1035761471 and this
behavior is confusing and was not intended when support for "args" parameters
was added to bitcoin-cli in #19762.
Instead of letting one "args" value overwrite the other in the client, just
pass the values to the server verbatim, and let the error be handled server
side.
Diffstat (limited to 'src')
-rw-r--r-- | src/rpc/client.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/rpc/client.cpp b/src/rpc/client.cpp index b3434b80c7..ea094976bf 100644 --- a/src/rpc/client.cpp +++ b/src/rpc/client.cpp @@ -289,6 +289,9 @@ UniValue RPCConvertNamedValues(const std::string &strMethod, const std::vector<s std::string name = s.substr(0, pos); std::string value = s.substr(pos+1); + // Intentionally overwrite earlier named values with later ones as a + // convenience for scripts and command line users that want to merge + // options. if (!rpcCvtTable.convert(strMethod, name)) { // insert string value directly params.pushKV(name, value); @@ -299,7 +302,10 @@ UniValue RPCConvertNamedValues(const std::string &strMethod, const std::vector<s } if (!positional_args.empty()) { - params.pushKV("args", positional_args); + // Use __pushKV instead of pushKV to avoid overwriting an explicit + // "args" value with an implicit one. Let the RPC server handle the + // request as given. + params.__pushKV("args", positional_args); } return params; |