Skip to content

Commit

Permalink
bitcoin-cli: Make it an error to specify the "args" parameter two dif…
Browse files Browse the repository at this point in the history
…ferent ways

MarcoFalke reported the case of positional arguments silently overwriting the
named "args" parameter in bitcoin-cli
#19762 (comment) and this
behavior is confusing and was not intended when support for support for "args"
was added to bitcoin-cli.

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.
  • Loading branch information
ryanofsky committed Dec 2, 2022
1 parent 691bce8 commit 763d394
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/rpc/client.cpp
Expand Up @@ -299,7 +299,7 @@ UniValue RPCConvertNamedValues(const std::string &strMethod, const std::vector<s
}

if (!positional_args.empty()) {
params.pushKV("args", positional_args);
params.__pushKV("args", positional_args);
}

return params;
Expand Down
2 changes: 1 addition & 1 deletion test/functional/interface_bitcoin_cli.py
Expand Up @@ -92,7 +92,7 @@ def run_test(self):

self.log.info("Test that later cli named arguments values silently overwrite earlier ones")
assert_equal(self.nodes[0].cli("-named", "echo", "arg0=0", "arg1=1", "arg2=2", "arg1=3").send_cli(), ['0', '3', '2'])
assert_equal(self.nodes[0].cli("-named", "echo", "args=[0,1,2,3]", "4", "5", "6", ).send_cli(), ['4', '5', '6'])
assert_raises_rpc_error(-8, "Parameter args specified multiple times", self.nodes[0].cli("-named", "echo", "args=[0,1,2,3]", "4", "5", "6", ).send_cli)

user, password = get_auth_cookie(self.nodes[0].datadir, self.chain)

Expand Down

0 comments on commit 763d394

Please sign in to comment.