From a0eaff8a1d18ebba33cdea4cd1efaddeb55519e7 Mon Sep 17 00:00:00 2001 From: Daniel Cousens Date: Fri, 15 Jan 2016 11:55:17 +1100 Subject: move rpc* to rpc/ --- src/rpc/client.cpp | 163 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 163 insertions(+) create mode 100644 src/rpc/client.cpp (limited to 'src/rpc/client.cpp') diff --git a/src/rpc/client.cpp b/src/rpc/client.cpp new file mode 100644 index 000000000..b0e9b6f15 --- /dev/null +++ b/src/rpc/client.cpp @@ -0,0 +1,163 @@ +// Copyright (c) 2010 Satoshi Nakamoto +// Copyright (c) 2009-2015 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include "rpc/client.h" +#include "rpc/protocol.h" +#include "util.h" + +#include +#include + +#include // for to_lower() +#include + +using namespace std; + +class CRPCConvertParam +{ +public: + std::string methodName; //! method whose params want conversion + int paramIdx; //! 0-based idx of param to convert +}; + +static const CRPCConvertParam vRPCConvertParams[] = +{ + { "stop", 0 }, + { "setmocktime", 0 }, + { "getaddednodeinfo", 0 }, + { "setgenerate", 0 }, + { "setgenerate", 1 }, + { "generate", 0 }, + { "getnetworkhashps", 0 }, + { "getnetworkhashps", 1 }, + { "sendtoaddress", 1 }, + { "sendtoaddress", 4 }, + { "settxfee", 0 }, + { "getreceivedbyaddress", 1 }, + { "getreceivedbyaccount", 1 }, + { "listreceivedbyaddress", 0 }, + { "listreceivedbyaddress", 1 }, + { "listreceivedbyaddress", 2 }, + { "listreceivedbyaccount", 0 }, + { "listreceivedbyaccount", 1 }, + { "listreceivedbyaccount", 2 }, + { "getbalance", 1 }, + { "getbalance", 2 }, + { "getblockhash", 0 }, + { "move", 2 }, + { "move", 3 }, + { "sendfrom", 2 }, + { "sendfrom", 3 }, + { "listtransactions", 1 }, + { "listtransactions", 2 }, + { "listtransactions", 3 }, + { "listaccounts", 0 }, + { "listaccounts", 1 }, + { "walletpassphrase", 1 }, + { "getblocktemplate", 0 }, + { "listsinceblock", 1 }, + { "listsinceblock", 2 }, + { "sendmany", 1 }, + { "sendmany", 2 }, + { "sendmany", 4 }, + { "addmultisigaddress", 0 }, + { "addmultisigaddress", 1 }, + { "createmultisig", 0 }, + { "createmultisig", 1 }, + { "listunspent", 0 }, + { "listunspent", 1 }, + { "listunspent", 2 }, + { "getblock", 1 }, + { "getblockheader", 1 }, + { "gettransaction", 1 }, + { "getrawtransaction", 1 }, + { "createrawtransaction", 0 }, + { "createrawtransaction", 1 }, + { "createrawtransaction", 2 }, + { "signrawtransaction", 1 }, + { "signrawtransaction", 2 }, + { "sendrawtransaction", 1 }, + { "fundrawtransaction", 1 }, + { "gettxout", 1 }, + { "gettxout", 2 }, + { "gettxoutproof", 0 }, + { "lockunspent", 0 }, + { "lockunspent", 1 }, + { "importprivkey", 2 }, + { "importaddress", 2 }, + { "importaddress", 3 }, + { "importpubkey", 2 }, + { "verifychain", 0 }, + { "verifychain", 1 }, + { "keypoolrefill", 0 }, + { "getrawmempool", 0 }, + { "estimatefee", 0 }, + { "estimatepriority", 0 }, + { "estimatesmartfee", 0 }, + { "estimatesmartpriority", 0 }, + { "prioritisetransaction", 1 }, + { "prioritisetransaction", 2 }, + { "setban", 2 }, + { "setban", 3 }, +}; + +class CRPCConvertTable +{ +private: + std::set > members; + +public: + CRPCConvertTable(); + + bool convert(const std::string& method, int idx) { + return (members.count(std::make_pair(method, idx)) > 0); + } +}; + +CRPCConvertTable::CRPCConvertTable() +{ + const unsigned int n_elem = + (sizeof(vRPCConvertParams) / sizeof(vRPCConvertParams[0])); + + for (unsigned int i = 0; i < n_elem; i++) { + members.insert(std::make_pair(vRPCConvertParams[i].methodName, + vRPCConvertParams[i].paramIdx)); + } +} + +static CRPCConvertTable rpcCvtTable; + +/** Non-RFC4627 JSON parser, accepts internal values (such as numbers, true, false, null) + * as well as objects and arrays. + */ +UniValue ParseNonRFCJSONValue(const std::string& strVal) +{ + UniValue jVal; + if (!jVal.read(std::string("[")+strVal+std::string("]")) || + !jVal.isArray() || jVal.size()!=1) + throw runtime_error(string("Error parsing JSON:")+strVal); + return jVal[0]; +} + +/** Convert strings to command-specific RPC representation */ +UniValue RPCConvertValues(const std::string &strMethod, const std::vector &strParams) +{ + UniValue params(UniValue::VARR); + + for (unsigned int idx = 0; idx < strParams.size(); idx++) { + const std::string& strVal = strParams[idx]; + + if (!rpcCvtTable.convert(strMethod, idx)) { + // insert string value directly + params.push_back(strVal); + } else { + // parse string as JSON, insert bool/number/object/etc. value + params.push_back(ParseNonRFCJSONValue(strVal)); + } + } + + return params; +} + -- cgit v1.2.3 From 8d1de43f0cbc79940d870d0ba09c7d28dd812ef8 Mon Sep 17 00:00:00 2001 From: Leviathn Date: Wed, 10 Feb 2016 18:29:13 -0800 Subject: Remove internal miner This code removes the internal miner which is only useful on Testnet. This leaves the internal miner that is useful on RegTest intact. --- src/rpc/client.cpp | 3 --- 1 file changed, 3 deletions(-) (limited to 'src/rpc/client.cpp') diff --git a/src/rpc/client.cpp b/src/rpc/client.cpp index b0e9b6f15..b127a3f1a 100644 --- a/src/rpc/client.cpp +++ b/src/rpc/client.cpp @@ -27,8 +27,6 @@ static const CRPCConvertParam vRPCConvertParams[] = { "stop", 0 }, { "setmocktime", 0 }, { "getaddednodeinfo", 0 }, - { "setgenerate", 0 }, - { "setgenerate", 1 }, { "generate", 0 }, { "getnetworkhashps", 0 }, { "getnetworkhashps", 1 }, @@ -160,4 +158,3 @@ UniValue RPCConvertValues(const std::string &strMethod, const std::vector Date: Wed, 9 Mar 2016 22:30:15 +0100 Subject: Make the generate RPC call function for non-regtest --- src/rpc/client.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/rpc/client.cpp') diff --git a/src/rpc/client.cpp b/src/rpc/client.cpp index b0e9b6f15..6fe16c0cd 100644 --- a/src/rpc/client.cpp +++ b/src/rpc/client.cpp @@ -30,6 +30,7 @@ static const CRPCConvertParam vRPCConvertParams[] = { "setgenerate", 0 }, { "setgenerate", 1 }, { "generate", 0 }, + { "generate", 1 }, { "getnetworkhashps", 0 }, { "getnetworkhashps", 1 }, { "sendtoaddress", 1 }, -- cgit v1.2.3 From fe00ca758a0f1ab2db3f7441c04780630a9df11a Mon Sep 17 00:00:00 2001 From: Andrew C Date: Sat, 12 Mar 2016 11:41:51 -0500 Subject: Create generatetoaddress rpc Creates the generatetoaddress rpc which is virtually identical to the generate rpc except that it takes an argument for the address to mine to. It does not rely on wallet functionality. The mining code shared by generate and generatetoaddress has been moved to another method to reduce duplication. --- src/rpc/client.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/rpc/client.cpp') diff --git a/src/rpc/client.cpp b/src/rpc/client.cpp index 45fb6c164..89420b93d 100644 --- a/src/rpc/client.cpp +++ b/src/rpc/client.cpp @@ -29,6 +29,9 @@ static const CRPCConvertParam vRPCConvertParams[] = { "getaddednodeinfo", 0 }, { "generate", 0 }, { "generate", 1 }, + { "generatetoaddress", 0 }, + { "generatetoaddress", 1 }, + { "generatetoaddress", 2 }, { "getnetworkhashps", 0 }, { "getnetworkhashps", 1 }, { "sendtoaddress", 1 }, -- cgit v1.2.3 From fada0c422c081ba53a324aaf63c0a750cb56498e Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Sun, 3 Apr 2016 11:49:36 +0200 Subject: [doc] Fix doxygen comments for members --- src/rpc/client.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/rpc/client.cpp') diff --git a/src/rpc/client.cpp b/src/rpc/client.cpp index 89420b93d..033987af5 100644 --- a/src/rpc/client.cpp +++ b/src/rpc/client.cpp @@ -18,8 +18,8 @@ using namespace std; class CRPCConvertParam { public: - std::string methodName; //! method whose params want conversion - int paramIdx; //! 0-based idx of param to convert + std::string methodName; //!< method whose params want conversion + int paramIdx; //!< 0-based idx of param to convert }; static const CRPCConvertParam vRPCConvertParams[] = -- cgit v1.2.3 From 60361ca4816dd5b2d10408db3194fb77fcac8720 Mon Sep 17 00:00:00 2001 From: mruddy Date: Sun, 3 Apr 2016 14:30:00 +0000 Subject: RPC: fix generatetoaddress failing to parse address and add unit test --- src/rpc/client.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src/rpc/client.cpp') diff --git a/src/rpc/client.cpp b/src/rpc/client.cpp index 89420b93d..b040d2bc8 100644 --- a/src/rpc/client.cpp +++ b/src/rpc/client.cpp @@ -30,7 +30,6 @@ static const CRPCConvertParam vRPCConvertParams[] = { "generate", 0 }, { "generate", 1 }, { "generatetoaddress", 0 }, - { "generatetoaddress", 1 }, { "generatetoaddress", 2 }, { "getnetworkhashps", 0 }, { "getnetworkhashps", 1 }, -- cgit v1.2.3 From 8f7b5dc4afb28e38ce0223339b8ce77aa0a47845 Mon Sep 17 00:00:00 2001 From: Suhas Daftuar Date: Mon, 4 Jan 2016 13:58:59 -0500 Subject: Add getmempoolancestors RPC call --- src/rpc/client.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/rpc/client.cpp') diff --git a/src/rpc/client.cpp b/src/rpc/client.cpp index c89af6bfa..3dfc27fff 100644 --- a/src/rpc/client.cpp +++ b/src/rpc/client.cpp @@ -102,6 +102,7 @@ static const CRPCConvertParam vRPCConvertParams[] = { "prioritisetransaction", 2 }, { "setban", 2 }, { "setban", 3 }, + { "getmempoolancestors", 1 }, }; class CRPCConvertTable -- cgit v1.2.3 From 0dfd86956dcd2ac8a2223437e9bbd4f29bd35fce Mon Sep 17 00:00:00 2001 From: Suhas Daftuar Date: Mon, 4 Jan 2016 14:48:22 -0500 Subject: Add getmempooldescendants RPC call --- src/rpc/client.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/rpc/client.cpp') diff --git a/src/rpc/client.cpp b/src/rpc/client.cpp index 3dfc27fff..d0675fdb4 100644 --- a/src/rpc/client.cpp +++ b/src/rpc/client.cpp @@ -103,6 +103,7 @@ static const CRPCConvertParam vRPCConvertParams[] = { "setban", 2 }, { "setban", 3 }, { "getmempoolancestors", 1 }, + { "getmempooldescendants", 1 }, }; class CRPCConvertTable -- cgit v1.2.3 From 854f1af22e930cbe37195a5e9ad7dd7b878a9106 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Sun, 26 Jun 2016 20:32:37 +0200 Subject: Make the dummy argument to getaddednodeinfo optional --- src/rpc/client.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src/rpc/client.cpp') diff --git a/src/rpc/client.cpp b/src/rpc/client.cpp index d0675fdb4..3003ea345 100644 --- a/src/rpc/client.cpp +++ b/src/rpc/client.cpp @@ -26,7 +26,6 @@ static const CRPCConvertParam vRPCConvertParams[] = { { "stop", 0 }, { "setmocktime", 0 }, - { "getaddednodeinfo", 0 }, { "generate", 0 }, { "generate", 1 }, { "generatetoaddress", 0 }, -- cgit v1.2.3 From d6a5dc4a2eaa0d7348804254ca09e75fc3a858ab Mon Sep 17 00:00:00 2001 From: Cory Fields Date: Thu, 1 Sep 2016 21:55:21 -0400 Subject: add waitfornewblock/waitforblock/waitforblockheight rpcs and use them for tests waitfornewblock waits until a new block is received, or the timeout expires, then returns the current block height/hash. waitforblock waits for a specific blockhash, or until the timeout expires, then returns the current block height/hash. If the target blockhash is the current tip, it will return immediately. waitforblockheight waits until the tip has reached a certain height or higher, then returns the current height and hash. waitforblockheight is used to avoid polling in the rpc tests. --- src/rpc/client.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/rpc/client.cpp') diff --git a/src/rpc/client.cpp b/src/rpc/client.cpp index 3003ea345..c14d9d674 100644 --- a/src/rpc/client.cpp +++ b/src/rpc/client.cpp @@ -46,6 +46,12 @@ static const CRPCConvertParam vRPCConvertParams[] = { "getbalance", 1 }, { "getbalance", 2 }, { "getblockhash", 0 }, + { "waitforblockheight", 0 }, + { "waitforblockheight", 1 }, + { "waitforblock", 1 }, + { "waitforblock", 2 }, + { "waitfornewblock", 0 }, + { "waitfornewblock", 1 }, { "move", 2 }, { "move", 3 }, { "sendfrom", 2 }, -- cgit v1.2.3 From cb08fdbf78685b55029768524ca867772711c32b Mon Sep 17 00:00:00 2001 From: Pedro Branco Date: Thu, 16 Jun 2016 15:57:48 +0100 Subject: Add importmulti rpc call --- src/rpc/client.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/rpc/client.cpp') diff --git a/src/rpc/client.cpp b/src/rpc/client.cpp index c14d9d674..8370a0f43 100644 --- a/src/rpc/client.cpp +++ b/src/rpc/client.cpp @@ -95,6 +95,8 @@ static const CRPCConvertParam vRPCConvertParams[] = { "importaddress", 2 }, { "importaddress", 3 }, { "importpubkey", 2 }, + { "importmulti", 0 }, + { "importmulti", 1 }, { "verifychain", 0 }, { "verifychain", 1 }, { "keypoolrefill", 0 }, -- cgit v1.2.3 From b2b33d9017cd7bc92099338773313fdf4572dc4a Mon Sep 17 00:00:00 2001 From: Jonas Schnelli Date: Wed, 19 Nov 2014 13:33:34 +0100 Subject: Overhaul network activity toggle - Rename RPC command "togglenetwork" to "setnetworkactive (true|false)" - Add simple test case - GUI toggle added to connections icon in statusbar --- src/rpc/client.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/rpc/client.cpp') diff --git a/src/rpc/client.cpp b/src/rpc/client.cpp index c14d9d674..66648b685 100644 --- a/src/rpc/client.cpp +++ b/src/rpc/client.cpp @@ -107,6 +107,7 @@ static const CRPCConvertParam vRPCConvertParams[] = { "prioritisetransaction", 2 }, { "setban", 2 }, { "setban", 3 }, + { "setnetworkactive", 0 }, { "getmempoolancestors", 1 }, { "getmempooldescendants", 1 }, }; -- cgit v1.2.3 From 27765b6403cece54320374b37afb01a0cfe571c3 Mon Sep 17 00:00:00 2001 From: isle2983 Date: Sat, 31 Dec 2016 11:01:21 -0700 Subject: Increment MIT Licence copyright header year on files modified in 2016 Edited via: $ contrib/devtools/copyright_header.py update . --- src/rpc/client.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/rpc/client.cpp') diff --git a/src/rpc/client.cpp b/src/rpc/client.cpp index 03992a278..e094524bc 100644 --- a/src/rpc/client.cpp +++ b/src/rpc/client.cpp @@ -1,5 +1,5 @@ // Copyright (c) 2010 Satoshi Nakamoto -// Copyright (c) 2009-2015 The Bitcoin Core developers +// Copyright (c) 2009-2016 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -- cgit v1.2.3 From 481f289765fab47ff2e0bd7dfb968f2bd92fd608 Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Tue, 22 Nov 2016 14:56:29 +0100 Subject: 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 --- src/rpc/client.cpp | 225 ++++++++++++++++++++++++++++++++--------------------- 1 file changed, 135 insertions(+), 90 deletions(-) (limited to 'src/rpc/client.cpp') diff --git a/src/rpc/client.cpp b/src/rpc/client.cpp index e094524bc..17d1de676 100644 --- a/src/rpc/client.cpp +++ b/src/rpc/client.cpp @@ -20,104 +20,120 @@ class CRPCConvertParam public: std::string methodName; //!< method whose params want conversion int paramIdx; //!< 0-based idx of param to convert + std::string paramName; //!< parameter name }; +/** + * Specifiy a (method, idx, name) here if the argument is a non-string RPC + * argument and needs to be converted from JSON. + * + * @note Parameter indexes start from 0. + */ static const CRPCConvertParam vRPCConvertParams[] = { - { "stop", 0 }, - { "setmocktime", 0 }, - { "generate", 0 }, - { "generate", 1 }, - { "generatetoaddress", 0 }, - { "generatetoaddress", 2 }, - { "getnetworkhashps", 0 }, - { "getnetworkhashps", 1 }, - { "sendtoaddress", 1 }, - { "sendtoaddress", 4 }, - { "settxfee", 0 }, - { "getreceivedbyaddress", 1 }, - { "getreceivedbyaccount", 1 }, - { "listreceivedbyaddress", 0 }, - { "listreceivedbyaddress", 1 }, - { "listreceivedbyaddress", 2 }, - { "listreceivedbyaccount", 0 }, - { "listreceivedbyaccount", 1 }, - { "listreceivedbyaccount", 2 }, - { "getbalance", 1 }, - { "getbalance", 2 }, - { "getblockhash", 0 }, - { "waitforblockheight", 0 }, - { "waitforblockheight", 1 }, - { "waitforblock", 1 }, - { "waitforblock", 2 }, - { "waitfornewblock", 0 }, - { "waitfornewblock", 1 }, - { "move", 2 }, - { "move", 3 }, - { "sendfrom", 2 }, - { "sendfrom", 3 }, - { "listtransactions", 1 }, - { "listtransactions", 2 }, - { "listtransactions", 3 }, - { "listaccounts", 0 }, - { "listaccounts", 1 }, - { "walletpassphrase", 1 }, - { "getblocktemplate", 0 }, - { "listsinceblock", 1 }, - { "listsinceblock", 2 }, - { "sendmany", 1 }, - { "sendmany", 2 }, - { "sendmany", 4 }, - { "addmultisigaddress", 0 }, - { "addmultisigaddress", 1 }, - { "createmultisig", 0 }, - { "createmultisig", 1 }, - { "listunspent", 0 }, - { "listunspent", 1 }, - { "listunspent", 2 }, - { "getblock", 1 }, - { "getblockheader", 1 }, - { "gettransaction", 1 }, - { "getrawtransaction", 1 }, - { "createrawtransaction", 0 }, - { "createrawtransaction", 1 }, - { "createrawtransaction", 2 }, - { "signrawtransaction", 1 }, - { "signrawtransaction", 2 }, - { "sendrawtransaction", 1 }, - { "fundrawtransaction", 1 }, - { "gettxout", 1 }, - { "gettxout", 2 }, - { "gettxoutproof", 0 }, - { "lockunspent", 0 }, - { "lockunspent", 1 }, - { "importprivkey", 2 }, - { "importaddress", 2 }, - { "importaddress", 3 }, - { "importpubkey", 2 }, - { "importmulti", 0 }, - { "importmulti", 1 }, - { "verifychain", 0 }, - { "verifychain", 1 }, - { "keypoolrefill", 0 }, - { "getrawmempool", 0 }, - { "estimatefee", 0 }, - { "estimatepriority", 0 }, - { "estimatesmartfee", 0 }, - { "estimatesmartpriority", 0 }, - { "prioritisetransaction", 1 }, - { "prioritisetransaction", 2 }, - { "setban", 2 }, - { "setban", 3 }, - { "setnetworkactive", 0 }, - { "getmempoolancestors", 1 }, - { "getmempooldescendants", 1 }, + { "setmocktime", 0, "timestamp" }, + { "generate", 0, "nblocks" }, + { "generate", 1, "maxtries" }, + { "generatetoaddress", 0, "nblocks" }, + { "generatetoaddress", 2, "maxtries" }, + { "getnetworkhashps", 0, "nblocks" }, + { "getnetworkhashps", 1, "height" }, + { "sendtoaddress", 1, "amount" }, + { "sendtoaddress", 4, "subtractfeefromamount" }, + { "settxfee", 0, "amount" }, + { "getreceivedbyaddress", 1, "minconf" }, + { "getreceivedbyaccount", 1, "minconf" }, + { "listreceivedbyaddress", 0, "minconf" }, + { "listreceivedbyaddress", 1, "include_empty" }, + { "listreceivedbyaddress", 2, "include_watchonly" }, + { "listreceivedbyaccount", 0, "minconf" }, + { "listreceivedbyaccount", 1, "include_empty" }, + { "listreceivedbyaccount", 2, "include_watchonly" }, + { "getbalance", 1, "minconf" }, + { "getbalance", 2, "include_watchonly" }, + { "getblockhash", 0, "index" }, + { "waitforblockheight", 0, "height" }, + { "waitforblockheight", 1, "timeout" }, + { "waitforblock", 1, "timeout" }, + { "waitfornewblock", 0, "timeout" }, + { "move", 2, "amount" }, + { "move", 3, "minconf" }, + { "sendfrom", 2, "amount" }, + { "sendfrom", 3, "minconf" }, + { "listtransactions", 1, "count" }, + { "listtransactions", 2, "from" }, + { "listtransactions", 3, "include_watchonly" }, + { "listaccounts", 0, "minconf" }, + { "listaccounts", 1, "include_watchonly" }, + { "walletpassphrase", 1, "timeout" }, + { "getblocktemplate", 0, "template_request" }, + { "listsinceblock", 1, "target_confirmations" }, + { "listsinceblock", 2, "include_watchonly" }, + { "sendmany", 1, "amounts" }, + { "sendmany", 2, "minconf" }, + { "sendmany", 4, "subtractfeefrom" }, + { "addmultisigaddress", 0, "nrequired" }, + { "addmultisigaddress", 1, "keys" }, + { "createmultisig", 0, "nrequired" }, + { "createmultisig", 1, "keys" }, + { "listunspent", 0, "minconf" }, + { "listunspent", 1, "maxconf" }, + { "listunspent", 2, "addresses" }, + { "getblock", 1, "verbose" }, + { "getblockheader", 1, "verbose" }, + { "gettransaction", 1, "include_watchonly" }, + { "getrawtransaction", 1, "verbose" }, + { "createrawtransaction", 0, "transactions" }, + { "createrawtransaction", 1, "outputs" }, + { "createrawtransaction", 2, "locktime" }, + { "signrawtransaction", 1, "prevtxs" }, + { "signrawtransaction", 2, "privkeys" }, + { "sendrawtransaction", 1, "allowhighfees" }, + { "fundrawtransaction", 1, "options" }, + { "gettxout", 1, "n" }, + { "gettxout", 2, "include_mempool" }, + { "gettxoutproof", 0, "txids" }, + { "lockunspent", 0, "unlock" }, + { "lockunspent", 1, "transactions" }, + { "importprivkey", 2, "rescan" }, + { "importaddress", 2, "rescan" }, + { "importaddress", 3, "p2sh" }, + { "importpubkey", 2, "rescan" }, + { "importmulti", 0, "requests" }, + { "importmulti", 1, "options" }, + { "verifychain", 0, "checklevel" }, + { "verifychain", 1, "nblocks" }, + { "keypoolrefill", 0, "newsize" }, + { "getrawmempool", 0, "verbose" }, + { "estimatefee", 0, "nblocks" }, + { "estimatepriority", 0, "nblocks" }, + { "estimatesmartfee", 0, "nblocks" }, + { "estimatesmartpriority", 0, "nblocks" }, + { "prioritisetransaction", 1, "priority_delta" }, + { "prioritisetransaction", 2, "fee_delta" }, + { "setban", 2, "bantime" }, + { "setban", 3, "absolute" }, + { "setnetworkactive", 0, "state" }, + { "getmempoolancestors", 1, "verbose" }, + { "getmempooldescendants", 1, "verbose" }, + // Echo with conversion (For testing only) + { "echojson", 0, "arg0" }, + { "echojson", 1, "arg1" }, + { "echojson", 2, "arg2" }, + { "echojson", 3, "arg3" }, + { "echojson", 4, "arg4" }, + { "echojson", 5, "arg5" }, + { "echojson", 6, "arg6" }, + { "echojson", 7, "arg7" }, + { "echojson", 8, "arg8" }, + { "echojson", 9, "arg9" }, }; class CRPCConvertTable { private: - std::set > members; + std::set> members; + std::set> membersByName; public: CRPCConvertTable(); @@ -125,6 +141,9 @@ public: bool convert(const std::string& method, int idx) { return (members.count(std::make_pair(method, idx)) > 0); } + bool convert(const std::string& method, const std::string& name) { + return (membersByName.count(std::make_pair(method, name)) > 0); + } }; CRPCConvertTable::CRPCConvertTable() @@ -135,6 +154,8 @@ CRPCConvertTable::CRPCConvertTable() for (unsigned int i = 0; i < n_elem; i++) { members.insert(std::make_pair(vRPCConvertParams[i].methodName, vRPCConvertParams[i].paramIdx)); + membersByName.insert(std::make_pair(vRPCConvertParams[i].methodName, + vRPCConvertParams[i].paramName)); } } @@ -152,7 +173,6 @@ UniValue ParseNonRFCJSONValue(const std::string& strVal) return jVal[0]; } -/** Convert strings to command-specific RPC representation */ UniValue RPCConvertValues(const std::string &strMethod, const std::vector &strParams) { UniValue params(UniValue::VARR); @@ -171,3 +191,28 @@ UniValue RPCConvertValues(const std::string &strMethod, const std::vector &strParams) +{ + UniValue params(UniValue::VOBJ); + + for (const std::string &s: strParams) { + size_t pos = s.find("="); + if (pos == std::string::npos) { + throw(std::runtime_error("No '=' in named argument '"+s+"', this needs to be present for every argument (even if it is empty)")); + } + + std::string name = s.substr(0, pos); + std::string value = s.substr(pos+1); + + if (!rpcCvtTable.convert(strMethod, name)) { + // insert string value directly + params.pushKV(name, value); + } else { + // parse string as JSON, insert bool/number/object/etc. value + params.pushKV(name, ParseNonRFCJSONValue(value)); + } + } + + return params; +} -- cgit v1.2.3 From 4e7e2e16e4530be31bfc696a08bd3d1265e6f235 Mon Sep 17 00:00:00 2001 From: John Newbery Date: Fri, 9 Dec 2016 17:06:42 +0000 Subject: Update RPC argument names --- src/rpc/client.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/rpc/client.cpp') diff --git a/src/rpc/client.cpp b/src/rpc/client.cpp index 17d1de676..422d005f0 100644 --- a/src/rpc/client.cpp +++ b/src/rpc/client.cpp @@ -51,7 +51,7 @@ static const CRPCConvertParam vRPCConvertParams[] = { "listreceivedbyaccount", 2, "include_watchonly" }, { "getbalance", 1, "minconf" }, { "getbalance", 2, "include_watchonly" }, - { "getblockhash", 0, "index" }, + { "getblockhash", 0, "height" }, { "waitforblockheight", 0, "height" }, { "waitforblockheight", 1, "timeout" }, { "waitforblock", 1, "timeout" }, @@ -61,7 +61,7 @@ static const CRPCConvertParam vRPCConvertParams[] = { "sendfrom", 2, "amount" }, { "sendfrom", 3, "minconf" }, { "listtransactions", 1, "count" }, - { "listtransactions", 2, "from" }, + { "listtransactions", 2, "skip" }, { "listtransactions", 3, "include_watchonly" }, { "listaccounts", 0, "minconf" }, { "listaccounts", 1, "include_watchonly" }, -- cgit v1.2.3 From 1fc4ec7bf224748d3d6271bffa23d121f015cbf3 Mon Sep 17 00:00:00 2001 From: mrbandrews Date: Tue, 29 Nov 2016 12:39:19 -0500 Subject: Add pruneblockchain RPC to enable manual block file pruning. --- src/rpc/client.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/rpc/client.cpp') diff --git a/src/rpc/client.cpp b/src/rpc/client.cpp index 422d005f0..5d3c45845 100644 --- a/src/rpc/client.cpp +++ b/src/rpc/client.cpp @@ -103,6 +103,7 @@ static const CRPCConvertParam vRPCConvertParams[] = { "importmulti", 1, "options" }, { "verifychain", 0, "checklevel" }, { "verifychain", 1, "nblocks" }, + { "pruneblockchain", 0, "height" }, { "keypoolrefill", 0, "newsize" }, { "getrawmempool", 0, "verbose" }, { "estimatefee", 0, "nblocks" }, -- cgit v1.2.3 From cc0243ad32cee1cc9faab317364b889beaf07647 Mon Sep 17 00:00:00 2001 From: mrbandrews Date: Fri, 9 Dec 2016 13:45:27 -0500 Subject: [RPC] bumpfee This command allows a user to increase the fee on a wallet transaction T, creating a "bumper" transaction B. T must signal that it is BIP-125 replaceable. T's change output is decremented to pay the additional fee. (B will not add inputs to T.) T cannot have any descendant transactions. Once B bumps T, neither T nor B's outputs can be spent until either T or (more likely) B is mined. Includes code by @jonasschnelli and @ryanofsky --- src/rpc/client.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/rpc/client.cpp') diff --git a/src/rpc/client.cpp b/src/rpc/client.cpp index 422d005f0..28d24b84f 100644 --- a/src/rpc/client.cpp +++ b/src/rpc/client.cpp @@ -116,6 +116,7 @@ static const CRPCConvertParam vRPCConvertParams[] = { "setnetworkactive", 0, "state" }, { "getmempoolancestors", 1, "verbose" }, { "getmempooldescendants", 1, "verbose" }, + { "bumpfee", 1, "options" }, // Echo with conversion (For testing only) { "echojson", 0, "arg0" }, { "echojson", 1, "arg1" }, -- cgit v1.2.3 From 142fbb2fec76adee001ffdabfe25ebc462560696 Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Sun, 26 Mar 2017 12:08:44 +0200 Subject: rpc: Rename first named arg of createrawtransaction Github-Pull: #10084 Rebased-From: fa558532192ca0bb519f811ee14df6037413b89f --- src/rpc/client.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/rpc/client.cpp') diff --git a/src/rpc/client.cpp b/src/rpc/client.cpp index 5bdd84e55..56d149591 100644 --- a/src/rpc/client.cpp +++ b/src/rpc/client.cpp @@ -83,7 +83,7 @@ static const CRPCConvertParam vRPCConvertParams[] = { "getblockheader", 1, "verbose" }, { "gettransaction", 1, "include_watchonly" }, { "getrawtransaction", 1, "verbose" }, - { "createrawtransaction", 0, "transactions" }, + { "createrawtransaction", 0, "inputs" }, { "createrawtransaction", 1, "outputs" }, { "createrawtransaction", 2, "locktime" }, { "signrawtransaction", 1, "prevtxs" }, -- cgit v1.2.3