aboutsummaryrefslogtreecommitdiff
path: root/src/rpcclient.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/rpcclient.cpp')
-rw-r--r--src/rpcclient.cpp35
1 files changed, 22 insertions, 13 deletions
diff --git a/src/rpcclient.cpp b/src/rpcclient.cpp
index 428e1049dc..f254da5de0 100644
--- a/src/rpcclient.cpp
+++ b/src/rpcclient.cpp
@@ -7,13 +7,14 @@
#include "rpcprotocol.h"
#include "util.h"
-#include "ui_interface.h"
#include <set>
#include <stdint.h>
+#include <boost/algorithm/string/case_conv.hpp> // for to_lower()
+#include "univalue/univalue.h"
+
using namespace std;
-using namespace json_spirit;
class CRPCConvertParam
{
@@ -79,6 +80,7 @@ static const CRPCConvertParam vRPCConvertParams[] =
{ "sendrawtransaction", 1 },
{ "gettxout", 1 },
{ "gettxout", 2 },
+ { "gettxoutproof", 0 },
{ "lockunspent", 0 },
{ "lockunspent", 1 },
{ "importprivkey", 2 },
@@ -119,25 +121,32 @@ 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 */
-Array RPCConvertValues(const std::string &strMethod, const std::vector<std::string> &strParams)
+UniValue RPCConvertValues(const std::string &strMethod, const std::vector<std::string> &strParams)
{
- Array params;
+ UniValue params(UniValue::VARR);
for (unsigned int idx = 0; idx < strParams.size(); idx++) {
const std::string& strVal = strParams[idx];
- // insert string value directly
if (!rpcCvtTable.convert(strMethod, idx)) {
+ // insert string value directly
params.push_back(strVal);
- }
-
- // parse string as JSON, insert bool/number/object/etc. value
- else {
- Value jVal;
- if (!read_string(strVal, jVal))
- 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));
}
}