Merge #11179: rpc: Push down safe mode checks

ec6902d0e rpc: Push down safe mode checks (Andrew Chow)

Pull request description:

  This contains most of the changes of #10563 "remove safe mode" by @achow101, but doesn't remove the safe mode yet, but put an `ObserveSafeMode()` check in (all 23) individual calls which used to have okSafeMode=false.

  This cleans up the ugly "okSafeMode" flag from the dispatch tables, which is not a concern for the RPC server.

  Extra-author: Wladimir J. van der Laan <laanwj@gmail.com>

Tree-SHA512: eee0f251fe2f38f122e7391e3c4e98d6a1e2757f3b718d6b560ad835ae94f11490865a0aef893e90b5fe298165932c8dd8298224173ac2677a5245cd532bac6e

More of 11179

more of 11179 privatesend

Signed-off-by: Pasta <pasta@dashboost.org>

cont

Signed-off-by: Pasta <pasta@dashboost.org>

fix merge from develop

Signed-off-by: Pasta <pasta@dashboost.org>
This commit is contained in:
Wladimir J. van der Laan 2017-09-05 18:43:07 +02:00 committed by Pasta
parent 3b620c356c
commit 09ed6a45e1
19 changed files with 241 additions and 188 deletions

View File

@ -214,6 +214,7 @@ BITCOIN_CORE_H = \
rpc/client.h \ rpc/client.h \
rpc/mining.h \ rpc/mining.h \
rpc/protocol.h \ rpc/protocol.h \
rpc/safemode.h \
rpc/server.h \ rpc/server.h \
rpc/register.h \ rpc/register.h \
saltedhasher.h \ saltedhasher.h \
@ -337,6 +338,7 @@ libdash_server_a_SOURCES = \
rpc/rawtransaction.cpp \ rpc/rawtransaction.cpp \
rpc/rpcevo.cpp \ rpc/rpcevo.cpp \
rpc/rpcquorums.cpp \ rpc/rpcquorums.cpp \
rpc/safemode.cpp \
rpc/server.cpp \ rpc/server.cpp \
rpc/privatesend.cpp \ rpc/privatesend.cpp \
script/sigcache.cpp \ script/sigcache.cpp \

View File

@ -32,6 +32,7 @@
#include "policy/policy.h" #include "policy/policy.h"
#include "rpc/server.h" #include "rpc/server.h"
#include "rpc/register.h" #include "rpc/register.h"
#include "rpc/safemode.h"
#include "rpc/blockchain.h" #include "rpc/blockchain.h"
#include "script/standard.h" #include "script/standard.h"
#include "script/sigcache.h" #include "script/sigcache.h"
@ -98,7 +99,6 @@
bool fFeeEstimatesInitialized = false; bool fFeeEstimatesInitialized = false;
static const bool DEFAULT_PROXYRANDOMIZE = true; static const bool DEFAULT_PROXYRANDOMIZE = true;
static const bool DEFAULT_REST_ENABLE = false; static const bool DEFAULT_REST_ENABLE = false;
static const bool DEFAULT_DISABLE_SAFEMODE = true;
static const bool DEFAULT_STOPAFTERBLOCKIMPORT = false; static const bool DEFAULT_STOPAFTERBLOCKIMPORT = false;
@ -418,15 +418,6 @@ void OnRPCStopped()
LogPrint(BCLog::RPC, "RPC stopped.\n"); LogPrint(BCLog::RPC, "RPC stopped.\n");
} }
void OnRPCPreCommand(const CRPCCommand& cmd)
{
// Observe safe mode
std::string strWarning = GetWarnings("rpc");
if (strWarning != "" && !gArgs.GetBoolArg("-disablesafemode", DEFAULT_DISABLE_SAFEMODE) &&
!cmd.okSafeMode)
throw JSONRPCError(RPC_FORBIDDEN_BY_SAFE_MODE, std::string("Safe mode: ") + strWarning);
}
std::string HelpMessage(HelpMessageMode mode) std::string HelpMessage(HelpMessageMode mode)
{ {
const auto defaultBaseParams = CreateBaseChainParams(CBaseChainParams::MAIN); const auto defaultBaseParams = CreateBaseChainParams(CBaseChainParams::MAIN);
@ -894,7 +885,6 @@ bool AppInitServers(boost::thread_group& threadGroup)
{ {
RPCServer::OnStarted(&OnRPCStarted); RPCServer::OnStarted(&OnRPCStarted);
RPCServer::OnStopped(&OnRPCStopped); RPCServer::OnStopped(&OnRPCStopped);
RPCServer::OnPreCommand(&OnRPCPreCommand);
if (!InitHTTPServer()) if (!InitHTTPServer())
return false; return false;
if (!StartRPC()) if (!StartRPC())

View File

@ -31,7 +31,7 @@ static UniValue rpcNestedTest_rpc(const JSONRPCRequest& request)
static const CRPCCommand vRPCCommands[] = static const CRPCCommand vRPCCommands[] =
{ {
{ "test", "rpcNestedTest", &rpcNestedTest_rpc, true, {} }, { "test", "rpcNestedTest", &rpcNestedTest_rpc, {} },
}; };
void RPCNestedTests::rpcNestedTests() void RPCNestedTests::rpcNestedTests()

View File

@ -2187,41 +2187,41 @@ UniValue getspecialtxes(const JSONRPCRequest& request)
} }
static const CRPCCommand commands[] = static const CRPCCommand commands[] =
{ // category name actor (function) okSafe argNames { // category name actor (function) argNames
// --------------------- ------------------------ ----------------------- ------ ---------- // --------------------- ------------------------ ----------------------- ----------
{ "blockchain", "getblockchaininfo", &getblockchaininfo, true, {} }, { "blockchain", "getblockchaininfo", &getblockchaininfo, {} },
{ "blockchain", "getchaintxstats", &getchaintxstats, true, {"nblocks", "blockhash"} }, { "blockchain", "getchaintxstats", &getchaintxstats, {"nblocks", "blockhash"} },
{ "blockchain", "getblockstats", &getblockstats, true, {"hash_or_height", "stats"} }, { "blockchain", "getblockstats", &getblockstats, {"hash_or_height", "stats"} },
{ "blockchain", "getbestblockhash", &getbestblockhash, true, {} }, { "blockchain", "getbestblockhash", &getbestblockhash, {} },
{ "blockchain", "getbestchainlock", &getbestchainlock, true, {} }, { "blockchain", "getbestchainlock", &getbestchainlock, {} },
{ "blockchain", "getblockcount", &getblockcount, true, {} }, { "blockchain", "getblockcount", &getblockcount, {} },
{ "blockchain", "getblock", &getblock, true, {"blockhash","verbosity|verbose"} }, { "blockchain", "getblock", &getblock, {"blockhash","verbosity|verbose"} },
{ "blockchain", "getblockhashes", &getblockhashes, true, {"high","low"} }, { "blockchain", "getblockhashes", &getblockhashes, {"high","low"} },
{ "blockchain", "getblockhash", &getblockhash, true, {"height"} }, { "blockchain", "getblockhash", &getblockhash, {"height"} },
{ "blockchain", "getblockheader", &getblockheader, true, {"blockhash","verbose"} }, { "blockchain", "getblockheader", &getblockheader, {"blockhash","verbose"} },
{ "blockchain", "getblockheaders", &getblockheaders, true, {"blockhash","count","verbose"} }, { "blockchain", "getblockheaders", &getblockheaders, {"blockhash","count","verbose"} },
{ "blockchain", "getmerkleblocks", &getmerkleblocks, true, {"filter","blockhash","count"} }, { "blockchain", "getmerkleblocks", &getmerkleblocks, {"filter","blockhash","count"} },
{ "blockchain", "getchaintips", &getchaintips, true, {"count","branchlen"} }, { "blockchain", "getchaintips", &getchaintips, {"count","branchlen"} },
{ "blockchain", "getdifficulty", &getdifficulty, true, {} }, { "blockchain", "getdifficulty", &getdifficulty, {} },
{ "blockchain", "getmempoolancestors", &getmempoolancestors, true, {"txid","verbose"} }, { "blockchain", "getmempoolancestors", &getmempoolancestors, {"txid","verbose"} },
{ "blockchain", "getmempooldescendants", &getmempooldescendants, true, {"txid","verbose"} }, { "blockchain", "getmempooldescendants", &getmempooldescendants, {"txid","verbose"} },
{ "blockchain", "getmempoolentry", &getmempoolentry, true, {"txid"} }, { "blockchain", "getmempoolentry", &getmempoolentry, {"txid"} },
{ "blockchain", "getmempoolinfo", &getmempoolinfo, true, {} }, { "blockchain", "getmempoolinfo", &getmempoolinfo, {} },
{ "blockchain", "getrawmempool", &getrawmempool, true, {"verbose"} }, { "blockchain", "getrawmempool", &getrawmempool, {"verbose"} },
{ "blockchain", "getspecialtxes", &getspecialtxes, true, {"blockhash", "type", "count", "skip", "verbosity"} }, { "blockchain", "getspecialtxes", &getspecialtxes, {"blockhash", "type", "count", "skip", "verbosity"} },
{ "blockchain", "gettxout", &gettxout, true, {"txid","n","include_mempool"} }, { "blockchain", "gettxout", &gettxout, {"txid","n","include_mempool"} },
{ "blockchain", "gettxoutsetinfo", &gettxoutsetinfo, true, {} }, { "blockchain", "gettxoutsetinfo", &gettxoutsetinfo, {} },
{ "blockchain", "pruneblockchain", &pruneblockchain, true, {"height"} }, { "blockchain", "pruneblockchain", &pruneblockchain, {"height"} },
{ "blockchain", "verifychain", &verifychain, true, {"checklevel","nblocks"} }, { "blockchain", "verifychain", &verifychain, {"checklevel","nblocks"} },
{ "blockchain", "preciousblock", &preciousblock, true, {"blockhash"} }, { "blockchain", "preciousblock", &preciousblock, {"blockhash"} },
/* Not shown in help */ /* Not shown in help */
{ "hidden", "invalidateblock", &invalidateblock, true, {"blockhash"} }, { "hidden", "invalidateblock", &invalidateblock, {"blockhash"} },
{ "hidden", "reconsiderblock", &reconsiderblock, true, {"blockhash"} }, { "hidden", "reconsiderblock", &reconsiderblock, {"blockhash"} },
{ "hidden", "waitfornewblock", &waitfornewblock, true, {"timeout"} }, { "hidden", "waitfornewblock", &waitfornewblock, {"timeout"} },
{ "hidden", "waitforblock", &waitforblock, true, {"blockhash","timeout"} }, { "hidden", "waitforblock", &waitforblock, {"blockhash","timeout"} },
{ "hidden", "waitforblockheight", &waitforblockheight, true, {"height","timeout"} }, { "hidden", "waitforblockheight", &waitforblockheight, {"height","timeout"} },
}; };
void RegisterBlockchainRPCCommands(CRPCTable &t) void RegisterBlockchainRPCCommands(CRPCTable &t)

View File

@ -1092,13 +1092,13 @@ UniValue getsuperblockbudget(const JSONRPCRequest& request)
} }
static const CRPCCommand commands[] = static const CRPCCommand commands[] =
{ // category name actor (function) okSafe argNames { // category name actor (function) argNames
// --------------------- ------------------------ ----------------------- ------ ---------- // --------------------- ------------------------ ----------------------- ----------
/* Dash features */ /* Dash features */
{ "dash", "getgovernanceinfo", &getgovernanceinfo, true, {} }, { "dash", "getgovernanceinfo", &getgovernanceinfo, {} },
{ "dash", "getsuperblockbudget", &getsuperblockbudget, true, {"index"} }, { "dash", "getsuperblockbudget", &getsuperblockbudget, {"index"} },
{ "dash", "gobject", &gobject, true, {} }, { "dash", "gobject", &gobject, {} },
{ "dash", "voteraw", &voteraw, true, {} }, { "dash", "voteraw", &voteraw, {} },
}; };

View File

@ -525,10 +525,10 @@ UniValue masternodelist(const JSONRPCRequest& request)
} }
static const CRPCCommand commands[] = static const CRPCCommand commands[] =
{ // category name actor (function) okSafe argNames { // category name actor (function) argNames
// --------------------- ------------------------ ----------------------- ------ ---------- // --------------------- ------------------------ ----------------------- ----------
{ "dash", "masternode", &masternode, true, {} }, { "dash", "masternode", &masternode, {} },
{ "dash", "masternodelist", &masternodelist, true, {} }, { "dash", "masternodelist", &masternodelist, {} },
}; };
void RegisterMasternodeRPCCommands(CRPCTable &t) void RegisterMasternodeRPCCommands(CRPCTable &t)

View File

@ -991,21 +991,22 @@ UniValue estimaterawfee(const JSONRPCRequest& request)
} }
static const CRPCCommand commands[] = static const CRPCCommand commands[] =
{ // category name actor (function) okSafeMode { // category name actor (function) argNames
// --------------------- ------------------------ ----------------------- ---------- // --------------------- ------------------------ ----------------------- ----------
{ "mining", "getnetworkhashps", &getnetworkhashps, true, {"nblocks","height"} }, { "mining", "getnetworkhashps", &getnetworkhashps, {"nblocks","height"} },
{ "mining", "getmininginfo", &getmininginfo, true, {} }, { "mining", "getmininginfo", &getmininginfo, {} },
{ "mining", "prioritisetransaction", &prioritisetransaction, true, {"txid","fee_delta"} }, { "mining", "prioritisetransaction", &prioritisetransaction, {"txid","fee_delta"} },
{ "mining", "getblocktemplate", &getblocktemplate, true, {"template_request"} }, { "mining", "getblocktemplate", &getblocktemplate, {"template_request"} },
{ "mining", "submitblock", &submitblock, true, {"hexdata","dummy"} }, { "mining", "submitblock", &submitblock, {"hexdata","dummy"} },
#if ENABLE_MINER #if ENABLE_MINER
{ "generating", "generatetoaddress", &generatetoaddress, true, {"nblocks","address","maxtries"} }, { "generating", "generatetoaddress", &generatetoaddress, {"nblocks","address","maxtries"} },
#endif // ENABLE_MINER #endif // ENABLE_MINER
{ "util", "estimatefee", &estimatefee, true, {"nblocks"} },
{ "util", "estimatesmartfee", &estimatesmartfee, true, {"conf_target", "estimate_mode"} },
{ "hidden", "estimaterawfee", &estimaterawfee, true, {"conf_target", "threshold"} }, { "util", "estimatefee", &estimatefee, {"nblocks"} },
{ "util", "estimatesmartfee", &estimatesmartfee, {"nblocks", "estimate_mode"} },
{ "hidden", "estimaterawfee", &estimaterawfee, {"conf_target", "threshold"} },
}; };
void RegisterMiningRPCCommands(CRPCTable &t) void RegisterMiningRPCCommands(CRPCTable &t)

View File

@ -1287,33 +1287,33 @@ UniValue echo(const JSONRPCRequest& request)
} }
static const CRPCCommand commands[] = static const CRPCCommand commands[] =
{ // category name actor (function) okSafeMode { // category name actor (function) argNames
// --------------------- ------------------------ ----------------------- ---------- // --------------------- ------------------------ ----------------------- ----------
{ "control", "debug", &debug, true, {} }, { "control", "debug", &debug, {} },
{ "control", "getinfo", &getinfo, true, {} }, /* uses wallet if enabled */ { "control", "getinfo", &getinfo, {} }, /* uses wallet if enabled */
{ "control", "getmemoryinfo", &getmemoryinfo, true, {"mode"} }, { "control", "getmemoryinfo", &getmemoryinfo, {"mode"} },
{ "util", "validateaddress", &validateaddress, true, {"address"} }, /* uses wallet if enabled */ { "util", "validateaddress", &validateaddress, {"address"} }, /* uses wallet if enabled */
{ "util", "createmultisig", &createmultisig, true, {"nrequired","keys"} }, { "util", "createmultisig", &createmultisig, {"nrequired","keys"} },
{ "util", "verifymessage", &verifymessage, true, {"address","signature","message"} }, { "util", "verifymessage", &verifymessage, {"address","signature","message"} },
{ "util", "signmessagewithprivkey", &signmessagewithprivkey, true, {"privkey","message"} }, { "util", "signmessagewithprivkey", &signmessagewithprivkey, {"privkey","message"} },
{ "blockchain", "getspentinfo", &getspentinfo, false, {"json"} }, { "blockchain", "getspentinfo", &getspentinfo, {"json"} },
/* Address index */ /* Address index */
{ "addressindex", "getaddressmempool", &getaddressmempool, true, {"addresses"} }, { "addressindex", "getaddressmempool", &getaddressmempool, {"addresses"} },
{ "addressindex", "getaddressutxos", &getaddressutxos, false, {"addresses"} }, { "addressindex", "getaddressutxos", &getaddressutxos, {"addresses"} },
{ "addressindex", "getaddressdeltas", &getaddressdeltas, false, {"addresses"} }, { "addressindex", "getaddressdeltas", &getaddressdeltas, {"addresses"} },
{ "addressindex", "getaddresstxids", &getaddresstxids, false, {"addresses"} }, { "addressindex", "getaddresstxids", &getaddresstxids, {"addresses"} },
{ "addressindex", "getaddressbalance", &getaddressbalance, false, {"addresses"} }, { "addressindex", "getaddressbalance", &getaddressbalance, {"addresses"} },
/* Dash features */ /* Dash features */
{ "dash", "mnsync", &mnsync, true, {} }, { "dash", "mnsync", &mnsync, {} },
{ "dash", "spork", &spork, true, {"value"} }, { "dash", "spork", &spork, {"value"} },
/* Not shown in help */ /* Not shown in help */
{ "hidden", "setmocktime", &setmocktime, true, {"timestamp"}}, { "hidden", "setmocktime", &setmocktime, {"timestamp"}},
{ "hidden", "echo", &echo, true, {"arg0","arg1","arg2","arg3","arg4","arg5","arg6","arg7","arg8","arg9"}}, { "hidden", "echo", &echo, {"arg0","arg1","arg2","arg3","arg4","arg5","arg6","arg7","arg8","arg9"}},
{ "hidden", "echojson", &echo, true, {"arg0","arg1","arg2","arg3","arg4","arg5","arg6","arg7","arg8","arg9"}}, { "hidden", "echojson", &echo, {"arg0","arg1","arg2","arg3","arg4","arg5","arg6","arg7","arg8","arg9"}},
{ "hidden", "logging", &logging, true, {"include", "exclude"}}, { "hidden", "logging", &logging, {"include", "exclude"}},
}; };
void RegisterMiscRPCCommands(CRPCTable &t) void RegisterMiscRPCCommands(CRPCTable &t)

View File

@ -633,20 +633,20 @@ UniValue setnetworkactive(const JSONRPCRequest& request)
} }
static const CRPCCommand commands[] = static const CRPCCommand commands[] =
{ // category name actor (function) okSafeMode { // category name actor (function) argNames
// --------------------- ------------------------ ----------------------- ---------- // --------------------- ------------------------ ----------------------- ----------
{ "network", "getconnectioncount", &getconnectioncount, true, {} }, { "network", "getconnectioncount", &getconnectioncount, {} },
{ "network", "ping", &ping, true, {} }, { "network", "ping", &ping, {} },
{ "network", "getpeerinfo", &getpeerinfo, true, {} }, { "network", "getpeerinfo", &getpeerinfo, {} },
{ "network", "addnode", &addnode, true, {"node","command"} }, { "network", "addnode", &addnode, {"node","command"} },
{ "network", "disconnectnode", &disconnectnode, true, {"address", "nodeid"} }, { "network", "disconnectnode", &disconnectnode, {"address", "nodeid"} },
{ "network", "getaddednodeinfo", &getaddednodeinfo, true, {"node"} }, { "network", "getaddednodeinfo", &getaddednodeinfo, {"node"} },
{ "network", "getnettotals", &getnettotals, true, {} }, { "network", "getnettotals", &getnettotals, {} },
{ "network", "getnetworkinfo", &getnetworkinfo, true, {} }, { "network", "getnetworkinfo", &getnetworkinfo, {} },
{ "network", "setban", &setban, true, {"subnet", "command", "bantime", "absolute"} }, { "network", "setban", &setban, {"subnet", "command", "bantime", "absolute"} },
{ "network", "listbanned", &listbanned, true, {} }, { "network", "listbanned", &listbanned, {} },
{ "network", "clearbanned", &clearbanned, true, {} }, { "network", "clearbanned", &clearbanned, {} },
{ "network", "setnetworkactive", &setnetworkactive, true, {"state"} }, { "network", "setnetworkactive", &setnetworkactive, {"state"} },
}; };
void RegisterNetRPCCommands(CRPCTable &t) void RegisterNetRPCCommands(CRPCTable &t)

View File

@ -8,6 +8,7 @@
#endif // ENABLE_WALLET #endif // ENABLE_WALLET
#include "privatesend/privatesend-server.h" #include "privatesend/privatesend-server.h"
#include "rpc/server.h" #include "rpc/server.h"
#include "rpc/safemode.h"
#include <univalue.h> #include <univalue.h>
@ -29,6 +30,8 @@ UniValue privatesend(const JSONRPCRequest& request)
" reset - Reset mixing\n" " reset - Reset mixing\n"
); );
ObserveSafeMode();
if (fMasternodeMode) if (fMasternodeMode)
throw JSONRPCError(RPC_INTERNAL_ERROR, "Client-side mixing is not supported on masternodes"); throw JSONRPCError(RPC_INTERNAL_ERROR, "Client-side mixing is not supported on masternodes");
@ -149,12 +152,12 @@ UniValue getprivatesendinfo(const JSONRPCRequest& request)
} }
static const CRPCCommand commands[] = static const CRPCCommand commands[] =
{ // category name actor (function) okSafe argNames { // category name actor (function) argNames
// --------------------- ------------------------ ----------------------- ------ ---------- // --------------------- ------------------------ ---------------------------------
{ "dash", "getpoolinfo", &getpoolinfo, true, {} }, { "dash", "getpoolinfo", &getpoolinfo, {} },
{ "dash", "getprivatesendinfo", &getprivatesendinfo, true, {} }, { "dash", "getprivatesendinfo", &getprivatesendinfo, {} },
#ifdef ENABLE_WALLET #ifdef ENABLE_WALLET
{ "dash", "privatesend", &privatesend, false, {} }, { "dash", "privatesend", &privatesend, {} },
#endif // ENABLE_WALLET #endif // ENABLE_WALLET
}; };

View File

@ -16,6 +16,7 @@
#include "net.h" #include "net.h"
#include "policy/policy.h" #include "policy/policy.h"
#include "primitives/transaction.h" #include "primitives/transaction.h"
#include "rpc/safemode.h"
#include "rpc/server.h" #include "rpc/server.h"
#include "script/script.h" #include "script/script.h"
#include "script/script_error.h" #include "script/script_error.h"
@ -737,6 +738,7 @@ UniValue signrawtransaction(const JSONRPCRequest& request)
+ HelpExampleRpc("signrawtransaction", "\"myhex\"") + HelpExampleRpc("signrawtransaction", "\"myhex\"")
); );
ObserveSafeMode();
#ifdef ENABLE_WALLET #ifdef ENABLE_WALLET
LOCK2(cs_main, pwallet ? &pwallet->cs_wallet : nullptr); LOCK2(cs_main, pwallet ? &pwallet->cs_wallet : nullptr);
#else #else
@ -944,6 +946,7 @@ UniValue sendrawtransaction(const JSONRPCRequest& request)
+ HelpExampleRpc("sendrawtransaction", "\"signedhex\"") + HelpExampleRpc("sendrawtransaction", "\"signedhex\"")
); );
ObserveSafeMode();
LOCK(cs_main); LOCK(cs_main);
RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VBOOL, UniValue::VBOOL}); RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VBOOL, UniValue::VBOOL});
@ -995,18 +998,18 @@ UniValue sendrawtransaction(const JSONRPCRequest& request)
} }
static const CRPCCommand commands[] = static const CRPCCommand commands[] =
{ // category name actor (function) okSafeMode { // category name actor (function) argNames
// --------------------- ------------------------ ----------------------- ---------- // --------------------- ------------------------ ----------------------- ----------
{ "rawtransactions", "getrawtransaction", &getrawtransaction, true, {"txid","verbose"} }, { "rawtransactions", "getrawtransaction", &getrawtransaction, {"txid","verbose"} },
{ "rawtransactions", "createrawtransaction", &createrawtransaction, true, {"inputs","outputs","locktime"} }, { "rawtransactions", "createrawtransaction", &createrawtransaction, {"inputs","outputs","locktime"} },
{ "rawtransactions", "decoderawtransaction", &decoderawtransaction, true, {"hexstring"} }, { "rawtransactions", "decoderawtransaction", &decoderawtransaction, {"hexstring"} },
{ "rawtransactions", "decodescript", &decodescript, true, {"hexstring"} }, { "rawtransactions", "decodescript", &decodescript, {"hexstring"} },
{ "rawtransactions", "sendrawtransaction", &sendrawtransaction, false, {"hexstring","allowhighfees","instantsend","bypasslimits"} }, { "rawtransactions", "sendrawtransaction", &sendrawtransaction, {"hexstring","allowhighfees","instantsend","bypasslimits"} },
{ "rawtransactions", "combinerawtransaction", &combinerawtransaction, true, {"txs"} }, { "rawtransactions", "combinerawtransaction", &combinerawtransaction, {"txs"} },
{ "rawtransactions", "signrawtransaction", &signrawtransaction, false, {"hexstring","prevtxs","privkeys","sighashtype"} }, /* uses wallet if enabled */ { "rawtransactions", "signrawtransaction", &signrawtransaction, {"hexstring","prevtxs","privkeys","sighashtype"} }, /* uses wallet if enabled */
{ "blockchain", "gettxoutproof", &gettxoutproof, true, {"txids", "blockhash"} }, { "blockchain", "gettxoutproof", &gettxoutproof, {"txids", "blockhash"} },
{ "blockchain", "verifytxoutproof", &verifytxoutproof, true, {"proof"} }, { "blockchain", "verifytxoutproof", &verifytxoutproof, {"proof"} },
}; };
void RegisterRawTransactionRPCCommands(CRPCTable &t) void RegisterRawTransactionRPCCommands(CRPCTable &t)

View File

@ -7,6 +7,7 @@
#include "core_io.h" #include "core_io.h"
#include "init.h" #include "init.h"
#include "messagesigner.h" #include "messagesigner.h"
#include "rpc/safemode.h"
#include "rpc/server.h" #include "rpc/server.h"
#include "utilmoneystr.h" #include "utilmoneystr.h"
#include "validation.h" #include "validation.h"
@ -417,6 +418,8 @@ UniValue protx_register(const JSONRPCRequest& request)
protx_register_prepare_help(); protx_register_prepare_help();
} }
ObserveSafeMode();
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) if (!EnsureWalletIsAvailable(pwallet, request.fHelp))
return NullUniValue; return NullUniValue;
@ -564,6 +567,8 @@ UniValue protx_register_submit(const JSONRPCRequest& request)
protx_register_submit_help(pwallet); protx_register_submit_help(pwallet);
} }
ObserveSafeMode();
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) if (!EnsureWalletIsAvailable(pwallet, request.fHelp))
return NullUniValue; return NullUniValue;
@ -617,6 +622,8 @@ UniValue protx_update_service(const JSONRPCRequest& request)
if (request.fHelp || (request.params.size() < 4 || request.params.size() > 6)) if (request.fHelp || (request.params.size() < 4 || request.params.size() > 6))
protx_update_service_help(pwallet); protx_update_service_help(pwallet);
ObserveSafeMode();
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) if (!EnsureWalletIsAvailable(pwallet, request.fHelp))
return NullUniValue; return NullUniValue;
@ -714,6 +721,8 @@ UniValue protx_update_registrar(const JSONRPCRequest& request)
protx_update_registrar_help(pwallet); protx_update_registrar_help(pwallet);
} }
ObserveSafeMode();
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) if (!EnsureWalletIsAvailable(pwallet, request.fHelp))
return NullUniValue; return NullUniValue;
@ -804,6 +813,8 @@ UniValue protx_revoke(const JSONRPCRequest& request)
protx_revoke_help(pwallet); protx_revoke_help(pwallet);
} }
ObserveSafeMode();
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) if (!EnsureWalletIsAvailable(pwallet, request.fHelp))
return NullUniValue; return NullUniValue;
@ -1271,10 +1282,10 @@ UniValue _bls(const JSONRPCRequest& request)
} }
static const CRPCCommand commands[] = static const CRPCCommand commands[] =
{ // category name actor (function) okSafeMode { // category name actor (function)
// --------------------- ------------------------ ----------------------- ---------- // --------------------- ------------------------ -----------------------
{ "evo", "bls", &_bls, false, {} }, { "evo", "bls", &_bls, {} },
{ "evo", "protx", &protx, false, {} }, { "evo", "protx", &protx, {} },
}; };
void RegisterEvoRPCCommands(CRPCTable &tableRPC) void RegisterEvoRPCCommands(CRPCTable &tableRPC)

View File

@ -429,9 +429,9 @@ UniValue quorum(const JSONRPCRequest& request)
} }
static const CRPCCommand commands[] = static const CRPCCommand commands[] =
{ // category name actor (function) okSafeMode { // category name actor (function)
// --------------------- ------------------------ ----------------------- ---------- // --------------------- ------------------------ -----------------------
{ "evo", "quorum", &quorum, false, {} }, { "evo", "quorum", &quorum, {} },
}; };
void RegisterQuorumsRPCCommands(CRPCTable &tableRPC) void RegisterQuorumsRPCCommands(CRPCTable &tableRPC)

14
src/rpc/safemode.cpp Normal file
View File

@ -0,0 +1,14 @@
#include "safemode.h"
#include "rpc/protocol.h"
#include "util.h"
#include "warnings.h"
void ObserveSafeMode()
{
std::string warning = GetWarnings("rpc");
if (warning != "" && !gArgs.GetBoolArg("-disablesafemode", DEFAULT_DISABLE_SAFEMODE)) {
throw JSONRPCError(RPC_FORBIDDEN_BY_SAFE_MODE, std::string("Safe mode: ") + warning);
}
}

12
src/rpc/safemode.h Normal file
View File

@ -0,0 +1,12 @@
// Copyright (c) 2017 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_RPC_SAFEMODE_H
#define BITCOIN_RPC_SAFEMODE_H
static const bool DEFAULT_DISABLE_SAFEMODE = true;
void ObserveSafeMode();
#endif // BITCOIN_RPC_SAFEMODE_H

View File

@ -53,11 +53,6 @@ void RPCServer::OnStopped(std::function<void ()> slot)
g_rpcSignals.Stopped.connect(slot); g_rpcSignals.Stopped.connect(slot);
} }
void RPCServer::OnPreCommand(std::function<void (const CRPCCommand&)> slot)
{
g_rpcSignals.PreCommand.connect(boost::bind(slot, _1));
}
void RPCTypeCheck(const UniValue& params, void RPCTypeCheck(const UniValue& params,
const std::list<UniValue::VType>& typesExpected, const std::list<UniValue::VType>& typesExpected,
bool fAllowNull) bool fAllowNull)
@ -329,12 +324,12 @@ UniValue uptime(const JSONRPCRequest& jsonRequest)
* Call Table * Call Table
*/ */
static const CRPCCommand vRPCCommands[] = static const CRPCCommand vRPCCommands[] =
{ // category name actor (function) okSafe argNames { // category name actor (function) argNames
// --------------------- ------------------------ ----------------------- ------ ---------- // --------------------- ------------------------ ----------------------- ----------
/* Overall control/query calls */ /* Overall control/query calls */
{ "control", "help", &help, true, {"command"} }, { "control", "help", &help, {"command"} },
{ "control", "stop", &stop, true, {"wait"} }, { "control", "stop", &stop, {"wait"} },
{ "control", "uptime", &uptime, true, {} }, { "control", "uptime", &uptime, {} },
}; };
CRPCTable::CRPCTable() CRPCTable::CRPCTable()

View File

@ -23,7 +23,6 @@ namespace RPCServer
{ {
void OnStarted(std::function<void ()> slot); void OnStarted(std::function<void ()> slot);
void OnStopped(std::function<void ()> slot); void OnStopped(std::function<void ()> slot);
void OnPreCommand(std::function<void (const CRPCCommand&)> slot);
} }
/** Wrapper for UniValue::VType, which includes typeAny: /** Wrapper for UniValue::VType, which includes typeAny:
@ -132,7 +131,6 @@ public:
std::string category; std::string category;
std::string name; std::string name;
rpcfn_type actor; rpcfn_type actor;
bool okSafeMode;
std::vector<std::string> argNames; std::vector<std::string> argNames;
}; };

View File

@ -5,6 +5,7 @@
#include "base58.h" #include "base58.h"
#include "chain.h" #include "chain.h"
#include "rpc/safemode.h"
#include "rpc/server.h" #include "rpc/server.h"
#include "init.h" #include "init.h"
#include "validation.h" #include "validation.h"
@ -175,6 +176,7 @@ UniValue abortrescan(const JSONRPCRequest& request)
+ HelpExampleRpc("abortrescan", "") + HelpExampleRpc("abortrescan", "")
); );
ObserveSafeMode();
if (!pwallet->IsScanning() || pwallet->IsAbortingRescan()) return false; if (!pwallet->IsScanning() || pwallet->IsAbortingRescan()) return false;
pwallet->AbortRescan(); pwallet->AbortRescan();
return true; return true;

View File

@ -17,6 +17,7 @@
#include "policy/fees.h" #include "policy/fees.h"
#include "privatesend/privatesend-client.h" #include "privatesend/privatesend-client.h"
#include "rpc/mining.h" #include "rpc/mining.h"
#include "rpc/safemode.h"
#include "rpc/server.h" #include "rpc/server.h"
#include "timedata.h" #include "timedata.h"
#include "util.h" #include "util.h"
@ -450,6 +451,7 @@ UniValue sendtoaddress(const JSONRPCRequest& request)
+ HelpExampleRpc("sendtoaddress", "\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwG\", 0.1, \"donation\", \"seans outpost\"") + HelpExampleRpc("sendtoaddress", "\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwG\", 0.1, \"donation\", \"seans outpost\"")
); );
ObserveSafeMode();
LOCK2(cs_main, pwallet->cs_wallet); LOCK2(cs_main, pwallet->cs_wallet);
CBitcoinAddress address(request.params[0].get_str()); CBitcoinAddress address(request.params[0].get_str());
@ -536,6 +538,7 @@ UniValue listaddressgroupings(const JSONRPCRequest& request)
+ HelpExampleRpc("listaddressgroupings", "") + HelpExampleRpc("listaddressgroupings", "")
); );
ObserveSafeMode();
LOCK2(cs_main, pwallet->cs_wallet); LOCK2(cs_main, pwallet->cs_wallet);
UniValue jsonGroupings(UniValue::VARR); UniValue jsonGroupings(UniValue::VARR);
@ -688,6 +691,7 @@ UniValue getreceivedbyaddress(const JSONRPCRequest& request)
+ HelpExampleRpc("getreceivedbyaddress", "\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwG\", 6") + HelpExampleRpc("getreceivedbyaddress", "\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwG\", 6")
); );
ObserveSafeMode();
LOCK2(cs_main, pwallet->cs_wallet); LOCK2(cs_main, pwallet->cs_wallet);
// Dash address // Dash address
@ -750,6 +754,7 @@ UniValue getreceivedbyaccount(const JSONRPCRequest& request)
+ HelpExampleRpc("getreceivedbyaccount", "\"tabby\", 6") + HelpExampleRpc("getreceivedbyaccount", "\"tabby\", 6")
); );
ObserveSafeMode();
LOCK2(cs_main, pwallet->cs_wallet); LOCK2(cs_main, pwallet->cs_wallet);
// Minimum confirmations // Minimum confirmations
@ -813,6 +818,7 @@ UniValue getbalance(const JSONRPCRequest& request)
+ HelpExampleRpc("getbalance", "\"*\", 6") + HelpExampleRpc("getbalance", "\"*\", 6")
); );
ObserveSafeMode();
LOCK2(cs_main, pwallet->cs_wallet); LOCK2(cs_main, pwallet->cs_wallet);
const UniValue& account_value = request.params[0]; const UniValue& account_value = request.params[0];
@ -861,6 +867,7 @@ UniValue getunconfirmedbalance(const JSONRPCRequest &request)
"getunconfirmedbalance\n" "getunconfirmedbalance\n"
"Returns the server's total unconfirmed balance\n"); "Returns the server's total unconfirmed balance\n");
ObserveSafeMode();
LOCK2(cs_main, pwallet->cs_wallet); LOCK2(cs_main, pwallet->cs_wallet);
return ValueFromAmount(pwallet->GetUnconfirmedBalance()); return ValueFromAmount(pwallet->GetUnconfirmedBalance());
@ -895,6 +902,7 @@ UniValue movecmd(const JSONRPCRequest& request)
+ HelpExampleRpc("move", "\"timotei\", \"akiko\", 0.01, 6, \"happy birthday!\"") + HelpExampleRpc("move", "\"timotei\", \"akiko\", 0.01, 6, \"happy birthday!\"")
); );
ObserveSafeMode();
LOCK2(cs_main, pwallet->cs_wallet); LOCK2(cs_main, pwallet->cs_wallet);
std::string strFrom = AccountFromValue(request.params[0]); std::string strFrom = AccountFromValue(request.params[0]);
@ -954,6 +962,7 @@ UniValue sendfrom(const JSONRPCRequest& request)
+ HelpExampleRpc("sendfrom", "\"tabby\", \"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwG\", 0.01, 6, false, \"donation\", \"seans outpost\"") + HelpExampleRpc("sendfrom", "\"tabby\", \"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwG\", 0.01, 6, false, \"donation\", \"seans outpost\"")
); );
ObserveSafeMode();
LOCK2(cs_main, pwallet->cs_wallet); LOCK2(cs_main, pwallet->cs_wallet);
std::string strAccount = AccountFromValue(request.params[0]); std::string strAccount = AccountFromValue(request.params[0]);
@ -1038,6 +1047,7 @@ UniValue sendmany(const JSONRPCRequest& request)
+ HelpExampleRpc("sendmany", "\"tabby\", \"{\\\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwG\\\":0.01,\\\"XuQQkwA4FYkq2XERzMY2CiAZhJTEDAbtcG\\\":0.02}\", 6, false, \"testing\"") + HelpExampleRpc("sendmany", "\"tabby\", \"{\\\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwG\\\":0.01,\\\"XuQQkwA4FYkq2XERzMY2CiAZhJTEDAbtcG\\\":0.02}\", 6, false, \"testing\"")
); );
ObserveSafeMode();
LOCK2(cs_main, pwallet->cs_wallet); LOCK2(cs_main, pwallet->cs_wallet);
if (pwallet->GetBroadcastTransactions() && !g_connman) { if (pwallet->GetBroadcastTransactions() && !g_connman) {
@ -1371,6 +1381,7 @@ UniValue listreceivedbyaddress(const JSONRPCRequest& request)
+ HelpExampleRpc("listreceivedbyaddress", "6, false, true, true") + HelpExampleRpc("listreceivedbyaddress", "6, false, true, true")
); );
ObserveSafeMode();
LOCK2(cs_main, pwallet->cs_wallet); LOCK2(cs_main, pwallet->cs_wallet);
return ListReceived(pwallet, request.params, false); return ListReceived(pwallet, request.params, false);
@ -1411,6 +1422,7 @@ UniValue listreceivedbyaccount(const JSONRPCRequest& request)
+ HelpExampleRpc("listreceivedbyaccount", "6, false, true, true") + HelpExampleRpc("listreceivedbyaccount", "6, false, true, true")
); );
ObserveSafeMode();
LOCK2(cs_main, pwallet->cs_wallet); LOCK2(cs_main, pwallet->cs_wallet);
return ListReceived(pwallet, request.params, true); return ListReceived(pwallet, request.params, true);
@ -1600,6 +1612,7 @@ UniValue listtransactions(const JSONRPCRequest& request)
+ HelpExampleRpc("listtransactions", "\"*\", 20, 100") + HelpExampleRpc("listtransactions", "\"*\", 20, 100")
); );
ObserveSafeMode();
LOCK2(cs_main, pwallet->cs_wallet); LOCK2(cs_main, pwallet->cs_wallet);
std::string strAccount = "*"; std::string strAccount = "*";
@ -1694,6 +1707,7 @@ UniValue listaccounts(const JSONRPCRequest& request)
+ HelpExampleRpc("listaccounts", "6") + HelpExampleRpc("listaccounts", "6")
); );
ObserveSafeMode();
LOCK2(cs_main, pwallet->cs_wallet); LOCK2(cs_main, pwallet->cs_wallet);
int nMinDepth = 1; int nMinDepth = 1;
@ -1806,6 +1820,7 @@ UniValue listsinceblock(const JSONRPCRequest& request)
+ HelpExampleRpc("listsinceblock", "\"000000000000000bacf66f7497b7dc45ef753ee9a7d38571037cdb1a57f663ad\", 6") + HelpExampleRpc("listsinceblock", "\"000000000000000bacf66f7497b7dc45ef753ee9a7d38571037cdb1a57f663ad\", 6")
); );
ObserveSafeMode();
LOCK2(cs_main, pwallet->cs_wallet); LOCK2(cs_main, pwallet->cs_wallet);
const CBlockIndex* pindex = nullptr; // Block index of the specified block or the common ancestor, if the block provided was in a deactivated chain. const CBlockIndex* pindex = nullptr; // Block index of the specified block or the common ancestor, if the block provided was in a deactivated chain.
@ -1938,6 +1953,7 @@ UniValue gettransaction(const JSONRPCRequest& request)
+ HelpExampleRpc("gettransaction", "\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\"") + HelpExampleRpc("gettransaction", "\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\"")
); );
ObserveSafeMode();
LOCK2(cs_main, pwallet->cs_wallet); LOCK2(cs_main, pwallet->cs_wallet);
uint256 hash; uint256 hash;
@ -1998,6 +2014,7 @@ UniValue abandontransaction(const JSONRPCRequest& request)
+ HelpExampleRpc("abandontransaction", "\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\"") + HelpExampleRpc("abandontransaction", "\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\"")
); );
ObserveSafeMode();
LOCK2(cs_main, pwallet->cs_wallet); LOCK2(cs_main, pwallet->cs_wallet);
uint256 hash; uint256 hash;
@ -2436,6 +2453,7 @@ UniValue listlockunspent(const JSONRPCRequest& request)
+ HelpExampleRpc("listlockunspent", "") + HelpExampleRpc("listlockunspent", "")
); );
ObserveSafeMode();
LOCK2(cs_main, pwallet->cs_wallet); LOCK2(cs_main, pwallet->cs_wallet);
std::vector<COutPoint> vOutpts; std::vector<COutPoint> vOutpts;
@ -2581,6 +2599,7 @@ UniValue getwalletinfo(const JSONRPCRequest& request)
+ HelpExampleRpc("getwalletinfo", "") + HelpExampleRpc("getwalletinfo", "")
); );
ObserveSafeMode();
LOCK2(cs_main, pwallet->cs_wallet); LOCK2(cs_main, pwallet->cs_wallet);
CHDChain hdChainCurrent; CHDChain hdChainCurrent;
@ -2806,6 +2825,8 @@ UniValue listunspent(const JSONRPCRequest& request)
+ HelpExampleRpc("listunspent", "6, 9999999, [] , true, { \"minimumAmount\": 0.005 } ") + HelpExampleRpc("listunspent", "6, 9999999, [] , true, { \"minimumAmount\": 0.005 } ")
); );
ObserveSafeMode();
int nMinDepth = 1; int nMinDepth = 1;
if (!request.params[0].isNull()) { if (!request.params[0].isNull()) {
RPCTypeCheckArgument(request.params[0], UniValue::VNUM); RPCTypeCheckArgument(request.params[0], UniValue::VNUM);
@ -2966,6 +2987,7 @@ UniValue fundrawtransaction(const JSONRPCRequest& request)
+ HelpExampleCli("sendrawtransaction", "\"signedtransactionhex\"") + HelpExampleCli("sendrawtransaction", "\"signedtransactionhex\"")
); );
ObserveSafeMode();
RPCTypeCheck(request.params, {UniValue::VSTR}); RPCTypeCheck(request.params, {UniValue::VSTR});
CCoinControl coinControl; CCoinControl coinControl;
@ -3140,67 +3162,67 @@ extern UniValue dumphdinfo(const JSONRPCRequest& request);
extern UniValue importelectrumwallet(const JSONRPCRequest& request); extern UniValue importelectrumwallet(const JSONRPCRequest& request);
static const CRPCCommand commands[] = static const CRPCCommand commands[] =
{ // category name actor (function) okSafeMode { // category name actor (function) argNames
// --------------------- ------------------------ ----------------------- ---------- // --------------------- ------------------------ ----------------------- ----------
{ "rawtransactions", "fundrawtransaction", &fundrawtransaction, false, {"hexstring","options"} }, { "rawtransactions", "fundrawtransaction", &fundrawtransaction, {"hexstring","options"} },
{ "hidden", "resendwallettransactions", &resendwallettransactions, true, {} }, { "hidden", "resendwallettransactions", &resendwallettransactions, {} },
{ "wallet", "abandontransaction", &abandontransaction, false, {"txid"} }, { "wallet", "abandontransaction", &abandontransaction, {"txid"} },
{ "wallet", "abortrescan", &abortrescan, false, {} }, { "wallet", "abortrescan", &abortrescan, {} },
{ "wallet", "addmultisigaddress", &addmultisigaddress, true, {"nrequired","keys","account"} }, { "wallet", "addmultisigaddress", &addmultisigaddress, {"nrequired","keys","account"} },
{ "wallet", "backupwallet", &backupwallet, true, {"destination"} }, { "wallet", "backupwallet", &backupwallet, {"destination"} },
{ "wallet", "dumpprivkey", &dumpprivkey, true, {"address"} }, { "wallet", "dumpprivkey", &dumpprivkey, {"address"} },
{ "wallet", "dumpwallet", &dumpwallet, true, {"filename"} }, { "wallet", "dumpwallet", &dumpwallet, {"filename"} },
{ "wallet", "encryptwallet", &encryptwallet, true, {"passphrase"} }, { "wallet", "encryptwallet", &encryptwallet, {"passphrase"} },
{ "wallet", "getaccountaddress", &getaccountaddress, true, {"account"} }, { "wallet", "getaccountaddress", &getaccountaddress, {"account"} },
{ "wallet", "getaccount", &getaccount, true, {"address"} }, { "wallet", "getaccount", &getaccount, {"address"} },
{ "wallet", "getaddressesbyaccount", &getaddressesbyaccount, true, {"account"} }, { "wallet", "getaddressesbyaccount", &getaddressesbyaccount, {"account"} },
{ "wallet", "getbalance", &getbalance, false, {"account","minconf","addlocked","include_watchonly"} }, { "wallet", "getbalance", &getbalance, {"account","minconf","addlocked","include_watchonly"} },
{ "wallet", "getnewaddress", &getnewaddress, true, {"account"} }, { "wallet", "getnewaddress", &getnewaddress, {"account"} },
{ "wallet", "getrawchangeaddress", &getrawchangeaddress, true, {} }, { "wallet", "getrawchangeaddress", &getrawchangeaddress, {} },
{ "wallet", "getreceivedbyaccount", &getreceivedbyaccount, false, {"account","minconf","addlocked"} }, { "wallet", "getreceivedbyaccount", &getreceivedbyaccount, {"account","minconf","addlocked"} },
{ "wallet", "getreceivedbyaddress", &getreceivedbyaddress, false, {"address","minconf","addlocked"} }, { "wallet", "getreceivedbyaddress", &getreceivedbyaddress, {"address","minconf","addlocked"} },
{ "wallet", "gettransaction", &gettransaction, false, {"txid","include_watchonly"} }, { "wallet", "gettransaction", &gettransaction, {"txid","include_watchonly"} },
{ "wallet", "getunconfirmedbalance", &getunconfirmedbalance, false, {} }, { "wallet", "getunconfirmedbalance", &getunconfirmedbalance, {} },
{ "wallet", "getwalletinfo", &getwalletinfo, false, {} }, { "wallet", "getwalletinfo", &getwalletinfo, {} },
{ "wallet", "importmulti", &importmulti, true, {"requests","options"} }, { "wallet", "importmulti", &importmulti, {"requests","options"} },
{ "wallet", "importprivkey", &importprivkey, true, {"privkey","label","rescan"} }, { "wallet", "importprivkey", &importprivkey, {"privkey","label","rescan"} },
{ "wallet", "importwallet", &importwallet, true, {"filename"} }, { "wallet", "importwallet", &importwallet, {"filename"} },
{ "wallet", "importaddress", &importaddress, true, {"address","label","rescan","p2sh"} }, { "wallet", "importaddress", &importaddress, {"address","label","rescan","p2sh"} },
{ "wallet", "importprunedfunds", &importprunedfunds, true, {"rawtransaction","txoutproof"} }, { "wallet", "importprunedfunds", &importprunedfunds, {"rawtransaction","txoutproof"} },
{ "wallet", "importpubkey", &importpubkey, true, {"pubkey","label","rescan"} }, { "wallet", "importpubkey", &importpubkey, {"pubkey","label","rescan"} },
{ "wallet", "keypoolrefill", &keypoolrefill, true, {"newsize"} }, { "wallet", "keypoolrefill", &keypoolrefill, {"newsize"} },
{ "wallet", "listaccounts", &listaccounts, false, {"minconf","addlocked","include_watchonly"} }, { "wallet", "listaccounts", &listaccounts, {"minconf","addlocked","include_watchonly"} },
{ "wallet", "listaddressgroupings", &listaddressgroupings, false, {} }, { "wallet", "listaddressgroupings", &listaddressgroupings, {} },
{ "wallet", "listaddressbalances", &listaddressbalances, false, {"minamount"} }, { "wallet", "listaddressbalances", &listaddressbalances, {"minamount"} },
{ "wallet", "listlockunspent", &listlockunspent, false, {} }, { "wallet", "listlockunspent", &listlockunspent, {} },
{ "wallet", "listreceivedbyaccount", &listreceivedbyaccount, false, {"minconf","addlocked","include_empty","include_watchonly"} }, { "wallet", "listreceivedbyaccount", &listreceivedbyaccount, {"minconf","addlocked","include_empty","include_watchonly"} },
{ "wallet", "listreceivedbyaddress", &listreceivedbyaddress, false, {"minconf","addlocked","include_empty","include_watchonly"} }, { "wallet", "listreceivedbyaddress", &listreceivedbyaddress, {"minconf","addlocked","include_empty","include_watchonly"} },
{ "wallet", "listsinceblock", &listsinceblock, false, {"blockhash","target_confirmations","include_watchonly","include_removed"} }, { "wallet", "listsinceblock", &listsinceblock, {"blockhash","target_confirmations","include_watchonly","include_removed"} },
{ "wallet", "listtransactions", &listtransactions, false, {"account","count","skip","include_watchonly"} }, { "wallet", "listtransactions", &listtransactions, {"account","count","skip","include_watchonly"} },
{ "wallet", "listunspent", &listunspent, false, {"minconf","maxconf","addresses","include_unsafe","query_options"} }, { "wallet", "listunspent", &listunspent, {"minconf","maxconf","addresses","include_unsafe","query_options"} },
{ "wallet", "listwallets", &listwallets, true, {} }, { "wallet", "listwallets", &listwallets, {} },
{ "wallet", "lockunspent", &lockunspent, true, {"unlock","transactions"} }, { "wallet", "lockunspent", &lockunspent, {"unlock","transactions"} },
{ "wallet", "move", &movecmd, false, {"fromaccount","toaccount","amount","minconf","comment"} }, { "wallet", "move", &movecmd, {"fromaccount","toaccount","amount","minconf","comment"} },
{ "wallet", "sendfrom", &sendfrom, false, {"fromaccount","toaddress","amount","minconf","addlocked","comment","comment_to"} }, { "wallet", "sendfrom", &sendfrom, {"fromaccount","toaddress","amount","minconf","addlocked","comment","comment_to"} },
{ "wallet", "sendmany", &sendmany, false, {"fromaccount","amounts","minconf","addlocked","comment","subtractfeefrom","use_ps","conf_target","estimate_mode"} }, { "wallet", "sendmany", &sendmany, {"fromaccount","amounts","minconf","addlocked","comment","subtractfeefrom","use_ps","conf_target","estimate_mode"} },
{ "wallet", "sendtoaddress", &sendtoaddress, false, {"address","amount","comment","comment_to","subtractfeefromamount","use_ps","conf_target","estimate_mode"} }, { "wallet", "sendtoaddress", &sendtoaddress, {"address","amount","comment","comment_to","subtractfeefromamount","use_ps","conf_target","estimate_mode"} },
{ "wallet", "setaccount", &setaccount, true, {"address","account"} }, { "wallet", "setaccount", &setaccount, {"address","account"} },
{ "wallet", "settxfee", &settxfee, true, {"amount"} }, { "wallet", "settxfee", &settxfee, {"amount"} },
{ "wallet", "setprivatesendrounds", &setprivatesendrounds, true, {"rounds"} }, { "wallet", "setprivatesendrounds", &setprivatesendrounds, {"rounds"} },
{ "wallet", "setprivatesendamount", &setprivatesendamount, true, {"amount"} }, { "wallet", "setprivatesendamount", &setprivatesendamount, {"amount"} },
{ "wallet", "signmessage", &signmessage, true, {"address","message"} }, { "wallet", "signmessage", &signmessage, {"address","message"} },
{ "wallet", "walletlock", &walletlock, true, {} }, { "wallet", "walletlock", &walletlock, {} },
{ "wallet", "walletpassphrasechange", &walletpassphrasechange, true, {"oldpassphrase","newpassphrase"} }, { "wallet", "walletpassphrasechange", &walletpassphrasechange, {"oldpassphrase","newpassphrase"} },
{ "wallet", "walletpassphrase", &walletpassphrase, true, {"passphrase","timeout","mixingonly"} }, { "wallet", "walletpassphrase", &walletpassphrase, {"passphrase","timeout","mixingonly"} },
{ "wallet", "removeprunedfunds", &removeprunedfunds, true, {"txid"} }, { "wallet", "removeprunedfunds", &removeprunedfunds, {"txid"} },
#if ENABLE_MINER #if ENABLE_MINER
{ "generating", "generate", &generate, true, {"nblocks","maxtries"} }, { "generating", "generate", &generate, {"nblocks","maxtries"} },
#endif //ENABLE_MINER #endif //ENABLE_MINER
{ "wallet", "keepass", &keepass, true, {} }, { "wallet", "keepass", &keepass, {} },
{ "hidden", "instantsendtoaddress", &instantsendtoaddress, false, {"address","amount","comment","comment_to","subtractfeefromamount"} }, { "hidden", "instantsendtoaddress", &instantsendtoaddress, {"address","amount","comment","comment_to","subtractfeefromamount"} },
{ "wallet", "dumphdinfo", &dumphdinfo, true, {} }, { "wallet", "dumphdinfo", &dumphdinfo, {} },
{ "wallet", "importelectrumwallet", &importelectrumwallet, true, {"filename", "index"} }, { "wallet", "importelectrumwallet", &importelectrumwallet, {"filename", "index"} },
}; };
void RegisterWalletRPCCommands(CRPCTable &t) void RegisterWalletRPCCommands(CRPCTable &t)