Convert tree to using univalue. Eliminate all json_spirit uses.
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
|
||||
#include "utiltime.h"
|
||||
#include "asyncrpcoperation.h"
|
||||
#include "asyncrpcqueue.h"
|
||||
#include "wallet/asyncrpcoperation_sendmany.h"
|
||||
|
||||
#include "sodium.h"
|
||||
@@ -30,9 +31,7 @@
|
||||
|
||||
#include <boost/assign/list_of.hpp>
|
||||
|
||||
#include "json/json_spirit_utils.h"
|
||||
#include "json/json_spirit_value.h"
|
||||
#include "asyncrpcqueue.h"
|
||||
#include "json_spirit_wrapper.h"
|
||||
|
||||
#include <numeric>
|
||||
|
||||
@@ -294,7 +293,7 @@ Value setaccount(const Array& params, bool fHelp)
|
||||
else
|
||||
throw JSONRPCError(RPC_MISC_ERROR, "setaccount can only be used with own address");
|
||||
|
||||
return Value::null;
|
||||
return NullUniValue;
|
||||
}
|
||||
|
||||
|
||||
@@ -438,9 +437,9 @@ Value sendtoaddress(const Array& params, bool fHelp)
|
||||
|
||||
// Wallet comments
|
||||
CWalletTx wtx;
|
||||
if (params.size() > 2 && params[2].type() != null_type && !params[2].get_str().empty())
|
||||
if (params.size() > 2 && !params[2].isNull() && !params[2].get_str().empty())
|
||||
wtx.mapValue["comment"] = params[2].get_str();
|
||||
if (params.size() > 3 && params[3].type() != null_type && !params[3].get_str().empty())
|
||||
if (params.size() > 3 && !params[3].isNull() && !params[3].get_str().empty())
|
||||
wtx.mapValue["to"] = params[3].get_str();
|
||||
|
||||
bool fSubtractFeeFromAmount = false;
|
||||
@@ -911,9 +910,9 @@ Value sendfrom(const Array& params, bool fHelp)
|
||||
|
||||
CWalletTx wtx;
|
||||
wtx.strFromAccount = strAccount;
|
||||
if (params.size() > 4 && params[4].type() != null_type && !params[4].get_str().empty())
|
||||
if (params.size() > 4 && !params[4].isNull() && !params[4].get_str().empty())
|
||||
wtx.mapValue["comment"] = params[4].get_str();
|
||||
if (params.size() > 5 && params[5].type() != null_type && !params[5].get_str().empty())
|
||||
if (params.size() > 5 && !params[5].isNull() && !params[5].get_str().empty())
|
||||
wtx.mapValue["to"] = params[5].get_str();
|
||||
|
||||
EnsureWalletIsUnlocked();
|
||||
@@ -980,7 +979,7 @@ Value sendmany(const Array& params, bool fHelp)
|
||||
|
||||
CWalletTx wtx;
|
||||
wtx.strFromAccount = strAccount;
|
||||
if (params.size() > 3 && params[3].type() != null_type && !params[3].get_str().empty())
|
||||
if (params.size() > 3 && !params[3].isNull() && !params[3].get_str().empty())
|
||||
wtx.mapValue["comment"] = params[3].get_str();
|
||||
|
||||
Array subtractFeeFromAmount;
|
||||
@@ -991,18 +990,19 @@ Value sendmany(const Array& params, bool fHelp)
|
||||
vector<CRecipient> vecSend;
|
||||
|
||||
CAmount totalAmount = 0;
|
||||
BOOST_FOREACH(const Pair& s, sendTo)
|
||||
vector<string> keys = sendTo.getKeys();
|
||||
BOOST_FOREACH(const string& name_, keys)
|
||||
{
|
||||
CBitcoinAddress address(s.name_);
|
||||
CBitcoinAddress address(name_);
|
||||
if (!address.IsValid())
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, string("Invalid Zcash address: ")+s.name_);
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, string("Invalid Zcash address: ")+name_);
|
||||
|
||||
if (setAddress.count(address))
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, string("Invalid parameter, duplicated address: ")+s.name_);
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, string("Invalid parameter, duplicated address: ")+name_);
|
||||
setAddress.insert(address);
|
||||
|
||||
CScript scriptPubKey = GetScriptForDestination(address.Get());
|
||||
CAmount nAmount = AmountFromValue(s.value_);
|
||||
CAmount nAmount = AmountFromValue(sendTo[name_]);
|
||||
totalAmount += nAmount;
|
||||
|
||||
bool fSubtractFeeFromAmount = false;
|
||||
@@ -1490,15 +1490,21 @@ Value listtransactions(const Array& params, bool fHelp)
|
||||
nFrom = ret.size();
|
||||
if ((nFrom + nCount) > (int)ret.size())
|
||||
nCount = ret.size() - nFrom;
|
||||
Array::iterator first = ret.begin();
|
||||
|
||||
vector<UniValue> arrTmp = ret.getValues();
|
||||
|
||||
vector<UniValue>::iterator first = arrTmp.begin();
|
||||
std::advance(first, nFrom);
|
||||
Array::iterator last = ret.begin();
|
||||
vector<UniValue>::iterator last = arrTmp.begin();
|
||||
std::advance(last, nFrom+nCount);
|
||||
|
||||
if (last != ret.end()) ret.erase(last, ret.end());
|
||||
if (first != ret.begin()) ret.erase(ret.begin(), first);
|
||||
if (last != arrTmp.end()) arrTmp.erase(last, arrTmp.end());
|
||||
if (first != arrTmp.begin()) arrTmp.erase(arrTmp.begin(), first);
|
||||
|
||||
std::reverse(ret.begin(), ret.end()); // Return oldest to newest
|
||||
std::reverse(arrTmp.begin(), arrTmp.end()); // Return oldest to newest
|
||||
|
||||
ret.clear();
|
||||
ret.push_backV(arrTmp);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -1839,7 +1845,7 @@ Value keypoolrefill(const Array& params, bool fHelp)
|
||||
if (pwalletMain->GetKeyPoolSize() < kpSize)
|
||||
throw JSONRPCError(RPC_WALLET_ERROR, "Error refreshing keypool.");
|
||||
|
||||
return Value::null;
|
||||
return NullUniValue;
|
||||
}
|
||||
|
||||
|
||||
@@ -1908,7 +1914,7 @@ Value walletpassphrase(const Array& params, bool fHelp)
|
||||
nWalletUnlockTime = GetTime() + nSleepTime;
|
||||
RPCRunLater("lockwallet", boost::bind(LockWallet, pwalletMain), nSleepTime);
|
||||
|
||||
return Value::null;
|
||||
return NullUniValue;
|
||||
}
|
||||
|
||||
|
||||
@@ -1954,7 +1960,7 @@ Value walletpassphrasechange(const Array& params, bool fHelp)
|
||||
if (!pwalletMain->ChangeWalletPassphrase(strOldWalletPass, strNewWalletPass))
|
||||
throw JSONRPCError(RPC_WALLET_PASSPHRASE_INCORRECT, "Error: The wallet passphrase entered was incorrect.");
|
||||
|
||||
return Value::null;
|
||||
return NullUniValue;
|
||||
}
|
||||
|
||||
|
||||
@@ -1993,7 +1999,7 @@ Value walletlock(const Array& params, bool fHelp)
|
||||
nWalletUnlockTime = 0;
|
||||
}
|
||||
|
||||
return Value::null;
|
||||
return NullUniValue;
|
||||
}
|
||||
|
||||
|
||||
@@ -2109,9 +2115,9 @@ Value lockunspent(const Array& params, bool fHelp)
|
||||
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||
|
||||
if (params.size() == 1)
|
||||
RPCTypeCheck(params, boost::assign::list_of(bool_type));
|
||||
RPCTypeCheck(params, boost::assign::list_of(UniValue::VBOOL));
|
||||
else
|
||||
RPCTypeCheck(params, boost::assign::list_of(bool_type)(array_type));
|
||||
RPCTypeCheck(params, boost::assign::list_of(UniValue::VBOOL)(UniValue::VARR));
|
||||
|
||||
bool fUnlock = params[0].get_bool();
|
||||
|
||||
@@ -2122,13 +2128,13 @@ Value lockunspent(const Array& params, bool fHelp)
|
||||
}
|
||||
|
||||
Array outputs = params[1].get_array();
|
||||
BOOST_FOREACH(Value& output, outputs)
|
||||
{
|
||||
if (output.type() != obj_type)
|
||||
for (unsigned int idx = 0; idx < outputs.size(); idx++) {
|
||||
const UniValue& output = outputs[idx];
|
||||
if (!output.isObject())
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, expected object");
|
||||
const Object& o = output.get_obj();
|
||||
|
||||
RPCTypeCheck(o, boost::assign::map_list_of("txid", str_type)("vout", int_type));
|
||||
RPCTypeCheckObj(o, boost::assign::map_list_of("txid", UniValue::VSTR)("vout", UniValue::VNUM));
|
||||
|
||||
string txid = find_value(o, "txid").get_str();
|
||||
if (!IsHex(txid))
|
||||
|
||||
Reference in New Issue
Block a user