remove JSON Spirit UniValue wrapper
This commit is contained in:
parent
1f263c899e
commit
3df0411ad9
23 changed files with 234 additions and 253 deletions
|
@ -98,7 +98,6 @@ 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 \
|
||||||
|
|
|
@ -94,7 +94,7 @@ static bool AppInitRPC(int argc, char* argv[])
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Object CallRPC(const string& strMethod, const Array& params)
|
UniValue CallRPC(const string& strMethod, const Array& params)
|
||||||
{
|
{
|
||||||
if (mapArgs["-rpcuser"] == "" && mapArgs["-rpcpassword"] == "")
|
if (mapArgs["-rpcuser"] == "" && mapArgs["-rpcpassword"] == "")
|
||||||
throw runtime_error(strprintf(
|
throw runtime_error(strprintf(
|
||||||
|
@ -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(UniValue::VSTR);
|
UniValue 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();
|
||||||
|
@ -170,14 +170,13 @@ int CommandLineRPC(int argc, char *argv[])
|
||||||
|
|
||||||
// Parameters default to strings
|
// Parameters default to strings
|
||||||
std::vector<std::string> strParams(&argv[2], &argv[argc]);
|
std::vector<std::string> strParams(&argv[2], &argv[argc]);
|
||||||
Array params = RPCConvertValues(strMethod, strParams);
|
UniValue params = RPCConvertValues(strMethod, strParams);
|
||||||
|
|
||||||
// Execute and handle connection failures with -rpcwait
|
// Execute and handle connection failures with -rpcwait
|
||||||
const bool fWait = GetBoolArg("-rpcwait", false);
|
const bool fWait = GetBoolArg("-rpcwait", false);
|
||||||
do {
|
do {
|
||||||
try {
|
try {
|
||||||
// Execute
|
const UniValue reply = CallRPC(strMethod, params);
|
||||||
Object reply = CallRPC(strMethod, params);
|
|
||||||
|
|
||||||
// Parse reply
|
// Parse reply
|
||||||
const Value& result = find_value(reply, "result");
|
const Value& result = find_value(reply, "result");
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
#ifndef __JSON_SPIRIT_WRAPPER_H__
|
|
||||||
#define __JSON_SPIRIT_WRAPPER_H__
|
|
||||||
|
|
||||||
#include "univalue/univalue.h"
|
|
||||||
|
|
||||||
namespace json_spirit {
|
|
||||||
|
|
||||||
typedef UniValue Value;
|
|
||||||
typedef UniValue Array;
|
|
||||||
typedef UniValue Object;
|
|
||||||
typedef UniValue::VType Value_type;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#define find_value(val,key) (val[key])
|
|
||||||
|
|
||||||
#endif // __JSON_SPIRIT_WRAPPER_H__
|
|
|
@ -62,7 +62,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
extern void TxToJSON(const CTransaction& tx, const uint256 hashBlock, Object& entry);
|
extern void TxToJSON(const CTransaction& tx, const uint256 hashBlock, Object& entry);
|
||||||
extern Object blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool txDetails = false);
|
extern UniValue blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool txDetails = false);
|
||||||
extern void ScriptPubKeyToJSON(const CScript& scriptPubKey, Object& out, bool fIncludeHex);
|
extern void ScriptPubKeyToJSON(const CScript& scriptPubKey, Object& out, bool fIncludeHex);
|
||||||
|
|
||||||
static RestErr RESTERR(enum HTTPStatusCode status, string message)
|
static RestErr RESTERR(enum HTTPStatusCode status, string message)
|
||||||
|
@ -221,7 +221,7 @@ static bool rest_block(AcceptedConnection* conn,
|
||||||
}
|
}
|
||||||
|
|
||||||
case RF_JSON: {
|
case RF_JSON: {
|
||||||
Object objBlock = blockToJSON(block, pblockindex, showTxDetails);
|
UniValue objBlock = blockToJSON(block, pblockindex, showTxDetails);
|
||||||
string strJSON = objBlock.write() + "\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;
|
||||||
|
@ -266,7 +266,7 @@ static bool rest_chaininfo(AcceptedConnection* conn,
|
||||||
switch (rf) {
|
switch (rf) {
|
||||||
case RF_JSON: {
|
case RF_JSON: {
|
||||||
UniValue rpcParams(UniValue::VARR);
|
UniValue rpcParams(UniValue::VARR);
|
||||||
Value chainInfoObject = getblockchaininfo(rpcParams, false);
|
UniValue chainInfoObject = getblockchaininfo(rpcParams, false);
|
||||||
string strJSON = chainInfoObject.write() + "\n";
|
string strJSON = chainInfoObject.write() + "\n";
|
||||||
conn->stream() << HTTPReply(HTTP_OK, strJSON, fRun) << std::flush;
|
conn->stream() << HTTPReply(HTTP_OK, strJSON, fRun) << std::flush;
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -53,7 +53,7 @@ double GetDifficulty(const CBlockIndex* blockindex)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Object blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool txDetails = false)
|
UniValue blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool txDetails = false)
|
||||||
{
|
{
|
||||||
UniValue result(UniValue::VOBJ);
|
UniValue result(UniValue::VOBJ);
|
||||||
result.push_back(Pair("hash", block.GetHash().GetHex()));
|
result.push_back(Pair("hash", block.GetHash().GetHex()));
|
||||||
|
@ -94,7 +94,7 @@ Object blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool txDe
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Value getblockcount(const Array& params, bool fHelp)
|
UniValue getblockcount(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (fHelp || params.size() != 0)
|
if (fHelp || params.size() != 0)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
@ -111,7 +111,7 @@ Value getblockcount(const Array& params, bool fHelp)
|
||||||
return chainActive.Height();
|
return chainActive.Height();
|
||||||
}
|
}
|
||||||
|
|
||||||
Value getbestblockhash(const Array& params, bool fHelp)
|
UniValue getbestblockhash(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (fHelp || params.size() != 0)
|
if (fHelp || params.size() != 0)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
@ -128,7 +128,7 @@ Value getbestblockhash(const Array& params, bool fHelp)
|
||||||
return chainActive.Tip()->GetBlockHash().GetHex();
|
return chainActive.Tip()->GetBlockHash().GetHex();
|
||||||
}
|
}
|
||||||
|
|
||||||
Value getdifficulty(const Array& params, bool fHelp)
|
UniValue getdifficulty(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (fHelp || params.size() != 0)
|
if (fHelp || params.size() != 0)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
@ -146,7 +146,7 @@ Value getdifficulty(const Array& params, bool fHelp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Value getrawmempool(const Array& params, bool fHelp)
|
UniValue getrawmempool(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (fHelp || params.size() > 1)
|
if (fHelp || params.size() > 1)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
@ -231,7 +231,7 @@ Value getrawmempool(const Array& params, bool fHelp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Value getblockhash(const Array& params, bool fHelp)
|
UniValue getblockhash(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (fHelp || params.size() != 1)
|
if (fHelp || params.size() != 1)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
@ -256,7 +256,7 @@ Value getblockhash(const Array& params, bool fHelp)
|
||||||
return pblockindex->GetBlockHash().GetHex();
|
return pblockindex->GetBlockHash().GetHex();
|
||||||
}
|
}
|
||||||
|
|
||||||
Value getblock(const Array& params, bool fHelp)
|
UniValue getblock(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (fHelp || params.size() < 1 || params.size() > 2)
|
if (fHelp || params.size() < 1 || params.size() > 2)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
@ -324,7 +324,7 @@ Value getblock(const Array& params, bool fHelp)
|
||||||
return blockToJSON(block, pblockindex);
|
return blockToJSON(block, pblockindex);
|
||||||
}
|
}
|
||||||
|
|
||||||
Value gettxoutsetinfo(const Array& params, bool fHelp)
|
UniValue gettxoutsetinfo(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (fHelp || params.size() != 0)
|
if (fHelp || params.size() != 0)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
@ -364,7 +364,7 @@ Value gettxoutsetinfo(const Array& params, bool fHelp)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
Value gettxout(const Array& params, bool fHelp)
|
UniValue gettxout(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (fHelp || params.size() < 2 || params.size() > 3)
|
if (fHelp || params.size() < 2 || params.size() > 3)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
@ -444,7 +444,7 @@ Value gettxout(const Array& params, bool fHelp)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
Value verifychain(const Array& params, bool fHelp)
|
UniValue verifychain(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (fHelp || params.size() > 2)
|
if (fHelp || params.size() > 2)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
@ -472,7 +472,7 @@ Value verifychain(const Array& params, bool fHelp)
|
||||||
return CVerifyDB().VerifyDB(pcoinsTip, nCheckLevel, nCheckDepth);
|
return CVerifyDB().VerifyDB(pcoinsTip, nCheckLevel, nCheckDepth);
|
||||||
}
|
}
|
||||||
|
|
||||||
Value getblockchaininfo(const Array& params, bool fHelp)
|
UniValue getblockchaininfo(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (fHelp || params.size() != 0)
|
if (fHelp || params.size() != 0)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
@ -530,7 +530,7 @@ struct CompareBlocksByHeight
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Value getchaintips(const Array& params, bool fHelp)
|
UniValue getchaintips(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (fHelp || params.size() != 0)
|
if (fHelp || params.size() != 0)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
@ -620,7 +620,7 @@ Value getchaintips(const Array& params, bool fHelp)
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
Value getmempoolinfo(const Array& params, bool fHelp)
|
UniValue getmempoolinfo(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (fHelp || params.size() != 0)
|
if (fHelp || params.size() != 0)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
@ -643,7 +643,7 @@ Value getmempoolinfo(const Array& params, bool fHelp)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
Value invalidateblock(const Array& params, bool fHelp)
|
UniValue invalidateblock(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (fHelp || params.size() != 1)
|
if (fHelp || params.size() != 1)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
@ -681,7 +681,7 @@ Value invalidateblock(const Array& params, bool fHelp)
|
||||||
return NullUniValue;
|
return NullUniValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Value reconsiderblock(const Array& params, bool fHelp)
|
UniValue reconsiderblock(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (fHelp || params.size() != 1)
|
if (fHelp || params.size() != 1)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
|
|
@ -122,7 +122,7 @@ CRPCConvertTable::CRPCConvertTable()
|
||||||
static CRPCConvertTable rpcCvtTable;
|
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)
|
UniValue RPCConvertValues(const std::string &strMethod, const std::vector<std::string> &strParams)
|
||||||
{
|
{
|
||||||
UniValue params(UniValue::VARR);
|
UniValue params(UniValue::VARR);
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
#ifndef BITCOIN_RPCCLIENT_H
|
#ifndef BITCOIN_RPCCLIENT_H
|
||||||
#define BITCOIN_RPCCLIENT_H
|
#define BITCOIN_RPCCLIENT_H
|
||||||
|
|
||||||
#include "json_spirit_wrapper.h"
|
#include "univalue/univalue.h"
|
||||||
|
|
||||||
json_spirit::Array RPCConvertValues(const std::string& strMethod, const std::vector<std::string>& strParams);
|
UniValue RPCConvertValues(const std::string& strMethod, const std::vector<std::string>& strParams);
|
||||||
|
|
||||||
#endif // BITCOIN_RPCCLIENT_H
|
#endif // BITCOIN_RPCCLIENT_H
|
||||||
|
|
|
@ -34,7 +34,7 @@ using namespace std;
|
||||||
* or from the last difficulty change if 'lookup' is nonpositive.
|
* or from the last difficulty change if 'lookup' is nonpositive.
|
||||||
* If 'height' is nonnegative, compute the estimate at the time when a given block was found.
|
* If 'height' is nonnegative, compute the estimate at the time when a given block was found.
|
||||||
*/
|
*/
|
||||||
Value GetNetworkHashPS(int lookup, int height) {
|
UniValue GetNetworkHashPS(int lookup, int height) {
|
||||||
CBlockIndex *pb = chainActive.Tip();
|
CBlockIndex *pb = chainActive.Tip();
|
||||||
|
|
||||||
if (height >= 0 && height < chainActive.Height())
|
if (height >= 0 && height < chainActive.Height())
|
||||||
|
@ -71,7 +71,7 @@ Value GetNetworkHashPS(int lookup, int height) {
|
||||||
return (int64_t)(workDiff.getdouble() / timeDiff);
|
return (int64_t)(workDiff.getdouble() / timeDiff);
|
||||||
}
|
}
|
||||||
|
|
||||||
Value getnetworkhashps(const Array& params, bool fHelp)
|
UniValue getnetworkhashps(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (fHelp || params.size() > 2)
|
if (fHelp || params.size() > 2)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
@ -94,7 +94,7 @@ Value getnetworkhashps(const Array& params, bool fHelp)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_WALLET
|
#ifdef ENABLE_WALLET
|
||||||
Value getgenerate(const Array& params, bool fHelp)
|
UniValue getgenerate(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (fHelp || params.size() != 0)
|
if (fHelp || params.size() != 0)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
@ -113,7 +113,7 @@ Value getgenerate(const Array& params, bool fHelp)
|
||||||
return GetBoolArg("-gen", false);
|
return GetBoolArg("-gen", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
Value generate(const Array& params, bool fHelp)
|
UniValue generate(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (fHelp || params.size() < 1 || params.size() > 1)
|
if (fHelp || params.size() < 1 || params.size() > 1)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
@ -172,7 +172,7 @@ Value generate(const Array& params, bool fHelp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Value setgenerate(const Array& params, bool fHelp)
|
UniValue setgenerate(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (fHelp || params.size() < 1 || params.size() > 2)
|
if (fHelp || params.size() < 1 || params.size() > 2)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
@ -220,7 +220,7 @@ Value setgenerate(const Array& params, bool fHelp)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
Value getmininginfo(const Array& params, bool fHelp)
|
UniValue getmininginfo(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (fHelp || params.size() != 0)
|
if (fHelp || params.size() != 0)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
@ -266,7 +266,7 @@ Value getmininginfo(const Array& params, bool fHelp)
|
||||||
|
|
||||||
|
|
||||||
// NOTE: Unlike wallet RPC (which use BTC values), mining RPCs follow GBT (BIP 22) in using satoshi amounts
|
// NOTE: Unlike wallet RPC (which use BTC values), mining RPCs follow GBT (BIP 22) in using satoshi amounts
|
||||||
Value prioritisetransaction(const Array& params, bool fHelp)
|
UniValue prioritisetransaction(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (fHelp || params.size() != 3)
|
if (fHelp || params.size() != 3)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
@ -298,7 +298,7 @@ Value prioritisetransaction(const Array& params, bool fHelp)
|
||||||
|
|
||||||
|
|
||||||
// NOTE: Assumes a conclusive result; if result is inconclusive, it must be handled by caller
|
// NOTE: Assumes a conclusive result; if result is inconclusive, it must be handled by caller
|
||||||
static Value BIP22ValidationResult(const CValidationState& state)
|
static UniValue BIP22ValidationResult(const CValidationState& state)
|
||||||
{
|
{
|
||||||
if (state.IsValid())
|
if (state.IsValid())
|
||||||
return Value::null;
|
return Value::null;
|
||||||
|
@ -316,7 +316,7 @@ static Value BIP22ValidationResult(const CValidationState& state)
|
||||||
return "valid?";
|
return "valid?";
|
||||||
}
|
}
|
||||||
|
|
||||||
Value getblocktemplate(const Array& params, bool fHelp)
|
UniValue getblocktemplate(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (fHelp || params.size() > 1)
|
if (fHelp || params.size() > 1)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
@ -381,7 +381,7 @@ Value getblocktemplate(const Array& params, bool fHelp)
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
|
|
||||||
std::string strMode = "template";
|
std::string strMode = "template";
|
||||||
Value lpval = NullUniValue;
|
UniValue lpval = NullUniValue;
|
||||||
if (params.size() > 0)
|
if (params.size() > 0)
|
||||||
{
|
{
|
||||||
const Object& oparam = params[0].get_obj();
|
const Object& oparam = params[0].get_obj();
|
||||||
|
@ -605,7 +605,7 @@ protected:
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
Value submitblock(const Array& params, bool fHelp)
|
UniValue submitblock(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (fHelp || params.size() < 1 || params.size() > 2)
|
if (fHelp || params.size() < 1 || params.size() > 2)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
@ -666,7 +666,7 @@ Value submitblock(const Array& params, bool fHelp)
|
||||||
return BIP22ValidationResult(state);
|
return BIP22ValidationResult(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
Value estimatefee(const Array& params, bool fHelp)
|
UniValue estimatefee(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (fHelp || params.size() != 1)
|
if (fHelp || params.size() != 1)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
@ -698,7 +698,7 @@ Value estimatefee(const Array& params, bool fHelp)
|
||||||
return ValueFromAmount(feeRate.GetFeePerK());
|
return ValueFromAmount(feeRate.GetFeePerK());
|
||||||
}
|
}
|
||||||
|
|
||||||
Value estimatepriority(const Array& params, bool fHelp)
|
UniValue estimatepriority(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (fHelp || params.size() != 1)
|
if (fHelp || params.size() != 1)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
|
|
@ -38,7 +38,7 @@ using namespace std;
|
||||||
*
|
*
|
||||||
* Or alternatively, create a specific query method for the information.
|
* 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)
|
if (fHelp || params.size() != 0)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
@ -115,9 +115,9 @@ private:
|
||||||
public:
|
public:
|
||||||
DescribeAddressVisitor(isminetype mineIn) : mine(mineIn) {}
|
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);
|
UniValue obj(UniValue::VOBJ);
|
||||||
CPubKey vchPubKey;
|
CPubKey vchPubKey;
|
||||||
obj.push_back(Pair("isscript", false));
|
obj.push_back(Pair("isscript", false));
|
||||||
|
@ -129,7 +129,7 @@ public:
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
Object operator()(const CScriptID &scriptID) const {
|
UniValue operator()(const CScriptID &scriptID) const {
|
||||||
UniValue obj(UniValue::VOBJ);
|
UniValue obj(UniValue::VOBJ);
|
||||||
obj.push_back(Pair("isscript", true));
|
obj.push_back(Pair("isscript", true));
|
||||||
if (mine != ISMINE_NO) {
|
if (mine != ISMINE_NO) {
|
||||||
|
@ -153,7 +153,7 @@ public:
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Value validateaddress(const Array& params, bool fHelp)
|
UniValue validateaddress(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (fHelp || params.size() != 1)
|
if (fHelp || params.size() != 1)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
@ -202,7 +202,7 @@ Value validateaddress(const Array& params, bool fHelp)
|
||||||
ret.push_back(Pair("ismine", (mine & ISMINE_SPENDABLE) ? true : false));
|
ret.push_back(Pair("ismine", (mine & ISMINE_SPENDABLE) ? true : false));
|
||||||
if (mine != ISMINE_NO) {
|
if (mine != ISMINE_NO) {
|
||||||
ret.push_back(Pair("iswatchonly", (mine & ISMINE_WATCH_ONLY) ? true: false));
|
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);
|
ret.pushKVs(detail);
|
||||||
}
|
}
|
||||||
if (pwalletMain && pwalletMain->mapAddressBook.count(dest))
|
if (pwalletMain && pwalletMain->mapAddressBook.count(dest))
|
||||||
|
@ -276,7 +276,7 @@ CScript _createmultisig_redeemScript(const Array& params)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Value createmultisig(const Array& params, bool fHelp)
|
UniValue createmultisig(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (fHelp || params.size() < 2 || params.size() > 2)
|
if (fHelp || params.size() < 2 || params.size() > 2)
|
||||||
{
|
{
|
||||||
|
@ -319,7 +319,7 @@ Value createmultisig(const Array& params, bool fHelp)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Value verifymessage(const Array& params, bool fHelp)
|
UniValue verifymessage(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (fHelp || params.size() != 3)
|
if (fHelp || params.size() != 3)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
@ -373,7 +373,7 @@ Value verifymessage(const Array& params, bool fHelp)
|
||||||
return (pubkey.GetID() == keyID);
|
return (pubkey.GetID() == keyID);
|
||||||
}
|
}
|
||||||
|
|
||||||
Value setmocktime(const Array& params, bool fHelp)
|
UniValue setmocktime(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (fHelp || params.size() != 1)
|
if (fHelp || params.size() != 1)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
using namespace json_spirit;
|
using namespace json_spirit;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
Value getconnectioncount(const Array& params, bool fHelp)
|
UniValue getconnectioncount(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (fHelp || params.size() != 0)
|
if (fHelp || params.size() != 0)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
@ -39,7 +39,7 @@ Value getconnectioncount(const Array& params, bool fHelp)
|
||||||
return (int)vNodes.size();
|
return (int)vNodes.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
Value ping(const Array& params, bool fHelp)
|
UniValue ping(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (fHelp || params.size() != 0)
|
if (fHelp || params.size() != 0)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
@ -75,7 +75,7 @@ static void CopyNodeStats(std::vector<CNodeStats>& vstats)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Value getpeerinfo(const Array& params, bool fHelp)
|
UniValue getpeerinfo(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (fHelp || params.size() != 0)
|
if (fHelp || params.size() != 0)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
@ -165,7 +165,7 @@ Value getpeerinfo(const Array& params, bool fHelp)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
Value addnode(const Array& params, bool fHelp)
|
UniValue addnode(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
string strCommand;
|
string strCommand;
|
||||||
if (params.size() == 2)
|
if (params.size() == 2)
|
||||||
|
@ -215,7 +215,7 @@ Value addnode(const Array& params, bool fHelp)
|
||||||
return NullUniValue;
|
return NullUniValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Value getaddednodeinfo(const Array& params, bool fHelp)
|
UniValue getaddednodeinfo(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (fHelp || params.size() < 1 || params.size() > 2)
|
if (fHelp || params.size() < 1 || params.size() > 2)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
@ -332,7 +332,7 @@ Value getaddednodeinfo(const Array& params, bool fHelp)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
Value getnettotals(const Array& params, bool fHelp)
|
UniValue getnettotals(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (fHelp || params.size() > 0)
|
if (fHelp || params.size() > 0)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
@ -357,7 +357,7 @@ Value getnettotals(const Array& params, bool fHelp)
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Array GetNetworksInfo()
|
static UniValue GetNetworksInfo()
|
||||||
{
|
{
|
||||||
UniValue networks(UniValue::VARR);
|
UniValue networks(UniValue::VARR);
|
||||||
for(int n=0; n<NET_MAX; ++n)
|
for(int n=0; n<NET_MAX; ++n)
|
||||||
|
@ -378,7 +378,7 @@ static Array GetNetworksInfo()
|
||||||
return networks;
|
return networks;
|
||||||
}
|
}
|
||||||
|
|
||||||
Value getnetworkinfo(const Array& params, bool fHelp)
|
UniValue getnetworkinfo(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (fHelp || params.size() != 0)
|
if (fHelp || params.size() != 0)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
|
|
@ -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(UniValue::VOBJ);
|
UniValue 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(UniValue::VOBJ);
|
UniValue reply(UniValue::VOBJ);
|
||||||
if (!error.isNull())
|
if (!error.isNull())
|
||||||
reply.push_back(Pair("result", NullUniValue));
|
reply.push_back(Pair("result", NullUniValue));
|
||||||
else
|
else
|
||||||
|
@ -277,11 +277,11 @@ Object JSONRPCReplyObj(const Value& result, const Value& error, const Value& id)
|
||||||
|
|
||||||
string JSONRPCReply(const Value& result, const Value& error, const Value& id)
|
string JSONRPCReply(const Value& result, const Value& error, const Value& id)
|
||||||
{
|
{
|
||||||
Object reply = JSONRPCReplyObj(result, error, id);
|
UniValue reply = JSONRPCReplyObj(result, error, id);
|
||||||
return reply.write() + "\n";
|
return reply.write() + "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
Object JSONRPCError(int code, const string& message)
|
UniValue JSONRPCError(int code, const string& message)
|
||||||
{
|
{
|
||||||
UniValue error(UniValue::VOBJ);
|
UniValue error(UniValue::VOBJ);
|
||||||
error.push_back(Pair("code", code));
|
error.push_back(Pair("code", code));
|
||||||
|
|
|
@ -158,9 +158,9 @@ int ReadHTTPStatus(std::basic_istream<char>& stream, int &proto);
|
||||||
int ReadHTTPHeaders(std::basic_istream<char>& stream, std::map<std::string, std::string>& mapHeadersRet);
|
int ReadHTTPHeaders(std::basic_istream<char>& stream, std::map<std::string, std::string>& mapHeadersRet);
|
||||||
int ReadHTTPMessage(std::basic_istream<char>& stream, std::map<std::string, std::string>& mapHeadersRet,
|
int ReadHTTPMessage(std::basic_istream<char>& stream, std::map<std::string, std::string>& mapHeadersRet,
|
||||||
std::string& strMessageRet, int nProto, size_t max_size);
|
std::string& strMessageRet, int nProto, size_t max_size);
|
||||||
std::string JSONRPCRequest(const std::string& strMethod, const json_spirit::Array& params, const json_spirit::Value& id);
|
std::string JSONRPCRequest(const std::string& strMethod, const UniValue& params, const UniValue& id);
|
||||||
json_spirit::Object JSONRPCReplyObj(const json_spirit::Value& result, const json_spirit::Value& error, const json_spirit::Value& id);
|
UniValue JSONRPCReplyObj(const UniValue& result, const UniValue& error, const UniValue& id);
|
||||||
std::string JSONRPCReply(const json_spirit::Value& result, const json_spirit::Value& error, const json_spirit::Value& id);
|
std::string JSONRPCReply(const UniValue& result, const UniValue& error, const UniValue& id);
|
||||||
json_spirit::Object JSONRPCError(int code, const std::string& message);
|
UniValue JSONRPCError(int code, const std::string& message);
|
||||||
|
|
||||||
#endif // BITCOIN_RPCPROTOCOL_H
|
#endif // BITCOIN_RPCPROTOCOL_H
|
||||||
|
|
|
@ -105,7 +105,7 @@ void TxToJSON(const CTransaction& tx, const uint256 hashBlock, Object& entry)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Value getrawtransaction(const Array& params, bool fHelp)
|
UniValue getrawtransaction(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (fHelp || params.size() < 1 || params.size() > 2)
|
if (fHelp || params.size() < 1 || params.size() > 2)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
@ -195,7 +195,7 @@ Value getrawtransaction(const Array& params, bool fHelp)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Value gettxoutproof(const Array& params, bool fHelp)
|
UniValue gettxoutproof(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (fHelp || (params.size() != 1 && params.size() != 2))
|
if (fHelp || (params.size() != 1 && params.size() != 2))
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
@ -219,7 +219,7 @@ Value gettxoutproof(const Array& params, bool fHelp)
|
||||||
|
|
||||||
set<uint256> setTxids;
|
set<uint256> setTxids;
|
||||||
uint256 oneTxid;
|
uint256 oneTxid;
|
||||||
Array txids = params[0].get_array();
|
UniValue txids = params[0].get_array();
|
||||||
for (unsigned int idx = 0; idx < txids.size(); idx++) {
|
for (unsigned int idx = 0; idx < txids.size(); idx++) {
|
||||||
const Value& txid = txids[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()))
|
||||||
|
@ -276,7 +276,7 @@ Value gettxoutproof(const Array& params, bool fHelp)
|
||||||
return strHex;
|
return strHex;
|
||||||
}
|
}
|
||||||
|
|
||||||
Value verifytxoutproof(const Array& params, bool fHelp)
|
UniValue verifytxoutproof(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (fHelp || params.size() != 1)
|
if (fHelp || params.size() != 1)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
@ -309,7 +309,7 @@ Value verifytxoutproof(const Array& params, bool fHelp)
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
Value createrawtransaction(const Array& params, bool fHelp)
|
UniValue createrawtransaction(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (fHelp || params.size() != 2)
|
if (fHelp || params.size() != 2)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
@ -345,8 +345,8 @@ Value createrawtransaction(const Array& params, bool fHelp)
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
RPCTypeCheck(params, boost::assign::list_of(UniValue::VARR)(UniValue::VOBJ));
|
RPCTypeCheck(params, boost::assign::list_of(UniValue::VARR)(UniValue::VOBJ));
|
||||||
|
|
||||||
Array inputs = params[0].get_array();
|
UniValue inputs = params[0].get_array();
|
||||||
Object sendTo = params[1].get_obj();
|
UniValue sendTo = params[1].get_obj();
|
||||||
|
|
||||||
CMutableTransaction rawTx;
|
CMutableTransaction rawTx;
|
||||||
|
|
||||||
|
@ -388,7 +388,7 @@ Value createrawtransaction(const Array& params, bool fHelp)
|
||||||
return EncodeHexTx(rawTx);
|
return EncodeHexTx(rawTx);
|
||||||
}
|
}
|
||||||
|
|
||||||
Value decoderawtransaction(const Array& params, bool fHelp)
|
UniValue decoderawtransaction(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (fHelp || params.size() != 1)
|
if (fHelp || params.size() != 1)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
@ -453,7 +453,7 @@ Value decoderawtransaction(const Array& params, bool fHelp)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Value decodescript(const Array& params, bool fHelp)
|
UniValue decodescript(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (fHelp || params.size() != 1)
|
if (fHelp || params.size() != 1)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
@ -507,7 +507,7 @@ static void TxInErrorToJSON(const CTxIn& txin, Array& vErrorsRet, const std::str
|
||||||
vErrorsRet.push_back(entry);
|
vErrorsRet.push_back(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
Value signrawtransaction(const Array& params, bool fHelp)
|
UniValue signrawtransaction(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (fHelp || params.size() < 1 || params.size() > 4)
|
if (fHelp || params.size() < 1 || params.size() > 4)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
@ -617,9 +617,9 @@ Value signrawtransaction(const Array& params, bool fHelp)
|
||||||
CBasicKeyStore tempKeystore;
|
CBasicKeyStore tempKeystore;
|
||||||
if (params.size() > 2 && !params[2].isNull()) {
|
if (params.size() > 2 && !params[2].isNull()) {
|
||||||
fGivenKeys = true;
|
fGivenKeys = true;
|
||||||
Array keys = params[2].get_array();
|
UniValue keys = params[2].get_array();
|
||||||
for (unsigned int idx = 0; idx < keys.size(); idx++) {
|
for (unsigned int idx = 0; idx < keys.size(); idx++) {
|
||||||
Value k = keys[idx];
|
UniValue k = keys[idx];
|
||||||
CBitcoinSecret vchSecret;
|
CBitcoinSecret vchSecret;
|
||||||
bool fGood = vchSecret.SetString(k.get_str());
|
bool fGood = vchSecret.SetString(k.get_str());
|
||||||
if (!fGood)
|
if (!fGood)
|
||||||
|
@ -637,13 +637,13 @@ Value signrawtransaction(const Array& params, bool fHelp)
|
||||||
|
|
||||||
// Add previous txouts given in the RPC call:
|
// Add previous txouts given in the RPC call:
|
||||||
if (params.size() > 1 && !params[1].isNull()) {
|
if (params.size() > 1 && !params[1].isNull()) {
|
||||||
Array prevTxs = params[1].get_array();
|
UniValue prevTxs = params[1].get_array();
|
||||||
for (unsigned int idx = 0; idx < prevTxs.size(); idx++) {
|
for (unsigned int idx = 0; idx < prevTxs.size(); idx++) {
|
||||||
const Value& p = prevTxs[idx];
|
const Value& p = prevTxs[idx];
|
||||||
if (!p.isObject())
|
if (!p.isObject())
|
||||||
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "expected object with {\"txid'\",\"vout\",\"scriptPubKey\"}");
|
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "expected object with {\"txid'\",\"vout\",\"scriptPubKey\"}");
|
||||||
|
|
||||||
Object prevOut = p.get_obj();
|
UniValue prevOut = p.get_obj();
|
||||||
|
|
||||||
RPCTypeCheckObj(prevOut, boost::assign::map_list_of("txid", UniValue::VSTR)("vout", UniValue::VNUM)("scriptPubKey", UniValue::VSTR));
|
RPCTypeCheckObj(prevOut, boost::assign::map_list_of("txid", UniValue::VSTR)("vout", UniValue::VNUM)("scriptPubKey", UniValue::VSTR));
|
||||||
|
|
||||||
|
@ -674,7 +674,7 @@ Value signrawtransaction(const Array& params, bool fHelp)
|
||||||
// given), add redeemScript to the tempKeystore so it can be signed:
|
// given), add redeemScript to the tempKeystore so it can be signed:
|
||||||
if (fGivenKeys && scriptPubKey.IsPayToScriptHash()) {
|
if (fGivenKeys && scriptPubKey.IsPayToScriptHash()) {
|
||||||
RPCTypeCheckObj(prevOut, boost::assign::map_list_of("txid", UniValue::VSTR)("vout", UniValue::VNUM)("scriptPubKey", UniValue::VSTR)("redeemScript",UniValue::VSTR));
|
RPCTypeCheckObj(prevOut, boost::assign::map_list_of("txid", UniValue::VSTR)("vout", UniValue::VNUM)("scriptPubKey", UniValue::VSTR)("redeemScript",UniValue::VSTR));
|
||||||
Value v = find_value(prevOut, "redeemScript");
|
UniValue v = find_value(prevOut, "redeemScript");
|
||||||
if (!v.isNull()) {
|
if (!v.isNull()) {
|
||||||
vector<unsigned char> rsData(ParseHexV(v, "redeemScript"));
|
vector<unsigned char> rsData(ParseHexV(v, "redeemScript"));
|
||||||
CScript redeemScript(rsData.begin(), rsData.end());
|
CScript redeemScript(rsData.begin(), rsData.end());
|
||||||
|
@ -749,7 +749,7 @@ Value signrawtransaction(const Array& params, bool fHelp)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Value sendrawtransaction(const Array& params, bool fHelp)
|
UniValue sendrawtransaction(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (fHelp || params.size() < 1 || params.size() > 2)
|
if (fHelp || params.size() < 1 || params.size() > 2)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
|
|
@ -135,7 +135,7 @@ CAmount AmountFromValue(const Value& value)
|
||||||
return nAmount;
|
return nAmount;
|
||||||
}
|
}
|
||||||
|
|
||||||
Value ValueFromAmount(const CAmount& amount)
|
UniValue ValueFromAmount(const CAmount& amount)
|
||||||
{
|
{
|
||||||
return (double)amount / (double)COIN;
|
return (double)amount / (double)COIN;
|
||||||
}
|
}
|
||||||
|
@ -196,7 +196,7 @@ string CRPCTable::help(string strCommand) const
|
||||||
continue;
|
continue;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Array params;
|
UniValue params;
|
||||||
rpcfn_type pfn = pcmd->actor;
|
rpcfn_type pfn = pcmd->actor;
|
||||||
if (setDone.insert(pfn).second)
|
if (setDone.insert(pfn).second)
|
||||||
(*pfn)(params, true);
|
(*pfn)(params, true);
|
||||||
|
@ -229,7 +229,7 @@ string CRPCTable::help(string strCommand) const
|
||||||
return strRet;
|
return strRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
Value help(const Array& params, bool fHelp)
|
UniValue help(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (fHelp || params.size() > 1)
|
if (fHelp || params.size() > 1)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
|
@ -249,7 +249,7 @@ Value help(const Array& params, bool fHelp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Value stop(const Array& params, bool fHelp)
|
UniValue stop(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
// Accept the deprecated and ignored 'detach' boolean argument
|
// Accept the deprecated and ignored 'detach' boolean argument
|
||||||
if (fHelp || params.size() > 1)
|
if (fHelp || params.size() > 1)
|
||||||
|
@ -825,9 +825,9 @@ void RPCRunLater(const std::string& name, boost::function<void(void)> func, int6
|
||||||
class JSONRequest
|
class JSONRequest
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Value id;
|
UniValue id;
|
||||||
string strMethod;
|
string strMethod;
|
||||||
Array params;
|
UniValue params;
|
||||||
|
|
||||||
JSONRequest() { id = NullUniValue; }
|
JSONRequest() { id = NullUniValue; }
|
||||||
void parse(const Value& valRequest);
|
void parse(const Value& valRequest);
|
||||||
|
@ -844,7 +844,7 @@ void JSONRequest::parse(const Value& valRequest)
|
||||||
id = find_value(request, "id");
|
id = find_value(request, "id");
|
||||||
|
|
||||||
// Parse method
|
// Parse method
|
||||||
Value valMethod = find_value(request, "method");
|
UniValue valMethod = find_value(request, "method");
|
||||||
if (valMethod.isNull())
|
if (valMethod.isNull())
|
||||||
throw JSONRPCError(RPC_INVALID_REQUEST, "Missing method");
|
throw JSONRPCError(RPC_INVALID_REQUEST, "Missing method");
|
||||||
if (!valMethod.isStr())
|
if (!valMethod.isStr())
|
||||||
|
@ -854,7 +854,7 @@ void JSONRequest::parse(const Value& valRequest)
|
||||||
LogPrint("rpc", "ThreadRPCServer method=%s\n", SanitizeString(strMethod));
|
LogPrint("rpc", "ThreadRPCServer method=%s\n", SanitizeString(strMethod));
|
||||||
|
|
||||||
// Parse params
|
// Parse params
|
||||||
Value valParams = find_value(request, "params");
|
UniValue valParams = find_value(request, "params");
|
||||||
if (valParams.isArray())
|
if (valParams.isArray())
|
||||||
params = valParams.get_array();
|
params = valParams.get_array();
|
||||||
else if (valParams.isNull())
|
else if (valParams.isNull())
|
||||||
|
@ -864,7 +864,7 @@ void JSONRequest::parse(const Value& valRequest)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static Object JSONRPCExecOne(const Value& req)
|
static UniValue JSONRPCExecOne(const Value& req)
|
||||||
{
|
{
|
||||||
UniValue rpc_result(UniValue::VOBJ);
|
UniValue rpc_result(UniValue::VOBJ);
|
||||||
|
|
||||||
|
@ -872,7 +872,7 @@ static Object JSONRPCExecOne(const Value& req)
|
||||||
try {
|
try {
|
||||||
jreq.parse(req);
|
jreq.parse(req);
|
||||||
|
|
||||||
Value result = tableRPC.execute(jreq.strMethod, jreq.params);
|
UniValue result = tableRPC.execute(jreq.strMethod, jreq.params);
|
||||||
rpc_result = JSONRPCReplyObj(result, NullUniValue, jreq.id);
|
rpc_result = JSONRPCReplyObj(result, NullUniValue, jreq.id);
|
||||||
}
|
}
|
||||||
catch (const Object& objError)
|
catch (const Object& objError)
|
||||||
|
@ -890,7 +890,7 @@ static Object JSONRPCExecOne(const Value& req)
|
||||||
|
|
||||||
static string JSONRPCExecBatch(const Array& vReq)
|
static string JSONRPCExecBatch(const Array& vReq)
|
||||||
{
|
{
|
||||||
Array ret;
|
UniValue ret;
|
||||||
for (unsigned int reqIdx = 0; reqIdx < vReq.size(); reqIdx++)
|
for (unsigned int reqIdx = 0; reqIdx < vReq.size(); reqIdx++)
|
||||||
ret.push_back(JSONRPCExecOne(vReq[reqIdx]));
|
ret.push_back(JSONRPCExecOne(vReq[reqIdx]));
|
||||||
|
|
||||||
|
@ -925,7 +925,7 @@ static bool HTTPReq_JSONRPC(AcceptedConnection *conn,
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Parse request
|
// Parse request
|
||||||
Value valRequest;
|
UniValue valRequest;
|
||||||
if (!valRequest.read(strRequest))
|
if (!valRequest.read(strRequest))
|
||||||
throw JSONRPCError(RPC_PARSE_ERROR, "Parse error");
|
throw JSONRPCError(RPC_PARSE_ERROR, "Parse error");
|
||||||
|
|
||||||
|
@ -942,7 +942,7 @@ static bool HTTPReq_JSONRPC(AcceptedConnection *conn,
|
||||||
if (valRequest.isObject()) {
|
if (valRequest.isObject()) {
|
||||||
jreq.parse(valRequest);
|
jreq.parse(valRequest);
|
||||||
|
|
||||||
Value result = tableRPC.execute(jreq.strMethod, jreq.params);
|
UniValue result = tableRPC.execute(jreq.strMethod, jreq.params);
|
||||||
|
|
||||||
// Send reply
|
// Send reply
|
||||||
strReply = JSONRPCReply(result, NullUniValue, jreq.id);
|
strReply = JSONRPCReply(result, NullUniValue, jreq.id);
|
||||||
|
@ -1005,7 +1005,7 @@ void ServiceConnection(AcceptedConnection *conn)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
json_spirit::Value CRPCTable::execute(const std::string &strMethod, const json_spirit::Array ¶ms) const
|
UniValue CRPCTable::execute(const std::string &strMethod, const UniValue ¶ms) const
|
||||||
{
|
{
|
||||||
// Find method
|
// Find method
|
||||||
const CRPCCommand *pcmd = tableRPC[strMethod];
|
const CRPCCommand *pcmd = tableRPC[strMethod];
|
||||||
|
|
192
src/rpcserver.h
192
src/rpcserver.h
|
@ -70,8 +70,8 @@ bool RPCIsInWarmup(std::string *statusOut);
|
||||||
* the right number of arguments are passed, just that any passed are the correct type.
|
* the right number of arguments are passed, just that any passed are the correct type.
|
||||||
* Use like: RPCTypeCheck(params, boost::assign::list_of(str_type)(int_type)(obj_type));
|
* Use like: RPCTypeCheck(params, boost::assign::list_of(str_type)(int_type)(obj_type));
|
||||||
*/
|
*/
|
||||||
void RPCTypeCheck(const json_spirit::Array& params,
|
void RPCTypeCheck(const UniValue& params,
|
||||||
const std::list<json_spirit::Value_type>& typesExpected, bool fAllowNull=false);
|
const std::list<UniValue::VType>& typesExpected, bool fAllowNull=false);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Check for expected keys/value types in an Object.
|
Check for expected keys/value types in an Object.
|
||||||
|
@ -89,7 +89,7 @@ void RPCRunLater(const std::string& name, boost::function<void(void)> func, int6
|
||||||
//! Convert boost::asio address to CNetAddr
|
//! Convert boost::asio address to CNetAddr
|
||||||
extern CNetAddr BoostAsioToCNetAddr(boost::asio::ip::address address);
|
extern CNetAddr BoostAsioToCNetAddr(boost::asio::ip::address address);
|
||||||
|
|
||||||
typedef json_spirit::Value(*rpcfn_type)(const json_spirit::Array& params, bool fHelp);
|
typedef UniValue(*rpcfn_type)(const UniValue& params, bool fHelp);
|
||||||
|
|
||||||
class CRPCCommand
|
class CRPCCommand
|
||||||
{
|
{
|
||||||
|
@ -115,11 +115,11 @@ public:
|
||||||
/**
|
/**
|
||||||
* Execute a method.
|
* Execute a method.
|
||||||
* @param method Method to execute
|
* @param method Method to execute
|
||||||
* @param params Array of arguments (JSON objects)
|
* @param params UniValue Array of arguments (JSON objects)
|
||||||
* @returns Result of the call.
|
* @returns Result of the call.
|
||||||
* @throws an exception (json_spirit::Value) when an error happens.
|
* @throws an exception (UniValue) when an error happens.
|
||||||
*/
|
*/
|
||||||
json_spirit::Value execute(const std::string &method, const json_spirit::Array ¶ms) const;
|
UniValue execute(const std::string &method, const UniValue ¶ms) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern const CRPCTable tableRPC;
|
extern const CRPCTable tableRPC;
|
||||||
|
@ -128,17 +128,17 @@ extern const CRPCTable tableRPC;
|
||||||
* Utilities: convert hex-encoded Values
|
* Utilities: convert hex-encoded Values
|
||||||
* (throws error if not hex).
|
* (throws error if not hex).
|
||||||
*/
|
*/
|
||||||
extern uint256 ParseHashV(const json_spirit::Value& v, std::string strName);
|
extern uint256 ParseHashV(const UniValue& v, std::string strName);
|
||||||
extern uint256 ParseHashO(const json_spirit::Object& o, std::string strKey);
|
extern uint256 ParseHashO(const UniValue& o, std::string strKey);
|
||||||
extern std::vector<unsigned char> ParseHexV(const json_spirit::Value& v, std::string strName);
|
extern std::vector<unsigned char> ParseHexV(const UniValue& v, std::string strName);
|
||||||
extern std::vector<unsigned char> ParseHexO(const json_spirit::Object& o, std::string strKey);
|
extern std::vector<unsigned char> ParseHexO(const UniValue& o, std::string strKey);
|
||||||
|
|
||||||
extern void InitRPCMining();
|
extern void InitRPCMining();
|
||||||
extern void ShutdownRPCMining();
|
extern void ShutdownRPCMining();
|
||||||
|
|
||||||
extern int64_t nWalletUnlockTime;
|
extern int64_t nWalletUnlockTime;
|
||||||
extern CAmount AmountFromValue(const json_spirit::Value& value);
|
extern CAmount AmountFromValue(const UniValue& value);
|
||||||
extern json_spirit::Value ValueFromAmount(const CAmount& amount);
|
extern UniValue ValueFromAmount(const CAmount& amount);
|
||||||
extern double GetDifficulty(const CBlockIndex* blockindex = NULL);
|
extern double GetDifficulty(const CBlockIndex* blockindex = NULL);
|
||||||
extern std::string HelpRequiringPassphrase();
|
extern std::string HelpRequiringPassphrase();
|
||||||
extern std::string HelpExampleCli(std::string methodname, std::string args);
|
extern std::string HelpExampleCli(std::string methodname, std::string args);
|
||||||
|
@ -146,95 +146,95 @@ extern std::string HelpExampleRpc(std::string methodname, std::string args);
|
||||||
|
|
||||||
extern void EnsureWalletIsUnlocked();
|
extern void EnsureWalletIsUnlocked();
|
||||||
|
|
||||||
extern json_spirit::Value getconnectioncount(const json_spirit::Array& params, bool fHelp); // in rpcnet.cpp
|
extern UniValue getconnectioncount(const UniValue& params, bool fHelp); // in rpcnet.cpp
|
||||||
extern json_spirit::Value getpeerinfo(const json_spirit::Array& params, bool fHelp);
|
extern UniValue getpeerinfo(const UniValue& params, bool fHelp);
|
||||||
extern json_spirit::Value ping(const json_spirit::Array& params, bool fHelp);
|
extern UniValue ping(const UniValue& params, bool fHelp);
|
||||||
extern json_spirit::Value addnode(const json_spirit::Array& params, bool fHelp);
|
extern UniValue addnode(const UniValue& params, bool fHelp);
|
||||||
extern json_spirit::Value getaddednodeinfo(const json_spirit::Array& params, bool fHelp);
|
extern UniValue getaddednodeinfo(const UniValue& params, bool fHelp);
|
||||||
extern json_spirit::Value getnettotals(const json_spirit::Array& params, bool fHelp);
|
extern UniValue getnettotals(const UniValue& params, bool fHelp);
|
||||||
|
|
||||||
extern json_spirit::Value dumpprivkey(const json_spirit::Array& params, bool fHelp); // in rpcdump.cpp
|
extern UniValue dumpprivkey(const UniValue& params, bool fHelp); // in rpcdump.cpp
|
||||||
extern json_spirit::Value importprivkey(const json_spirit::Array& params, bool fHelp);
|
extern UniValue importprivkey(const UniValue& params, bool fHelp);
|
||||||
extern json_spirit::Value importaddress(const json_spirit::Array& params, bool fHelp);
|
extern UniValue importaddress(const UniValue& params, bool fHelp);
|
||||||
extern json_spirit::Value dumpwallet(const json_spirit::Array& params, bool fHelp);
|
extern UniValue dumpwallet(const UniValue& params, bool fHelp);
|
||||||
extern json_spirit::Value importwallet(const json_spirit::Array& params, bool fHelp);
|
extern UniValue importwallet(const UniValue& params, bool fHelp);
|
||||||
|
|
||||||
extern json_spirit::Value getgenerate(const json_spirit::Array& params, bool fHelp); // in rpcmining.cpp
|
extern UniValue getgenerate(const UniValue& params, bool fHelp); // in rpcmining.cpp
|
||||||
extern json_spirit::Value setgenerate(const json_spirit::Array& params, bool fHelp);
|
extern UniValue setgenerate(const UniValue& params, bool fHelp);
|
||||||
extern json_spirit::Value generate(const json_spirit::Array& params, bool fHelp);
|
extern UniValue generate(const UniValue& params, bool fHelp);
|
||||||
extern json_spirit::Value getnetworkhashps(const json_spirit::Array& params, bool fHelp);
|
extern UniValue getnetworkhashps(const UniValue& params, bool fHelp);
|
||||||
extern json_spirit::Value getmininginfo(const json_spirit::Array& params, bool fHelp);
|
extern UniValue getmininginfo(const UniValue& params, bool fHelp);
|
||||||
extern json_spirit::Value prioritisetransaction(const json_spirit::Array& params, bool fHelp);
|
extern UniValue prioritisetransaction(const UniValue& params, bool fHelp);
|
||||||
extern json_spirit::Value getblocktemplate(const json_spirit::Array& params, bool fHelp);
|
extern UniValue getblocktemplate(const UniValue& params, bool fHelp);
|
||||||
extern json_spirit::Value submitblock(const json_spirit::Array& params, bool fHelp);
|
extern UniValue submitblock(const UniValue& params, bool fHelp);
|
||||||
extern json_spirit::Value estimatefee(const json_spirit::Array& params, bool fHelp);
|
extern UniValue estimatefee(const UniValue& params, bool fHelp);
|
||||||
extern json_spirit::Value estimatepriority(const json_spirit::Array& params, bool fHelp);
|
extern UniValue estimatepriority(const UniValue& params, bool fHelp);
|
||||||
|
|
||||||
extern json_spirit::Value getnewaddress(const json_spirit::Array& params, bool fHelp); // in rpcwallet.cpp
|
extern UniValue getnewaddress(const UniValue& params, bool fHelp); // in rpcwallet.cpp
|
||||||
extern json_spirit::Value getaccountaddress(const json_spirit::Array& params, bool fHelp);
|
extern UniValue getaccountaddress(const UniValue& params, bool fHelp);
|
||||||
extern json_spirit::Value getrawchangeaddress(const json_spirit::Array& params, bool fHelp);
|
extern UniValue getrawchangeaddress(const UniValue& params, bool fHelp);
|
||||||
extern json_spirit::Value setaccount(const json_spirit::Array& params, bool fHelp);
|
extern UniValue setaccount(const UniValue& params, bool fHelp);
|
||||||
extern json_spirit::Value getaccount(const json_spirit::Array& params, bool fHelp);
|
extern UniValue getaccount(const UniValue& params, bool fHelp);
|
||||||
extern json_spirit::Value getaddressesbyaccount(const json_spirit::Array& params, bool fHelp);
|
extern UniValue getaddressesbyaccount(const UniValue& params, bool fHelp);
|
||||||
extern json_spirit::Value sendtoaddress(const json_spirit::Array& params, bool fHelp);
|
extern UniValue sendtoaddress(const UniValue& params, bool fHelp);
|
||||||
extern json_spirit::Value signmessage(const json_spirit::Array& params, bool fHelp);
|
extern UniValue signmessage(const UniValue& params, bool fHelp);
|
||||||
extern json_spirit::Value verifymessage(const json_spirit::Array& params, bool fHelp);
|
extern UniValue verifymessage(const UniValue& params, bool fHelp);
|
||||||
extern json_spirit::Value getreceivedbyaddress(const json_spirit::Array& params, bool fHelp);
|
extern UniValue getreceivedbyaddress(const UniValue& params, bool fHelp);
|
||||||
extern json_spirit::Value getreceivedbyaccount(const json_spirit::Array& params, bool fHelp);
|
extern UniValue getreceivedbyaccount(const UniValue& params, bool fHelp);
|
||||||
extern json_spirit::Value getbalance(const json_spirit::Array& params, bool fHelp);
|
extern UniValue getbalance(const UniValue& params, bool fHelp);
|
||||||
extern json_spirit::Value getunconfirmedbalance(const json_spirit::Array& params, bool fHelp);
|
extern UniValue getunconfirmedbalance(const UniValue& params, bool fHelp);
|
||||||
extern json_spirit::Value movecmd(const json_spirit::Array& params, bool fHelp);
|
extern UniValue movecmd(const UniValue& params, bool fHelp);
|
||||||
extern json_spirit::Value sendfrom(const json_spirit::Array& params, bool fHelp);
|
extern UniValue sendfrom(const UniValue& params, bool fHelp);
|
||||||
extern json_spirit::Value sendmany(const json_spirit::Array& params, bool fHelp);
|
extern UniValue sendmany(const UniValue& params, bool fHelp);
|
||||||
extern json_spirit::Value addmultisigaddress(const json_spirit::Array& params, bool fHelp);
|
extern UniValue addmultisigaddress(const UniValue& params, bool fHelp);
|
||||||
extern json_spirit::Value createmultisig(const json_spirit::Array& params, bool fHelp);
|
extern UniValue createmultisig(const UniValue& params, bool fHelp);
|
||||||
extern json_spirit::Value listreceivedbyaddress(const json_spirit::Array& params, bool fHelp);
|
extern UniValue listreceivedbyaddress(const UniValue& params, bool fHelp);
|
||||||
extern json_spirit::Value listreceivedbyaccount(const json_spirit::Array& params, bool fHelp);
|
extern UniValue listreceivedbyaccount(const UniValue& params, bool fHelp);
|
||||||
extern json_spirit::Value listtransactions(const json_spirit::Array& params, bool fHelp);
|
extern UniValue listtransactions(const UniValue& params, bool fHelp);
|
||||||
extern json_spirit::Value listaddressgroupings(const json_spirit::Array& params, bool fHelp);
|
extern UniValue listaddressgroupings(const UniValue& params, bool fHelp);
|
||||||
extern json_spirit::Value listaccounts(const json_spirit::Array& params, bool fHelp);
|
extern UniValue listaccounts(const UniValue& params, bool fHelp);
|
||||||
extern json_spirit::Value listsinceblock(const json_spirit::Array& params, bool fHelp);
|
extern UniValue listsinceblock(const UniValue& params, bool fHelp);
|
||||||
extern json_spirit::Value gettransaction(const json_spirit::Array& params, bool fHelp);
|
extern UniValue gettransaction(const UniValue& params, bool fHelp);
|
||||||
extern json_spirit::Value backupwallet(const json_spirit::Array& params, bool fHelp);
|
extern UniValue backupwallet(const UniValue& params, bool fHelp);
|
||||||
extern json_spirit::Value keypoolrefill(const json_spirit::Array& params, bool fHelp);
|
extern UniValue keypoolrefill(const UniValue& params, bool fHelp);
|
||||||
extern json_spirit::Value walletpassphrase(const json_spirit::Array& params, bool fHelp);
|
extern UniValue walletpassphrase(const UniValue& params, bool fHelp);
|
||||||
extern json_spirit::Value walletpassphrasechange(const json_spirit::Array& params, bool fHelp);
|
extern UniValue walletpassphrasechange(const UniValue& params, bool fHelp);
|
||||||
extern json_spirit::Value walletlock(const json_spirit::Array& params, bool fHelp);
|
extern UniValue walletlock(const UniValue& params, bool fHelp);
|
||||||
extern json_spirit::Value encryptwallet(const json_spirit::Array& params, bool fHelp);
|
extern UniValue encryptwallet(const UniValue& params, bool fHelp);
|
||||||
extern json_spirit::Value validateaddress(const json_spirit::Array& params, bool fHelp);
|
extern UniValue validateaddress(const UniValue& params, bool fHelp);
|
||||||
extern json_spirit::Value getinfo(const json_spirit::Array& params, bool fHelp);
|
extern UniValue getinfo(const UniValue& params, bool fHelp);
|
||||||
extern json_spirit::Value getwalletinfo(const json_spirit::Array& params, bool fHelp);
|
extern UniValue getwalletinfo(const UniValue& params, bool fHelp);
|
||||||
extern json_spirit::Value getblockchaininfo(const json_spirit::Array& params, bool fHelp);
|
extern UniValue getblockchaininfo(const UniValue& params, bool fHelp);
|
||||||
extern json_spirit::Value getnetworkinfo(const json_spirit::Array& params, bool fHelp);
|
extern UniValue getnetworkinfo(const UniValue& params, bool fHelp);
|
||||||
extern json_spirit::Value setmocktime(const json_spirit::Array& params, bool fHelp);
|
extern UniValue setmocktime(const UniValue& params, bool fHelp);
|
||||||
extern json_spirit::Value resendwallettransactions(const json_spirit::Array& params, bool fHelp);
|
extern UniValue resendwallettransactions(const UniValue& params, bool fHelp);
|
||||||
|
|
||||||
extern json_spirit::Value getrawtransaction(const json_spirit::Array& params, bool fHelp); // in rcprawtransaction.cpp
|
extern UniValue getrawtransaction(const UniValue& params, bool fHelp); // in rcprawtransaction.cpp
|
||||||
extern json_spirit::Value listunspent(const json_spirit::Array& params, bool fHelp);
|
extern UniValue listunspent(const UniValue& params, bool fHelp);
|
||||||
extern json_spirit::Value lockunspent(const json_spirit::Array& params, bool fHelp);
|
extern UniValue lockunspent(const UniValue& params, bool fHelp);
|
||||||
extern json_spirit::Value listlockunspent(const json_spirit::Array& params, bool fHelp);
|
extern UniValue listlockunspent(const UniValue& params, bool fHelp);
|
||||||
extern json_spirit::Value createrawtransaction(const json_spirit::Array& params, bool fHelp);
|
extern UniValue createrawtransaction(const UniValue& params, bool fHelp);
|
||||||
extern json_spirit::Value decoderawtransaction(const json_spirit::Array& params, bool fHelp);
|
extern UniValue decoderawtransaction(const UniValue& params, bool fHelp);
|
||||||
extern json_spirit::Value decodescript(const json_spirit::Array& params, bool fHelp);
|
extern UniValue decodescript(const UniValue& params, bool fHelp);
|
||||||
extern json_spirit::Value signrawtransaction(const json_spirit::Array& params, bool fHelp);
|
extern UniValue signrawtransaction(const UniValue& params, bool fHelp);
|
||||||
extern json_spirit::Value sendrawtransaction(const json_spirit::Array& params, bool fHelp);
|
extern UniValue sendrawtransaction(const UniValue& params, bool fHelp);
|
||||||
extern json_spirit::Value gettxoutproof(const json_spirit::Array& params, bool fHelp);
|
extern UniValue gettxoutproof(const UniValue& params, bool fHelp);
|
||||||
extern json_spirit::Value verifytxoutproof(const json_spirit::Array& params, bool fHelp);
|
extern UniValue verifytxoutproof(const UniValue& params, bool fHelp);
|
||||||
|
|
||||||
extern json_spirit::Value getblockcount(const json_spirit::Array& params, bool fHelp); // in rpcblockchain.cpp
|
extern UniValue getblockcount(const UniValue& params, bool fHelp); // in rpcblockchain.cpp
|
||||||
extern json_spirit::Value getbestblockhash(const json_spirit::Array& params, bool fHelp);
|
extern UniValue getbestblockhash(const UniValue& params, bool fHelp);
|
||||||
extern json_spirit::Value getdifficulty(const json_spirit::Array& params, bool fHelp);
|
extern UniValue getdifficulty(const UniValue& params, bool fHelp);
|
||||||
extern json_spirit::Value settxfee(const json_spirit::Array& params, bool fHelp);
|
extern UniValue settxfee(const UniValue& params, bool fHelp);
|
||||||
extern json_spirit::Value getmempoolinfo(const json_spirit::Array& params, bool fHelp);
|
extern UniValue getmempoolinfo(const UniValue& params, bool fHelp);
|
||||||
extern json_spirit::Value getrawmempool(const json_spirit::Array& params, bool fHelp);
|
extern UniValue getrawmempool(const UniValue& params, bool fHelp);
|
||||||
extern json_spirit::Value getblockhash(const json_spirit::Array& params, bool fHelp);
|
extern UniValue getblockhash(const UniValue& params, bool fHelp);
|
||||||
extern json_spirit::Value getblock(const json_spirit::Array& params, bool fHelp);
|
extern UniValue getblock(const UniValue& params, bool fHelp);
|
||||||
extern json_spirit::Value gettxoutsetinfo(const json_spirit::Array& params, bool fHelp);
|
extern UniValue gettxoutsetinfo(const UniValue& params, bool fHelp);
|
||||||
extern json_spirit::Value gettxout(const json_spirit::Array& params, bool fHelp);
|
extern UniValue gettxout(const UniValue& params, bool fHelp);
|
||||||
extern json_spirit::Value verifychain(const json_spirit::Array& params, bool fHelp);
|
extern UniValue verifychain(const UniValue& params, bool fHelp);
|
||||||
extern json_spirit::Value getchaintips(const json_spirit::Array& params, bool fHelp);
|
extern UniValue getchaintips(const UniValue& params, bool fHelp);
|
||||||
extern json_spirit::Value invalidateblock(const json_spirit::Array& params, bool fHelp);
|
extern UniValue invalidateblock(const UniValue& params, bool fHelp);
|
||||||
extern json_spirit::Value reconsiderblock(const json_spirit::Array& params, bool fHelp);
|
extern UniValue reconsiderblock(const UniValue& params, bool fHelp);
|
||||||
|
|
||||||
// in rest.cpp
|
// in rest.cpp
|
||||||
extern bool HTTPReq_REST(AcceptedConnection *conn,
|
extern bool HTTPReq_REST(AcceptedConnection *conn,
|
||||||
|
|
|
@ -20,16 +20,16 @@
|
||||||
#include "json_spirit_wrapper.h"
|
#include "json_spirit_wrapper.h"
|
||||||
|
|
||||||
using namespace json_spirit;
|
using namespace json_spirit;
|
||||||
extern Array read_json(const std::string& jsondata);
|
extern UniValue read_json(const std::string& jsondata);
|
||||||
|
|
||||||
BOOST_FIXTURE_TEST_SUITE(base58_tests, BasicTestingSetup)
|
BOOST_FIXTURE_TEST_SUITE(base58_tests, BasicTestingSetup)
|
||||||
|
|
||||||
// Goal: test low-level base58 encoding functionality
|
// Goal: test low-level base58 encoding functionality
|
||||||
BOOST_AUTO_TEST_CASE(base58_EncodeBase58)
|
BOOST_AUTO_TEST_CASE(base58_EncodeBase58)
|
||||||
{
|
{
|
||||||
Array tests = read_json(std::string(json_tests::base58_encode_decode, json_tests::base58_encode_decode + sizeof(json_tests::base58_encode_decode)));
|
UniValue tests = read_json(std::string(json_tests::base58_encode_decode, json_tests::base58_encode_decode + sizeof(json_tests::base58_encode_decode)));
|
||||||
for (unsigned int idx = 0; idx < tests.size(); idx++) {
|
for (unsigned int idx = 0; idx < tests.size(); idx++) {
|
||||||
Array test = tests[idx];
|
UniValue test = tests[idx];
|
||||||
std::string strTest = test.write();
|
std::string strTest = test.write();
|
||||||
if (test.size() < 2) // Allow for extra stuff (useful for comments)
|
if (test.size() < 2) // Allow for extra stuff (useful for comments)
|
||||||
{
|
{
|
||||||
|
@ -47,11 +47,11 @@ BOOST_AUTO_TEST_CASE(base58_EncodeBase58)
|
||||||
// Goal: test low-level base58 decoding functionality
|
// Goal: test low-level base58 decoding functionality
|
||||||
BOOST_AUTO_TEST_CASE(base58_DecodeBase58)
|
BOOST_AUTO_TEST_CASE(base58_DecodeBase58)
|
||||||
{
|
{
|
||||||
Array tests = read_json(std::string(json_tests::base58_encode_decode, json_tests::base58_encode_decode + sizeof(json_tests::base58_encode_decode)));
|
UniValue tests = read_json(std::string(json_tests::base58_encode_decode, json_tests::base58_encode_decode + sizeof(json_tests::base58_encode_decode)));
|
||||||
std::vector<unsigned char> result;
|
std::vector<unsigned char> result;
|
||||||
|
|
||||||
for (unsigned int idx = 0; idx < tests.size(); idx++) {
|
for (unsigned int idx = 0; idx < tests.size(); idx++) {
|
||||||
Array test = tests[idx];
|
UniValue test = tests[idx];
|
||||||
std::string strTest = test.write();
|
std::string strTest = test.write();
|
||||||
if (test.size() < 2) // Allow for extra stuff (useful for comments)
|
if (test.size() < 2) // Allow for extra stuff (useful for comments)
|
||||||
{
|
{
|
||||||
|
@ -120,14 +120,14 @@ public:
|
||||||
// Goal: check that parsed keys match test payload
|
// Goal: check that parsed keys match test payload
|
||||||
BOOST_AUTO_TEST_CASE(base58_keys_valid_parse)
|
BOOST_AUTO_TEST_CASE(base58_keys_valid_parse)
|
||||||
{
|
{
|
||||||
Array tests = read_json(std::string(json_tests::base58_keys_valid, json_tests::base58_keys_valid + sizeof(json_tests::base58_keys_valid)));
|
UniValue tests = read_json(std::string(json_tests::base58_keys_valid, json_tests::base58_keys_valid + sizeof(json_tests::base58_keys_valid)));
|
||||||
std::vector<unsigned char> result;
|
std::vector<unsigned char> result;
|
||||||
CBitcoinSecret secret;
|
CBitcoinSecret secret;
|
||||||
CBitcoinAddress addr;
|
CBitcoinAddress addr;
|
||||||
SelectParams(CBaseChainParams::MAIN);
|
SelectParams(CBaseChainParams::MAIN);
|
||||||
|
|
||||||
for (unsigned int idx = 0; idx < tests.size(); idx++) {
|
for (unsigned int idx = 0; idx < tests.size(); idx++) {
|
||||||
Array test = tests[idx];
|
UniValue test = tests[idx];
|
||||||
std::string strTest = test.write();
|
std::string strTest = test.write();
|
||||||
if (test.size() < 3) // Allow for extra stuff (useful for comments)
|
if (test.size() < 3) // Allow for extra stuff (useful for comments)
|
||||||
{
|
{
|
||||||
|
@ -136,7 +136,7 @@ BOOST_AUTO_TEST_CASE(base58_keys_valid_parse)
|
||||||
}
|
}
|
||||||
std::string exp_base58string = test[0].get_str();
|
std::string exp_base58string = test[0].get_str();
|
||||||
std::vector<unsigned char> exp_payload = ParseHex(test[1].get_str());
|
std::vector<unsigned char> exp_payload = ParseHex(test[1].get_str());
|
||||||
const Object &metadata = test[2].get_obj();
|
const UniValue &metadata = test[2].get_obj();
|
||||||
bool isPrivkey = find_value(metadata, "isPrivkey").get_bool();
|
bool isPrivkey = find_value(metadata, "isPrivkey").get_bool();
|
||||||
bool isTestnet = find_value(metadata, "isTestnet").get_bool();
|
bool isTestnet = find_value(metadata, "isTestnet").get_bool();
|
||||||
if (isTestnet)
|
if (isTestnet)
|
||||||
|
@ -178,11 +178,11 @@ BOOST_AUTO_TEST_CASE(base58_keys_valid_parse)
|
||||||
// Goal: check that generated keys match test vectors
|
// Goal: check that generated keys match test vectors
|
||||||
BOOST_AUTO_TEST_CASE(base58_keys_valid_gen)
|
BOOST_AUTO_TEST_CASE(base58_keys_valid_gen)
|
||||||
{
|
{
|
||||||
Array tests = read_json(std::string(json_tests::base58_keys_valid, json_tests::base58_keys_valid + sizeof(json_tests::base58_keys_valid)));
|
UniValue tests = read_json(std::string(json_tests::base58_keys_valid, json_tests::base58_keys_valid + sizeof(json_tests::base58_keys_valid)));
|
||||||
std::vector<unsigned char> result;
|
std::vector<unsigned char> result;
|
||||||
|
|
||||||
for (unsigned int idx = 0; idx < tests.size(); idx++) {
|
for (unsigned int idx = 0; idx < tests.size(); idx++) {
|
||||||
Array test = tests[idx];
|
UniValue test = tests[idx];
|
||||||
std::string strTest = test.write();
|
std::string strTest = test.write();
|
||||||
if (test.size() < 3) // Allow for extra stuff (useful for comments)
|
if (test.size() < 3) // Allow for extra stuff (useful for comments)
|
||||||
{
|
{
|
||||||
|
@ -191,7 +191,7 @@ BOOST_AUTO_TEST_CASE(base58_keys_valid_gen)
|
||||||
}
|
}
|
||||||
std::string exp_base58string = test[0].get_str();
|
std::string exp_base58string = test[0].get_str();
|
||||||
std::vector<unsigned char> exp_payload = ParseHex(test[1].get_str());
|
std::vector<unsigned char> exp_payload = ParseHex(test[1].get_str());
|
||||||
const Object &metadata = test[2].get_obj();
|
const UniValue &metadata = test[2].get_obj();
|
||||||
bool isPrivkey = find_value(metadata, "isPrivkey").get_bool();
|
bool isPrivkey = find_value(metadata, "isPrivkey").get_bool();
|
||||||
bool isTestnet = find_value(metadata, "isTestnet").get_bool();
|
bool isTestnet = find_value(metadata, "isTestnet").get_bool();
|
||||||
if (isTestnet)
|
if (isTestnet)
|
||||||
|
@ -246,13 +246,13 @@ BOOST_AUTO_TEST_CASE(base58_keys_valid_gen)
|
||||||
// Goal: check that base58 parsing code is robust against a variety of corrupted data
|
// Goal: check that base58 parsing code is robust against a variety of corrupted data
|
||||||
BOOST_AUTO_TEST_CASE(base58_keys_invalid)
|
BOOST_AUTO_TEST_CASE(base58_keys_invalid)
|
||||||
{
|
{
|
||||||
Array tests = read_json(std::string(json_tests::base58_keys_invalid, json_tests::base58_keys_invalid + sizeof(json_tests::base58_keys_invalid))); // Negative testcases
|
UniValue tests = read_json(std::string(json_tests::base58_keys_invalid, json_tests::base58_keys_invalid + sizeof(json_tests::base58_keys_invalid))); // Negative testcases
|
||||||
std::vector<unsigned char> result;
|
std::vector<unsigned char> result;
|
||||||
CBitcoinSecret secret;
|
CBitcoinSecret secret;
|
||||||
CBitcoinAddress addr;
|
CBitcoinAddress addr;
|
||||||
|
|
||||||
for (unsigned int idx = 0; idx < tests.size(); idx++) {
|
for (unsigned int idx = 0; idx < tests.size(); idx++) {
|
||||||
Array test = tests[idx];
|
UniValue test = tests[idx];
|
||||||
std::string strTest = test.write();
|
std::string strTest = test.write();
|
||||||
if (test.size() < 1) // Allow for extra stuff (useful for comments)
|
if (test.size() < 1) // Allow for extra stuff (useful for comments)
|
||||||
{
|
{
|
||||||
|
|
|
@ -34,7 +34,7 @@ Value CallRPC(string args)
|
||||||
boost::split(vArgs, args, boost::is_any_of(" \t"));
|
boost::split(vArgs, args, boost::is_any_of(" \t"));
|
||||||
string strMethod = vArgs[0];
|
string strMethod = vArgs[0];
|
||||||
vArgs.erase(vArgs.begin());
|
vArgs.erase(vArgs.begin());
|
||||||
Array params = RPCConvertValues(strMethod, vArgs);
|
UniValue params = RPCConvertValues(strMethod, vArgs);
|
||||||
|
|
||||||
rpcfn_type method = tableRPC[strMethod]->actor;
|
rpcfn_type method = tableRPC[strMethod]->actor;
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace json_spirit;
|
using namespace json_spirit;
|
||||||
|
|
||||||
extern Array createArgs(int nRequired, const char* address1 = NULL, const char* address2 = NULL);
|
extern UniValue createArgs(int nRequired, const char* address1 = NULL, const char* address2 = NULL);
|
||||||
extern Value CallRPC(string args);
|
extern Value CallRPC(string args);
|
||||||
|
|
||||||
extern CWallet* pwalletMain;
|
extern CWallet* pwalletMain;
|
||||||
|
@ -213,7 +213,7 @@ BOOST_AUTO_TEST_CASE(rpc_wallet)
|
||||||
*********************************/
|
*********************************/
|
||||||
BOOST_CHECK_THROW(CallRPC("getaddressesbyaccount"), runtime_error);
|
BOOST_CHECK_THROW(CallRPC("getaddressesbyaccount"), runtime_error);
|
||||||
BOOST_CHECK_NO_THROW(retValue = CallRPC("getaddressesbyaccount " + strAccount));
|
BOOST_CHECK_NO_THROW(retValue = CallRPC("getaddressesbyaccount " + strAccount));
|
||||||
Array arr = retValue.get_array();
|
UniValue arr = retValue.get_array();
|
||||||
BOOST_CHECK(arr.size() > 0);
|
BOOST_CHECK(arr.size() > 0);
|
||||||
BOOST_CHECK(CBitcoinAddress(arr[0].get_str()).Get() == demoAddress.Get());
|
BOOST_CHECK(CBitcoinAddress(arr[0].get_str()).Get() == demoAddress.Get());
|
||||||
}
|
}
|
||||||
|
|
|
@ -293,7 +293,7 @@ public:
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
Array GetJSON()
|
UniValue GetJSON()
|
||||||
{
|
{
|
||||||
DoPush();
|
DoPush();
|
||||||
UniValue array(UniValue::VARR);
|
UniValue array(UniValue::VARR);
|
||||||
|
@ -580,8 +580,8 @@ BOOST_AUTO_TEST_CASE(script_build)
|
||||||
std::set<std::string> tests_bad;
|
std::set<std::string> tests_bad;
|
||||||
|
|
||||||
{
|
{
|
||||||
Array json_good = read_json(std::string(json_tests::script_valid, json_tests::script_valid + sizeof(json_tests::script_valid)));
|
UniValue 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)));
|
UniValue json_bad = read_json(std::string(json_tests::script_invalid, json_tests::script_invalid + sizeof(json_tests::script_invalid)));
|
||||||
|
|
||||||
for (unsigned int idx = 0; idx < json_good.size(); idx++) {
|
for (unsigned int idx = 0; idx < json_good.size(); idx++) {
|
||||||
const Value& tv = json_good[idx];
|
const Value& tv = json_good[idx];
|
||||||
|
@ -634,10 +634,10 @@ BOOST_AUTO_TEST_CASE(script_valid)
|
||||||
// Inner arrays are [ "scriptSig", "scriptPubKey", "flags" ]
|
// Inner arrays are [ "scriptSig", "scriptPubKey", "flags" ]
|
||||||
// ... where scriptSig and scriptPubKey are stringified
|
// ... where scriptSig and scriptPubKey are stringified
|
||||||
// scripts.
|
// scripts.
|
||||||
Array tests = read_json(std::string(json_tests::script_valid, json_tests::script_valid + sizeof(json_tests::script_valid)));
|
UniValue tests = read_json(std::string(json_tests::script_valid, json_tests::script_valid + sizeof(json_tests::script_valid)));
|
||||||
|
|
||||||
for (unsigned int idx = 0; idx < tests.size(); idx++) {
|
for (unsigned int idx = 0; idx < tests.size(); idx++) {
|
||||||
Array test = tests[idx];
|
UniValue test = tests[idx];
|
||||||
string strTest = test.write();
|
string strTest = test.write();
|
||||||
if (test.size() < 3) // Allow size > 3; extra stuff ignored (useful for comments)
|
if (test.size() < 3) // Allow size > 3; extra stuff ignored (useful for comments)
|
||||||
{
|
{
|
||||||
|
@ -659,10 +659,10 @@ BOOST_AUTO_TEST_CASE(script_valid)
|
||||||
BOOST_AUTO_TEST_CASE(script_invalid)
|
BOOST_AUTO_TEST_CASE(script_invalid)
|
||||||
{
|
{
|
||||||
// Scripts that should evaluate as invalid
|
// Scripts that should evaluate as invalid
|
||||||
Array tests = read_json(std::string(json_tests::script_invalid, json_tests::script_invalid + sizeof(json_tests::script_invalid)));
|
UniValue tests = read_json(std::string(json_tests::script_invalid, json_tests::script_invalid + sizeof(json_tests::script_invalid)));
|
||||||
|
|
||||||
for (unsigned int idx = 0; idx < tests.size(); idx++) {
|
for (unsigned int idx = 0; idx < tests.size(); idx++) {
|
||||||
Array test = tests[idx];
|
UniValue test = tests[idx];
|
||||||
string strTest = test.write();
|
string strTest = test.write();
|
||||||
if (test.size() < 3) // Allow size > 2; extra stuff ignored (useful for comments)
|
if (test.size() < 3) // Allow size > 2; extra stuff ignored (useful for comments)
|
||||||
{
|
{
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
#include "json_spirit_wrapper.h"
|
#include "json_spirit_wrapper.h"
|
||||||
|
|
||||||
using namespace json_spirit;
|
using namespace json_spirit;
|
||||||
extern Array read_json(const std::string& jsondata);
|
extern UniValue read_json(const std::string& jsondata);
|
||||||
|
|
||||||
// Old script.cpp SignatureHash function
|
// Old script.cpp SignatureHash function
|
||||||
uint256 static SignatureHashOld(CScript scriptCode, const CTransaction& txTo, unsigned int nIn, int nHashType)
|
uint256 static SignatureHashOld(CScript scriptCode, const CTransaction& txTo, unsigned int nIn, int nHashType)
|
||||||
|
@ -166,10 +166,10 @@ BOOST_AUTO_TEST_CASE(sighash_test)
|
||||||
// Goal: check that SignatureHash generates correct hash
|
// Goal: check that SignatureHash generates correct hash
|
||||||
BOOST_AUTO_TEST_CASE(sighash_from_data)
|
BOOST_AUTO_TEST_CASE(sighash_from_data)
|
||||||
{
|
{
|
||||||
Array tests = read_json(std::string(json_tests::sighash, json_tests::sighash + sizeof(json_tests::sighash)));
|
UniValue tests = read_json(std::string(json_tests::sighash, json_tests::sighash + sizeof(json_tests::sighash)));
|
||||||
|
|
||||||
for (unsigned int idx = 0; idx < tests.size(); idx++) {
|
for (unsigned int idx = 0; idx < tests.size(); idx++) {
|
||||||
Array test = tests[idx];
|
UniValue test = tests[idx];
|
||||||
std::string strTest = test.write();
|
std::string strTest = test.write();
|
||||||
if (test.size() < 1) // Allow for extra stuff (useful for comments)
|
if (test.size() < 1) // Allow for extra stuff (useful for comments)
|
||||||
{
|
{
|
||||||
|
|
|
@ -30,7 +30,7 @@ using namespace std;
|
||||||
using namespace json_spirit;
|
using namespace json_spirit;
|
||||||
|
|
||||||
// In script_tests.cpp
|
// In script_tests.cpp
|
||||||
extern Array read_json(const std::string& jsondata);
|
extern UniValue read_json(const std::string& jsondata);
|
||||||
|
|
||||||
static std::map<string, unsigned int> mapFlagNames = boost::assign::map_list_of
|
static std::map<string, unsigned int> mapFlagNames = boost::assign::map_list_of
|
||||||
(string("NONE"), (unsigned int)SCRIPT_VERIFY_NONE)
|
(string("NONE"), (unsigned int)SCRIPT_VERIFY_NONE)
|
||||||
|
@ -90,7 +90,7 @@ BOOST_AUTO_TEST_CASE(tx_valid)
|
||||||
// ... where all scripts are stringified scripts.
|
// ... where all scripts are stringified scripts.
|
||||||
//
|
//
|
||||||
// verifyFlags is a comma separated list of script verification flags to apply, or "NONE"
|
// verifyFlags is a comma separated list of script verification flags to apply, or "NONE"
|
||||||
Array tests = read_json(std::string(json_tests::tx_valid, json_tests::tx_valid + sizeof(json_tests::tx_valid)));
|
UniValue tests = read_json(std::string(json_tests::tx_valid, json_tests::tx_valid + sizeof(json_tests::tx_valid)));
|
||||||
|
|
||||||
<<<<<<< HEAD
|
<<<<<<< HEAD
|
||||||
ScriptError err;
|
ScriptError err;
|
||||||
|
@ -101,7 +101,7 @@ BOOST_AUTO_TEST_CASE(tx_valid)
|
||||||
if (test[0].type() == array_type)
|
if (test[0].type() == array_type)
|
||||||
=======
|
=======
|
||||||
for (unsigned int idx = 0; idx < tests.size(); idx++) {
|
for (unsigned int idx = 0; idx < tests.size(); idx++) {
|
||||||
Array test = tests[idx];
|
UniValue test = tests[idx];
|
||||||
string strTest = test.write();
|
string strTest = test.write();
|
||||||
if (test[0].isArray())
|
if (test[0].isArray())
|
||||||
>>>>>>> Convert tree to using univalue. Eliminate all json_spirit uses.
|
>>>>>>> Convert tree to using univalue. Eliminate all json_spirit uses.
|
||||||
|
@ -113,7 +113,7 @@ BOOST_AUTO_TEST_CASE(tx_valid)
|
||||||
}
|
}
|
||||||
|
|
||||||
map<COutPoint, CScript> mapprevOutScriptPubKeys;
|
map<COutPoint, CScript> mapprevOutScriptPubKeys;
|
||||||
Array inputs = test[0].get_array();
|
UniValue inputs = test[0].get_array();
|
||||||
bool fValid = true;
|
bool fValid = true;
|
||||||
for (unsigned int inpIdx = 0; inpIdx < inputs.size(); inpIdx++) {
|
for (unsigned int inpIdx = 0; inpIdx < inputs.size(); inpIdx++) {
|
||||||
const Value& input = inputs[inpIdx];
|
const Value& input = inputs[inpIdx];
|
||||||
|
@ -122,7 +122,7 @@ BOOST_AUTO_TEST_CASE(tx_valid)
|
||||||
fValid = false;
|
fValid = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Array vinput = input.get_array();
|
UniValue vinput = input.get_array();
|
||||||
if (vinput.size() != 3)
|
if (vinput.size() != 3)
|
||||||
{
|
{
|
||||||
fValid = false;
|
fValid = false;
|
||||||
|
@ -173,7 +173,7 @@ BOOST_AUTO_TEST_CASE(tx_invalid)
|
||||||
// ... where all scripts are stringified scripts.
|
// ... where all scripts are stringified scripts.
|
||||||
//
|
//
|
||||||
// verifyFlags is a comma separated list of script verification flags to apply, or "NONE"
|
// verifyFlags is a comma separated list of script verification flags to apply, or "NONE"
|
||||||
Array tests = read_json(std::string(json_tests::tx_invalid, json_tests::tx_invalid + sizeof(json_tests::tx_invalid)));
|
UniValue tests = read_json(std::string(json_tests::tx_invalid, json_tests::tx_invalid + sizeof(json_tests::tx_invalid)));
|
||||||
|
|
||||||
<<<<<<< HEAD
|
<<<<<<< HEAD
|
||||||
ScriptError err;
|
ScriptError err;
|
||||||
|
@ -184,7 +184,7 @@ BOOST_AUTO_TEST_CASE(tx_invalid)
|
||||||
if (test[0].type() == array_type)
|
if (test[0].type() == array_type)
|
||||||
=======
|
=======
|
||||||
for (unsigned int idx = 0; idx < tests.size(); idx++) {
|
for (unsigned int idx = 0; idx < tests.size(); idx++) {
|
||||||
Array test = tests[idx];
|
UniValue test = tests[idx];
|
||||||
string strTest = test.write();
|
string strTest = test.write();
|
||||||
if (test[0].isArray())
|
if (test[0].isArray())
|
||||||
>>>>>>> Convert tree to using univalue. Eliminate all json_spirit uses.
|
>>>>>>> Convert tree to using univalue. Eliminate all json_spirit uses.
|
||||||
|
@ -196,7 +196,7 @@ BOOST_AUTO_TEST_CASE(tx_invalid)
|
||||||
}
|
}
|
||||||
|
|
||||||
map<COutPoint, CScript> mapprevOutScriptPubKeys;
|
map<COutPoint, CScript> mapprevOutScriptPubKeys;
|
||||||
Array inputs = test[0].get_array();
|
UniValue inputs = test[0].get_array();
|
||||||
bool fValid = true;
|
bool fValid = true;
|
||||||
for (unsigned int inpIdx = 0; inpIdx < inputs.size(); inpIdx++) {
|
for (unsigned int inpIdx = 0; inpIdx < inputs.size(); inpIdx++) {
|
||||||
const Value& input = inputs[inpIdx];
|
const Value& input = inputs[inpIdx];
|
||||||
|
@ -205,7 +205,7 @@ BOOST_AUTO_TEST_CASE(tx_invalid)
|
||||||
fValid = false;
|
fValid = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Array vinput = input.get_array();
|
UniValue vinput = input.get_array();
|
||||||
if (vinput.size() != 3)
|
if (vinput.size() != 3)
|
||||||
{
|
{
|
||||||
fValid = false;
|
fValid = false;
|
||||||
|
|
|
@ -70,7 +70,7 @@ std::string DecodeDumpString(const std::string &str) {
|
||||||
return ret.str();
|
return ret.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
Value importprivkey(const Array& params, bool fHelp)
|
UniValue importprivkey(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (!EnsureWalletIsAvailable(fHelp))
|
if (!EnsureWalletIsAvailable(fHelp))
|
||||||
return NullUniValue;
|
return NullUniValue;
|
||||||
|
@ -144,7 +144,7 @@ Value importprivkey(const Array& params, bool fHelp)
|
||||||
return NullUniValue;
|
return NullUniValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Value importaddress(const Array& params, bool fHelp)
|
UniValue importaddress(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (!EnsureWalletIsAvailable(fHelp))
|
if (!EnsureWalletIsAvailable(fHelp))
|
||||||
return NullUniValue;
|
return NullUniValue;
|
||||||
|
@ -217,7 +217,7 @@ Value importaddress(const Array& params, bool fHelp)
|
||||||
return NullUniValue;
|
return NullUniValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Value importwallet(const Array& params, bool fHelp)
|
UniValue importwallet(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (!EnsureWalletIsAvailable(fHelp))
|
if (!EnsureWalletIsAvailable(fHelp))
|
||||||
return NullUniValue;
|
return NullUniValue;
|
||||||
|
@ -321,7 +321,7 @@ Value importwallet(const Array& params, bool fHelp)
|
||||||
return NullUniValue;
|
return NullUniValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Value dumpprivkey(const Array& params, bool fHelp)
|
UniValue dumpprivkey(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (!EnsureWalletIsAvailable(fHelp))
|
if (!EnsureWalletIsAvailable(fHelp))
|
||||||
return NullUniValue;
|
return NullUniValue;
|
||||||
|
@ -359,7 +359,7 @@ Value dumpprivkey(const Array& params, bool fHelp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Value dumpwallet(const Array& params, bool fHelp)
|
UniValue dumpwallet(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (!EnsureWalletIsAvailable(fHelp))
|
if (!EnsureWalletIsAvailable(fHelp))
|
||||||
return NullUniValue;
|
return NullUniValue;
|
||||||
|
|
|
@ -764,7 +764,7 @@ Value getbalance(const Array& params, bool fHelp)
|
||||||
return ValueFromAmount(nBalance);
|
return ValueFromAmount(nBalance);
|
||||||
}
|
}
|
||||||
|
|
||||||
Value getunconfirmedbalance(const Array ¶ms, bool fHelp)
|
Value getunconfirmedbalance(const UniValue ¶ms, bool fHelp)
|
||||||
{
|
{
|
||||||
if (!EnsureWalletIsAvailable(fHelp))
|
if (!EnsureWalletIsAvailable(fHelp))
|
||||||
return NullUniValue;
|
return NullUniValue;
|
||||||
|
@ -957,7 +957,7 @@ Value sendmany(const Array& params, bool fHelp)
|
||||||
LOCK2(cs_main, pwalletMain->cs_wallet);
|
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||||
|
|
||||||
string strAccount = AccountFromValue(params[0]);
|
string strAccount = AccountFromValue(params[0]);
|
||||||
Object sendTo = params[1].get_obj();
|
UniValue sendTo = params[1].get_obj();
|
||||||
int nMinDepth = 1;
|
int nMinDepth = 1;
|
||||||
if (params.size() > 2)
|
if (params.size() > 2)
|
||||||
nMinDepth = params[2].get_int();
|
nMinDepth = params[2].get_int();
|
||||||
|
@ -1279,7 +1279,7 @@ Value listreceivedbyaccount(const Array& params, bool fHelp)
|
||||||
return ListReceived(params, true);
|
return ListReceived(params, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MaybePushAddress(Object & entry, const CTxDestination &dest)
|
static void MaybePushAddress(UniValue & entry, const CTxDestination &dest)
|
||||||
{
|
{
|
||||||
CBitcoinAddress addr;
|
CBitcoinAddress addr;
|
||||||
if (addr.Set(dest))
|
if (addr.Set(dest))
|
||||||
|
@ -2071,7 +2071,7 @@ Value lockunspent(const Array& params, bool fHelp)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Array outputs = params[1].get_array();
|
UniValue outputs = params[1].get_array();
|
||||||
for (unsigned int idx = 0; idx < outputs.size(); idx++) {
|
for (unsigned int idx = 0; idx < outputs.size(); idx++) {
|
||||||
const UniValue& output = outputs[idx];
|
const UniValue& output = outputs[idx];
|
||||||
if (!output.isObject())
|
if (!output.isObject())
|
||||||
|
@ -2295,7 +2295,7 @@ 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();
|
UniValue inputs = params[2].get_array();
|
||||||
for (unsigned int idx = 0; idx < inputs.size(); idx++) {
|
for (unsigned int idx = 0; idx < inputs.size(); idx++) {
|
||||||
const Value& input = inputs[idx];
|
const Value& input = inputs[idx];
|
||||||
CBitcoinAddress address(input.get_str());
|
CBitcoinAddress address(input.get_str());
|
||||||
|
|
Loading…
Reference in a new issue