From 15982a8b69ec6ab3c3a6bf71fc6a9b681d3ff541 Mon Sep 17 00:00:00 2001 From: Jeff Garzik Date: Wed, 20 Aug 2014 15:15:16 -0400 Subject: Convert tree to using univalue. Eliminate all json_spirit uses. --- src/rpcclient.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/rpcclient.cpp') diff --git a/src/rpcclient.cpp b/src/rpcclient.cpp index 4b576b370..d8c4da420 100644 --- a/src/rpcclient.cpp +++ b/src/rpcclient.cpp @@ -135,7 +135,7 @@ Array RPCConvertValues(const std::string &strMethod, const std::vector Date: Sun, 10 May 2015 13:35:44 +0200 Subject: extend conversion to UniValue --- src/rpcclient.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/rpcclient.cpp') diff --git a/src/rpcclient.cpp b/src/rpcclient.cpp index d8c4da420..8b7b9e149 100644 --- a/src/rpcclient.cpp +++ b/src/rpcclient.cpp @@ -122,7 +122,7 @@ static CRPCConvertTable rpcCvtTable; /** Convert strings to command-specific RPC representation */ Array RPCConvertValues(const std::string &strMethod, const std::vector &strParams) { - Array params; + UniValue params(UniValue::VARR); for (unsigned int idx = 0; idx < strParams.size(); idx++) { const std::string& strVal = strParams[idx]; -- cgit v1.2.3 From 21c10de8c2de17a6357dbbcea7613b41f6ab8449 Mon Sep 17 00:00:00 2001 From: Jonas Schnelli Date: Sun, 10 May 2015 14:49:18 +0200 Subject: special threatment for null,true,false because they are non valid json --- src/rpcclient.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'src/rpcclient.cpp') diff --git a/src/rpcclient.cpp b/src/rpcclient.cpp index 8b7b9e149..bedf9ffbc 100644 --- a/src/rpcclient.cpp +++ b/src/rpcclient.cpp @@ -11,6 +11,8 @@ #include #include +#include // for to_lower() + using namespace std; using namespace json_spirit; @@ -134,9 +136,19 @@ Array RPCConvertValues(const std::string &strMethod, const std::vector Date: Sun, 10 May 2015 15:53:54 +0200 Subject: univalue: add support for real, fix percision and make it json_spirit compatible - avoid breaking the API because of different number/percision handling --- src/rpcclient.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/rpcclient.cpp') diff --git a/src/rpcclient.cpp b/src/rpcclient.cpp index bedf9ffbc..aa6d1eff5 100644 --- a/src/rpcclient.cpp +++ b/src/rpcclient.cpp @@ -146,8 +146,9 @@ Array RPCConvertValues(const std::string &strMethod, const std::vector 0)) + if(!jVal.setNumStr(strVal) || jVal.isNull()) + throw runtime_error(string("Error parsing JSON:")+strVal); } params.push_back(jVal); } -- cgit v1.2.3 From 3df0411ad9fd75fb27af53e44835d41f5480fe3f Mon Sep 17 00:00:00 2001 From: Jonas Schnelli Date: Wed, 13 May 2015 21:29:19 +0200 Subject: remove JSON Spirit UniValue wrapper --- src/rpcclient.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/rpcclient.cpp') diff --git a/src/rpcclient.cpp b/src/rpcclient.cpp index aa6d1eff5..ec098a17a 100644 --- a/src/rpcclient.cpp +++ b/src/rpcclient.cpp @@ -122,7 +122,7 @@ CRPCConvertTable::CRPCConvertTable() static CRPCConvertTable rpcCvtTable; /** Convert strings to command-specific RPC representation */ -Array RPCConvertValues(const std::string &strMethod, const std::vector &strParams) +UniValue RPCConvertValues(const std::string &strMethod, const std::vector &strParams) { UniValue params(UniValue::VARR); -- cgit v1.2.3 From 9a8897f4ac992741e153d88b54bd2cde877c713d Mon Sep 17 00:00:00 2001 From: Jonas Schnelli Date: Mon, 18 May 2015 14:02:18 +0200 Subject: Remove JSON Spirit wrapper, remove JSON Spirit leftovers - implement find_value() function for UniValue - replace all Array/Value/Object types with UniValues, remove JSON Spirit to UniValue wrapper - remove JSON Spirit sources --- src/rpcclient.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/rpcclient.cpp') diff --git a/src/rpcclient.cpp b/src/rpcclient.cpp index ec098a17a..d175db09e 100644 --- a/src/rpcclient.cpp +++ b/src/rpcclient.cpp @@ -12,9 +12,9 @@ #include #include // for to_lower() +#include "univalue/univalue.h" using namespace std; -using namespace json_spirit; class CRPCConvertParam { @@ -137,7 +137,7 @@ UniValue RPCConvertValues(const std::string &strMethod, const std::vector Date: Thu, 4 Jun 2015 10:31:22 +0200 Subject: Simplify RPCclient, adapt json_parse_error test # Conflicts: # src/test/rpc_tests.cpp --- src/rpcclient.cpp | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) (limited to 'src/rpcclient.cpp') diff --git a/src/rpcclient.cpp b/src/rpcclient.cpp index d175db09e..f254da5de 100644 --- a/src/rpcclient.cpp +++ b/src/rpcclient.cpp @@ -121,6 +121,18 @@ CRPCConvertTable::CRPCConvertTable() 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) { @@ -129,28 +141,12 @@ UniValue RPCConvertValues(const std::string &strMethod, const std::vector 0)) - if(!jVal.setNumStr(strVal) || jVal.isNull()) - throw runtime_error(string("Error parsing JSON:")+strVal); - } - params.push_back(jVal); + } else { + // parse string as JSON, insert bool/number/object/etc. value + params.push_back(ParseNonRFCJSONValue(strVal)); } } -- cgit v1.2.3 From 076badb60f33f0c32b035de220ca14c52a423a2a Mon Sep 17 00:00:00 2001 From: Peter Todd Date: Fri, 5 Jun 2015 17:07:17 -0230 Subject: Add getblockheader RPC call Alternative to getblock that works even when the block itself has been pruned, returning all available information. --- src/rpcclient.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/rpcclient.cpp') diff --git a/src/rpcclient.cpp b/src/rpcclient.cpp index f254da5de..b15df6a9b 100644 --- a/src/rpcclient.cpp +++ b/src/rpcclient.cpp @@ -71,6 +71,7 @@ static const CRPCConvertParam vRPCConvertParams[] = { "listunspent", 1 }, { "listunspent", 2 }, { "getblock", 1 }, + { "getblockheader", 1 }, { "gettransaction", 1 }, { "getrawtransaction", 1 }, { "createrawtransaction", 0 }, -- cgit v1.2.3 From 21bbd920e5cc02dae5e75795c1f0bbfba9a41b53 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Fri, 24 Apr 2015 18:27:30 -0700 Subject: Add fundrawtransaction RPC method --- src/rpcclient.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/rpcclient.cpp') diff --git a/src/rpcclient.cpp b/src/rpcclient.cpp index f254da5de..ca673aa52 100644 --- a/src/rpcclient.cpp +++ b/src/rpcclient.cpp @@ -78,6 +78,7 @@ static const CRPCConvertParam vRPCConvertParams[] = { "signrawtransaction", 1 }, { "signrawtransaction", 2 }, { "sendrawtransaction", 1 }, + { "fundrawtransaction", 1 }, { "gettxout", 1 }, { "gettxout", 2 }, { "gettxoutproof", 0 }, -- cgit v1.2.3 From d930b26a264ed7eae6ce239f3bfb4ff023df8195 Mon Sep 17 00:00:00 2001 From: Jonas Schnelli Date: Tue, 19 May 2015 10:07:46 +0200 Subject: [RPC] add setban/listbanned/clearbanned RPC commands --- src/rpcclient.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/rpcclient.cpp') diff --git a/src/rpcclient.cpp b/src/rpcclient.cpp index f254da5de..1cc516e7b 100644 --- a/src/rpcclient.cpp +++ b/src/rpcclient.cpp @@ -93,6 +93,7 @@ static const CRPCConvertParam vRPCConvertParams[] = { "estimatepriority", 0 }, { "prioritisetransaction", 1 }, { "prioritisetransaction", 2 }, + { "setban", 2 }, }; class CRPCConvertTable -- cgit v1.2.3 From 4e36e9bcc7d071bba4c45fd89c0cfd2e2361ffe3 Mon Sep 17 00:00:00 2001 From: Jonas Schnelli Date: Fri, 12 Jun 2015 18:31:47 +0200 Subject: setban: rewrite to UniValue, allow absolute bantime --- src/rpcclient.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/rpcclient.cpp') diff --git a/src/rpcclient.cpp b/src/rpcclient.cpp index 1cc516e7b..1d94e4f61 100644 --- a/src/rpcclient.cpp +++ b/src/rpcclient.cpp @@ -94,6 +94,7 @@ static const CRPCConvertParam vRPCConvertParams[] = { "prioritisetransaction", 1 }, { "prioritisetransaction", 2 }, { "setban", 2 }, + { "setban", 3 }, }; class CRPCConvertTable -- cgit v1.2.3 From 907a425aa5b8fd90cf1d28215712a309e934b364 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Thu, 11 Jun 2015 00:57:50 -0700 Subject: Add p2sh option to importaddress to import redeemScripts --- src/rpcclient.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/rpcclient.cpp') diff --git a/src/rpcclient.cpp b/src/rpcclient.cpp index b41e960e8..450f33b3e 100644 --- a/src/rpcclient.cpp +++ b/src/rpcclient.cpp @@ -87,6 +87,7 @@ static const CRPCConvertParam vRPCConvertParams[] = { "lockunspent", 1 }, { "importprivkey", 2 }, { "importaddress", 2 }, + { "importaddress", 3 }, { "verifychain", 0 }, { "verifychain", 1 }, { "keypoolrefill", 0 }, -- cgit v1.2.3 From a1d7df32360605724d8f0ea4b7aebfa7aea24c97 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Thu, 9 Jul 2015 22:47:36 -0700 Subject: Add importpubkey method to import a watch-only pubkey --- src/rpcclient.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/rpcclient.cpp') diff --git a/src/rpcclient.cpp b/src/rpcclient.cpp index 450f33b3e..0c8e6d6d6 100644 --- a/src/rpcclient.cpp +++ b/src/rpcclient.cpp @@ -88,6 +88,7 @@ static const CRPCConvertParam vRPCConvertParams[] = { "importprivkey", 2 }, { "importaddress", 2 }, { "importaddress", 3 }, + { "importpubkey", 2 }, { "verifychain", 0 }, { "verifychain", 1 }, { "keypoolrefill", 0 }, -- cgit v1.2.3 From 212bcca92089f406d9313dbe6d0e1d25143d61ff Mon Sep 17 00:00:00 2001 From: Tom Harding Date: Sun, 22 Mar 2015 10:51:43 -0700 Subject: Add optional locktime to createrawtransaction A non-zero locktime also causes input sequences to be set to non-max, activating the locktime. --- src/rpcclient.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/rpcclient.cpp') diff --git a/src/rpcclient.cpp b/src/rpcclient.cpp index b41e960e8..85c05354a 100644 --- a/src/rpcclient.cpp +++ b/src/rpcclient.cpp @@ -76,6 +76,7 @@ static const CRPCConvertParam vRPCConvertParams[] = { "getrawtransaction", 1 }, { "createrawtransaction", 0 }, { "createrawtransaction", 1 }, + { "createrawtransaction", 2 }, { "signrawtransaction", 1 }, { "signrawtransaction", 2 }, { "sendrawtransaction", 1 }, -- cgit v1.2.3 From 9623e934732ba0f0a5176cd3d993ebcda327b413 Mon Sep 17 00:00:00 2001 From: Jonas Schnelli Date: Fri, 4 Sep 2015 16:11:34 +0200 Subject: [Univalue] add univalue over subtree similar to secp256k1 include and compile univalue over a subtree --- src/rpcclient.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/rpcclient.cpp') diff --git a/src/rpcclient.cpp b/src/rpcclient.cpp index 0c8e6d6d6..4064c2fee 100644 --- a/src/rpcclient.cpp +++ b/src/rpcclient.cpp @@ -12,7 +12,7 @@ #include #include // for to_lower() -#include "univalue/univalue.h" +#include using namespace std; -- cgit v1.2.3 From 56106a3300f844afcadf6dce50d5ef1d337f50b9 Mon Sep 17 00:00:00 2001 From: Alex Morcos Date: Mon, 16 Nov 2015 15:26:57 -0500 Subject: Expose RPC calls for estimatesmart functions Also add testing for estimatesmartfee in smartfees.py --- src/rpcclient.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/rpcclient.cpp') diff --git a/src/rpcclient.cpp b/src/rpcclient.cpp index 343b6234d..cab581901 100644 --- a/src/rpcclient.cpp +++ b/src/rpcclient.cpp @@ -96,6 +96,8 @@ static const CRPCConvertParam vRPCConvertParams[] = { "getrawmempool", 0 }, { "estimatefee", 0 }, { "estimatepriority", 0 }, + { "estimatesmartfee", 0 }, + { "estimatesmartpriority", 0 }, { "prioritisetransaction", 1 }, { "prioritisetransaction", 2 }, { "setban", 2 }, -- cgit v1.2.3 From fa24439ff3d8ab5b9efaf66ef4dae6713b88cb35 Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Sun, 13 Dec 2015 17:58:29 +0100 Subject: Bump copyright headers to 2015 --- src/rpcclient.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/rpcclient.cpp') diff --git a/src/rpcclient.cpp b/src/rpcclient.cpp index cab581901..047158023 100644 --- a/src/rpcclient.cpp +++ b/src/rpcclient.cpp @@ -1,5 +1,5 @@ // Copyright (c) 2010 Satoshi Nakamoto -// Copyright (c) 2009-2014 The Bitcoin Core developers +// 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. -- cgit v1.2.3 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/rpcclient.cpp | 164 ------------------------------------------------------ 1 file changed, 164 deletions(-) delete mode 100644 src/rpcclient.cpp (limited to 'src/rpcclient.cpp') diff --git a/src/rpcclient.cpp b/src/rpcclient.cpp deleted file mode 100644 index 047158023..000000000 --- a/src/rpcclient.cpp +++ /dev/null @@ -1,164 +0,0 @@ -// 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 "rpcclient.h" - -#include "rpcprotocol.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