Browse Source

[RPC] Give RPC commands more information about the RPC request

0.14
Jonas Schnelli 8 years ago
parent
commit
69d1c25768
No known key found for this signature in database
GPG Key ID: 29D4BCB6416F53EC
  1. 7
      src/httprpc.cpp
  2. 5
      src/qt/rpcconsole.cpp
  3. 6
      src/rest.cpp
  4. 158
      src/rpc/blockchain.cpp
  5. 90
      src/rpc/mining.cpp
  6. 42
      src/rpc/misc.cpp
  7. 72
      src/rpc/net.cpp
  8. 90
      src/rpc/rawtransaction.cpp
  9. 29
      src/rpc/server.cpp
  10. 13
      src/rpc/server.h
  11. 7
      src/test/rpc_tests.cpp
  12. 100
      src/wallet/rpcdump.cpp
  13. 486
      src/wallet/rpcwallet.cpp

7
src/httprpc.cpp

@ -172,19 +172,22 @@ static bool HTTPReq_JSONRPC(HTTPRequest* req, const std::string &)
return false; return false;
} }
JSONRequest jreq; JSONRPCRequest jreq;
try { try {
// Parse request // Parse request
UniValue valRequest; UniValue valRequest;
if (!valRequest.read(req->ReadBody())) if (!valRequest.read(req->ReadBody()))
throw JSONRPCError(RPC_PARSE_ERROR, "Parse error"); throw JSONRPCError(RPC_PARSE_ERROR, "Parse error");
// Set the URI
jreq.URI = req->GetURI();
std::string strReply; std::string strReply;
// singleton request // singleton request
if (valRequest.isObject()) { if (valRequest.isObject()) {
jreq.parse(valRequest); jreq.parse(valRequest);
UniValue result = tableRPC.execute(jreq.strMethod, jreq.params); UniValue result = tableRPC.execute(jreq);
// Send reply // Send reply
strReply = JSONRPCReply(result, NullUniValue, jreq.id); strReply = JSONRPCReply(result, NullUniValue, jreq.id);

5
src/qt/rpcconsole.cpp

@ -246,7 +246,10 @@ bool RPCConsole::RPCExecuteCommandLine(std::string &strResult, const std::string
std::string strPrint; std::string strPrint;
// Convert argument list to JSON objects in method-dependent way, // Convert argument list to JSON objects in method-dependent way,
// and pass it along with the method name to the dispatcher. // and pass it along with the method name to the dispatcher.
lastResult = tableRPC.execute(stack.back()[0], RPCConvertValues(stack.back()[0], std::vector<std::string>(stack.back().begin() + 1, stack.back().end()))); JSONRPCRequest req;
req.params = RPCConvertValues(stack.back()[0], std::vector<std::string>(stack.back().begin() + 1, stack.back().end()));
req.strMethod = stack.back()[0];
lastResult = tableRPC.execute(req);
state = STATE_COMMAND_EXECUTED; state = STATE_COMMAND_EXECUTED;
curarg.clear(); curarg.clear();

6
src/rest.cpp

@ -274,7 +274,7 @@ static bool rest_block_notxdetails(HTTPRequest* req, const std::string& strURIPa
} }
// A bit of a hack - dependency on a function defined in rpc/blockchain.cpp // A bit of a hack - dependency on a function defined in rpc/blockchain.cpp
UniValue getblockchaininfo(const UniValue& params, bool fHelp); UniValue getblockchaininfo(const JSONRPCRequest& request);
static bool rest_chaininfo(HTTPRequest* req, const std::string& strURIPart) static bool rest_chaininfo(HTTPRequest* req, const std::string& strURIPart)
{ {
@ -285,8 +285,8 @@ static bool rest_chaininfo(HTTPRequest* req, const std::string& strURIPart)
switch (rf) { switch (rf) {
case RF_JSON: { case RF_JSON: {
UniValue rpcParams(UniValue::VARR); JSONRPCRequest jsonRequest;
UniValue chainInfoObject = getblockchaininfo(rpcParams, false); UniValue chainInfoObject = getblockchaininfo(jsonRequest);
string strJSON = chainInfoObject.write() + "\n"; string strJSON = chainInfoObject.write() + "\n";
req->WriteHeader("Content-Type", "application/json"); req->WriteHeader("Content-Type", "application/json");
req->WriteReply(HTTP_OK, strJSON); req->WriteReply(HTTP_OK, strJSON);

158
src/rpc/blockchain.cpp

@ -146,9 +146,9 @@ UniValue blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool tx
return result; return result;
} }
UniValue getblockcount(const UniValue& params, bool fHelp) UniValue getblockcount(const JSONRPCRequest& request)
{ {
if (fHelp || params.size() != 0) if (request.fHelp || request.params.size() != 0)
throw runtime_error( throw runtime_error(
"getblockcount\n" "getblockcount\n"
"\nReturns the number of blocks in the longest block chain.\n" "\nReturns the number of blocks in the longest block chain.\n"
@ -163,9 +163,9 @@ UniValue getblockcount(const UniValue& params, bool fHelp)
return chainActive.Height(); return chainActive.Height();
} }
UniValue getbestblockhash(const UniValue& params, bool fHelp) UniValue getbestblockhash(const JSONRPCRequest& request)
{ {
if (fHelp || params.size() != 0) if (request.fHelp || request.params.size() != 0)
throw runtime_error( throw runtime_error(
"getbestblockhash\n" "getbestblockhash\n"
"\nReturns the hash of the best (tip) block in the longest block chain.\n" "\nReturns the hash of the best (tip) block in the longest block chain.\n"
@ -190,9 +190,9 @@ void RPCNotifyBlockChange(bool ibd, const CBlockIndex * pindex)
cond_blockchange.notify_all(); cond_blockchange.notify_all();
} }
UniValue waitfornewblock(const UniValue& params, bool fHelp) UniValue waitfornewblock(const JSONRPCRequest& request)
{ {
if (fHelp || params.size() > 1) if (request.fHelp || request.params.size() > 1)
throw runtime_error( throw runtime_error(
"waitfornewblock\n" "waitfornewblock\n"
"\nWaits for a specific new block and returns useful info about it.\n" "\nWaits for a specific new block and returns useful info about it.\n"
@ -209,8 +209,8 @@ UniValue waitfornewblock(const UniValue& params, bool fHelp)
+ HelpExampleRpc("waitfornewblock", "1000") + HelpExampleRpc("waitfornewblock", "1000")
); );
int timeout = 0; int timeout = 0;
if (params.size() > 0) if (request.params.size() > 0)
timeout = params[0].get_int(); timeout = request.params[0].get_int();
CUpdatedBlock block; CUpdatedBlock block;
{ {
@ -228,9 +228,9 @@ UniValue waitfornewblock(const UniValue& params, bool fHelp)
return ret; return ret;
} }
UniValue waitforblock(const UniValue& params, bool fHelp) UniValue waitforblock(const JSONRPCRequest& request)
{ {
if (fHelp || params.size() < 1 || params.size() > 2) if (request.fHelp || request.params.size() < 1 || request.params.size() > 2)
throw runtime_error( throw runtime_error(
"waitforblock\n" "waitforblock\n"
"\nWaits for a specific new block and returns useful info about it.\n" "\nWaits for a specific new block and returns useful info about it.\n"
@ -249,10 +249,10 @@ UniValue waitforblock(const UniValue& params, bool fHelp)
); );
int timeout = 0; int timeout = 0;
uint256 hash = uint256S(params[0].get_str()); uint256 hash = uint256S(request.params[0].get_str());
if (params.size() > 1) if (request.params.size() > 1)
timeout = params[1].get_int(); timeout = request.params[1].get_int();
CUpdatedBlock block; CUpdatedBlock block;
{ {
@ -270,9 +270,9 @@ UniValue waitforblock(const UniValue& params, bool fHelp)
return ret; return ret;
} }
UniValue waitforblockheight(const UniValue& params, bool fHelp) UniValue waitforblockheight(const JSONRPCRequest& request)
{ {
if (fHelp || params.size() < 1 || params.size() > 2) if (request.fHelp || request.params.size() < 1 || request.params.size() > 2)
throw runtime_error( throw runtime_error(
"waitforblock\n" "waitforblock\n"
"\nWaits for (at least) block height and returns the height and hash\n" "\nWaits for (at least) block height and returns the height and hash\n"
@ -292,10 +292,10 @@ UniValue waitforblockheight(const UniValue& params, bool fHelp)
); );
int timeout = 0; int timeout = 0;
int height = params[0].get_int(); int height = request.params[0].get_int();
if (params.size() > 1) if (request.params.size() > 1)
timeout = params[1].get_int(); timeout = request.params[1].get_int();
CUpdatedBlock block; CUpdatedBlock block;
{ {
@ -312,9 +312,9 @@ UniValue waitforblockheight(const UniValue& params, bool fHelp)
return ret; return ret;
} }
UniValue getdifficulty(const UniValue& params, bool fHelp) UniValue getdifficulty(const JSONRPCRequest& request)
{ {
if (fHelp || params.size() != 0) if (request.fHelp || request.params.size() != 0)
throw runtime_error( throw runtime_error(
"getdifficulty\n" "getdifficulty\n"
"\nReturns the proof-of-work difficulty as a multiple of the minimum difficulty.\n" "\nReturns the proof-of-work difficulty as a multiple of the minimum difficulty.\n"
@ -411,9 +411,9 @@ UniValue mempoolToJSON(bool fVerbose = false)
} }
} }
UniValue getrawmempool(const UniValue& params, bool fHelp) UniValue getrawmempool(const JSONRPCRequest& request)
{ {
if (fHelp || params.size() > 1) if (request.fHelp || request.params.size() > 1)
throw runtime_error( throw runtime_error(
"getrawmempool ( verbose )\n" "getrawmempool ( verbose )\n"
"\nReturns all transaction ids in memory pool as a json array of string transaction ids.\n" "\nReturns all transaction ids in memory pool as a json array of string transaction ids.\n"
@ -436,15 +436,15 @@ UniValue getrawmempool(const UniValue& params, bool fHelp)
); );
bool fVerbose = false; bool fVerbose = false;
if (params.size() > 0) if (request.params.size() > 0)
fVerbose = params[0].get_bool(); fVerbose = request.params[0].get_bool();
return mempoolToJSON(fVerbose); return mempoolToJSON(fVerbose);
} }
UniValue getmempoolancestors(const UniValue& params, bool fHelp) UniValue getmempoolancestors(const JSONRPCRequest& request)
{ {
if (fHelp || params.size() < 1 || params.size() > 2) { if (request.fHelp || request.params.size() < 1 || request.params.size() > 2) {
throw runtime_error( throw runtime_error(
"getmempoolancestors txid (verbose)\n" "getmempoolancestors txid (verbose)\n"
"\nIf txid is in the mempool, returns all in-mempool ancestors.\n" "\nIf txid is in the mempool, returns all in-mempool ancestors.\n"
@ -469,10 +469,10 @@ UniValue getmempoolancestors(const UniValue& params, bool fHelp)
} }
bool fVerbose = false; bool fVerbose = false;
if (params.size() > 1) if (request.params.size() > 1)
fVerbose = params[1].get_bool(); fVerbose = request.params[1].get_bool();
uint256 hash = ParseHashV(params[0], "parameter 1"); uint256 hash = ParseHashV(request.params[0], "parameter 1");
LOCK(mempool.cs); LOCK(mempool.cs);
@ -506,9 +506,9 @@ UniValue getmempoolancestors(const UniValue& params, bool fHelp)
} }
} }
UniValue getmempooldescendants(const UniValue& params, bool fHelp) UniValue getmempooldescendants(const JSONRPCRequest& request)
{ {
if (fHelp || params.size() < 1 || params.size() > 2) { if (request.fHelp || request.params.size() < 1 || request.params.size() > 2) {
throw runtime_error( throw runtime_error(
"getmempooldescendants txid (verbose)\n" "getmempooldescendants txid (verbose)\n"
"\nIf txid is in the mempool, returns all in-mempool descendants.\n" "\nIf txid is in the mempool, returns all in-mempool descendants.\n"
@ -533,10 +533,10 @@ UniValue getmempooldescendants(const UniValue& params, bool fHelp)
} }
bool fVerbose = false; bool fVerbose = false;
if (params.size() > 1) if (request.params.size() > 1)
fVerbose = params[1].get_bool(); fVerbose = request.params[1].get_bool();
uint256 hash = ParseHashV(params[0], "parameter 1"); uint256 hash = ParseHashV(request.params[0], "parameter 1");
LOCK(mempool.cs); LOCK(mempool.cs);
@ -570,9 +570,9 @@ UniValue getmempooldescendants(const UniValue& params, bool fHelp)
} }
} }
UniValue getmempoolentry(const UniValue& params, bool fHelp) UniValue getmempoolentry(const JSONRPCRequest& request)
{ {
if (fHelp || params.size() != 1) { if (request.fHelp || request.params.size() != 1) {
throw runtime_error( throw runtime_error(
"getmempoolentry txid\n" "getmempoolentry txid\n"
"\nReturns mempool data for given transaction\n" "\nReturns mempool data for given transaction\n"
@ -588,7 +588,7 @@ UniValue getmempoolentry(const UniValue& params, bool fHelp)
); );
} }
uint256 hash = ParseHashV(params[0], "parameter 1"); uint256 hash = ParseHashV(request.params[0], "parameter 1");
LOCK(mempool.cs); LOCK(mempool.cs);
@ -603,9 +603,9 @@ UniValue getmempoolentry(const UniValue& params, bool fHelp)
return info; return info;
} }
UniValue getblockhash(const UniValue& params, bool fHelp) UniValue getblockhash(const JSONRPCRequest& request)
{ {
if (fHelp || params.size() != 1) if (request.fHelp || request.params.size() != 1)
throw runtime_error( throw runtime_error(
"getblockhash index\n" "getblockhash index\n"
"\nReturns hash of block in best-block-chain at index provided.\n" "\nReturns hash of block in best-block-chain at index provided.\n"
@ -620,7 +620,7 @@ UniValue getblockhash(const UniValue& params, bool fHelp)
LOCK(cs_main); LOCK(cs_main);
int nHeight = params[0].get_int(); int nHeight = request.params[0].get_int();
if (nHeight < 0 || nHeight > chainActive.Height()) if (nHeight < 0 || nHeight > chainActive.Height())
throw JSONRPCError(RPC_INVALID_PARAMETER, "Block height out of range"); throw JSONRPCError(RPC_INVALID_PARAMETER, "Block height out of range");
@ -628,9 +628,9 @@ UniValue getblockhash(const UniValue& params, bool fHelp)
return pblockindex->GetBlockHash().GetHex(); return pblockindex->GetBlockHash().GetHex();
} }
UniValue getblockheader(const UniValue& params, bool fHelp) UniValue getblockheader(const JSONRPCRequest& request)
{ {
if (fHelp || params.size() < 1 || params.size() > 2) if (request.fHelp || request.params.size() < 1 || request.params.size() > 2)
throw runtime_error( throw runtime_error(
"getblockheader \"hash\" ( verbose )\n" "getblockheader \"hash\" ( verbose )\n"
"\nIf verbose is false, returns a string that is serialized, hex-encoded data for blockheader 'hash'.\n" "\nIf verbose is false, returns a string that is serialized, hex-encoded data for blockheader 'hash'.\n"
@ -664,12 +664,12 @@ UniValue getblockheader(const UniValue& params, bool fHelp)
LOCK(cs_main); LOCK(cs_main);
std::string strHash = params[0].get_str(); std::string strHash = request.params[0].get_str();
uint256 hash(uint256S(strHash)); uint256 hash(uint256S(strHash));
bool fVerbose = true; bool fVerbose = true;
if (params.size() > 1) if (request.params.size() > 1)
fVerbose = params[1].get_bool(); fVerbose = request.params[1].get_bool();
if (mapBlockIndex.count(hash) == 0) if (mapBlockIndex.count(hash) == 0)
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found"); throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found");
@ -687,9 +687,9 @@ UniValue getblockheader(const UniValue& params, bool fHelp)
return blockheaderToJSON(pblockindex); return blockheaderToJSON(pblockindex);
} }
UniValue getblock(const UniValue& params, bool fHelp) UniValue getblock(const JSONRPCRequest& request)
{ {
if (fHelp || params.size() < 1 || params.size() > 2) if (request.fHelp || request.params.size() < 1 || request.params.size() > 2)
throw runtime_error( throw runtime_error(
"getblock \"hash\" ( verbose )\n" "getblock \"hash\" ( verbose )\n"
"\nIf verbose is false, returns a string that is serialized, hex-encoded data for block 'hash'.\n" "\nIf verbose is false, returns a string that is serialized, hex-encoded data for block 'hash'.\n"
@ -730,12 +730,12 @@ UniValue getblock(const UniValue& params, bool fHelp)
LOCK(cs_main); LOCK(cs_main);
std::string strHash = params[0].get_str(); std::string strHash = request.params[0].get_str();
uint256 hash(uint256S(strHash)); uint256 hash(uint256S(strHash));
bool fVerbose = true; bool fVerbose = true;
if (params.size() > 1) if (request.params.size() > 1)
fVerbose = params[1].get_bool(); fVerbose = request.params[1].get_bool();
if (mapBlockIndex.count(hash) == 0) if (mapBlockIndex.count(hash) == 0)
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found"); throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found");
@ -814,9 +814,9 @@ static bool GetUTXOStats(CCoinsView *view, CCoinsStats &stats)
return true; return true;
} }
UniValue gettxoutsetinfo(const UniValue& params, bool fHelp) UniValue gettxoutsetinfo(const JSONRPCRequest& request)
{ {
if (fHelp || params.size() != 0) if (request.fHelp || request.params.size() != 0)
throw runtime_error( throw runtime_error(
"gettxoutsetinfo\n" "gettxoutsetinfo\n"
"\nReturns statistics about the unspent transaction output set.\n" "\nReturns statistics about the unspent transaction output set.\n"
@ -854,9 +854,9 @@ UniValue gettxoutsetinfo(const UniValue& params, bool fHelp)
return ret; return ret;
} }
UniValue gettxout(const UniValue& params, bool fHelp) UniValue gettxout(const JSONRPCRequest& request)
{ {
if (fHelp || params.size() < 2 || params.size() > 3) if (request.fHelp || request.params.size() < 2 || request.params.size() > 3)
throw runtime_error( throw runtime_error(
"gettxout \"txid\" n ( includemempool )\n" "gettxout \"txid\" n ( includemempool )\n"
"\nReturns details about an unspent transaction output.\n" "\nReturns details about an unspent transaction output.\n"
@ -896,12 +896,12 @@ UniValue gettxout(const UniValue& params, bool fHelp)
UniValue ret(UniValue::VOBJ); UniValue ret(UniValue::VOBJ);
std::string strHash = params[0].get_str(); std::string strHash = request.params[0].get_str();
uint256 hash(uint256S(strHash)); uint256 hash(uint256S(strHash));
int n = params[1].get_int(); int n = request.params[1].get_int();
bool fMempool = true; bool fMempool = true;
if (params.size() > 2) if (request.params.size() > 2)
fMempool = params[2].get_bool(); fMempool = request.params[2].get_bool();
CCoins coins; CCoins coins;
if (fMempool) { if (fMempool) {
@ -934,11 +934,11 @@ UniValue gettxout(const UniValue& params, bool fHelp)
return ret; return ret;
} }
UniValue verifychain(const UniValue& params, bool fHelp) UniValue verifychain(const JSONRPCRequest& request)
{ {
int nCheckLevel = GetArg("-checklevel", DEFAULT_CHECKLEVEL); int nCheckLevel = GetArg("-checklevel", DEFAULT_CHECKLEVEL);
int nCheckDepth = GetArg("-checkblocks", DEFAULT_CHECKBLOCKS); int nCheckDepth = GetArg("-checkblocks", DEFAULT_CHECKBLOCKS);
if (fHelp || params.size() > 2) if (request.fHelp || request.params.size() > 2)
throw runtime_error( throw runtime_error(
"verifychain ( checklevel numblocks )\n" "verifychain ( checklevel numblocks )\n"
"\nVerifies blockchain database.\n" "\nVerifies blockchain database.\n"
@ -954,10 +954,10 @@ UniValue verifychain(const UniValue& params, bool fHelp)
LOCK(cs_main); LOCK(cs_main);
if (params.size() > 0) if (request.params.size() > 0)
nCheckLevel = params[0].get_int(); nCheckLevel = request.params[0].get_int();
if (params.size() > 1) if (request.params.size() > 1)
nCheckDepth = params[1].get_int(); nCheckDepth = request.params[1].get_int();
return CVerifyDB().VerifyDB(Params(), pcoinsTip, nCheckLevel, nCheckDepth); return CVerifyDB().VerifyDB(Params(), pcoinsTip, nCheckLevel, nCheckDepth);
} }
@ -1021,9 +1021,9 @@ void BIP9SoftForkDescPushBack(UniValue& bip9_softforks, const std::string &name,
bip9_softforks.push_back(Pair(name, BIP9SoftForkDesc(consensusParams, id))); bip9_softforks.push_back(Pair(name, BIP9SoftForkDesc(consensusParams, id)));
} }
UniValue getblockchaininfo(const UniValue& params, bool fHelp) UniValue getblockchaininfo(const JSONRPCRequest& request)
{ {
if (fHelp || params.size() != 0) if (request.fHelp || request.params.size() != 0)
throw runtime_error( throw runtime_error(
"getblockchaininfo\n" "getblockchaininfo\n"
"Returns an object containing various state info regarding block chain processing.\n" "Returns an object containing various state info regarding block chain processing.\n"
@ -1113,9 +1113,9 @@ struct CompareBlocksByHeight
} }
}; };
UniValue getchaintips(const UniValue& params, bool fHelp) UniValue getchaintips(const JSONRPCRequest& request)
{ {
if (fHelp || params.size() != 0) if (request.fHelp || request.params.size() != 0)
throw runtime_error( throw runtime_error(
"getchaintips\n" "getchaintips\n"
"Return information about all known tips in the block tree," "Return information about all known tips in the block tree,"
@ -1229,9 +1229,9 @@ UniValue mempoolInfoToJSON()
return ret; return ret;
} }
UniValue getmempoolinfo(const UniValue& params, bool fHelp) UniValue getmempoolinfo(const JSONRPCRequest& request)
{ {
if (fHelp || params.size() != 0) if (request.fHelp || request.params.size() != 0)
throw runtime_error( throw runtime_error(
"getmempoolinfo\n" "getmempoolinfo\n"
"\nReturns details on the active state of the TX memory pool.\n" "\nReturns details on the active state of the TX memory pool.\n"
@ -1251,9 +1251,9 @@ UniValue getmempoolinfo(const UniValue& params, bool fHelp)
return mempoolInfoToJSON(); return mempoolInfoToJSON();
} }
UniValue preciousblock(const UniValue& params, bool fHelp) UniValue preciousblock(const JSONRPCRequest& request)
{ {
if (fHelp || params.size() != 1) if (request.fHelp || request.params.size() != 1)
throw runtime_error( throw runtime_error(
"preciousblock \"hash\"\n" "preciousblock \"hash\"\n"
"\nTreats a block as if it were received before others with the same work.\n" "\nTreats a block as if it were received before others with the same work.\n"
@ -1267,7 +1267,7 @@ UniValue preciousblock(const UniValue& params, bool fHelp)
+ HelpExampleRpc("preciousblock", "\"blockhash\"") + HelpExampleRpc("preciousblock", "\"blockhash\"")
); );
std::string strHash = params[0].get_str(); std::string strHash = request.params[0].get_str();
uint256 hash(uint256S(strHash)); uint256 hash(uint256S(strHash));
CBlockIndex* pblockindex; CBlockIndex* pblockindex;
@ -1289,9 +1289,9 @@ UniValue preciousblock(const UniValue& params, bool fHelp)
return NullUniValue; return NullUniValue;
} }
UniValue invalidateblock(const UniValue& params, bool fHelp) UniValue invalidateblock(const JSONRPCRequest& request)
{ {
if (fHelp || params.size() != 1) if (request.fHelp || request.params.size() != 1)
throw runtime_error( throw runtime_error(
"invalidateblock \"hash\"\n" "invalidateblock \"hash\"\n"
"\nPermanently marks a block as invalid, as if it violated a consensus rule.\n" "\nPermanently marks a block as invalid, as if it violated a consensus rule.\n"
@ -1303,7 +1303,7 @@ UniValue invalidateblock(const UniValue& params, bool fHelp)
+ HelpExampleRpc("invalidateblock", "\"blockhash\"") + HelpExampleRpc("invalidateblock", "\"blockhash\"")
); );
std::string strHash = params[0].get_str(); std::string strHash = request.params[0].get_str();
uint256 hash(uint256S(strHash)); uint256 hash(uint256S(strHash));
CValidationState state; CValidationState state;
@ -1327,9 +1327,9 @@ UniValue invalidateblock(const UniValue& params, bool fHelp)
return NullUniValue; return NullUniValue;
} }
UniValue reconsiderblock(const UniValue& params, bool fHelp) UniValue reconsiderblock(const JSONRPCRequest& request)
{ {
if (fHelp || params.size() != 1) if (request.fHelp || request.params.size() != 1)
throw runtime_error( throw runtime_error(
"reconsiderblock \"hash\"\n" "reconsiderblock \"hash\"\n"
"\nRemoves invalidity status of a block and its descendants, reconsider them for activation.\n" "\nRemoves invalidity status of a block and its descendants, reconsider them for activation.\n"
@ -1342,7 +1342,7 @@ UniValue reconsiderblock(const UniValue& params, bool fHelp)
+ HelpExampleRpc("reconsiderblock", "\"blockhash\"") + HelpExampleRpc("reconsiderblock", "\"blockhash\"")
); );
std::string strHash = params[0].get_str(); std::string strHash = request.params[0].get_str();
uint256 hash(uint256S(strHash)); uint256 hash(uint256S(strHash));
{ {

90
src/rpc/mining.cpp

@ -74,9 +74,9 @@ UniValue GetNetworkHashPS(int lookup, int height) {
return workDiff.getdouble() / timeDiff; return workDiff.getdouble() / timeDiff;
} }
UniValue getnetworkhashps(const UniValue& params, bool fHelp) UniValue getnetworkhashps(const JSONRPCRequest& request)
{ {
if (fHelp || params.size() > 2) if (request.fHelp || request.params.size() > 2)
throw runtime_error( throw runtime_error(
"getnetworkhashps ( blocks height )\n" "getnetworkhashps ( blocks height )\n"
"\nReturns the estimated network hashes per second based on the last n blocks.\n" "\nReturns the estimated network hashes per second based on the last n blocks.\n"
@ -93,7 +93,7 @@ UniValue getnetworkhashps(const UniValue& params, bool fHelp)
); );
LOCK(cs_main); LOCK(cs_main);
return GetNetworkHashPS(params.size() > 0 ? params[0].get_int() : 120, params.size() > 1 ? params[1].get_int() : -1); return GetNetworkHashPS(request.params.size() > 0 ? request.params[0].get_int() : 120, request.params.size() > 1 ? request.params[1].get_int() : -1);
} }
UniValue generateBlocks(boost::shared_ptr<CReserveScript> coinbaseScript, int nGenerate, uint64_t nMaxTries, bool keepScript) UniValue generateBlocks(boost::shared_ptr<CReserveScript> coinbaseScript, int nGenerate, uint64_t nMaxTries, bool keepScript)
@ -146,9 +146,9 @@ UniValue generateBlocks(boost::shared_ptr<CReserveScript> coinbaseScript, int nG
return blockHashes; return blockHashes;
} }
UniValue generate(const UniValue& params, bool fHelp) UniValue generate(const JSONRPCRequest& request)
{ {
if (fHelp || params.size() < 1 || params.size() > 2) if (request.fHelp || request.params.size() < 1 || request.params.size() > 2)
throw runtime_error( throw runtime_error(
"generate numblocks ( maxtries )\n" "generate numblocks ( maxtries )\n"
"\nMine up to numblocks blocks immediately (before the RPC call returns)\n" "\nMine up to numblocks blocks immediately (before the RPC call returns)\n"
@ -162,10 +162,10 @@ UniValue generate(const UniValue& params, bool fHelp)
+ HelpExampleCli("generate", "11") + HelpExampleCli("generate", "11")
); );
int nGenerate = params[0].get_int(); int nGenerate = request.params[0].get_int();
uint64_t nMaxTries = 1000000; uint64_t nMaxTries = 1000000;
if (params.size() > 1) { if (request.params.size() > 1) {
nMaxTries = params[1].get_int(); nMaxTries = request.params[1].get_int();
} }
boost::shared_ptr<CReserveScript> coinbaseScript; boost::shared_ptr<CReserveScript> coinbaseScript;
@ -182,9 +182,9 @@ UniValue generate(const UniValue& params, bool fHelp)
return generateBlocks(coinbaseScript, nGenerate, nMaxTries, true); return generateBlocks(coinbaseScript, nGenerate, nMaxTries, true);
} }
UniValue generatetoaddress(const UniValue& params, bool fHelp) UniValue generatetoaddress(const JSONRPCRequest& request)
{ {
if (fHelp || params.size() < 2 || params.size() > 3) if (request.fHelp || request.params.size() < 2 || request.params.size() > 3)
throw runtime_error( throw runtime_error(
"generatetoaddress numblocks address (maxtries)\n" "generatetoaddress numblocks address (maxtries)\n"
"\nMine blocks immediately to a specified address (before the RPC call returns)\n" "\nMine blocks immediately to a specified address (before the RPC call returns)\n"
@ -199,13 +199,13 @@ UniValue generatetoaddress(const UniValue& params, bool fHelp)
+ HelpExampleCli("generatetoaddress", "11 \"myaddress\"") + HelpExampleCli("generatetoaddress", "11 \"myaddress\"")
); );
int nGenerate = params[0].get_int(); int nGenerate = request.params[0].get_int();
uint64_t nMaxTries = 1000000; uint64_t nMaxTries = 1000000;
if (params.size() > 2) { if (request.params.size() > 2) {
nMaxTries = params[2].get_int(); nMaxTries = request.params[2].get_int();
} }
CBitcoinAddress address(params[1].get_str()); CBitcoinAddress address(request.params[1].get_str());
if (!address.IsValid()) if (!address.IsValid())
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Error: Invalid address"); throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Error: Invalid address");
@ -215,9 +215,9 @@ UniValue generatetoaddress(const UniValue& params, bool fHelp)
return generateBlocks(coinbaseScript, nGenerate, nMaxTries, false); return generateBlocks(coinbaseScript, nGenerate, nMaxTries, false);
} }
UniValue getmininginfo(const UniValue& params, bool fHelp) UniValue getmininginfo(const JSONRPCRequest& request)
{ {
if (fHelp || params.size() != 0) if (request.fHelp || request.params.size() != 0)
throw runtime_error( throw runtime_error(
"getmininginfo\n" "getmininginfo\n"
"\nReturns a json object containing mining-related information." "\nReturns a json object containing mining-related information."
@ -248,7 +248,7 @@ UniValue getmininginfo(const UniValue& params, bool fHelp)
obj.push_back(Pair("currentblocktx", (uint64_t)nLastBlockTx)); obj.push_back(Pair("currentblocktx", (uint64_t)nLastBlockTx));
obj.push_back(Pair("difficulty", (double)GetDifficulty())); obj.push_back(Pair("difficulty", (double)GetDifficulty()));
obj.push_back(Pair("errors", GetWarnings("statusbar"))); obj.push_back(Pair("errors", GetWarnings("statusbar")));
obj.push_back(Pair("networkhashps", getnetworkhashps(params, false))); obj.push_back(Pair("networkhashps", getnetworkhashps(request)));
obj.push_back(Pair("pooledtx", (uint64_t)mempool.size())); obj.push_back(Pair("pooledtx", (uint64_t)mempool.size()));
obj.push_back(Pair("chain", Params().NetworkIDString())); obj.push_back(Pair("chain", Params().NetworkIDString()));
return obj; return obj;
@ -256,9 +256,9 @@ UniValue getmininginfo(const UniValue& 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
UniValue prioritisetransaction(const UniValue& params, bool fHelp) UniValue prioritisetransaction(const JSONRPCRequest& request)
{ {
if (fHelp || params.size() != 3) if (request.fHelp || request.params.size() != 3)
throw runtime_error( throw runtime_error(
"prioritisetransaction <txid> <priority delta> <fee delta>\n" "prioritisetransaction <txid> <priority delta> <fee delta>\n"
"Accepts the transaction into mined blocks at a higher (or lower) priority\n" "Accepts the transaction into mined blocks at a higher (or lower) priority\n"
@ -279,10 +279,10 @@ UniValue prioritisetransaction(const UniValue& params, bool fHelp)
LOCK(cs_main); LOCK(cs_main);
uint256 hash = ParseHashStr(params[0].get_str(), "txid"); uint256 hash = ParseHashStr(request.params[0].get_str(), "txid");
CAmount nAmount = params[2].get_int64(); CAmount nAmount = request.params[2].get_int64();
mempool.PrioritiseTransaction(hash, params[0].get_str(), params[1].get_real(), nAmount); mempool.PrioritiseTransaction(hash, request.params[0].get_str(), request.params[1].get_real(), nAmount);
return true; return true;
} }
@ -315,9 +315,9 @@ std::string gbt_vb_name(const Consensus::DeploymentPos pos) {
return s; return s;
} }
UniValue getblocktemplate(const UniValue& params, bool fHelp) UniValue getblocktemplate(const JSONRPCRequest& request)
{ {
if (fHelp || params.size() > 1) if (request.fHelp || request.params.size() > 1)
throw runtime_error( throw runtime_error(
"getblocktemplate ( TemplateRequest )\n" "getblocktemplate ( TemplateRequest )\n"
"\nIf the request parameters include a 'mode' key, that is used to explicitly select between the default 'template' request or a 'proposal'.\n" "\nIf the request parameters include a 'mode' key, that is used to explicitly select between the default 'template' request or a 'proposal'.\n"
@ -400,9 +400,9 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp)
UniValue lpval = NullUniValue; UniValue lpval = NullUniValue;
std::set<std::string> setClientRules; std::set<std::string> setClientRules;
int64_t nMaxVersionPreVB = -1; int64_t nMaxVersionPreVB = -1;
if (params.size() > 0) if (request.params.size() > 0)
{ {
const UniValue& oparam = params[0].get_obj(); const UniValue& oparam = request.params[0].get_obj();
const UniValue& modeval = find_value(oparam, "mode"); const UniValue& modeval = find_value(oparam, "mode");
if (modeval.isStr()) if (modeval.isStr())
strMode = modeval.get_str(); strMode = modeval.get_str();
@ -705,9 +705,9 @@ protected:
}; };
}; };
UniValue submitblock(const UniValue& params, bool fHelp) UniValue submitblock(const JSONRPCRequest& request)
{ {
if (fHelp || params.size() < 1 || params.size() > 2) if (request.fHelp || request.params.size() < 1 || request.params.size() > 2)
throw runtime_error( throw runtime_error(
"submitblock \"hexdata\" ( \"jsonparametersobject\" )\n" "submitblock \"hexdata\" ( \"jsonparametersobject\" )\n"
"\nAttempts to submit new block to network.\n" "\nAttempts to submit new block to network.\n"
@ -727,7 +727,7 @@ UniValue submitblock(const UniValue& params, bool fHelp)
); );
CBlock block; CBlock block;
if (!DecodeHexBlk(block, params[0].get_str())) if (!DecodeHexBlk(block, request.params[0].get_str()))
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "Block decode failed"); throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "Block decode failed");
uint256 hash = block.GetHash(); uint256 hash = block.GetHash();
@ -774,9 +774,9 @@ UniValue submitblock(const UniValue& params, bool fHelp)
return BIP22ValidationResult(state); return BIP22ValidationResult(state);
} }
UniValue estimatefee(const UniValue& params, bool fHelp) UniValue estimatefee(const JSONRPCRequest& request)
{ {
if (fHelp || params.size() != 1) if (request.fHelp || request.params.size() != 1)
throw runtime_error( throw runtime_error(
"estimatefee nblocks\n" "estimatefee nblocks\n"
"\nEstimates the approximate fee per kilobyte needed for a transaction to begin\n" "\nEstimates the approximate fee per kilobyte needed for a transaction to begin\n"
@ -792,9 +792,9 @@ UniValue estimatefee(const UniValue& params, bool fHelp)
+ HelpExampleCli("estimatefee", "6") + HelpExampleCli("estimatefee", "6")
); );
RPCTypeCheck(params, boost::assign::list_of(UniValue::VNUM)); RPCTypeCheck(request.params, boost::assign::list_of(UniValue::VNUM));
int nBlocks = params[0].get_int(); int nBlocks = request.params[0].get_int();
if (nBlocks < 1) if (nBlocks < 1)
nBlocks = 1; nBlocks = 1;
@ -805,9 +805,9 @@ UniValue estimatefee(const UniValue& params, bool fHelp)
return ValueFromAmount(feeRate.GetFeePerK()); return ValueFromAmount(feeRate.GetFeePerK());
} }
UniValue estimatepriority(const UniValue& params, bool fHelp) UniValue estimatepriority(const JSONRPCRequest& request)
{ {
if (fHelp || params.size() != 1) if (request.fHelp || request.params.size() != 1)
throw runtime_error( throw runtime_error(
"estimatepriority nblocks\n" "estimatepriority nblocks\n"
"\nEstimates the approximate priority a zero-fee transaction needs to begin\n" "\nEstimates the approximate priority a zero-fee transaction needs to begin\n"
@ -823,18 +823,18 @@ UniValue estimatepriority(const UniValue& params, bool fHelp)
+ HelpExampleCli("estimatepriority", "6") + HelpExampleCli("estimatepriority", "6")
); );
RPCTypeCheck(params, boost::assign::list_of(UniValue::VNUM)); RPCTypeCheck(request.params, boost::assign::list_of(UniValue::VNUM));
int nBlocks = params[0].get_int(); int nBlocks = request.params[0].get_int();
if (nBlocks < 1) if (nBlocks < 1)
nBlocks = 1; nBlocks = 1;
return mempool.estimatePriority(nBlocks); return mempool.estimatePriority(nBlocks);
} }
UniValue estimatesmartfee(const UniValue& params, bool fHelp) UniValue estimatesmartfee(const JSONRPCRequest& request)
{ {
if (fHelp || params.size() != 1) if (request.fHelp || request.params.size() != 1)
throw runtime_error( throw runtime_error(
"estimatesmartfee nblocks\n" "estimatesmartfee nblocks\n"
"\nWARNING: This interface is unstable and may disappear or change!\n" "\nWARNING: This interface is unstable and may disappear or change!\n"
@ -856,9 +856,9 @@ UniValue estimatesmartfee(const UniValue& params, bool fHelp)
+ HelpExampleCli("estimatesmartfee", "6") + HelpExampleCli("estimatesmartfee", "6")
); );
RPCTypeCheck(params, boost::assign::list_of(UniValue::VNUM)); RPCTypeCheck(request.params, boost::assign::list_of(UniValue::VNUM));
int nBlocks = params[0].get_int(); int nBlocks = request.params[0].get_int();
UniValue result(UniValue::VOBJ); UniValue result(UniValue::VOBJ);
int answerFound; int answerFound;
@ -868,9 +868,9 @@ UniValue estimatesmartfee(const UniValue& params, bool fHelp)
return result; return result;
} }
UniValue estimatesmartpriority(const UniValue& params, bool fHelp) UniValue estimatesmartpriority(const JSONRPCRequest& request)
{ {
if (fHelp || params.size() != 1) if (request.fHelp || request.params.size() != 1)
throw runtime_error( throw runtime_error(
"estimatesmartpriority nblocks\n" "estimatesmartpriority nblocks\n"
"\nWARNING: This interface is unstable and may disappear or change!\n" "\nWARNING: This interface is unstable and may disappear or change!\n"
@ -892,9 +892,9 @@ UniValue estimatesmartpriority(const UniValue& params, bool fHelp)
+ HelpExampleCli("estimatesmartpriority", "6") + HelpExampleCli("estimatesmartpriority", "6")
); );
RPCTypeCheck(params, boost::assign::list_of(UniValue::VNUM)); RPCTypeCheck(request.params, boost::assign::list_of(UniValue::VNUM));
int nBlocks = params[0].get_int(); int nBlocks = request.params[0].get_int();
UniValue result(UniValue::VOBJ); UniValue result(UniValue::VOBJ);
int answerFound; int answerFound;

42
src/rpc/misc.cpp

@ -39,9 +39,9 @@ using namespace std;
* *
* Or alternatively, create a specific query method for the information. * Or alternatively, create a specific query method for the information.
**/ **/
UniValue getinfo(const UniValue& params, bool fHelp) UniValue getinfo(const JSONRPCRequest& request)
{ {
if (fHelp || params.size() != 0) if (request.fHelp || request.params.size() != 0)
throw runtime_error( throw runtime_error(
"getinfo\n" "getinfo\n"
"\nDEPRECATED. Returns an object containing various state info.\n" "\nDEPRECATED. Returns an object containing various state info.\n"
@ -148,9 +148,9 @@ public:
}; };
#endif #endif
UniValue validateaddress(const UniValue& params, bool fHelp) UniValue validateaddress(const JSONRPCRequest& request)
{ {
if (fHelp || params.size() != 1) if (request.fHelp || request.params.size() != 1)
throw runtime_error( throw runtime_error(
"validateaddress \"bitcoinaddress\"\n" "validateaddress \"bitcoinaddress\"\n"
"\nReturn information about the given bitcoin address.\n" "\nReturn information about the given bitcoin address.\n"
@ -181,7 +181,7 @@ UniValue validateaddress(const UniValue& params, bool fHelp)
LOCK(cs_main); LOCK(cs_main);
#endif #endif
CBitcoinAddress address(params[0].get_str()); CBitcoinAddress address(request.params[0].get_str());
bool isValid = address.IsValid(); bool isValid = address.IsValid();
UniValue ret(UniValue::VOBJ); UniValue ret(UniValue::VOBJ);
@ -278,9 +278,9 @@ CScript _createmultisig_redeemScript(const UniValue& params)
return result; return result;
} }
UniValue createmultisig(const UniValue& params, bool fHelp) UniValue createmultisig(const JSONRPCRequest& request)
{ {
if (fHelp || params.size() < 2 || params.size() > 2) if (request.fHelp || request.params.size() < 2 || request.params.size() > 2)
{ {
string msg = "createmultisig nrequired [\"key\",...]\n" string msg = "createmultisig nrequired [\"key\",...]\n"
"\nCreates a multi-signature address with n signature of m keys required.\n" "\nCreates a multi-signature address with n signature of m keys required.\n"
@ -310,7 +310,7 @@ UniValue createmultisig(const UniValue& params, bool fHelp)
} }
// Construct using pay-to-script-hash: // Construct using pay-to-script-hash:
CScript inner = _createmultisig_redeemScript(params); CScript inner = _createmultisig_redeemScript(request.params);
CScriptID innerID(inner); CScriptID innerID(inner);
CBitcoinAddress address(innerID); CBitcoinAddress address(innerID);
@ -321,9 +321,9 @@ UniValue createmultisig(const UniValue& params, bool fHelp)
return result; return result;
} }
UniValue verifymessage(const UniValue& params, bool fHelp) UniValue verifymessage(const JSONRPCRequest& request)
{ {
if (fHelp || params.size() != 3) if (request.fHelp || request.params.size() != 3)
throw runtime_error( throw runtime_error(
"verifymessage \"bitcoinaddress\" \"signature\" \"message\"\n" "verifymessage \"bitcoinaddress\" \"signature\" \"message\"\n"
"\nVerify a signed message\n" "\nVerify a signed message\n"
@ -346,9 +346,9 @@ UniValue verifymessage(const UniValue& params, bool fHelp)
LOCK(cs_main); LOCK(cs_main);
string strAddress = params[0].get_str(); string strAddress = request.params[0].get_str();
string strSign = params[1].get_str(); string strSign = request.params[1].get_str();
string strMessage = params[2].get_str(); string strMessage = request.params[2].get_str();
CBitcoinAddress addr(strAddress); CBitcoinAddress addr(strAddress);
if (!addr.IsValid()) if (!addr.IsValid())
@ -375,9 +375,9 @@ UniValue verifymessage(const UniValue& params, bool fHelp)
return (pubkey.GetID() == keyID); return (pubkey.GetID() == keyID);
} }
UniValue signmessagewithprivkey(const UniValue& params, bool fHelp) UniValue signmessagewithprivkey(const JSONRPCRequest& request)
{ {
if (fHelp || params.size() != 2) if (request.fHelp || request.params.size() != 2)
throw runtime_error( throw runtime_error(
"signmessagewithprivkey \"privkey\" \"message\"\n" "signmessagewithprivkey \"privkey\" \"message\"\n"
"\nSign a message with the private key of an address\n" "\nSign a message with the private key of an address\n"
@ -395,8 +395,8 @@ UniValue signmessagewithprivkey(const UniValue& params, bool fHelp)
+ HelpExampleRpc("signmessagewithprivkey", "\"privkey\", \"my message\"") + HelpExampleRpc("signmessagewithprivkey", "\"privkey\", \"my message\"")
); );
string strPrivkey = params[0].get_str(); string strPrivkey = request.params[0].get_str();
string strMessage = params[1].get_str(); string strMessage = request.params[1].get_str();
CBitcoinSecret vchSecret; CBitcoinSecret vchSecret;
bool fGood = vchSecret.SetString(strPrivkey); bool fGood = vchSecret.SetString(strPrivkey);
@ -417,9 +417,9 @@ UniValue signmessagewithprivkey(const UniValue& params, bool fHelp)
return EncodeBase64(&vchSig[0], vchSig.size()); return EncodeBase64(&vchSig[0], vchSig.size());
} }
UniValue setmocktime(const UniValue& params, bool fHelp) UniValue setmocktime(const JSONRPCRequest& request)
{ {
if (fHelp || params.size() != 1) if (request.fHelp || request.params.size() != 1)
throw runtime_error( throw runtime_error(
"setmocktime timestamp\n" "setmocktime timestamp\n"
"\nSet the local time to given timestamp (-regtest only)\n" "\nSet the local time to given timestamp (-regtest only)\n"
@ -437,8 +437,8 @@ UniValue setmocktime(const UniValue& params, bool fHelp)
// in a long time. // in a long time.
LOCK(cs_main); LOCK(cs_main);
RPCTypeCheck(params, boost::assign::list_of(UniValue::VNUM)); RPCTypeCheck(request.params, boost::assign::list_of(UniValue::VNUM));
SetMockTime(params[0].get_int64()); SetMockTime(request.params[0].get_int64());
uint64_t t = GetTime(); uint64_t t = GetTime();
if(g_connman) { if(g_connman) {

72
src/rpc/net.cpp

@ -23,9 +23,9 @@
using namespace std; using namespace std;
UniValue getconnectioncount(const UniValue& params, bool fHelp) UniValue getconnectioncount(const JSONRPCRequest& request)
{ {
if (fHelp || params.size() != 0) if (request.fHelp || request.params.size() != 0)
throw runtime_error( throw runtime_error(
"getconnectioncount\n" "getconnectioncount\n"
"\nReturns the number of connections to other nodes.\n" "\nReturns the number of connections to other nodes.\n"
@ -42,9 +42,9 @@ UniValue getconnectioncount(const UniValue& params, bool fHelp)
return (int)g_connman->GetNodeCount(CConnman::CONNECTIONS_ALL); return (int)g_connman->GetNodeCount(CConnman::CONNECTIONS_ALL);
} }
UniValue ping(const UniValue& params, bool fHelp) UniValue ping(const JSONRPCRequest& request)
{ {
if (fHelp || params.size() != 0) if (request.fHelp || request.params.size() != 0)
throw runtime_error( throw runtime_error(
"ping\n" "ping\n"
"\nRequests that a ping be sent to all other nodes, to measure ping time.\n" "\nRequests that a ping be sent to all other nodes, to measure ping time.\n"
@ -65,9 +65,9 @@ UniValue ping(const UniValue& params, bool fHelp)
return NullUniValue; return NullUniValue;
} }
UniValue getpeerinfo(const UniValue& params, bool fHelp) UniValue getpeerinfo(const JSONRPCRequest& request)
{ {
if (fHelp || params.size() != 0) if (request.fHelp || request.params.size() != 0)
throw runtime_error( throw runtime_error(
"getpeerinfo\n" "getpeerinfo\n"
"\nReturns data about each connected network node as a json array of objects.\n" "\nReturns data about each connected network node as a json array of objects.\n"
@ -184,12 +184,12 @@ UniValue getpeerinfo(const UniValue& params, bool fHelp)
return ret; return ret;
} }
UniValue addnode(const UniValue& params, bool fHelp) UniValue addnode(const JSONRPCRequest& request)
{ {
string strCommand; string strCommand;
if (params.size() == 2) if (request.params.size() == 2)
strCommand = params[1].get_str(); strCommand = request.params[1].get_str();
if (fHelp || params.size() != 2 || if (request.fHelp || request.params.size() != 2 ||
(strCommand != "onetry" && strCommand != "add" && strCommand != "remove")) (strCommand != "onetry" && strCommand != "add" && strCommand != "remove"))
throw runtime_error( throw runtime_error(
"addnode \"node\" \"add|remove|onetry\"\n" "addnode \"node\" \"add|remove|onetry\"\n"
@ -206,7 +206,7 @@ UniValue addnode(const UniValue& params, bool fHelp)
if(!g_connman) if(!g_connman)
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled"); throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
string strNode = params[0].get_str(); string strNode = request.params[0].get_str();
if (strCommand == "onetry") if (strCommand == "onetry")
{ {
@ -229,9 +229,9 @@ UniValue addnode(const UniValue& params, bool fHelp)
return NullUniValue; return NullUniValue;
} }
UniValue disconnectnode(const UniValue& params, bool fHelp) UniValue disconnectnode(const JSONRPCRequest& request)
{ {
if (fHelp || params.size() != 1) if (request.fHelp || request.params.size() != 1)
throw runtime_error( throw runtime_error(
"disconnectnode \"node\" \n" "disconnectnode \"node\" \n"
"\nImmediately disconnects from the specified node.\n" "\nImmediately disconnects from the specified node.\n"
@ -245,16 +245,16 @@ UniValue disconnectnode(const UniValue& params, bool fHelp)
if(!g_connman) if(!g_connman)
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled"); throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
bool ret = g_connman->DisconnectNode(params[0].get_str()); bool ret = g_connman->DisconnectNode(request.params[0].get_str());
if (!ret) if (!ret)
throw JSONRPCError(RPC_CLIENT_NODE_NOT_CONNECTED, "Node not found in connected nodes"); throw JSONRPCError(RPC_CLIENT_NODE_NOT_CONNECTED, "Node not found in connected nodes");
return NullUniValue; return NullUniValue;
} }
UniValue getaddednodeinfo(const UniValue& params, bool fHelp) UniValue getaddednodeinfo(const JSONRPCRequest& request)
{ {
if (fHelp || params.size() > 1) if (request.fHelp || request.params.size() > 1)
throw runtime_error( throw runtime_error(
"getaddednodeinfo ( \"node\" )\n" "getaddednodeinfo ( \"node\" )\n"
"\nReturns information about the given added node, or all added nodes\n" "\nReturns information about the given added node, or all added nodes\n"
@ -286,10 +286,10 @@ UniValue getaddednodeinfo(const UniValue& params, bool fHelp)
std::vector<AddedNodeInfo> vInfo = g_connman->GetAddedNodeInfo(); std::vector<AddedNodeInfo> vInfo = g_connman->GetAddedNodeInfo();
if (params.size() == 1) { if (request.params.size() == 1) {
bool found = false; bool found = false;
for (const AddedNodeInfo& info : vInfo) { for (const AddedNodeInfo& info : vInfo) {
if (info.strAddedNode == params[0].get_str()) { if (info.strAddedNode == request.params[0].get_str()) {
vInfo.assign(1, info); vInfo.assign(1, info);
found = true; found = true;
break; break;
@ -320,9 +320,9 @@ UniValue getaddednodeinfo(const UniValue& params, bool fHelp)
return ret; return ret;
} }
UniValue getnettotals(const UniValue& params, bool fHelp) UniValue getnettotals(const JSONRPCRequest& request)
{ {
if (fHelp || params.size() > 0) if (request.fHelp || request.params.size() > 0)
throw runtime_error( throw runtime_error(
"getnettotals\n" "getnettotals\n"
"\nReturns information about network traffic, including bytes in, bytes out,\n" "\nReturns information about network traffic, including bytes in, bytes out,\n"
@ -386,9 +386,9 @@ static UniValue GetNetworksInfo()
return networks; return networks;
} }
UniValue getnetworkinfo(const UniValue& params, bool fHelp) UniValue getnetworkinfo(const JSONRPCRequest& request)
{ {
if (fHelp || params.size() != 0) if (request.fHelp || request.params.size() != 0)
throw runtime_error( throw runtime_error(
"getnetworkinfo\n" "getnetworkinfo\n"
"Returns an object containing various state info regarding P2P networking.\n" "Returns an object containing various state info regarding P2P networking.\n"
@ -456,12 +456,12 @@ UniValue getnetworkinfo(const UniValue& params, bool fHelp)
return obj; return obj;
} }
UniValue setban(const UniValue& params, bool fHelp) UniValue setban(const JSONRPCRequest& request)
{ {
string strCommand; string strCommand;
if (params.size() >= 2) if (request.params.size() >= 2)
strCommand = params[1].get_str(); strCommand = request.params[1].get_str();
if (fHelp || params.size() < 2 || if (request.fHelp || request.params.size() < 2 ||
(strCommand != "add" && strCommand != "remove")) (strCommand != "add" && strCommand != "remove"))
throw runtime_error( throw runtime_error(
"setban \"ip(/netmask)\" \"add|remove\" (bantime) (absolute)\n" "setban \"ip(/netmask)\" \"add|remove\" (bantime) (absolute)\n"
@ -483,16 +483,16 @@ UniValue setban(const UniValue& params, bool fHelp)
CNetAddr netAddr; CNetAddr netAddr;
bool isSubnet = false; bool isSubnet = false;
if (params[0].get_str().find("/") != string::npos) if (request.params[0].get_str().find("/") != string::npos)
isSubnet = true; isSubnet = true;
if (!isSubnet) { if (!isSubnet) {
CNetAddr resolved; CNetAddr resolved;
LookupHost(params[0].get_str().c_str(), resolved, false); LookupHost(request.params[0].get_str().c_str(), resolved, false);
netAddr = resolved; netAddr = resolved;
} }
else else
LookupSubNet(params[0].get_str().c_str(), subNet); LookupSubNet(request.params[0].get_str().c_str(), subNet);
if (! (isSubnet ? subNet.IsValid() : netAddr.IsValid()) ) if (! (isSubnet ? subNet.IsValid() : netAddr.IsValid()) )
throw JSONRPCError(RPC_CLIENT_NODE_ALREADY_ADDED, "Error: Invalid IP/Subnet"); throw JSONRPCError(RPC_CLIENT_NODE_ALREADY_ADDED, "Error: Invalid IP/Subnet");
@ -503,11 +503,11 @@ UniValue setban(const UniValue& params, bool fHelp)
throw JSONRPCError(RPC_CLIENT_NODE_ALREADY_ADDED, "Error: IP/Subnet already banned"); throw JSONRPCError(RPC_CLIENT_NODE_ALREADY_ADDED, "Error: IP/Subnet already banned");
int64_t banTime = 0; //use standard bantime if not specified int64_t banTime = 0; //use standard bantime if not specified
if (params.size() >= 3 && !params[2].isNull()) if (request.params.size() >= 3 && !request.params[2].isNull())
banTime = params[2].get_int64(); banTime = request.params[2].get_int64();
bool absolute = false; bool absolute = false;
if (params.size() == 4 && params[3].isTrue()) if (request.params.size() == 4 && request.params[3].isTrue())
absolute = true; absolute = true;
isSubnet ? g_connman->Ban(subNet, BanReasonManuallyAdded, banTime, absolute) : g_connman->Ban(netAddr, BanReasonManuallyAdded, banTime, absolute); isSubnet ? g_connman->Ban(subNet, BanReasonManuallyAdded, banTime, absolute) : g_connman->Ban(netAddr, BanReasonManuallyAdded, banTime, absolute);
@ -520,9 +520,9 @@ UniValue setban(const UniValue& params, bool fHelp)
return NullUniValue; return NullUniValue;
} }
UniValue listbanned(const UniValue& params, bool fHelp) UniValue listbanned(const JSONRPCRequest& request)
{ {
if (fHelp || params.size() != 0) if (request.fHelp || request.params.size() != 0)
throw runtime_error( throw runtime_error(
"listbanned\n" "listbanned\n"
"\nList all banned IPs/Subnets.\n" "\nList all banned IPs/Subnets.\n"
@ -553,9 +553,9 @@ UniValue listbanned(const UniValue& params, bool fHelp)
return bannedAddresses; return bannedAddresses;
} }
UniValue clearbanned(const UniValue& params, bool fHelp) UniValue clearbanned(const JSONRPCRequest& request)
{ {
if (fHelp || params.size() != 0) if (request.fHelp || request.params.size() != 0)
throw runtime_error( throw runtime_error(
"clearbanned\n" "clearbanned\n"
"\nClear all banned IPs.\n" "\nClear all banned IPs.\n"

90
src/rpc/rawtransaction.cpp

@ -126,9 +126,9 @@ void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry)
} }
} }
UniValue getrawtransaction(const UniValue& params, bool fHelp) UniValue getrawtransaction(const JSONRPCRequest& request)
{ {
if (fHelp || params.size() < 1 || params.size() > 2) if (request.fHelp || request.params.size() < 1 || request.params.size() > 2)
throw runtime_error( throw runtime_error(
"getrawtransaction \"txid\" ( verbose )\n" "getrawtransaction \"txid\" ( verbose )\n"
"\nNOTE: By default this function only works sometimes. This is when the tx is in the mempool\n" "\nNOTE: By default this function only works sometimes. This is when the tx is in the mempool\n"
@ -198,11 +198,11 @@ UniValue getrawtransaction(const UniValue& params, bool fHelp)
LOCK(cs_main); LOCK(cs_main);
uint256 hash = ParseHashV(params[0], "parameter 1"); uint256 hash = ParseHashV(request.params[0], "parameter 1");
bool fVerbose = false; bool fVerbose = false;
if (params.size() > 1) if (request.params.size() > 1)
fVerbose = (params[1].get_int() != 0); fVerbose = (request.params[1].get_int() != 0);
CTransaction tx; CTransaction tx;
uint256 hashBlock; uint256 hashBlock;
@ -220,9 +220,9 @@ UniValue getrawtransaction(const UniValue& params, bool fHelp)
return result; return result;
} }
UniValue gettxoutproof(const UniValue& params, bool fHelp) UniValue gettxoutproof(const JSONRPCRequest& request)
{ {
if (fHelp || (params.size() != 1 && params.size() != 2)) if (request.fHelp || (request.params.size() != 1 && request.params.size() != 2))
throw runtime_error( throw runtime_error(
"gettxoutproof [\"txid\",...] ( blockhash )\n" "gettxoutproof [\"txid\",...] ( blockhash )\n"
"\nReturns a hex-encoded proof that \"txid\" was included in a block.\n" "\nReturns a hex-encoded proof that \"txid\" was included in a block.\n"
@ -244,7 +244,7 @@ UniValue gettxoutproof(const UniValue& params, bool fHelp)
set<uint256> setTxids; set<uint256> setTxids;
uint256 oneTxid; uint256 oneTxid;
UniValue txids = params[0].get_array(); UniValue txids = request.params[0].get_array();
for (unsigned int idx = 0; idx < txids.size(); idx++) { for (unsigned int idx = 0; idx < txids.size(); idx++) {
const UniValue& txid = txids[idx]; const UniValue& txid = txids[idx];
if (txid.get_str().length() != 64 || !IsHex(txid.get_str())) if (txid.get_str().length() != 64 || !IsHex(txid.get_str()))
@ -261,9 +261,9 @@ UniValue gettxoutproof(const UniValue& params, bool fHelp)
CBlockIndex* pblockindex = NULL; CBlockIndex* pblockindex = NULL;
uint256 hashBlock; uint256 hashBlock;
if (params.size() > 1) if (request.params.size() > 1)
{ {
hashBlock = uint256S(params[1].get_str()); hashBlock = uint256S(request.params[1].get_str());
if (!mapBlockIndex.count(hashBlock)) if (!mapBlockIndex.count(hashBlock))
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found"); throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found");
pblockindex = mapBlockIndex[hashBlock]; pblockindex = mapBlockIndex[hashBlock];
@ -301,9 +301,9 @@ UniValue gettxoutproof(const UniValue& params, bool fHelp)
return strHex; return strHex;
} }
UniValue verifytxoutproof(const UniValue& params, bool fHelp) UniValue verifytxoutproof(const JSONRPCRequest& request)
{ {
if (fHelp || params.size() != 1) if (request.fHelp || request.params.size() != 1)
throw runtime_error( throw runtime_error(
"verifytxoutproof \"proof\"\n" "verifytxoutproof \"proof\"\n"
"\nVerifies that a proof points to a transaction in a block, returning the transaction it commits to\n" "\nVerifies that a proof points to a transaction in a block, returning the transaction it commits to\n"
@ -314,7 +314,7 @@ UniValue verifytxoutproof(const UniValue& params, bool fHelp)
"[\"txid\"] (array, strings) The txid(s) which the proof commits to, or empty array if the proof is invalid\n" "[\"txid\"] (array, strings) The txid(s) which the proof commits to, or empty array if the proof is invalid\n"
); );
CDataStream ssMB(ParseHexV(params[0], "proof"), SER_NETWORK, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS); CDataStream ssMB(ParseHexV(request.params[0], "proof"), SER_NETWORK, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS);
CMerkleBlock merkleBlock; CMerkleBlock merkleBlock;
ssMB >> merkleBlock; ssMB >> merkleBlock;
@ -335,9 +335,9 @@ UniValue verifytxoutproof(const UniValue& params, bool fHelp)
return res; return res;
} }
UniValue createrawtransaction(const UniValue& params, bool fHelp) UniValue createrawtransaction(const JSONRPCRequest& request)
{ {
if (fHelp || params.size() < 2 || params.size() > 3) if (request.fHelp || request.params.size() < 2 || request.params.size() > 3)
throw runtime_error( throw runtime_error(
"createrawtransaction [{\"txid\":\"id\",\"vout\":n},...] {\"address\":amount,\"data\":\"hex\",...} ( locktime )\n" "createrawtransaction [{\"txid\":\"id\",\"vout\":n},...] {\"address\":amount,\"data\":\"hex\",...} ( locktime )\n"
"\nCreate a transaction spending the given inputs and creating new outputs.\n" "\nCreate a transaction spending the given inputs and creating new outputs.\n"
@ -373,17 +373,17 @@ UniValue createrawtransaction(const UniValue& params, bool fHelp)
+ HelpExampleRpc("createrawtransaction", "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\", \"{\\\"data\\\":\\\"00010203\\\"}\"") + HelpExampleRpc("createrawtransaction", "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\", \"{\\\"data\\\":\\\"00010203\\\"}\"")
); );
RPCTypeCheck(params, boost::assign::list_of(UniValue::VARR)(UniValue::VOBJ)(UniValue::VNUM), true); RPCTypeCheck(request.params, boost::assign::list_of(UniValue::VARR)(UniValue::VOBJ)(UniValue::VNUM), true);
if (params[0].isNull() || params[1].isNull()) if (request.params[0].isNull() || request.params[1].isNull())
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, arguments 1 and 2 must be non-null"); throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, arguments 1 and 2 must be non-null");
UniValue inputs = params[0].get_array(); UniValue inputs = request.params[0].get_array();
UniValue sendTo = params[1].get_obj(); UniValue sendTo = request.params[1].get_obj();
CMutableTransaction rawTx; CMutableTransaction rawTx;
if (params.size() > 2 && !params[2].isNull()) { if (request.params.size() > 2 && !request.params[2].isNull()) {
int64_t nLockTime = params[2].get_int64(); int64_t nLockTime = request.params[2].get_int64();
if (nLockTime < 0 || nLockTime > std::numeric_limits<uint32_t>::max()) if (nLockTime < 0 || nLockTime > std::numeric_limits<uint32_t>::max())
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, locktime out of range"); throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, locktime out of range");
rawTx.nLockTime = nLockTime; rawTx.nLockTime = nLockTime;
@ -448,9 +448,9 @@ UniValue createrawtransaction(const UniValue& params, bool fHelp)
return EncodeHexTx(rawTx); return EncodeHexTx(rawTx);
} }
UniValue decoderawtransaction(const UniValue& params, bool fHelp) UniValue decoderawtransaction(const JSONRPCRequest& request)
{ {
if (fHelp || params.size() != 1) if (request.fHelp || request.params.size() != 1)
throw runtime_error( throw runtime_error(
"decoderawtransaction \"hexstring\"\n" "decoderawtransaction \"hexstring\"\n"
"\nReturn a JSON object representing the serialized, hex-encoded transaction.\n" "\nReturn a JSON object representing the serialized, hex-encoded transaction.\n"
@ -504,11 +504,11 @@ UniValue decoderawtransaction(const UniValue& params, bool fHelp)
); );
LOCK(cs_main); LOCK(cs_main);
RPCTypeCheck(params, boost::assign::list_of(UniValue::VSTR)); RPCTypeCheck(request.params, boost::assign::list_of(UniValue::VSTR));
CTransaction tx; CTransaction tx;
if (!DecodeHexTx(tx, params[0].get_str(), true)) if (!DecodeHexTx(tx, request.params[0].get_str(), true))
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed"); throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed");
UniValue result(UniValue::VOBJ); UniValue result(UniValue::VOBJ);
@ -517,9 +517,9 @@ UniValue decoderawtransaction(const UniValue& params, bool fHelp)
return result; return result;
} }
UniValue decodescript(const UniValue& params, bool fHelp) UniValue decodescript(const JSONRPCRequest& request)
{ {
if (fHelp || params.size() != 1) if (request.fHelp || request.params.size() != 1)
throw runtime_error( throw runtime_error(
"decodescript \"hex\"\n" "decodescript \"hex\"\n"
"\nDecode a hex-encoded script.\n" "\nDecode a hex-encoded script.\n"
@ -542,12 +542,12 @@ UniValue decodescript(const UniValue& params, bool fHelp)
+ HelpExampleRpc("decodescript", "\"hexstring\"") + HelpExampleRpc("decodescript", "\"hexstring\"")
); );
RPCTypeCheck(params, boost::assign::list_of(UniValue::VSTR)); RPCTypeCheck(request.params, boost::assign::list_of(UniValue::VSTR));
UniValue r(UniValue::VOBJ); UniValue r(UniValue::VOBJ);
CScript script; CScript script;
if (params[0].get_str().size() > 0){ if (request.params[0].get_str().size() > 0){
vector<unsigned char> scriptData(ParseHexV(params[0], "argument")); vector<unsigned char> scriptData(ParseHexV(request.params[0], "argument"));
script = CScript(scriptData.begin(), scriptData.end()); script = CScript(scriptData.begin(), scriptData.end());
} else { } else {
// Empty scripts are valid // Empty scripts are valid
@ -578,9 +578,9 @@ static void TxInErrorToJSON(const CTxIn& txin, UniValue& vErrorsRet, const std::
vErrorsRet.push_back(entry); vErrorsRet.push_back(entry);
} }
UniValue signrawtransaction(const UniValue& params, bool fHelp) UniValue signrawtransaction(const JSONRPCRequest& request)
{ {
if (fHelp || params.size() < 1 || params.size() > 4) if (request.fHelp || request.params.size() < 1 || request.params.size() > 4)
throw runtime_error( throw runtime_error(
"signrawtransaction \"hexstring\" ( [{\"txid\":\"id\",\"vout\":n,\"scriptPubKey\":\"hex\",\"redeemScript\":\"hex\"},...] [\"privatekey1\",...] sighashtype )\n" "signrawtransaction \"hexstring\" ( [{\"txid\":\"id\",\"vout\":n,\"scriptPubKey\":\"hex\",\"redeemScript\":\"hex\"},...] [\"privatekey1\",...] sighashtype )\n"
"\nSign inputs for raw transaction (serialized, hex-encoded).\n" "\nSign inputs for raw transaction (serialized, hex-encoded).\n"
@ -644,9 +644,9 @@ UniValue signrawtransaction(const UniValue& params, bool fHelp)
#else #else
LOCK(cs_main); LOCK(cs_main);
#endif #endif
RPCTypeCheck(params, boost::assign::list_of(UniValue::VSTR)(UniValue::VARR)(UniValue::VARR)(UniValue::VSTR), true); RPCTypeCheck(request.params, boost::assign::list_of(UniValue::VSTR)(UniValue::VARR)(UniValue::VARR)(UniValue::VSTR), true);
vector<unsigned char> txData(ParseHexV(params[0], "argument 1")); vector<unsigned char> txData(ParseHexV(request.params[0], "argument 1"));
CDataStream ssData(txData, SER_NETWORK, PROTOCOL_VERSION); CDataStream ssData(txData, SER_NETWORK, PROTOCOL_VERSION);
vector<CMutableTransaction> txVariants; vector<CMutableTransaction> txVariants;
while (!ssData.empty()) { while (!ssData.empty()) {
@ -687,9 +687,9 @@ UniValue signrawtransaction(const UniValue& params, bool fHelp)
bool fGivenKeys = false; bool fGivenKeys = false;
CBasicKeyStore tempKeystore; CBasicKeyStore tempKeystore;
if (params.size() > 2 && !params[2].isNull()) { if (request.params.size() > 2 && !request.params[2].isNull()) {
fGivenKeys = true; fGivenKeys = true;
UniValue keys = params[2].get_array(); UniValue keys = request.params[2].get_array();
for (unsigned int idx = 0; idx < keys.size(); idx++) { for (unsigned int idx = 0; idx < keys.size(); idx++) {
UniValue k = keys[idx]; UniValue k = keys[idx];
CBitcoinSecret vchSecret; CBitcoinSecret vchSecret;
@ -708,8 +708,8 @@ UniValue signrawtransaction(const UniValue& params, bool fHelp)
#endif #endif
// Add previous txouts given in the RPC call: // Add previous txouts given in the RPC call:
if (params.size() > 1 && !params[1].isNull()) { if (request.params.size() > 1 && !request.params[1].isNull()) {
UniValue prevTxs = params[1].get_array(); UniValue prevTxs = request.params[1].get_array();
for (unsigned int idx = 0; idx < prevTxs.size(); idx++) { for (unsigned int idx = 0; idx < prevTxs.size(); idx++) {
const UniValue& p = prevTxs[idx]; const UniValue& p = prevTxs[idx];
if (!p.isObject()) if (!p.isObject())
@ -777,7 +777,7 @@ UniValue signrawtransaction(const UniValue& params, bool fHelp)
#endif #endif
int nHashType = SIGHASH_ALL; int nHashType = SIGHASH_ALL;
if (params.size() > 3 && !params[3].isNull()) { if (request.params.size() > 3 && !request.params[3].isNull()) {
static map<string, int> mapSigHashValues = static map<string, int> mapSigHashValues =
boost::assign::map_list_of boost::assign::map_list_of
(string("ALL"), int(SIGHASH_ALL)) (string("ALL"), int(SIGHASH_ALL))
@ -787,7 +787,7 @@ UniValue signrawtransaction(const UniValue& params, bool fHelp)
(string("SINGLE"), int(SIGHASH_SINGLE)) (string("SINGLE"), int(SIGHASH_SINGLE))
(string("SINGLE|ANYONECANPAY"), int(SIGHASH_SINGLE|SIGHASH_ANYONECANPAY)) (string("SINGLE|ANYONECANPAY"), int(SIGHASH_SINGLE|SIGHASH_ANYONECANPAY))
; ;
string strHashType = params[3].get_str(); string strHashType = request.params[3].get_str();
if (mapSigHashValues.count(strHashType)) if (mapSigHashValues.count(strHashType))
nHashType = mapSigHashValues[strHashType]; nHashType = mapSigHashValues[strHashType];
else else
@ -842,9 +842,9 @@ UniValue signrawtransaction(const UniValue& params, bool fHelp)
return result; return result;
} }
UniValue sendrawtransaction(const UniValue& params, bool fHelp) UniValue sendrawtransaction(const JSONRPCRequest& request)
{ {
if (fHelp || params.size() < 1 || params.size() > 2) if (request.fHelp || request.params.size() < 1 || request.params.size() > 2)
throw runtime_error( throw runtime_error(
"sendrawtransaction \"hexstring\" ( allowhighfees )\n" "sendrawtransaction \"hexstring\" ( allowhighfees )\n"
"\nSubmits raw transaction (serialized, hex-encoded) to local node and network.\n" "\nSubmits raw transaction (serialized, hex-encoded) to local node and network.\n"
@ -866,17 +866,17 @@ UniValue sendrawtransaction(const UniValue& params, bool fHelp)
); );
LOCK(cs_main); LOCK(cs_main);
RPCTypeCheck(params, boost::assign::list_of(UniValue::VSTR)(UniValue::VBOOL)); RPCTypeCheck(request.params, boost::assign::list_of(UniValue::VSTR)(UniValue::VBOOL));
// parse hex string from parameter // parse hex string from parameter
CTransaction tx; CTransaction tx;
if (!DecodeHexTx(tx, params[0].get_str())) if (!DecodeHexTx(tx, request.params[0].get_str()))
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed"); throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed");
uint256 hashTx = tx.GetHash(); uint256 hashTx = tx.GetHash();
bool fLimitFree = false; bool fLimitFree = false;
CAmount nMaxRawTxFee = maxTxFee; CAmount nMaxRawTxFee = maxTxFee;
if (params.size() > 1 && params[1].get_bool()) if (request.params.size() > 1 && request.params[1].get_bool())
nMaxRawTxFee = 0; nMaxRawTxFee = 0;
CCoinsViewCache &view = *pcoinsTip; CCoinsViewCache &view = *pcoinsTip;

29
src/rpc/server.cpp

@ -195,10 +195,11 @@ std::string CRPCTable::help(const std::string& strCommand) const
continue; continue;
try try
{ {
UniValue params; JSONRPCRequest jreq;
jreq.fHelp = true;
rpcfn_type pfn = pcmd->actor; rpcfn_type pfn = pcmd->actor;
if (setDone.insert(pfn).second) if (setDone.insert(pfn).second)
(*pfn)(params, true); (*pfn)(jreq);
} }
catch (const std::exception& e) catch (const std::exception& e)
{ {
@ -228,9 +229,9 @@ std::string CRPCTable::help(const std::string& strCommand) const
return strRet; return strRet;
} }
UniValue help(const UniValue& params, bool fHelp) UniValue help(const JSONRPCRequest& jsonRequest)
{ {
if (fHelp || params.size() > 1) if (jsonRequest.fHelp || jsonRequest.params.size() > 1)
throw runtime_error( throw runtime_error(
"help ( \"command\" )\n" "help ( \"command\" )\n"
"\nList all commands, or get help for a specified command.\n" "\nList all commands, or get help for a specified command.\n"
@ -241,17 +242,17 @@ UniValue help(const UniValue& params, bool fHelp)
); );
string strCommand; string strCommand;
if (params.size() > 0) if (jsonRequest.params.size() > 0)
strCommand = params[0].get_str(); strCommand = jsonRequest.params[0].get_str();
return tableRPC.help(strCommand); return tableRPC.help(strCommand);
} }
UniValue stop(const UniValue& params, bool fHelp) UniValue stop(const JSONRPCRequest& jsonRequest)
{ {
// Accept the deprecated and ignored 'detach' boolean argument // Accept the deprecated and ignored 'detach' boolean argument
if (fHelp || params.size() > 1) if (jsonRequest.fHelp || jsonRequest.params.size() > 1)
throw runtime_error( throw runtime_error(
"stop\n" "stop\n"
"\nStop Bitcoin server."); "\nStop Bitcoin server.");
@ -354,7 +355,7 @@ bool RPCIsInWarmup(std::string *outStatus)
return fRPCInWarmup; return fRPCInWarmup;
} }
void JSONRequest::parse(const UniValue& valRequest) void JSONRPCRequest::parse(const UniValue& valRequest)
{ {
// Parse request // Parse request
if (!valRequest.isObject()) if (!valRequest.isObject())
@ -388,11 +389,11 @@ static UniValue JSONRPCExecOne(const UniValue& req)
{ {
UniValue rpc_result(UniValue::VOBJ); UniValue rpc_result(UniValue::VOBJ);
JSONRequest jreq; JSONRPCRequest jreq;
try { try {
jreq.parse(req); jreq.parse(req);
UniValue result = tableRPC.execute(jreq.strMethod, jreq.params); UniValue result = tableRPC.execute(jreq);
rpc_result = JSONRPCReplyObj(result, NullUniValue, jreq.id); rpc_result = JSONRPCReplyObj(result, NullUniValue, jreq.id);
} }
catch (const UniValue& objError) catch (const UniValue& objError)
@ -417,7 +418,7 @@ std::string JSONRPCExecBatch(const UniValue& vReq)
return ret.write() + "\n"; return ret.write() + "\n";
} }
UniValue CRPCTable::execute(const std::string &strMethod, const UniValue &params) const UniValue CRPCTable::execute(const JSONRPCRequest &request) const
{ {
// Return immediately if in warmup // Return immediately if in warmup
{ {
@ -427,7 +428,7 @@ UniValue CRPCTable::execute(const std::string &strMethod, const UniValue &params
} }
// Find method // Find method
const CRPCCommand *pcmd = tableRPC[strMethod]; const CRPCCommand *pcmd = tableRPC[request.strMethod];
if (!pcmd) if (!pcmd)
throw JSONRPCError(RPC_METHOD_NOT_FOUND, "Method not found"); throw JSONRPCError(RPC_METHOD_NOT_FOUND, "Method not found");
@ -436,7 +437,7 @@ UniValue CRPCTable::execute(const std::string &strMethod, const UniValue &params
try try
{ {
// Execute // Execute
return pcmd->actor(params, false); return pcmd->actor(request);
} }
catch (const std::exception& e) catch (const std::exception& e)
{ {

13
src/rpc/server.h

@ -41,14 +41,16 @@ struct UniValueType {
UniValue::VType type; UniValue::VType type;
}; };
class JSONRequest class JSONRPCRequest
{ {
public: public:
UniValue id; UniValue id;
std::string strMethod; std::string strMethod;
UniValue params; UniValue params;
bool fHelp;
std::string URI;
JSONRequest() { id = NullUniValue; } JSONRPCRequest() { id = NullUniValue; }
void parse(const UniValue& valRequest); void parse(const UniValue& valRequest);
}; };
@ -122,7 +124,7 @@ void RPCUnsetTimerInterface(RPCTimerInterface *iface);
*/ */
void RPCRunLater(const std::string& name, boost::function<void(void)> func, int64_t nSeconds); void RPCRunLater(const std::string& name, boost::function<void(void)> func, int64_t nSeconds);
typedef UniValue(*rpcfn_type)(const UniValue& params, bool fHelp); typedef UniValue(*rpcfn_type)(const JSONRPCRequest& jsonRequest);
class CRPCCommand class CRPCCommand
{ {
@ -147,12 +149,11 @@ public:
/** /**
* Execute a method. * Execute a method.
* @param method Method to execute * @param request The JSONRPCRequest to execute
* @param params UniValue Array of arguments (JSON objects)
* @returns Result of the call. * @returns Result of the call.
* @throws an exception (UniValue) when an error happens. * @throws an exception (UniValue) when an error happens.
*/ */
UniValue execute(const std::string &method, const UniValue &params) const; UniValue execute(const JSONRPCRequest &request) const;
/** /**
* Returns a list of registered commands * Returns a list of registered commands

7
src/test/rpc_tests.cpp

@ -24,11 +24,14 @@ UniValue 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());
UniValue params = RPCConvertValues(strMethod, vArgs); JSONRPCRequest request;
request.strMethod = strMethod;
request.params = RPCConvertValues(strMethod, vArgs);
request.fHelp = false;
BOOST_CHECK(tableRPC[strMethod]); BOOST_CHECK(tableRPC[strMethod]);
rpcfn_type method = tableRPC[strMethod]->actor; rpcfn_type method = tableRPC[strMethod]->actor;
try { try {
UniValue result = (*method)(params, false); UniValue result = (*method)(request);
return result; return result;
} }
catch (const UniValue& objError) { catch (const UniValue& objError) {

100
src/wallet/rpcdump.cpp

@ -74,12 +74,12 @@ std::string DecodeDumpString(const std::string &str) {
return ret.str(); return ret.str();
} }
UniValue importprivkey(const UniValue& params, bool fHelp) UniValue importprivkey(const JSONRPCRequest& request)
{ {
if (!EnsureWalletIsAvailable(fHelp)) if (!EnsureWalletIsAvailable(request.fHelp))
return NullUniValue; return NullUniValue;
if (fHelp || params.size() < 1 || params.size() > 3) if (request.fHelp || request.params.size() < 1 || request.params.size() > 3)
throw runtime_error( throw runtime_error(
"importprivkey \"bitcoinprivkey\" ( \"label\" rescan )\n" "importprivkey \"bitcoinprivkey\" ( \"label\" rescan )\n"
"\nAdds a private key (as returned by dumpprivkey) to your wallet.\n" "\nAdds a private key (as returned by dumpprivkey) to your wallet.\n"
@ -104,15 +104,15 @@ UniValue importprivkey(const UniValue& params, bool fHelp)
EnsureWalletIsUnlocked(); EnsureWalletIsUnlocked();
string strSecret = params[0].get_str(); string strSecret = request.params[0].get_str();
string strLabel = ""; string strLabel = "";
if (params.size() > 1) if (request.params.size() > 1)
strLabel = params[1].get_str(); strLabel = request.params[1].get_str();
// Whether to perform rescan after import // Whether to perform rescan after import
bool fRescan = true; bool fRescan = true;
if (params.size() > 2) if (request.params.size() > 2)
fRescan = params[2].get_bool(); fRescan = request.params[2].get_bool();
if (fRescan && fPruneMode) if (fRescan && fPruneMode)
throw JSONRPCError(RPC_WALLET_ERROR, "Rescan is disabled in pruned mode"); throw JSONRPCError(RPC_WALLET_ERROR, "Rescan is disabled in pruned mode");
@ -184,12 +184,12 @@ void ImportAddress(const CBitcoinAddress& address, const string& strLabel)
pwalletMain->SetAddressBook(address.Get(), strLabel, "receive"); pwalletMain->SetAddressBook(address.Get(), strLabel, "receive");
} }
UniValue importaddress(const UniValue& params, bool fHelp) UniValue importaddress(const JSONRPCRequest& request)
{ {
if (!EnsureWalletIsAvailable(fHelp)) if (!EnsureWalletIsAvailable(request.fHelp))
return NullUniValue; return NullUniValue;
if (fHelp || params.size() < 1 || params.size() > 4) if (request.fHelp || request.params.size() < 1 || request.params.size() > 4)
throw runtime_error( throw runtime_error(
"importaddress \"address\" ( \"label\" rescan p2sh )\n" "importaddress \"address\" ( \"label\" rescan p2sh )\n"
"\nAdds a script (in hex) or address that can be watched as if it were in your wallet but cannot be used to spend.\n" "\nAdds a script (in hex) or address that can be watched as if it were in your wallet but cannot be used to spend.\n"
@ -213,31 +213,31 @@ UniValue importaddress(const UniValue& params, bool fHelp)
string strLabel = ""; string strLabel = "";
if (params.size() > 1) if (request.params.size() > 1)
strLabel = params[1].get_str(); strLabel = request.params[1].get_str();
// Whether to perform rescan after import // Whether to perform rescan after import
bool fRescan = true; bool fRescan = true;
if (params.size() > 2) if (request.params.size() > 2)
fRescan = params[2].get_bool(); fRescan = request.params[2].get_bool();
if (fRescan && fPruneMode) if (fRescan && fPruneMode)
throw JSONRPCError(RPC_WALLET_ERROR, "Rescan is disabled in pruned mode"); throw JSONRPCError(RPC_WALLET_ERROR, "Rescan is disabled in pruned mode");
// Whether to import a p2sh version, too // Whether to import a p2sh version, too
bool fP2SH = false; bool fP2SH = false;
if (params.size() > 3) if (request.params.size() > 3)
fP2SH = params[3].get_bool(); fP2SH = request.params[3].get_bool();
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
CBitcoinAddress address(params[0].get_str()); CBitcoinAddress address(request.params[0].get_str());
if (address.IsValid()) { if (address.IsValid()) {
if (fP2SH) if (fP2SH)
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Cannot use the p2sh flag with an address - use a script instead"); throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Cannot use the p2sh flag with an address - use a script instead");
ImportAddress(address, strLabel); ImportAddress(address, strLabel);
} else if (IsHex(params[0].get_str())) { } else if (IsHex(request.params[0].get_str())) {
std::vector<unsigned char> data(ParseHex(params[0].get_str())); std::vector<unsigned char> data(ParseHex(request.params[0].get_str()));
ImportScript(CScript(data.begin(), data.end()), strLabel, fP2SH); ImportScript(CScript(data.begin(), data.end()), strLabel, fP2SH);
} else { } else {
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Bitcoin address or script"); throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Bitcoin address or script");
@ -252,12 +252,12 @@ UniValue importaddress(const UniValue& params, bool fHelp)
return NullUniValue; return NullUniValue;
} }
UniValue importprunedfunds(const UniValue& params, bool fHelp) UniValue importprunedfunds(const JSONRPCRequest& request)
{ {
if (!EnsureWalletIsAvailable(fHelp)) if (!EnsureWalletIsAvailable(request.fHelp))
return NullUniValue; return NullUniValue;
if (fHelp || params.size() != 2) if (request.fHelp || request.params.size() != 2)
throw runtime_error( throw runtime_error(
"importprunedfunds\n" "importprunedfunds\n"
"\nImports funds without rescan. Corresponding address or script must previously be included in wallet. Aimed towards pruned wallets. The end-user is responsible to import additional transactions that subsequently spend the imported outputs or rescan after the point in the blockchain the transaction is included.\n" "\nImports funds without rescan. Corresponding address or script must previously be included in wallet. Aimed towards pruned wallets. The end-user is responsible to import additional transactions that subsequently spend the imported outputs or rescan after the point in the blockchain the transaction is included.\n"
@ -267,12 +267,12 @@ UniValue importprunedfunds(const UniValue& params, bool fHelp)
); );
CTransaction tx; CTransaction tx;
if (!DecodeHexTx(tx, params[0].get_str())) if (!DecodeHexTx(tx, request.params[0].get_str()))
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed"); throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed");
uint256 hashTx = tx.GetHash(); uint256 hashTx = tx.GetHash();
CWalletTx wtx(pwalletMain,tx); CWalletTx wtx(pwalletMain,tx);
CDataStream ssMB(ParseHexV(params[1], "proof"), SER_NETWORK, PROTOCOL_VERSION); CDataStream ssMB(ParseHexV(request.params[1], "proof"), SER_NETWORK, PROTOCOL_VERSION);
CMerkleBlock merkleBlock; CMerkleBlock merkleBlock;
ssMB >> merkleBlock; ssMB >> merkleBlock;
@ -311,12 +311,12 @@ UniValue importprunedfunds(const UniValue& params, bool fHelp)
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No addresses in wallet correspond to included transaction"); throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No addresses in wallet correspond to included transaction");
} }
UniValue removeprunedfunds(const UniValue& params, bool fHelp) UniValue removeprunedfunds(const JSONRPCRequest& request)
{ {
if (!EnsureWalletIsAvailable(fHelp)) if (!EnsureWalletIsAvailable(request.fHelp))
return NullUniValue; return NullUniValue;
if (fHelp || params.size() != 1) if (request.fHelp || request.params.size() != 1)
throw runtime_error( throw runtime_error(
"removeprunedfunds \"txid\"\n" "removeprunedfunds \"txid\"\n"
"\nDeletes the specified transaction from the wallet. Meant for use with pruned wallets and as a companion to importprunedfunds. This will effect wallet balances.\n" "\nDeletes the specified transaction from the wallet. Meant for use with pruned wallets and as a companion to importprunedfunds. This will effect wallet balances.\n"
@ -331,7 +331,7 @@ UniValue removeprunedfunds(const UniValue& params, bool fHelp)
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
uint256 hash; uint256 hash;
hash.SetHex(params[0].get_str()); hash.SetHex(request.params[0].get_str());
vector<uint256> vHash; vector<uint256> vHash;
vHash.push_back(hash); vHash.push_back(hash);
vector<uint256> vHashOut; vector<uint256> vHashOut;
@ -347,12 +347,12 @@ UniValue removeprunedfunds(const UniValue& params, bool fHelp)
return NullUniValue; return NullUniValue;
} }
UniValue importpubkey(const UniValue& params, bool fHelp) UniValue importpubkey(const JSONRPCRequest& request)
{ {
if (!EnsureWalletIsAvailable(fHelp)) if (!EnsureWalletIsAvailable(request.fHelp))
return NullUniValue; return NullUniValue;
if (fHelp || params.size() < 1 || params.size() > 4) if (request.fHelp || request.params.size() < 1 || request.params.size() > 4)
throw runtime_error( throw runtime_error(
"importpubkey \"pubkey\" ( \"label\" rescan )\n" "importpubkey \"pubkey\" ( \"label\" rescan )\n"
"\nAdds a public key (in hex) that can be watched as if it were in your wallet but cannot be used to spend.\n" "\nAdds a public key (in hex) that can be watched as if it were in your wallet but cannot be used to spend.\n"
@ -372,20 +372,20 @@ UniValue importpubkey(const UniValue& params, bool fHelp)
string strLabel = ""; string strLabel = "";
if (params.size() > 1) if (request.params.size() > 1)
strLabel = params[1].get_str(); strLabel = request.params[1].get_str();
// Whether to perform rescan after import // Whether to perform rescan after import
bool fRescan = true; bool fRescan = true;
if (params.size() > 2) if (request.params.size() > 2)
fRescan = params[2].get_bool(); fRescan = request.params[2].get_bool();
if (fRescan && fPruneMode) if (fRescan && fPruneMode)
throw JSONRPCError(RPC_WALLET_ERROR, "Rescan is disabled in pruned mode"); throw JSONRPCError(RPC_WALLET_ERROR, "Rescan is disabled in pruned mode");
if (!IsHex(params[0].get_str())) if (!IsHex(request.params[0].get_str()))
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Pubkey must be a hex string"); throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Pubkey must be a hex string");
std::vector<unsigned char> data(ParseHex(params[0].get_str())); std::vector<unsigned char> data(ParseHex(request.params[0].get_str()));
CPubKey pubKey(data.begin(), data.end()); CPubKey pubKey(data.begin(), data.end());
if (!pubKey.IsFullyValid()) if (!pubKey.IsFullyValid())
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Pubkey is not a valid public key"); throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Pubkey is not a valid public key");
@ -405,12 +405,12 @@ UniValue importpubkey(const UniValue& params, bool fHelp)
} }
UniValue importwallet(const UniValue& params, bool fHelp) UniValue importwallet(const JSONRPCRequest& request)
{ {
if (!EnsureWalletIsAvailable(fHelp)) if (!EnsureWalletIsAvailable(request.fHelp))
return NullUniValue; return NullUniValue;
if (fHelp || params.size() != 1) if (request.fHelp || request.params.size() != 1)
throw runtime_error( throw runtime_error(
"importwallet \"filename\"\n" "importwallet \"filename\"\n"
"\nImports keys from a wallet dump file (see dumpwallet).\n" "\nImports keys from a wallet dump file (see dumpwallet).\n"
@ -433,7 +433,7 @@ UniValue importwallet(const UniValue& params, bool fHelp)
EnsureWalletIsUnlocked(); EnsureWalletIsUnlocked();
ifstream file; ifstream file;
file.open(params[0].get_str().c_str(), std::ios::in | std::ios::ate); file.open(request.params[0].get_str().c_str(), std::ios::in | std::ios::ate);
if (!file.is_open()) if (!file.is_open())
throw JSONRPCError(RPC_INVALID_PARAMETER, "Cannot open wallet dump file"); throw JSONRPCError(RPC_INVALID_PARAMETER, "Cannot open wallet dump file");
@ -512,12 +512,12 @@ UniValue importwallet(const UniValue& params, bool fHelp)
return NullUniValue; return NullUniValue;
} }
UniValue dumpprivkey(const UniValue& params, bool fHelp) UniValue dumpprivkey(const JSONRPCRequest& request)
{ {
if (!EnsureWalletIsAvailable(fHelp)) if (!EnsureWalletIsAvailable(request.fHelp))
return NullUniValue; return NullUniValue;
if (fHelp || params.size() != 1) if (request.fHelp || request.params.size() != 1)
throw runtime_error( throw runtime_error(
"dumpprivkey \"bitcoinaddress\"\n" "dumpprivkey \"bitcoinaddress\"\n"
"\nReveals the private key corresponding to 'bitcoinaddress'.\n" "\nReveals the private key corresponding to 'bitcoinaddress'.\n"
@ -536,7 +536,7 @@ UniValue dumpprivkey(const UniValue& params, bool fHelp)
EnsureWalletIsUnlocked(); EnsureWalletIsUnlocked();
string strAddress = params[0].get_str(); string strAddress = request.params[0].get_str();
CBitcoinAddress address; CBitcoinAddress address;
if (!address.SetString(strAddress)) if (!address.SetString(strAddress))
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Bitcoin address"); throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Bitcoin address");
@ -550,12 +550,12 @@ UniValue dumpprivkey(const UniValue& params, bool fHelp)
} }
UniValue dumpwallet(const UniValue& params, bool fHelp) UniValue dumpwallet(const JSONRPCRequest& request)
{ {
if (!EnsureWalletIsAvailable(fHelp)) if (!EnsureWalletIsAvailable(request.fHelp))
return NullUniValue; return NullUniValue;
if (fHelp || params.size() != 1) if (request.fHelp || request.params.size() != 1)
throw runtime_error( throw runtime_error(
"dumpwallet \"filename\"\n" "dumpwallet \"filename\"\n"
"\nDumps all wallet keys in a human-readable format.\n" "\nDumps all wallet keys in a human-readable format.\n"
@ -571,7 +571,7 @@ UniValue dumpwallet(const UniValue& params, bool fHelp)
EnsureWalletIsUnlocked(); EnsureWalletIsUnlocked();
ofstream file; ofstream file;
file.open(params[0].get_str().c_str()); file.open(request.params[0].get_str().c_str());
if (!file.is_open()) if (!file.is_open())
throw JSONRPCError(RPC_INVALID_PARAMETER, "Cannot open wallet dump file"); throw JSONRPCError(RPC_INVALID_PARAMETER, "Cannot open wallet dump file");

486
src/wallet/rpcwallet.cpp

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save