extend conversion to UniValue
This commit is contained in:
parent
15982a8b69
commit
53b4671a9d
13 changed files with 76 additions and 69 deletions
|
@ -98,6 +98,7 @@ BITCOIN_CORE_H = \
|
||||||
ecwrapper.h \
|
ecwrapper.h \
|
||||||
hash.h \
|
hash.h \
|
||||||
init.h \
|
init.h \
|
||||||
|
json_spirit_wrapper.h \
|
||||||
key.h \
|
key.h \
|
||||||
keystore.h \
|
keystore.h \
|
||||||
leveldbwrapper.h \
|
leveldbwrapper.h \
|
||||||
|
|
|
@ -142,7 +142,7 @@ Object CallRPC(const string& strMethod, const Array& params)
|
||||||
throw runtime_error("no response from server");
|
throw runtime_error("no response from server");
|
||||||
|
|
||||||
// Parse reply
|
// Parse reply
|
||||||
Value valReply;
|
Value valReply(UniValue::VSTR);
|
||||||
if (!valReply.read(strReply))
|
if (!valReply.read(strReply))
|
||||||
throw runtime_error("couldn't parse reply from server");
|
throw runtime_error("couldn't parse reply from server");
|
||||||
const Object& reply = valReply.get_obj();
|
const Object& reply = valReply.get_obj();
|
||||||
|
|
|
@ -222,7 +222,7 @@ static bool rest_block(AcceptedConnection* conn,
|
||||||
|
|
||||||
case RF_JSON: {
|
case RF_JSON: {
|
||||||
Object objBlock = blockToJSON(block, pblockindex, showTxDetails);
|
Object objBlock = blockToJSON(block, pblockindex, showTxDetails);
|
||||||
string strJSON = write_string(Value(objBlock), false) + "\n";
|
string strJSON = objBlock.write() + "\n";
|
||||||
conn->stream() << HTTPReply(HTTP_OK, strJSON, fRun) << std::flush;
|
conn->stream() << HTTPReply(HTTP_OK, strJSON, fRun) << std::flush;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -267,8 +267,7 @@ static bool rest_chaininfo(AcceptedConnection* conn,
|
||||||
case RF_JSON: {
|
case RF_JSON: {
|
||||||
Array rpcParams;
|
Array rpcParams;
|
||||||
Value chainInfoObject = getblockchaininfo(rpcParams, false);
|
Value chainInfoObject = getblockchaininfo(rpcParams, false);
|
||||||
|
string strJSON = chainInfoObject.write() + "\n";
|
||||||
string strJSON = write_string(chainInfoObject, false) + "\n";
|
|
||||||
conn->stream() << HTTPReply(HTTP_OK, strJSON, fRun) << std::flush;
|
conn->stream() << HTTPReply(HTTP_OK, strJSON, fRun) << std::flush;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -319,7 +318,7 @@ static bool rest_tx(AcceptedConnection* conn,
|
||||||
case RF_JSON: {
|
case RF_JSON: {
|
||||||
Object objTx;
|
Object objTx;
|
||||||
TxToJSON(tx, hashBlock, objTx);
|
TxToJSON(tx, hashBlock, objTx);
|
||||||
string strJSON = write_string(Value(objTx), false) + "\n";
|
string strJSON = objTx.write() + "\n";
|
||||||
conn->stream() << HTTPReply(HTTP_OK, strJSON, fRun) << std::flush;
|
conn->stream() << HTTPReply(HTTP_OK, strJSON, fRun) << std::flush;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -516,7 +515,7 @@ static bool rest_getutxos(AcceptedConnection* conn,
|
||||||
objGetUTXOResponse.push_back(Pair("utxos", utxos));
|
objGetUTXOResponse.push_back(Pair("utxos", utxos));
|
||||||
|
|
||||||
// return json string
|
// return json string
|
||||||
string strJSON = write_string(Value(objGetUTXOResponse), false) + "\n";
|
string strJSON = objGetUTXOResponse.write() + "\n";
|
||||||
conn->stream() << HTTPReply(HTTP_OK, strJSON, fRun) << std::flush;
|
conn->stream() << HTTPReply(HTTP_OK, strJSON, fRun) << std::flush;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -678,7 +678,7 @@ Value invalidateblock(const Array& params, bool fHelp)
|
||||||
throw JSONRPCError(RPC_DATABASE_ERROR, state.GetRejectReason());
|
throw JSONRPCError(RPC_DATABASE_ERROR, state.GetRejectReason());
|
||||||
}
|
}
|
||||||
|
|
||||||
return Value::null;
|
return NullUniValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Value reconsiderblock(const Array& params, bool fHelp)
|
Value reconsiderblock(const Array& params, bool fHelp)
|
||||||
|
@ -717,5 +717,5 @@ Value reconsiderblock(const Array& params, bool fHelp)
|
||||||
throw JSONRPCError(RPC_DATABASE_ERROR, state.GetRejectReason());
|
throw JSONRPCError(RPC_DATABASE_ERROR, state.GetRejectReason());
|
||||||
}
|
}
|
||||||
|
|
||||||
return Value::null;
|
return NullUniValue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,7 +122,7 @@ static CRPCConvertTable rpcCvtTable;
|
||||||
/** Convert strings to command-specific RPC representation */
|
/** Convert strings to command-specific RPC representation */
|
||||||
Array RPCConvertValues(const std::string &strMethod, const std::vector<std::string> &strParams)
|
Array 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++) {
|
for (unsigned int idx = 0; idx < strParams.size(); idx++) {
|
||||||
const std::string& strVal = strParams[idx];
|
const std::string& strVal = strParams[idx];
|
||||||
|
|
|
@ -399,7 +399,7 @@ Value getblocktemplate(const Array& params, bool fHelp)
|
||||||
if (strMode == "proposal")
|
if (strMode == "proposal")
|
||||||
{
|
{
|
||||||
const Value& dataval = find_value(oparam, "data");
|
const Value& dataval = find_value(oparam, "data");
|
||||||
if (dataval.type() != str_type)
|
if (dataval.isStr())
|
||||||
throw JSONRPCError(RPC_TYPE_ERROR, "Missing data String key for proposal");
|
throw JSONRPCError(RPC_TYPE_ERROR, "Missing data String key for proposal");
|
||||||
|
|
||||||
CBlock block;
|
CBlock block;
|
||||||
|
@ -519,7 +519,7 @@ Value getblocktemplate(const Array& params, bool fHelp)
|
||||||
UpdateTime(pblock, Params().GetConsensus(), pindexPrev);
|
UpdateTime(pblock, Params().GetConsensus(), pindexPrev);
|
||||||
pblock->nNonce = 0;
|
pblock->nNonce = 0;
|
||||||
|
|
||||||
static const Array aCaps = boost::assign::list_of("proposal");
|
Array aCaps; aCaps.push_back("proposal");
|
||||||
|
|
||||||
Array transactions;
|
Array transactions;
|
||||||
map<uint256, int64_t> setTxIndex;
|
map<uint256, int64_t> setTxIndex;
|
||||||
|
|
|
@ -389,8 +389,8 @@ Value setmocktime(const Array& params, bool fHelp)
|
||||||
|
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
|
|
||||||
RPCTypeCheck(params, boost::assign::list_of(int_type));
|
RPCTypeCheck(params, boost::assign::list_of(UniValue::VNUM));
|
||||||
SetMockTime(params[0].get_int64());
|
SetMockTime(params[0].get_int64());
|
||||||
|
|
||||||
return Value::null;
|
return NullUniValue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -256,7 +256,7 @@ int ReadHTTPMessage(std::basic_istream<char>& stream, map<string,
|
||||||
|
|
||||||
string JSONRPCRequest(const string& strMethod, const Array& params, const Value& id)
|
string JSONRPCRequest(const string& strMethod, const Array& params, const Value& id)
|
||||||
{
|
{
|
||||||
Object request;
|
Object request(UniValue::VOBJ);
|
||||||
request.push_back(Pair("method", strMethod));
|
request.push_back(Pair("method", strMethod));
|
||||||
request.push_back(Pair("params", params));
|
request.push_back(Pair("params", params));
|
||||||
request.push_back(Pair("id", id));
|
request.push_back(Pair("id", id));
|
||||||
|
@ -265,7 +265,7 @@ string JSONRPCRequest(const string& strMethod, const Array& params, const Value&
|
||||||
|
|
||||||
Object JSONRPCReplyObj(const Value& result, const Value& error, const Value& id)
|
Object JSONRPCReplyObj(const Value& result, const Value& error, const Value& id)
|
||||||
{
|
{
|
||||||
Object reply;
|
Object reply(UniValue::VOBJ);
|
||||||
if (!error.isNull())
|
if (!error.isNull())
|
||||||
reply.push_back(Pair("result", NullUniValue));
|
reply.push_back(Pair("result", NullUniValue));
|
||||||
else
|
else
|
||||||
|
@ -283,7 +283,7 @@ string JSONRPCReply(const Value& result, const Value& error, const Value& id)
|
||||||
|
|
||||||
Object JSONRPCError(int code, const string& message)
|
Object JSONRPCError(int code, const string& message)
|
||||||
{
|
{
|
||||||
Object error;
|
UniValue error(UniValue::VOBJ);
|
||||||
error.push_back(Pair("code", code));
|
error.push_back(Pair("code", code));
|
||||||
error.push_back(Pair("message", message));
|
error.push_back(Pair("message", message));
|
||||||
return error;
|
return error;
|
||||||
|
|
|
@ -220,7 +220,8 @@ Value gettxoutproof(const Array& params, bool fHelp)
|
||||||
set<uint256> setTxids;
|
set<uint256> setTxids;
|
||||||
uint256 oneTxid;
|
uint256 oneTxid;
|
||||||
Array txids = params[0].get_array();
|
Array txids = params[0].get_array();
|
||||||
BOOST_FOREACH(Value& txid, txids) {
|
for (unsigned int idx = 0; idx < txids.size(); idx++) {
|
||||||
|
const Value& txid = txids[idx];
|
||||||
if (txid.get_str().length() != 64 || !IsHex(txid.get_str()))
|
if (txid.get_str().length() != 64 || !IsHex(txid.get_str()))
|
||||||
throw JSONRPCError(RPC_INVALID_PARAMETER, string("Invalid txid ")+txid.get_str());
|
throw JSONRPCError(RPC_INVALID_PARAMETER, string("Invalid txid ")+txid.get_str());
|
||||||
uint256 hash(uint256S(txid.get_str()));
|
uint256 hash(uint256S(txid.get_str()));
|
||||||
|
@ -446,7 +447,7 @@ Value decoderawtransaction(const Array& params, bool fHelp)
|
||||||
if (!DecodeHexTx(tx, params[0].get_str()))
|
if (!DecodeHexTx(tx, params[0].get_str()))
|
||||||
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed");
|
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed");
|
||||||
|
|
||||||
Object result;
|
UniValue result(UniValue::VOBJ);
|
||||||
TxToJSON(tx, uint256(), result);
|
TxToJSON(tx, uint256(), result);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -478,7 +479,7 @@ Value decodescript(const Array& params, bool fHelp)
|
||||||
);
|
);
|
||||||
|
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
RPCTypeCheck(params, boost::assign::list_of(str_type));
|
RPCTypeCheck(params, boost::assign::list_of(UniValue::VSTR));
|
||||||
|
|
||||||
Object r;
|
Object r;
|
||||||
CScript script;
|
CScript script;
|
||||||
|
|
|
@ -583,11 +583,13 @@ BOOST_AUTO_TEST_CASE(script_build)
|
||||||
Array json_good = read_json(std::string(json_tests::script_valid, json_tests::script_valid + sizeof(json_tests::script_valid)));
|
Array json_good = read_json(std::string(json_tests::script_valid, json_tests::script_valid + sizeof(json_tests::script_valid)));
|
||||||
Array json_bad = read_json(std::string(json_tests::script_invalid, json_tests::script_invalid + sizeof(json_tests::script_invalid)));
|
Array json_bad = read_json(std::string(json_tests::script_invalid, json_tests::script_invalid + sizeof(json_tests::script_invalid)));
|
||||||
|
|
||||||
BOOST_FOREACH(Value& tv, json_good) {
|
for (unsigned int idx = 0; idx < json_good.size(); idx++) {
|
||||||
tests_good.insert(write_string(Value(tv.get_array()), true));
|
const Value& tv = json_good[idx];
|
||||||
|
tests_good.insert(tv.get_array().write());
|
||||||
}
|
}
|
||||||
BOOST_FOREACH(Value& tv, json_bad) {
|
for (unsigned int idx = 0; idx < json_bad.size(); idx++) {
|
||||||
tests_bad.insert(write_string(Value(tv.get_array()), true));
|
const Value& tv = json_bad[idx];
|
||||||
|
tests_bad.insert(tv.get_array().write());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -596,7 +598,7 @@ BOOST_AUTO_TEST_CASE(script_build)
|
||||||
|
|
||||||
BOOST_FOREACH(TestBuilder& test, good) {
|
BOOST_FOREACH(TestBuilder& test, good) {
|
||||||
test.Test(true);
|
test.Test(true);
|
||||||
std::string str = write_string(Value(test.GetJSON()), true);
|
std::string str = test.GetJSON().write();
|
||||||
#ifndef UPDATE_JSON_TESTS
|
#ifndef UPDATE_JSON_TESTS
|
||||||
if (tests_good.count(str) == 0) {
|
if (tests_good.count(str) == 0) {
|
||||||
BOOST_CHECK_MESSAGE(false, "Missing auto script_valid test: " + test.GetComment());
|
BOOST_CHECK_MESSAGE(false, "Missing auto script_valid test: " + test.GetComment());
|
||||||
|
@ -606,7 +608,7 @@ BOOST_AUTO_TEST_CASE(script_build)
|
||||||
}
|
}
|
||||||
BOOST_FOREACH(TestBuilder& test, bad) {
|
BOOST_FOREACH(TestBuilder& test, bad) {
|
||||||
test.Test(false);
|
test.Test(false);
|
||||||
std::string str = write_string(Value(test.GetJSON()), true);
|
std::string str = test.GetJSON().write();
|
||||||
#ifndef UPDATE_JSON_TESTS
|
#ifndef UPDATE_JSON_TESTS
|
||||||
if (tests_bad.count(str) == 0) {
|
if (tests_bad.count(str) == 0) {
|
||||||
BOOST_CHECK_MESSAGE(false, "Missing auto script_invalid test: " + test.GetComment());
|
BOOST_CHECK_MESSAGE(false, "Missing auto script_invalid test: " + test.GetComment());
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
#include <boost/algorithm/string/classification.hpp>
|
#include <boost/algorithm/string/classification.hpp>
|
||||||
#include <boost/algorithm/string/split.hpp>
|
#include <boost/algorithm/string/split.hpp>
|
||||||
|
#include <boost/assign/list_of.hpp>
|
||||||
#include <boost/test/unit_test.hpp>
|
#include <boost/test/unit_test.hpp>
|
||||||
#include <boost/assign/list_of.hpp>
|
#include <boost/assign/list_of.hpp>
|
||||||
|
|
||||||
|
|
|
@ -73,7 +73,7 @@ std::string DecodeDumpString(const std::string &str) {
|
||||||
Value importprivkey(const Array& params, bool fHelp)
|
Value importprivkey(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (!EnsureWalletIsAvailable(fHelp))
|
if (!EnsureWalletIsAvailable(fHelp))
|
||||||
return Value::null;
|
return NullUniValue;
|
||||||
|
|
||||||
if (fHelp || params.size() < 1 || params.size() > 3)
|
if (fHelp || params.size() < 1 || params.size() > 3)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
@ -147,7 +147,7 @@ Value importprivkey(const Array& params, bool fHelp)
|
||||||
Value importaddress(const Array& params, bool fHelp)
|
Value importaddress(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (!EnsureWalletIsAvailable(fHelp))
|
if (!EnsureWalletIsAvailable(fHelp))
|
||||||
return Value::null;
|
return NullUniValue;
|
||||||
|
|
||||||
if (fHelp || params.size() < 1 || params.size() > 3)
|
if (fHelp || params.size() < 1 || params.size() > 3)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
@ -220,7 +220,7 @@ Value importaddress(const Array& params, bool fHelp)
|
||||||
Value importwallet(const Array& params, bool fHelp)
|
Value importwallet(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (!EnsureWalletIsAvailable(fHelp))
|
if (!EnsureWalletIsAvailable(fHelp))
|
||||||
return Value::null;
|
return NullUniValue;
|
||||||
|
|
||||||
if (fHelp || params.size() != 1)
|
if (fHelp || params.size() != 1)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
@ -324,7 +324,7 @@ Value importwallet(const Array& params, bool fHelp)
|
||||||
Value dumpprivkey(const Array& params, bool fHelp)
|
Value dumpprivkey(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (!EnsureWalletIsAvailable(fHelp))
|
if (!EnsureWalletIsAvailable(fHelp))
|
||||||
return Value::null;
|
return NullUniValue;
|
||||||
|
|
||||||
if (fHelp || params.size() != 1)
|
if (fHelp || params.size() != 1)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
@ -362,7 +362,7 @@ Value dumpprivkey(const Array& params, bool fHelp)
|
||||||
Value dumpwallet(const Array& params, bool fHelp)
|
Value dumpwallet(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (!EnsureWalletIsAvailable(fHelp))
|
if (!EnsureWalletIsAvailable(fHelp))
|
||||||
return Value::null;
|
return NullUniValue;
|
||||||
|
|
||||||
if (fHelp || params.size() != 1)
|
if (fHelp || params.size() != 1)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
|
|
@ -89,7 +89,7 @@ string AccountFromValue(const Value& value)
|
||||||
Value getnewaddress(const Array& params, bool fHelp)
|
Value getnewaddress(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (!EnsureWalletIsAvailable(fHelp))
|
if (!EnsureWalletIsAvailable(fHelp))
|
||||||
return Value::null;
|
return NullUniValue;
|
||||||
|
|
||||||
if (fHelp || params.size() > 1)
|
if (fHelp || params.size() > 1)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
@ -168,7 +168,7 @@ CBitcoinAddress GetAccountAddress(string strAccount, bool bForceNew=false)
|
||||||
Value getaccountaddress(const Array& params, bool fHelp)
|
Value getaccountaddress(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (!EnsureWalletIsAvailable(fHelp))
|
if (!EnsureWalletIsAvailable(fHelp))
|
||||||
return Value::null;
|
return NullUniValue;
|
||||||
|
|
||||||
if (fHelp || params.size() != 1)
|
if (fHelp || params.size() != 1)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
@ -200,7 +200,7 @@ Value getaccountaddress(const Array& params, bool fHelp)
|
||||||
Value getrawchangeaddress(const Array& params, bool fHelp)
|
Value getrawchangeaddress(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (!EnsureWalletIsAvailable(fHelp))
|
if (!EnsureWalletIsAvailable(fHelp))
|
||||||
return Value::null;
|
return NullUniValue;
|
||||||
|
|
||||||
if (fHelp || params.size() > 1)
|
if (fHelp || params.size() > 1)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
@ -235,7 +235,7 @@ Value getrawchangeaddress(const Array& params, bool fHelp)
|
||||||
Value setaccount(const Array& params, bool fHelp)
|
Value setaccount(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (!EnsureWalletIsAvailable(fHelp))
|
if (!EnsureWalletIsAvailable(fHelp))
|
||||||
return Value::null;
|
return NullUniValue;
|
||||||
|
|
||||||
if (fHelp || params.size() < 1 || params.size() > 2)
|
if (fHelp || params.size() < 1 || params.size() > 2)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
@ -281,7 +281,7 @@ Value setaccount(const Array& params, bool fHelp)
|
||||||
Value getaccount(const Array& params, bool fHelp)
|
Value getaccount(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (!EnsureWalletIsAvailable(fHelp))
|
if (!EnsureWalletIsAvailable(fHelp))
|
||||||
return Value::null;
|
return NullUniValue;
|
||||||
|
|
||||||
if (fHelp || params.size() != 1)
|
if (fHelp || params.size() != 1)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
@ -313,7 +313,7 @@ Value getaccount(const Array& params, bool fHelp)
|
||||||
Value getaddressesbyaccount(const Array& params, bool fHelp)
|
Value getaddressesbyaccount(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (!EnsureWalletIsAvailable(fHelp))
|
if (!EnsureWalletIsAvailable(fHelp))
|
||||||
return Value::null;
|
return NullUniValue;
|
||||||
|
|
||||||
if (fHelp || params.size() != 1)
|
if (fHelp || params.size() != 1)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
@ -381,7 +381,7 @@ static void SendMoney(const CTxDestination &address, CAmount nValue, bool fSubtr
|
||||||
Value sendtoaddress(const Array& params, bool fHelp)
|
Value sendtoaddress(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (!EnsureWalletIsAvailable(fHelp))
|
if (!EnsureWalletIsAvailable(fHelp))
|
||||||
return Value::null;
|
return NullUniValue;
|
||||||
|
|
||||||
if (fHelp || params.size() < 2 || params.size() > 5)
|
if (fHelp || params.size() < 2 || params.size() > 5)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
@ -437,7 +437,7 @@ Value sendtoaddress(const Array& params, bool fHelp)
|
||||||
Value listaddressgroupings(const Array& params, bool fHelp)
|
Value listaddressgroupings(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (!EnsureWalletIsAvailable(fHelp))
|
if (!EnsureWalletIsAvailable(fHelp))
|
||||||
return Value::null;
|
return NullUniValue;
|
||||||
|
|
||||||
if (fHelp)
|
if (fHelp)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
@ -489,7 +489,7 @@ Value listaddressgroupings(const Array& params, bool fHelp)
|
||||||
Value signmessage(const Array& params, bool fHelp)
|
Value signmessage(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (!EnsureWalletIsAvailable(fHelp))
|
if (!EnsureWalletIsAvailable(fHelp))
|
||||||
return Value::null;
|
return NullUniValue;
|
||||||
|
|
||||||
if (fHelp || params.size() != 2)
|
if (fHelp || params.size() != 2)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
@ -545,7 +545,7 @@ Value signmessage(const Array& params, bool fHelp)
|
||||||
Value getreceivedbyaddress(const Array& params, bool fHelp)
|
Value getreceivedbyaddress(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (!EnsureWalletIsAvailable(fHelp))
|
if (!EnsureWalletIsAvailable(fHelp))
|
||||||
return Value::null;
|
return NullUniValue;
|
||||||
|
|
||||||
if (fHelp || params.size() < 1 || params.size() > 2)
|
if (fHelp || params.size() < 1 || params.size() > 2)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
@ -603,7 +603,7 @@ Value getreceivedbyaddress(const Array& params, bool fHelp)
|
||||||
Value getreceivedbyaccount(const Array& params, bool fHelp)
|
Value getreceivedbyaccount(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (!EnsureWalletIsAvailable(fHelp))
|
if (!EnsureWalletIsAvailable(fHelp))
|
||||||
return Value::null;
|
return NullUniValue;
|
||||||
|
|
||||||
if (fHelp || params.size() < 1 || params.size() > 2)
|
if (fHelp || params.size() < 1 || params.size() > 2)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
@ -692,7 +692,7 @@ CAmount GetAccountBalance(const string& strAccount, int nMinDepth, const isminef
|
||||||
Value getbalance(const Array& params, bool fHelp)
|
Value getbalance(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (!EnsureWalletIsAvailable(fHelp))
|
if (!EnsureWalletIsAvailable(fHelp))
|
||||||
return Value::null;
|
return NullUniValue;
|
||||||
|
|
||||||
if (fHelp || params.size() > 3)
|
if (fHelp || params.size() > 3)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
@ -767,7 +767,7 @@ Value getbalance(const Array& params, bool fHelp)
|
||||||
Value getunconfirmedbalance(const Array ¶ms, bool fHelp)
|
Value getunconfirmedbalance(const Array ¶ms, bool fHelp)
|
||||||
{
|
{
|
||||||
if (!EnsureWalletIsAvailable(fHelp))
|
if (!EnsureWalletIsAvailable(fHelp))
|
||||||
return Value::null;
|
return NullUniValue;
|
||||||
|
|
||||||
if (fHelp || params.size() > 0)
|
if (fHelp || params.size() > 0)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
@ -783,7 +783,7 @@ Value getunconfirmedbalance(const Array ¶ms, bool fHelp)
|
||||||
Value movecmd(const Array& params, bool fHelp)
|
Value movecmd(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (!EnsureWalletIsAvailable(fHelp))
|
if (!EnsureWalletIsAvailable(fHelp))
|
||||||
return Value::null;
|
return NullUniValue;
|
||||||
|
|
||||||
if (fHelp || params.size() < 3 || params.size() > 5)
|
if (fHelp || params.size() < 3 || params.size() > 5)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
@ -853,7 +853,7 @@ Value movecmd(const Array& params, bool fHelp)
|
||||||
Value sendfrom(const Array& params, bool fHelp)
|
Value sendfrom(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (!EnsureWalletIsAvailable(fHelp))
|
if (!EnsureWalletIsAvailable(fHelp))
|
||||||
return Value::null;
|
return NullUniValue;
|
||||||
|
|
||||||
if (fHelp || params.size() < 3 || params.size() > 6)
|
if (fHelp || params.size() < 3 || params.size() > 6)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
@ -916,7 +916,7 @@ Value sendfrom(const Array& params, bool fHelp)
|
||||||
Value sendmany(const Array& params, bool fHelp)
|
Value sendmany(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (!EnsureWalletIsAvailable(fHelp))
|
if (!EnsureWalletIsAvailable(fHelp))
|
||||||
return Value::null;
|
return NullUniValue;
|
||||||
|
|
||||||
if (fHelp || params.size() < 2 || params.size() > 5)
|
if (fHelp || params.size() < 2 || params.size() > 5)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
@ -991,9 +991,11 @@ Value sendmany(const Array& params, bool fHelp)
|
||||||
totalAmount += nAmount;
|
totalAmount += nAmount;
|
||||||
|
|
||||||
bool fSubtractFeeFromAmount = false;
|
bool fSubtractFeeFromAmount = false;
|
||||||
BOOST_FOREACH(const Value& addr, subtractFeeFromAmount)
|
for (unsigned int idx = 0; idx < subtractFeeFromAmount.size(); idx++) {
|
||||||
if (addr.get_str() == s.name_)
|
const Value& addr = subtractFeeFromAmount[idx];
|
||||||
|
if (addr.get_str() == name_)
|
||||||
fSubtractFeeFromAmount = true;
|
fSubtractFeeFromAmount = true;
|
||||||
|
}
|
||||||
|
|
||||||
CRecipient recipient = {scriptPubKey, nAmount, fSubtractFeeFromAmount};
|
CRecipient recipient = {scriptPubKey, nAmount, fSubtractFeeFromAmount};
|
||||||
vecSend.push_back(recipient);
|
vecSend.push_back(recipient);
|
||||||
|
@ -1026,7 +1028,7 @@ extern CScript _createmultisig_redeemScript(const Array& params);
|
||||||
Value addmultisigaddress(const Array& params, bool fHelp)
|
Value addmultisigaddress(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (!EnsureWalletIsAvailable(fHelp))
|
if (!EnsureWalletIsAvailable(fHelp))
|
||||||
return Value::null;
|
return NullUniValue;
|
||||||
|
|
||||||
if (fHelp || params.size() < 2 || params.size() > 3)
|
if (fHelp || params.size() < 2 || params.size() > 3)
|
||||||
{
|
{
|
||||||
|
@ -1207,7 +1209,7 @@ Value ListReceived(const Array& params, bool fByAccounts)
|
||||||
Value listreceivedbyaddress(const Array& params, bool fHelp)
|
Value listreceivedbyaddress(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (!EnsureWalletIsAvailable(fHelp))
|
if (!EnsureWalletIsAvailable(fHelp))
|
||||||
return Value::null;
|
return NullUniValue;
|
||||||
|
|
||||||
if (fHelp || params.size() > 3)
|
if (fHelp || params.size() > 3)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
@ -1244,7 +1246,7 @@ Value listreceivedbyaddress(const Array& params, bool fHelp)
|
||||||
Value listreceivedbyaccount(const Array& params, bool fHelp)
|
Value listreceivedbyaccount(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (!EnsureWalletIsAvailable(fHelp))
|
if (!EnsureWalletIsAvailable(fHelp))
|
||||||
return Value::null;
|
return NullUniValue;
|
||||||
|
|
||||||
if (fHelp || params.size() > 3)
|
if (fHelp || params.size() > 3)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
@ -1374,7 +1376,7 @@ void AcentryToJSON(const CAccountingEntry& acentry, const string& strAccount, Ar
|
||||||
Value listtransactions(const Array& params, bool fHelp)
|
Value listtransactions(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (!EnsureWalletIsAvailable(fHelp))
|
if (!EnsureWalletIsAvailable(fHelp))
|
||||||
return Value::null;
|
return NullUniValue;
|
||||||
|
|
||||||
if (fHelp || params.size() > 4)
|
if (fHelp || params.size() > 4)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
@ -1494,7 +1496,7 @@ Value listtransactions(const Array& params, bool fHelp)
|
||||||
Value listaccounts(const Array& params, bool fHelp)
|
Value listaccounts(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (!EnsureWalletIsAvailable(fHelp))
|
if (!EnsureWalletIsAvailable(fHelp))
|
||||||
return Value::null;
|
return NullUniValue;
|
||||||
|
|
||||||
if (fHelp || params.size() > 2)
|
if (fHelp || params.size() > 2)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
@ -1574,7 +1576,7 @@ Value listaccounts(const Array& params, bool fHelp)
|
||||||
Value listsinceblock(const Array& params, bool fHelp)
|
Value listsinceblock(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (!EnsureWalletIsAvailable(fHelp))
|
if (!EnsureWalletIsAvailable(fHelp))
|
||||||
return Value::null;
|
return NullUniValue;
|
||||||
|
|
||||||
if (fHelp)
|
if (fHelp)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
@ -1665,7 +1667,7 @@ Value listsinceblock(const Array& params, bool fHelp)
|
||||||
Value gettransaction(const Array& params, bool fHelp)
|
Value gettransaction(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (!EnsureWalletIsAvailable(fHelp))
|
if (!EnsureWalletIsAvailable(fHelp))
|
||||||
return Value::null;
|
return NullUniValue;
|
||||||
|
|
||||||
if (fHelp || params.size() < 1 || params.size() > 2)
|
if (fHelp || params.size() < 1 || params.size() > 2)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
@ -1743,7 +1745,7 @@ Value gettransaction(const Array& params, bool fHelp)
|
||||||
Value backupwallet(const Array& params, bool fHelp)
|
Value backupwallet(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (!EnsureWalletIsAvailable(fHelp))
|
if (!EnsureWalletIsAvailable(fHelp))
|
||||||
return Value::null;
|
return NullUniValue;
|
||||||
|
|
||||||
if (fHelp || params.size() != 1)
|
if (fHelp || params.size() != 1)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
@ -1769,7 +1771,7 @@ Value backupwallet(const Array& params, bool fHelp)
|
||||||
Value keypoolrefill(const Array& params, bool fHelp)
|
Value keypoolrefill(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (!EnsureWalletIsAvailable(fHelp))
|
if (!EnsureWalletIsAvailable(fHelp))
|
||||||
return Value::null;
|
return NullUniValue;
|
||||||
|
|
||||||
if (fHelp || params.size() > 1)
|
if (fHelp || params.size() > 1)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
@ -1813,7 +1815,7 @@ static void LockWallet(CWallet* pWallet)
|
||||||
Value walletpassphrase(const Array& params, bool fHelp)
|
Value walletpassphrase(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (!EnsureWalletIsAvailable(fHelp))
|
if (!EnsureWalletIsAvailable(fHelp))
|
||||||
return Value::null;
|
return NullUniValue;
|
||||||
|
|
||||||
if (pwalletMain->IsCrypted() && (fHelp || params.size() != 2))
|
if (pwalletMain->IsCrypted() && (fHelp || params.size() != 2))
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
@ -1873,7 +1875,7 @@ Value walletpassphrase(const Array& params, bool fHelp)
|
||||||
Value walletpassphrasechange(const Array& params, bool fHelp)
|
Value walletpassphrasechange(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (!EnsureWalletIsAvailable(fHelp))
|
if (!EnsureWalletIsAvailable(fHelp))
|
||||||
return Value::null;
|
return NullUniValue;
|
||||||
|
|
||||||
if (pwalletMain->IsCrypted() && (fHelp || params.size() != 2))
|
if (pwalletMain->IsCrypted() && (fHelp || params.size() != 2))
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
@ -1919,7 +1921,7 @@ Value walletpassphrasechange(const Array& params, bool fHelp)
|
||||||
Value walletlock(const Array& params, bool fHelp)
|
Value walletlock(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (!EnsureWalletIsAvailable(fHelp))
|
if (!EnsureWalletIsAvailable(fHelp))
|
||||||
return Value::null;
|
return NullUniValue;
|
||||||
|
|
||||||
if (pwalletMain->IsCrypted() && (fHelp || params.size() != 0))
|
if (pwalletMain->IsCrypted() && (fHelp || params.size() != 0))
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
@ -1958,7 +1960,7 @@ Value walletlock(const Array& params, bool fHelp)
|
||||||
Value encryptwallet(const Array& params, bool fHelp)
|
Value encryptwallet(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (!EnsureWalletIsAvailable(fHelp))
|
if (!EnsureWalletIsAvailable(fHelp))
|
||||||
return Value::null;
|
return NullUniValue;
|
||||||
|
|
||||||
if (!pwalletMain->IsCrypted() && (fHelp || params.size() != 1))
|
if (!pwalletMain->IsCrypted() && (fHelp || params.size() != 1))
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
@ -2015,7 +2017,7 @@ Value encryptwallet(const Array& params, bool fHelp)
|
||||||
Value lockunspent(const Array& params, bool fHelp)
|
Value lockunspent(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (!EnsureWalletIsAvailable(fHelp))
|
if (!EnsureWalletIsAvailable(fHelp))
|
||||||
return Value::null;
|
return NullUniValue;
|
||||||
|
|
||||||
if (fHelp || params.size() < 1 || params.size() > 2)
|
if (fHelp || params.size() < 1 || params.size() > 2)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
@ -2099,7 +2101,7 @@ Value lockunspent(const Array& params, bool fHelp)
|
||||||
Value listlockunspent(const Array& params, bool fHelp)
|
Value listlockunspent(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (!EnsureWalletIsAvailable(fHelp))
|
if (!EnsureWalletIsAvailable(fHelp))
|
||||||
return Value::null;
|
return NullUniValue;
|
||||||
|
|
||||||
if (fHelp || params.size() > 0)
|
if (fHelp || params.size() > 0)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
@ -2148,7 +2150,7 @@ Value listlockunspent(const Array& params, bool fHelp)
|
||||||
Value settxfee(const Array& params, bool fHelp)
|
Value settxfee(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (!EnsureWalletIsAvailable(fHelp))
|
if (!EnsureWalletIsAvailable(fHelp))
|
||||||
return Value::null;
|
return NullUniValue;
|
||||||
|
|
||||||
if (fHelp || params.size() < 1 || params.size() > 1)
|
if (fHelp || params.size() < 1 || params.size() > 1)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
@ -2177,7 +2179,7 @@ Value settxfee(const Array& params, bool fHelp)
|
||||||
Value getwalletinfo(const Array& params, bool fHelp)
|
Value getwalletinfo(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (!EnsureWalletIsAvailable(fHelp))
|
if (!EnsureWalletIsAvailable(fHelp))
|
||||||
return Value::null;
|
return NullUniValue;
|
||||||
|
|
||||||
if (fHelp || params.size() != 0)
|
if (fHelp || params.size() != 0)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
@ -2217,7 +2219,7 @@ Value getwalletinfo(const Array& params, bool fHelp)
|
||||||
Value resendwallettransactions(const Array& params, bool fHelp)
|
Value resendwallettransactions(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (!EnsureWalletIsAvailable(fHelp))
|
if (!EnsureWalletIsAvailable(fHelp))
|
||||||
return Value::null;
|
return NullUniValue;
|
||||||
|
|
||||||
if (fHelp || params.size() != 0)
|
if (fHelp || params.size() != 0)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
@ -2242,7 +2244,7 @@ Value resendwallettransactions(const Array& params, bool fHelp)
|
||||||
Value listunspent(const Array& params, bool fHelp)
|
Value listunspent(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (!EnsureWalletIsAvailable(fHelp))
|
if (!EnsureWalletIsAvailable(fHelp))
|
||||||
return Value::null;
|
return NullUniValue;
|
||||||
|
|
||||||
if (fHelp || params.size() > 3)
|
if (fHelp || params.size() > 3)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
@ -2280,7 +2282,7 @@ Value listunspent(const Array& params, bool fHelp)
|
||||||
+ HelpExampleRpc("listunspent", "6, 9999999 \"[\\\"1PGFqEzfmQch1gKD3ra4k18PNj3tTUUSqg\\\",\\\"1LtvqCaApEdUGFkpKMM4MstjcaL4dKg8SP\\\"]\"")
|
+ HelpExampleRpc("listunspent", "6, 9999999 \"[\\\"1PGFqEzfmQch1gKD3ra4k18PNj3tTUUSqg\\\",\\\"1LtvqCaApEdUGFkpKMM4MstjcaL4dKg8SP\\\"]\"")
|
||||||
);
|
);
|
||||||
|
|
||||||
RPCTypeCheck(params, boost::assign::list_of(int_type)(int_type)(array_type));
|
RPCTypeCheck(params, boost::assign::list_of(UniValue::VNUM)(UniValue::VNUM)(UniValue::VARR));
|
||||||
|
|
||||||
int nMinDepth = 1;
|
int nMinDepth = 1;
|
||||||
if (params.size() > 0)
|
if (params.size() > 0)
|
||||||
|
@ -2293,7 +2295,8 @@ Value listunspent(const Array& params, bool fHelp)
|
||||||
set<CBitcoinAddress> setAddress;
|
set<CBitcoinAddress> setAddress;
|
||||||
if (params.size() > 2) {
|
if (params.size() > 2) {
|
||||||
Array inputs = params[2].get_array();
|
Array inputs = params[2].get_array();
|
||||||
BOOST_FOREACH(Value& input, inputs) {
|
for (unsigned int idx = 0; idx < inputs.size(); idx++) {
|
||||||
|
const Value& input = inputs[idx];
|
||||||
CBitcoinAddress address(input.get_str());
|
CBitcoinAddress address(input.get_str());
|
||||||
if (!address.IsValid())
|
if (!address.IsValid())
|
||||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, string("Invalid Bitcoin address: ")+input.get_str());
|
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, string("Invalid Bitcoin address: ")+input.get_str());
|
||||||
|
|
Loading…
Reference in a new issue