rpc: Named argument support for bitcoin-cli

Usage e.g.:

    $ src/bitcoin-cli -testnet -named echo arg0="dfdf"
    [
    "dfdf"
    ]

Argument conversion also works, for arguments thus flagged in the table in
`src/rpc/client.cpp`.

    $ src/bitcoin-cli -testnet -named echojson arg0="[1,2,3]"
    [
      [
        1,
        2,
        3
      ]
    ]

Unknown parameter (detected server-side):

    $ src/bitcoin-cli -testnet -named getinfo arg0="dfdf"
    error code: -8
    error message:
    Unknown named parameter arg0
This commit is contained in:
Wladimir J. van der Laan
2016-11-22 14:56:29 +01:00
parent 9adb4e1a59
commit 481f289765
4 changed files with 156 additions and 93 deletions

View File

@@ -496,8 +496,10 @@ UniValue echo(const JSONRPCRequest& request)
{
if (request.fHelp)
throw runtime_error(
"echo \"message\" ...\n"
"\nSimply echo back the input arguments\n"
"echo|echojson \"message\" ...\n"
"\nSimply echo back the input arguments. This command is for testing.\n"
"\nThe difference between echo and echojson is that echojson has argument conversion enabled in the client-side table in"
"bitcoin-cli and the GUI. There is no server-side difference."
);
return request.params;
@@ -516,6 +518,7 @@ static const CRPCCommand commands[] =
/* Not shown in help */
{ "hidden", "setmocktime", &setmocktime, true, {"timestamp"}},
{ "hidden", "echo", &echo, true, {"arg0","arg1","arg2","arg3","arg4","arg5","arg6","arg7","arg8","arg9"}},
{ "hidden", "echojson", &echo, true, {"arg0","arg1","arg2","arg3","arg4","arg5","arg6","arg7","arg8","arg9"}},
};
void RegisterMiscRPCCommands(CRPCTable &t)