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/rpcmisc.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/rpcmisc.cpp') diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index f5bef2a077..f7bd3e0d5a 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -20,8 +20,7 @@ #include #include -#include "json/json_spirit_utils.h" -#include "json/json_spirit_value.h" +#include "json_spirit_wrapper.h" using namespace json_spirit; using namespace std; @@ -204,7 +203,7 @@ Value validateaddress(const Array& params, bool fHelp) if (mine != ISMINE_NO) { ret.push_back(Pair("iswatchonly", (mine & ISMINE_WATCH_ONLY) ? true: false)); Object detail = boost::apply_visitor(DescribeAddressVisitor(mine), dest); - ret.insert(ret.end(), detail.begin(), detail.end()); + ret.pushKVs(detail); } if (pwalletMain && pwalletMain->mapAddressBook.count(dest)) ret.push_back(Pair("account", pwalletMain->mapAddressBook[dest].name)); -- cgit v1.2.3 From 53b4671a9de75f7c8e2903d510cf88867c3f6b97 Mon Sep 17 00:00:00 2001 From: Jonas Schnelli Date: Sun, 10 May 2015 13:35:44 +0200 Subject: extend conversion to UniValue --- src/rpcmisc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/rpcmisc.cpp') diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index f7bd3e0d5a..b06408f21e 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -389,8 +389,8 @@ Value setmocktime(const Array& params, bool fHelp) LOCK(cs_main); - RPCTypeCheck(params, boost::assign::list_of(int_type)); + RPCTypeCheck(params, boost::assign::list_of(UniValue::VNUM)); SetMockTime(params[0].get_int64()); - return Value::null; + return NullUniValue; } -- cgit v1.2.3 From 6c7bee062437acbc078533fdcf8e53794031bf99 Mon Sep 17 00:00:00 2001 From: Jonas Schnelli Date: Sun, 10 May 2015 14:48:35 +0200 Subject: expicit set UniValue type to avoid empty values --- src/rpcmisc.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/rpcmisc.cpp') diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index b06408f21e..2d54b555b9 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -77,7 +77,7 @@ Value getinfo(const Array& params, bool fHelp) proxyType proxy; GetProxy(NET_IPV4, proxy); - Object obj; + UniValue obj(UniValue::VOBJ); obj.push_back(Pair("version", CLIENT_VERSION)); obj.push_back(Pair("protocolversion", PROTOCOL_VERSION)); #ifdef ENABLE_WALLET @@ -118,7 +118,7 @@ public: Object operator()(const CNoDestination &dest) const { return Object(); } Object operator()(const CKeyID &keyID) const { - Object obj; + UniValue obj(UniValue::VOBJ); CPubKey vchPubKey; obj.push_back(Pair("isscript", false)); if (mine == ISMINE_SPENDABLE) { @@ -130,7 +130,7 @@ public: } Object operator()(const CScriptID &scriptID) const { - Object obj; + UniValue obj(UniValue::VOBJ); obj.push_back(Pair("isscript", true)); if (mine != ISMINE_NO) { CScript subscript; @@ -141,7 +141,7 @@ public: ExtractDestinations(subscript, whichType, addresses, nRequired); obj.push_back(Pair("script", GetTxnOutputType(whichType))); obj.push_back(Pair("hex", HexStr(subscript.begin(), subscript.end()))); - Array a; + UniValue a(UniValue::VARR); BOOST_FOREACH(const CTxDestination& addr, addresses) a.push_back(CBitcoinAddress(addr).ToString()); obj.push_back(Pair("addresses", a)); @@ -186,7 +186,7 @@ Value validateaddress(const Array& params, bool fHelp) CBitcoinAddress address(params[0].get_str()); bool isValid = address.IsValid(); - Object ret; + UniValue ret(UniValue::VOBJ); ret.push_back(Pair("isvalid", isValid)); if (isValid) { @@ -312,7 +312,7 @@ Value createmultisig(const Array& params, bool fHelp) CScriptID innerID(inner); CBitcoinAddress address(innerID); - Object result; + UniValue result; result.push_back(Pair("address", address.ToString())); result.push_back(Pair("redeemScript", HexStr(inner.begin(), inner.end()))); -- 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/rpcmisc.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/rpcmisc.cpp') diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 2d54b555b9..15bbe90bc7 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -38,7 +38,7 @@ using namespace std; * * Or alternatively, create a specific query method for the information. **/ -Value getinfo(const Array& params, bool fHelp) +UniValue getinfo(const Array& params, bool fHelp) { if (fHelp || params.size() != 0) throw runtime_error( @@ -115,9 +115,9 @@ private: public: DescribeAddressVisitor(isminetype mineIn) : mine(mineIn) {} - Object operator()(const CNoDestination &dest) const { return Object(); } + UniValue operator()(const CNoDestination &dest) const { return Object(); } - Object operator()(const CKeyID &keyID) const { + UniValue operator()(const CKeyID &keyID) const { UniValue obj(UniValue::VOBJ); CPubKey vchPubKey; obj.push_back(Pair("isscript", false)); @@ -129,7 +129,7 @@ public: return obj; } - Object operator()(const CScriptID &scriptID) const { + UniValue operator()(const CScriptID &scriptID) const { UniValue obj(UniValue::VOBJ); obj.push_back(Pair("isscript", true)); if (mine != ISMINE_NO) { @@ -153,7 +153,7 @@ public: }; #endif -Value validateaddress(const Array& params, bool fHelp) +UniValue validateaddress(const Array& params, bool fHelp) { if (fHelp || params.size() != 1) throw runtime_error( @@ -202,7 +202,7 @@ Value validateaddress(const Array& params, bool fHelp) ret.push_back(Pair("ismine", (mine & ISMINE_SPENDABLE) ? true : false)); if (mine != ISMINE_NO) { ret.push_back(Pair("iswatchonly", (mine & ISMINE_WATCH_ONLY) ? true: false)); - Object detail = boost::apply_visitor(DescribeAddressVisitor(mine), dest); + UniValue detail = boost::apply_visitor(DescribeAddressVisitor(mine), dest); ret.pushKVs(detail); } if (pwalletMain && pwalletMain->mapAddressBook.count(dest)) @@ -276,7 +276,7 @@ CScript _createmultisig_redeemScript(const Array& params) return result; } -Value createmultisig(const Array& params, bool fHelp) +UniValue createmultisig(const Array& params, bool fHelp) { if (fHelp || params.size() < 2 || params.size() > 2) { @@ -319,7 +319,7 @@ Value createmultisig(const Array& params, bool fHelp) return result; } -Value verifymessage(const Array& params, bool fHelp) +UniValue verifymessage(const Array& params, bool fHelp) { if (fHelp || params.size() != 3) throw runtime_error( @@ -373,7 +373,7 @@ Value verifymessage(const Array& params, bool fHelp) return (pubkey.GetID() == keyID); } -Value setmocktime(const Array& params, bool fHelp) +UniValue setmocktime(const Array& params, bool fHelp) { if (fHelp || params.size() != 1) throw runtime_error( -- 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/rpcmisc.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src/rpcmisc.cpp') diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 15bbe90bc7..f5fc22aff1 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -20,9 +20,9 @@ #include #include -#include "json_spirit_wrapper.h" -using namespace json_spirit; +#include "univalue/univalue.h" + using namespace std; /** @@ -38,7 +38,7 @@ using namespace std; * * Or alternatively, create a specific query method for the information. **/ -UniValue getinfo(const Array& params, bool fHelp) +UniValue getinfo(const UniValue& params, bool fHelp) { if (fHelp || params.size() != 0) throw runtime_error( @@ -107,7 +107,7 @@ UniValue getinfo(const Array& params, bool fHelp) } #ifdef ENABLE_WALLET -class DescribeAddressVisitor : public boost::static_visitor +class DescribeAddressVisitor : public boost::static_visitor { private: isminetype mine; @@ -115,7 +115,7 @@ private: public: DescribeAddressVisitor(isminetype mineIn) : mine(mineIn) {} - UniValue operator()(const CNoDestination &dest) const { return Object(); } + UniValue operator()(const CNoDestination &dest) const { return UniValue(UniValue::VOBJ); } UniValue operator()(const CKeyID &keyID) const { UniValue obj(UniValue::VOBJ); @@ -153,7 +153,7 @@ public: }; #endif -UniValue validateaddress(const Array& params, bool fHelp) +UniValue validateaddress(const UniValue& params, bool fHelp) { if (fHelp || params.size() != 1) throw runtime_error( @@ -215,10 +215,10 @@ UniValue validateaddress(const Array& params, bool fHelp) /** * Used by addmultisigaddress / createmultisig: */ -CScript _createmultisig_redeemScript(const Array& params) +CScript _createmultisig_redeemScript(const UniValue& params) { int nRequired = params[0].get_int(); - const Array& keys = params[1].get_array(); + const UniValue& keys = params[1].get_array(); // Gather public keys if (nRequired < 1) @@ -276,7 +276,7 @@ CScript _createmultisig_redeemScript(const Array& params) return result; } -UniValue createmultisig(const Array& params, bool fHelp) +UniValue createmultisig(const UniValue& params, bool fHelp) { if (fHelp || params.size() < 2 || params.size() > 2) { @@ -319,7 +319,7 @@ UniValue createmultisig(const Array& params, bool fHelp) return result; } -UniValue verifymessage(const Array& params, bool fHelp) +UniValue verifymessage(const UniValue& params, bool fHelp) { if (fHelp || params.size() != 3) throw runtime_error( @@ -373,7 +373,7 @@ UniValue verifymessage(const Array& params, bool fHelp) return (pubkey.GetID() == keyID); } -UniValue setmocktime(const Array& params, bool fHelp) +UniValue setmocktime(const UniValue& params, bool fHelp) { if (fHelp || params.size() != 1) throw runtime_error( -- cgit v1.2.3 From c7fbbc7e1d7b076f68f0b2d87f7e86faba5d3a26 Mon Sep 17 00:00:00 2001 From: Jonas Schnelli Date: Tue, 2 Jun 2015 12:28:54 +0200 Subject: fix missing univalue types during constructing --- src/rpcmisc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/rpcmisc.cpp') diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index f5fc22aff1..fe6eb81b84 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -312,7 +312,7 @@ UniValue createmultisig(const UniValue& params, bool fHelp) CScriptID innerID(inner); CBitcoinAddress address(innerID); - UniValue result; + UniValue result(UniValue::VOBJ); result.push_back(Pair("address", address.ToString())); result.push_back(Pair("redeemScript", HexStr(inner.begin(), inner.end()))); -- cgit v1.2.3