|
|
@ -9,7 +9,10 @@ |
|
|
|
#include "init.h" |
|
|
|
#include "init.h" |
|
|
|
#include "main.h" |
|
|
|
#include "main.h" |
|
|
|
#include "util.h" |
|
|
|
#include "util.h" |
|
|
|
|
|
|
|
#include "ui_interface.h" |
|
|
|
|
|
|
|
#ifdef ENABLE_WALLET |
|
|
|
#include "wallet.h" |
|
|
|
#include "wallet.h" |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
#include <boost/algorithm/string.hpp> |
|
|
|
#include <boost/algorithm/string.hpp> |
|
|
|
#include <boost/asio.hpp> |
|
|
|
#include <boost/asio.hpp> |
|
|
@ -149,8 +152,10 @@ string CRPCTable::help(string strCommand) const |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
if (strCommand != "" && strMethod != strCommand) |
|
|
|
if (strCommand != "" && strMethod != strCommand) |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
|
|
|
|
#ifdef ENABLE_WALLET |
|
|
|
if (pcmd->reqWallet && !pwalletMain) |
|
|
|
if (pcmd->reqWallet && !pwalletMain) |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
try |
|
|
|
try |
|
|
|
{ |
|
|
|
{ |
|
|
@ -228,11 +233,26 @@ static const CRPCCommand vRPCCommands[] = |
|
|
|
{ "getaddednodeinfo", &getaddednodeinfo, true, true, false }, |
|
|
|
{ "getaddednodeinfo", &getaddednodeinfo, true, true, false }, |
|
|
|
{ "getnettotals", &getnettotals, true, true, false }, |
|
|
|
{ "getnettotals", &getnettotals, true, true, false }, |
|
|
|
{ "getdifficulty", &getdifficulty, true, false, false }, |
|
|
|
{ "getdifficulty", &getdifficulty, true, false, false }, |
|
|
|
|
|
|
|
{ "getinfo", &getinfo, true, false, false }, |
|
|
|
|
|
|
|
{ "getrawmempool", &getrawmempool, true, false, false }, |
|
|
|
|
|
|
|
{ "getblock", &getblock, false, false, false }, |
|
|
|
|
|
|
|
{ "getblockhash", &getblockhash, false, false, false }, |
|
|
|
|
|
|
|
{ "settxfee", &settxfee, false, false, true }, |
|
|
|
|
|
|
|
{ "getrawtransaction", &getrawtransaction, false, false, false }, |
|
|
|
|
|
|
|
{ "createrawtransaction", &createrawtransaction, false, false, false }, |
|
|
|
|
|
|
|
{ "decoderawtransaction", &decoderawtransaction, false, false, false }, |
|
|
|
|
|
|
|
{ "decodescript", &decodescript, false, false, false }, |
|
|
|
|
|
|
|
{ "signrawtransaction", &signrawtransaction, false, false, false }, |
|
|
|
|
|
|
|
{ "sendrawtransaction", &sendrawtransaction, false, false, false }, |
|
|
|
|
|
|
|
{ "gettxoutsetinfo", &gettxoutsetinfo, true, false, false }, |
|
|
|
|
|
|
|
{ "gettxout", &gettxout, true, false, false }, |
|
|
|
|
|
|
|
{ "verifychain", &verifychain, true, false, false }, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef ENABLE_WALLET |
|
|
|
{ "getnetworkhashps", &getnetworkhashps, true, false, false }, |
|
|
|
{ "getnetworkhashps", &getnetworkhashps, true, false, false }, |
|
|
|
{ "getgenerate", &getgenerate, true, false, false }, |
|
|
|
{ "getgenerate", &getgenerate, true, false, false }, |
|
|
|
{ "setgenerate", &setgenerate, true, true, false }, |
|
|
|
{ "setgenerate", &setgenerate, true, true, false }, |
|
|
|
{ "gethashespersec", &gethashespersec, true, false, false }, |
|
|
|
{ "gethashespersec", &gethashespersec, true, false, false }, |
|
|
|
{ "getinfo", &getinfo, true, false, false }, |
|
|
|
|
|
|
|
{ "getmininginfo", &getmininginfo, true, false, false }, |
|
|
|
{ "getmininginfo", &getmininginfo, true, false, false }, |
|
|
|
{ "getnewaddress", &getnewaddress, true, false, true }, |
|
|
|
{ "getnewaddress", &getnewaddress, true, false, true }, |
|
|
|
{ "getaccountaddress", &getaccountaddress, true, false, true }, |
|
|
|
{ "getaccountaddress", &getaccountaddress, true, false, true }, |
|
|
@ -258,9 +278,6 @@ static const CRPCCommand vRPCCommands[] = |
|
|
|
{ "sendmany", &sendmany, false, false, true }, |
|
|
|
{ "sendmany", &sendmany, false, false, true }, |
|
|
|
{ "addmultisigaddress", &addmultisigaddress, false, false, true }, |
|
|
|
{ "addmultisigaddress", &addmultisigaddress, false, false, true }, |
|
|
|
{ "createmultisig", &createmultisig, true, true , false }, |
|
|
|
{ "createmultisig", &createmultisig, true, true , false }, |
|
|
|
{ "getrawmempool", &getrawmempool, true, false, false }, |
|
|
|
|
|
|
|
{ "getblock", &getblock, false, false, false }, |
|
|
|
|
|
|
|
{ "getblockhash", &getblockhash, false, false, false }, |
|
|
|
|
|
|
|
{ "gettransaction", &gettransaction, false, false, true }, |
|
|
|
{ "gettransaction", &gettransaction, false, false, true }, |
|
|
|
{ "listtransactions", &listtransactions, false, false, true }, |
|
|
|
{ "listtransactions", &listtransactions, false, false, true }, |
|
|
|
{ "listaddressgroupings", &listaddressgroupings, false, false, true }, |
|
|
|
{ "listaddressgroupings", &listaddressgroupings, false, false, true }, |
|
|
@ -268,7 +285,6 @@ static const CRPCCommand vRPCCommands[] = |
|
|
|
{ "verifymessage", &verifymessage, false, false, false }, |
|
|
|
{ "verifymessage", &verifymessage, false, false, false }, |
|
|
|
{ "getwork", &getwork, true, false, true }, |
|
|
|
{ "getwork", &getwork, true, false, true }, |
|
|
|
{ "listaccounts", &listaccounts, false, false, true }, |
|
|
|
{ "listaccounts", &listaccounts, false, false, true }, |
|
|
|
{ "settxfee", &settxfee, false, false, true }, |
|
|
|
|
|
|
|
{ "getblocktemplate", &getblocktemplate, true, false, false }, |
|
|
|
{ "getblocktemplate", &getblocktemplate, true, false, false }, |
|
|
|
{ "submitblock", &submitblock, false, false, false }, |
|
|
|
{ "submitblock", &submitblock, false, false, false }, |
|
|
|
{ "listsinceblock", &listsinceblock, false, false, true }, |
|
|
|
{ "listsinceblock", &listsinceblock, false, false, true }, |
|
|
@ -277,17 +293,9 @@ static const CRPCCommand vRPCCommands[] = |
|
|
|
{ "importprivkey", &importprivkey, false, false, true }, |
|
|
|
{ "importprivkey", &importprivkey, false, false, true }, |
|
|
|
{ "importwallet", &importwallet, false, false, true }, |
|
|
|
{ "importwallet", &importwallet, false, false, true }, |
|
|
|
{ "listunspent", &listunspent, false, false, true }, |
|
|
|
{ "listunspent", &listunspent, false, false, true }, |
|
|
|
{ "getrawtransaction", &getrawtransaction, false, false, false }, |
|
|
|
|
|
|
|
{ "createrawtransaction", &createrawtransaction, false, false, false }, |
|
|
|
|
|
|
|
{ "decoderawtransaction", &decoderawtransaction, false, false, false }, |
|
|
|
|
|
|
|
{ "decodescript", &decodescript, false, false, false }, |
|
|
|
|
|
|
|
{ "signrawtransaction", &signrawtransaction, false, false, false }, |
|
|
|
|
|
|
|
{ "sendrawtransaction", &sendrawtransaction, false, false, false }, |
|
|
|
|
|
|
|
{ "gettxoutsetinfo", &gettxoutsetinfo, true, false, false }, |
|
|
|
|
|
|
|
{ "gettxout", &gettxout, true, false, false }, |
|
|
|
|
|
|
|
{ "lockunspent", &lockunspent, false, false, true }, |
|
|
|
{ "lockunspent", &lockunspent, false, false, true }, |
|
|
|
{ "listlockunspent", &listlockunspent, false, false, true }, |
|
|
|
{ "listlockunspent", &listlockunspent, false, false, true }, |
|
|
|
{ "verifychain", &verifychain, true, false, false }, |
|
|
|
#endif // ENABLE_WALLET
|
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
CRPCTable::CRPCTable() |
|
|
|
CRPCTable::CRPCTable() |
|
|
@ -788,8 +796,10 @@ json_spirit::Value CRPCTable::execute(const std::string &strMethod, const json_s |
|
|
|
const CRPCCommand *pcmd = tableRPC[strMethod]; |
|
|
|
const CRPCCommand *pcmd = tableRPC[strMethod]; |
|
|
|
if (!pcmd) |
|
|
|
if (!pcmd) |
|
|
|
throw JSONRPCError(RPC_METHOD_NOT_FOUND, "Method not found"); |
|
|
|
throw JSONRPCError(RPC_METHOD_NOT_FOUND, "Method not found"); |
|
|
|
|
|
|
|
#ifdef ENABLE_WALLET |
|
|
|
if (pcmd->reqWallet && !pwalletMain) |
|
|
|
if (pcmd->reqWallet && !pwalletMain) |
|
|
|
throw JSONRPCError(RPC_METHOD_NOT_FOUND, "Method not found (disabled)"); |
|
|
|
throw JSONRPCError(RPC_METHOD_NOT_FOUND, "Method not found (disabled)"); |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
// Observe safe mode
|
|
|
|
// Observe safe mode
|
|
|
|
string strWarning = GetWarnings("rpc"); |
|
|
|
string strWarning = GetWarnings("rpc"); |
|
|
@ -804,6 +814,7 @@ json_spirit::Value CRPCTable::execute(const std::string &strMethod, const json_s |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (pcmd->threadSafe) |
|
|
|
if (pcmd->threadSafe) |
|
|
|
result = pcmd->actor(params, false); |
|
|
|
result = pcmd->actor(params, false); |
|
|
|
|
|
|
|
#ifdef ENABLE_WALLET |
|
|
|
else if (!pwalletMain) { |
|
|
|
else if (!pwalletMain) { |
|
|
|
LOCK(cs_main); |
|
|
|
LOCK(cs_main); |
|
|
|
result = pcmd->actor(params, false); |
|
|
|
result = pcmd->actor(params, false); |
|
|
@ -811,6 +822,12 @@ json_spirit::Value CRPCTable::execute(const std::string &strMethod, const json_s |
|
|
|
LOCK2(cs_main, pwalletMain->cs_wallet); |
|
|
|
LOCK2(cs_main, pwalletMain->cs_wallet); |
|
|
|
result = pcmd->actor(params, false); |
|
|
|
result = pcmd->actor(params, false); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#else // ENABLE_WALLET
|
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
LOCK(cs_main); |
|
|
|
|
|
|
|
result = pcmd->actor(params, false); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#endif // !ENABLE_WALLET
|
|
|
|
} |
|
|
|
} |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|