diff --git a/doc/release-notes.md b/doc/release-notes.md --- a/doc/release-notes.md +++ b/doc/release-notes.md @@ -7,4 +7,4 @@ - Upgrade reproducible build to us Qt 5.9.6 - Improve SHA256 performance using SSE4.1, AVX2 and/or SHA if available. - Add a mode argument to the `getmemoryinfo` RPC call to query `malloc_info` from the system if available. - + - Disable safe mode by default diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -209,6 +209,7 @@ rpc/misc.cpp rpc/net.cpp rpc/rawtransaction.cpp + rpc/safemode.cpp rpc/server.cpp script/scriptcache.cpp script/sigcache.cpp diff --git a/src/Makefile.am b/src/Makefile.am --- a/src/Makefile.am +++ b/src/Makefile.am @@ -165,6 +165,7 @@ rpc/mining.h \ rpc/misc.h \ rpc/protocol.h \ + rpc/safemode.h \ rpc/server.h \ rpc/tojson.h \ rpc/register.h \ @@ -252,6 +253,7 @@ rpc/misc.cpp \ rpc/net.cpp \ rpc/rawtransaction.cpp \ + rpc/safemode.cpp \ rpc/server.cpp \ script/scriptcache.cpp \ script/sigcache.cpp \ diff --git a/src/init.cpp b/src/init.cpp --- a/src/init.cpp +++ b/src/init.cpp @@ -28,6 +28,7 @@ #include "netbase.h" #include "policy/policy.h" #include "rpc/register.h" +#include "rpc/safemode.h" #include "rpc/server.h" #include "scheduler.h" #include "script/scriptcache.h" @@ -71,7 +72,6 @@ bool fFeeEstimatesInitialized = false; static const bool DEFAULT_PROXYRANDOMIZE = true; static const bool DEFAULT_REST_ENABLE = false; -static const bool DEFAULT_DISABLE_SAFEMODE = false; static const bool DEFAULT_STOPAFTERBLOCKIMPORT = false; std::unique_ptr g_connman; @@ -292,17 +292,6 @@ LogPrint(BCLog::RPC, "RPC stopped.\n"); } -void OnRPCPreCommand(const ContextFreeRPCCommand &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) { const auto defaultBaseParams = CreateBaseChainParams(CBaseChainParams::MAIN); @@ -1118,7 +1107,6 @@ boost::thread_group &threadGroup) { RPCServerSignals::OnStarted(&OnRPCStarted); RPCServerSignals::OnStopped(&OnRPCStopped); - RPCServerSignals::OnPreCommand(&OnRPCPreCommand); if (!InitHTTPServer(config)) { return false; } diff --git a/src/qt/test/rpcnestedtests.cpp b/src/qt/test/rpcnestedtests.cpp --- a/src/qt/test/rpcnestedtests.cpp +++ b/src/qt/test/rpcnestedtests.cpp @@ -28,7 +28,7 @@ } static const ContextFreeRPCCommand vRPCCommands[] = { - {"test", "rpcNestedTest", rpcNestedTest_rpc, true, {}}, + {"test", "rpcNestedTest", &rpcNestedTest_rpc, {}}, }; void RPCNestedTests::rpcNestedTests() { diff --git a/src/rpc/abc.cpp b/src/rpc/abc.cpp --- a/src/rpc/abc.cpp +++ b/src/rpc/abc.cpp @@ -78,10 +78,10 @@ // clang-format off static const ContextFreeRPCCommand commands[] = { - // category name actor (function) okSafeMode + // category name actor (function) argNames // ------------------- ------------------------ ---------------------- ---------- - { "network", "getexcessiveblock", getexcessiveblock, true, {}}, - { "network", "setexcessiveblock", setexcessiveblock, true, {"maxBlockSize"}}, + { "network", "getexcessiveblock", getexcessiveblock, {}}, + { "network", "setexcessiveblock", setexcessiveblock, {"maxBlockSize"}}, }; // clang-format on diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1664,34 +1664,34 @@ // clang-format off static const ContextFreeRPCCommand commands[] = { - // category name actor (function) okSafe argNames - // ------------------- ------------------------ ---------------------- ------ ---------- - { "blockchain", "getblockchaininfo", getblockchaininfo, true, {} }, - { "blockchain", "getchaintxstats", &getchaintxstats, true, {"nblocks", "blockhash"} }, - { "blockchain", "getbestblockhash", getbestblockhash, true, {} }, - { "blockchain", "getblockcount", getblockcount, true, {} }, - { "blockchain", "getblock", getblock, true, {"blockhash","verbose"} }, - { "blockchain", "getblockhash", getblockhash, true, {"height"} }, - { "blockchain", "getblockheader", getblockheader, true, {"blockhash","verbose"} }, - { "blockchain", "getchaintips", getchaintips, true, {} }, - { "blockchain", "getdifficulty", getdifficulty, true, {} }, - { "blockchain", "getmempoolancestors", getmempoolancestors, true, {"txid","verbose"} }, - { "blockchain", "getmempooldescendants", getmempooldescendants, true, {"txid","verbose"} }, - { "blockchain", "getmempoolentry", getmempoolentry, true, {"txid"} }, - { "blockchain", "getmempoolinfo", getmempoolinfo, true, {} }, - { "blockchain", "getrawmempool", getrawmempool, true, {"verbose"} }, - { "blockchain", "gettxout", gettxout, true, {"txid","n","include_mempool"} }, - { "blockchain", "gettxoutsetinfo", gettxoutsetinfo, true, {} }, - { "blockchain", "pruneblockchain", pruneblockchain, true, {"height"} }, - { "blockchain", "verifychain", verifychain, true, {"checklevel","nblocks"} }, - { "blockchain", "preciousblock", preciousblock, true, {"blockhash"} }, + // category name actor (function) argNames + // ------------------- ------------------------ ---------------------- ---------- + { "blockchain", "getblockchaininfo", getblockchaininfo, {} }, + { "blockchain", "getchaintxstats", &getchaintxstats, {"nblocks", "blockhash"} }, + { "blockchain", "getbestblockhash", getbestblockhash, {} }, + { "blockchain", "getblockcount", getblockcount, {} }, + { "blockchain", "getblock", getblock, {"blockhash","verbose"} }, + { "blockchain", "getblockhash", getblockhash, {"height"} }, + { "blockchain", "getblockheader", getblockheader, {"blockhash","verbose"} }, + { "blockchain", "getchaintips", getchaintips, {} }, + { "blockchain", "getdifficulty", getdifficulty, {} }, + { "blockchain", "getmempoolancestors", getmempoolancestors, {"txid","verbose"} }, + { "blockchain", "getmempooldescendants", getmempooldescendants, {"txid","verbose"} }, + { "blockchain", "getmempoolentry", getmempoolentry, {"txid"} }, + { "blockchain", "getmempoolinfo", getmempoolinfo, {} }, + { "blockchain", "getrawmempool", getrawmempool, {"verbose"} }, + { "blockchain", "gettxout", gettxout, {"txid","n","include_mempool"} }, + { "blockchain", "gettxoutsetinfo", gettxoutsetinfo, {} }, + { "blockchain", "pruneblockchain", pruneblockchain, {"height"} }, + { "blockchain", "verifychain", verifychain, {"checklevel","nblocks"} }, + { "blockchain", "preciousblock", preciousblock, {"blockhash"} }, /* Not shown in help */ - { "hidden", "invalidateblock", invalidateblock, true, {"blockhash"} }, - { "hidden", "reconsiderblock", reconsiderblock, true, {"blockhash"} }, - { "hidden", "waitfornewblock", waitfornewblock, true, {"timeout"} }, - { "hidden", "waitforblock", waitforblock, true, {"blockhash","timeout"} }, - { "hidden", "waitforblockheight", waitforblockheight, true, {"height","timeout"} }, + { "hidden", "invalidateblock", invalidateblock, {"blockhash"} }, + { "hidden", "reconsiderblock", reconsiderblock, {"blockhash"} }, + { "hidden", "waitfornewblock", waitfornewblock, {"timeout"} }, + { "hidden", "waitforblock", waitforblock, {"blockhash","timeout"} }, + { "hidden", "waitforblockheight", waitforblockheight, {"height","timeout"} }, }; // clang-format on diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -815,17 +815,17 @@ // clang-format off static const ContextFreeRPCCommand commands[] = { - // category name actor (function) okSafeMode + // category name actor (function) argNames // ---------- ------------------------ ---------------------- ---------- - {"mining", "getnetworkhashps", getnetworkhashps, true, {"nblocks", "height"}}, - {"mining", "getmininginfo", getmininginfo, true, {}}, - {"mining", "prioritisetransaction", prioritisetransaction, true, {"txid", "priority_delta", "fee_delta"}}, - {"mining", "getblocktemplate", getblocktemplate, true, {"template_request"}}, - {"mining", "submitblock", submitblock, true, {"hexdata", "parameters"}}, + {"mining", "getnetworkhashps", getnetworkhashps, {"nblocks", "height"}}, + {"mining", "getmininginfo", getmininginfo, {}}, + {"mining", "prioritisetransaction", prioritisetransaction, {"txid", "priority_delta", "fee_delta"}}, + {"mining", "getblocktemplate", getblocktemplate, {"template_request"}}, + {"mining", "submitblock", submitblock, {"hexdata", "parameters"}}, - {"generating", "generatetoaddress", generatetoaddress, true, {"nblocks", "address", "maxtries"}}, + {"generating", "generatetoaddress", generatetoaddress, {"nblocks", "address", "maxtries"}}, - {"util", "estimatefee", estimatefee, true, {"nblocks"}}, + {"util", "estimatefee", estimatefee, {"nblocks"}}, }; // clang-format on diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -675,18 +675,18 @@ // clang-format off static const ContextFreeRPCCommand commands[] = { - // category name actor (function) okSafeMode + // category name actor (function) argNames // ------------------- ------------------------ ---------------------- ---------- - { "control", "getinfo", getinfo, true, {} }, /* uses wallet if enabled */ - { "control", "getmemoryinfo", getmemoryinfo, true, {"mode"} }, - { "util", "validateaddress", validateaddress, true, {"address"} }, /* uses wallet if enabled */ - { "util", "createmultisig", createmultisig, true, {"nrequired","keys"} }, - { "util", "verifymessage", verifymessage, true, {"address","signature","message"} }, - { "util", "signmessagewithprivkey", signmessagewithprivkey, true, {"privkey","message"} }, + { "control", "getinfo", getinfo, {} }, /* uses wallet if enabled */ + { "control", "getmemoryinfo", getmemoryinfo, {"mode"} }, + { "util", "validateaddress", validateaddress, {"address"} }, /* uses wallet if enabled */ + { "util", "createmultisig", createmultisig, {"nrequired","keys"} }, + { "util", "verifymessage", verifymessage, {"address","signature","message"} }, + { "util", "signmessagewithprivkey", signmessagewithprivkey, {"privkey","message"} }, /* Not shown in help */ - { "hidden", "setmocktime", setmocktime, true, {"timestamp"}}, - { "hidden", "echo", echo, true, {"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", "setmocktime", setmocktime, {"timestamp"}}, + { "hidden", "echo", echo, {"arg0","arg1","arg2","arg3","arg4","arg5","arg6","arg7","arg8","arg9"}}, + { "hidden", "echojson", echo, {"arg0","arg1","arg2","arg3","arg4","arg5","arg6","arg7","arg8","arg9"}}, }; // clang-format on diff --git a/src/rpc/net.cpp b/src/rpc/net.cpp --- a/src/rpc/net.cpp +++ b/src/rpc/net.cpp @@ -778,20 +778,20 @@ // clang-format off static const ContextFreeRPCCommand commands[] = { - // category name actor (function) okSafeMode + // category name actor (function) argNames // ------------------- ------------------------ ---------------------- ---------- - { "network", "getconnectioncount", getconnectioncount, true, {} }, - { "network", "ping", ping, true, {} }, - { "network", "getpeerinfo", getpeerinfo, true, {} }, - { "network", "addnode", addnode, true, {"node","command"} }, - { "network", "disconnectnode", disconnectnode, true, {"address", "nodeid"} }, - { "network", "getaddednodeinfo", getaddednodeinfo, true, {"node"} }, - { "network", "getnettotals", getnettotals, true, {} }, - { "network", "getnetworkinfo", getnetworkinfo, true, {} }, - { "network", "setban", setban, true, {"subnet", "command", "bantime", "absolute"} }, - { "network", "listbanned", listbanned, true, {} }, - { "network", "clearbanned", clearbanned, true, {} }, - { "network", "setnetworkactive", setnetworkactive, true, {"state"} }, + { "network", "getconnectioncount", getconnectioncount, {} }, + { "network", "ping", ping, {} }, + { "network", "getpeerinfo", getpeerinfo, {} }, + { "network", "addnode", addnode, {"node","command"} }, + { "network", "disconnectnode", disconnectnode, {"address", "nodeid"} }, + { "network", "getaddednodeinfo", getaddednodeinfo, {"node"} }, + { "network", "getnettotals", getnettotals, {} }, + { "network", "getnetworkinfo", getnetworkinfo, {} }, + { "network", "setban", setban, {"subnet", "command", "bantime", "absolute"} }, + { "network", "listbanned", listbanned, {} }, + { "network", "clearbanned", clearbanned, {} }, + { "network", "setnetworkactive", setnetworkactive, {"state"} }, }; // clang-format on diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -16,6 +16,7 @@ #include "net.h" #include "policy/policy.h" #include "primitives/transaction.h" +#include "rpc/safemode.h" #include "rpc/server.h" #include "rpc/tojson.h" #include "script/script.h" @@ -822,6 +823,7 @@ HelpExampleRpc("signrawtransaction", "\"myhex\"")); } + ObserveSafeMode(); #ifdef ENABLE_WALLET LOCK2(cs_main, pwallet ? &pwallet->cs_wallet : nullptr); #else @@ -1117,6 +1119,7 @@ HelpExampleRpc("sendrawtransaction", "\"signedhex\"")); } + ObserveSafeMode(); LOCK(cs_main); RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VBOOL}); @@ -1181,17 +1184,17 @@ // clang-format off static const ContextFreeRPCCommand commands[] = { - // category name actor (function) okSafeMode + // category name actor (function) argNames // ------------------- ------------------------ ---------------------- ---------- - { "rawtransactions", "getrawtransaction", getrawtransaction, true, {"txid","verbose"} }, - { "rawtransactions", "createrawtransaction", createrawtransaction, true, {"inputs","outputs","locktime"} }, - { "rawtransactions", "decoderawtransaction", decoderawtransaction, true, {"hexstring"} }, - { "rawtransactions", "decodescript", decodescript, true, {"hexstring"} }, - { "rawtransactions", "sendrawtransaction", sendrawtransaction, false, {"hexstring","allowhighfees"} }, - { "rawtransactions", "signrawtransaction", signrawtransaction, false, {"hexstring","prevtxs","privkeys","sighashtype"} }, /* uses wallet if enabled */ - - { "blockchain", "gettxoutproof", gettxoutproof, true, {"txids", "blockhash"} }, - { "blockchain", "verifytxoutproof", verifytxoutproof, true, {"proof"} }, + { "rawtransactions", "getrawtransaction", getrawtransaction, {"txid","verbose"} }, + { "rawtransactions", "createrawtransaction", createrawtransaction, {"inputs","outputs","locktime"} }, + { "rawtransactions", "decoderawtransaction", decoderawtransaction, {"hexstring"} }, + { "rawtransactions", "decodescript", decodescript, {"hexstring"} }, + { "rawtransactions", "sendrawtransaction", sendrawtransaction, {"hexstring","allowhighfees"} }, + { "rawtransactions", "signrawtransaction", signrawtransaction, {"hexstring","prevtxs","privkeys","sighashtype"} }, /* uses wallet if enabled */ + + { "blockchain", "gettxoutproof", gettxoutproof, {"txids", "blockhash"} }, + { "blockchain", "verifytxoutproof", verifytxoutproof, {"proof"} }, }; // clang-format on diff --git a/src/rpc/safemode.h b/src/rpc/safemode.h new file mode 100644 --- /dev/null +++ b/src/rpc/safemode.h @@ -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 diff --git a/src/rpc/safemode.cpp b/src/rpc/safemode.cpp new file mode 100644 --- /dev/null +++ b/src/rpc/safemode.cpp @@ -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); + } +} diff --git a/src/rpc/server.h b/src/rpc/server.h --- a/src/rpc/server.h +++ b/src/rpc/server.h @@ -28,7 +28,6 @@ namespace RPCServerSignals { void OnStarted(std::function slot); void OnStopped(std::function slot); -void OnPreCommand(std::function slot); } // namespace RPCServerSignals class CBlockIndex; @@ -170,7 +169,6 @@ public: std::string category; std::string name; - bool okSafeMode; private: union { @@ -183,11 +181,9 @@ std::vector argNames; ContextFreeRPCCommand(std::string _category, std::string _name, - rpcfn_type _actor, bool _okSafeMode, - std::vector _argNames) + rpcfn_type _actor, std::vector _argNames) : category{std::move(_category)}, name{std::move(_name)}, - okSafeMode{_okSafeMode}, useConstConfig{false}, argNames{std::move( - _argNames)} { + useConstConfig{false}, argNames{std::move(_argNames)} { actor.fn = _actor; } @@ -197,11 +193,10 @@ * on parameters of function is undefined behavior. */ ContextFreeRPCCommand(std::string _category, std::string _name, - const_rpcfn_type _actor, bool _okSafeMode, + const_rpcfn_type _actor, std::vector _argNames) : category{std::move(_category)}, name{std::move(_name)}, - okSafeMode{_okSafeMode}, useConstConfig{true}, argNames{std::move( - _argNames)} { + useConstConfig{true}, argNames{std::move(_argNames)} { actor.cfn = _actor; } diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -65,11 +65,6 @@ g_rpcSignals.Stopped.connect(slot); } -void RPCServerSignals::OnPreCommand( - std::function slot) { - g_rpcSignals.PreCommand.connect(boost::bind(slot, _1)); -} - void RPCTypeCheck(const UniValue ¶ms, const std::list &typesExpected, bool fAllowNull) { @@ -319,12 +314,12 @@ */ // clang-format off static const ContextFreeRPCCommand vRPCCommands[] = { - // category name actor (function) okSafe argNames - // ------------------- ------------------------ ---------------------- ------ ---------- + // category name actor (function) argNames + // ------------------- ------------------------ ---------------------- ---------- /* Overall control/query calls */ - { "control", "help", help, true, {"command"} }, - { "control", "stop", stop, true, {} }, - { "control", "uptime", uptime, true, {} }, + { "control", "help", help, {"command"} }, + { "control", "stop", stop, {} }, + { "control", "uptime", uptime, {} }, }; // clang-format on diff --git a/src/wallet/rpcdump.cpp b/src/wallet/rpcdump.cpp --- a/src/wallet/rpcdump.cpp +++ b/src/wallet/rpcdump.cpp @@ -9,6 +9,7 @@ #include "dstencode.h" #include "init.h" #include "merkleblock.h" +#include "rpc/safemode.h" #include "rpc/server.h" #include "rpcwallet.h" #include "script/script.h" @@ -187,10 +188,10 @@ HelpExampleRpc("abortrescan", "")); } + ObserveSafeMode(); if (!pwallet->IsScanning() || pwallet->IsAbortingRescan()) { return false; } - pwallet->AbortRescan(); return true; } @@ -1363,18 +1364,18 @@ // clang-format off static const ContextFreeRPCCommand commands[] = { - // category name actor (function) okSafeMode + // category name actor (function) argNames // ------------------- ------------------------ ---------------------- ---------- - { "wallet", "abortrescan", abortrescan, false, {} }, - { "wallet", "dumpprivkey", dumpprivkey, true, {"address"} }, - { "wallet", "dumpwallet", dumpwallet, true, {"filename"} }, - { "wallet", "importmulti", importmulti, true, {"requests","options"} }, - { "wallet", "importprivkey", importprivkey, true, {"privkey","label","rescan"} }, - { "wallet", "importwallet", importwallet, true, {"filename"} }, - { "wallet", "importaddress", importaddress, true, {"address","label","rescan","p2sh"} }, - { "wallet", "importprunedfunds", importprunedfunds, true, {"rawtransaction","txoutproof"} }, - { "wallet", "importpubkey", importpubkey, true, {"pubkey","label","rescan"} }, - { "wallet", "removeprunedfunds", removeprunedfunds, true, {"txid"} }, + { "wallet", "abortrescan", abortrescan, {} }, + { "wallet", "dumpprivkey", dumpprivkey, {"address"} }, + { "wallet", "dumpwallet", dumpwallet, {"filename"} }, + { "wallet", "importmulti", importmulti, {"requests","options"} }, + { "wallet", "importprivkey", importprivkey, {"privkey","label","rescan"} }, + { "wallet", "importwallet", importwallet, {"filename"} }, + { "wallet", "importaddress", importaddress, {"address","label","rescan","p2sh"} }, + { "wallet", "importprunedfunds", importprunedfunds, {"rawtransaction","txoutproof"} }, + { "wallet", "importpubkey", importpubkey, {"pubkey","label","rescan"} }, + { "wallet", "removeprunedfunds", removeprunedfunds, {"txid"} }, }; // clang-format on diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -15,6 +15,7 @@ #include "policy/policy.h" #include "rpc/mining.h" #include "rpc/misc.h" +#include "rpc/safemode.h" #include "rpc/server.h" #include "timedata.h" #include "util.h" @@ -536,6 +537,7 @@ "outpost\"")); } + ObserveSafeMode(); LOCK2(cs_main, pwallet->cs_wallet); CTxDestination dest = @@ -606,6 +608,7 @@ HelpExampleRpc("listaddressgroupings", "")); } + ObserveSafeMode(); LOCK2(cs_main, pwallet->cs_wallet); UniValue jsonGroupings(UniValue::VARR); @@ -742,6 +745,7 @@ "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\", 6")); } + ObserveSafeMode(); LOCK2(cs_main, pwallet->cs_wallet); // Bitcoin address @@ -820,6 +824,7 @@ HelpExampleRpc("getreceivedbyaccount", "\"tabby\", 6")); } + ObserveSafeMode(); LOCK2(cs_main, pwallet->cs_wallet); // Minimum confirmations @@ -914,6 +919,7 @@ HelpExampleRpc("getbalance", "\"*\", 6")); } + ObserveSafeMode(); LOCK2(cs_main, pwallet->cs_wallet); if (request.params.size() == 0) { @@ -951,6 +957,7 @@ "Returns the server's total unconfirmed balance\n"); } + ObserveSafeMode(); LOCK2(cs_main, pwallet->cs_wallet); return ValueFromAmount(pwallet->GetUnconfirmedBalance()); @@ -998,6 +1005,7 @@ "\"timotei\", \"akiko\", 0.01, 6, \"happy birthday!\"")); } + ObserveSafeMode(); LOCK2(cs_main, pwallet->cs_wallet); std::string strFrom = AccountFromValue(request.params[0]); @@ -1085,6 +1093,7 @@ "0.01, 6, \"donation\", \"seans outpost\"")); } + ObserveSafeMode(); LOCK2(cs_main, pwallet->cs_wallet); std::string strAccount = AccountFromValue(request.params[0]); @@ -1210,6 +1219,7 @@ " 6, \"testing\"")); } + ObserveSafeMode(); LOCK2(cs_main, pwallet->cs_wallet); if (pwallet->GetBroadcastTransactions() && !g_connman) { @@ -1562,6 +1572,7 @@ HelpExampleRpc("listreceivedbyaddress", "6, true, true")); } + ObserveSafeMode(); LOCK2(cs_main, pwallet->cs_wallet); return ListReceived(config, pwallet, request.params, false); } @@ -1608,6 +1619,7 @@ HelpExampleRpc("listreceivedbyaccount", "6, true, true")); } + ObserveSafeMode(); LOCK2(cs_main, pwallet->cs_wallet); return ListReceived(config, pwallet, request.params, true); @@ -1822,6 +1834,7 @@ HelpExampleRpc("listtransactions", "\"*\", 20, 100")); } + ObserveSafeMode(); LOCK2(cs_main, pwallet->cs_wallet); std::string strAccount = "*"; @@ -1939,6 +1952,7 @@ HelpExampleRpc("listaccounts", "6")); } + ObserveSafeMode(); LOCK2(cs_main, pwallet->cs_wallet); int nMinDepth = 1; @@ -2090,6 +2104,7 @@ "\", 6")); } + ObserveSafeMode(); LOCK2(cs_main, pwallet->cs_wallet); const CBlockIndex *pindex = nullptr; @@ -2238,6 +2253,7 @@ "\"")); } + ObserveSafeMode(); LOCK2(cs_main, pwallet->cs_wallet); TxId txid; @@ -2311,6 +2327,7 @@ "bf5d48d\"")); } + ObserveSafeMode(); LOCK2(cs_main, pwallet->cs_wallet); TxId txid; @@ -2830,6 +2847,7 @@ "\nAs a json rpc call\n" + HelpExampleRpc("listlockunspent", "")); } + ObserveSafeMode(); LOCK2(cs_main, pwallet->cs_wallet); std::vector vOutpts; @@ -2932,6 +2950,7 @@ HelpExampleRpc("getwalletinfo", "")); } + ObserveSafeMode(); LOCK2(cs_main, pwallet->cs_wallet); UniValue obj(UniValue::VOBJ); @@ -3113,6 +3132,8 @@ "\\\"1LtvqCaApEdUGFkpKMM4MstjcaL4dKg8SP\\\"]\"")); } + ObserveSafeMode(); + int nMinDepth = 1; if (request.params.size() > 0 && !request.params[0].isNull()) { RPCTypeCheckArgument(request.params[0], UniValue::VNUM); @@ -3295,6 +3316,7 @@ HelpExampleCli("sendrawtransaction", "\"signedtransactionhex\"")); } + ObserveSafeMode(); RPCTypeCheck(request.params, {UniValue::VSTR}); CTxDestination changeAddress = CNoDestination(); @@ -3562,49 +3584,48 @@ // clang-format off static const ContextFreeRPCCommand commands[] = { - // category name actor (function) okSafeMode + // category name actor (function) argNames // ------------------- ------------------------ ---------------------- ---------- - { "rawtransactions", "fundrawtransaction", fundrawtransaction, false, {"hexstring","options"} }, - { "hidden", "resendwallettransactions", resendwallettransactions, true, {} }, - { "wallet", "abandontransaction", abandontransaction, false, {"txid"} }, - { "wallet", "addmultisigaddress", addmultisigaddress, true, {"nrequired","keys","account"} }, - { "wallet", "backupwallet", backupwallet, true, {"destination"} }, - { "wallet", "encryptwallet", encryptwallet, true, {"passphrase"} }, - { "wallet", "getaccountaddress", getaccountaddress, true, {"account"} }, - { "wallet", "getaccount", getaccount, true, {"address"} }, - { "wallet", "getaddressesbyaccount", getaddressesbyaccount, true, {"account"} }, - { "wallet", "getbalance", getbalance, false, {"account","minconf","include_watchonly"} }, - { "wallet", "getnewaddress", getnewaddress, true, {"account"} }, - { "wallet", "getrawchangeaddress", getrawchangeaddress, true, {} }, - { "wallet", "getreceivedbyaccount", getreceivedbyaccount, false, {"account","minconf"} }, - { "wallet", "getreceivedbyaddress", getreceivedbyaddress, false, {"address","minconf"} }, - { "wallet", "gettransaction", gettransaction, false, {"txid","include_watchonly"} }, - { "wallet", "getunconfirmedbalance", getunconfirmedbalance, false, {} }, - { "wallet", "getwalletinfo", getwalletinfo, false, {} }, - { "wallet", "keypoolrefill", keypoolrefill, true, {"newsize"} }, - { "wallet", "listaccounts", listaccounts, false, {"minconf","include_watchonly"} }, - { "wallet", "listaddressgroupings", listaddressgroupings, false, {} }, - { "wallet", "listlockunspent", listlockunspent, false, {} }, - { "wallet", "listreceivedbyaccount", listreceivedbyaccount, false, {"minconf","include_empty","include_watchonly"} }, - { "wallet", "listreceivedbyaddress", listreceivedbyaddress, false, {"minconf","include_empty","include_watchonly"} }, - { "wallet", "listsinceblock", listsinceblock, false, {"blockhash","target_confirmations","include_watchonly"} }, - { "wallet", "listtransactions", listtransactions, false, {"account","count","skip","include_watchonly"} }, - { "wallet", "listunspent", listunspent, false, {"minconf","maxconf","addresses","include_unsafe"} }, - { "wallet", "listwallets", listwallets, true, {} }, - { "wallet", "lockunspent", lockunspent, true, {"unlock","transactions"} }, - { "wallet", "move", movecmd, false, {"fromaccount","toaccount","amount","minconf","comment"} }, - { "wallet", "rescanblockchain", rescanblockchain, false, {"start_height", "stop_height"} }, - { "wallet", "sendfrom", sendfrom, false, {"fromaccount","toaddress","amount","minconf","comment","comment_to"} }, - { "wallet", "sendmany", sendmany, false, {"fromaccount","amounts","minconf","comment","subtractfeefrom"} }, - { "wallet", "sendtoaddress", sendtoaddress, false, {"address","amount","comment","comment_to","subtractfeefromamount"} }, - { "wallet", "setaccount", setaccount, true, {"address","account"} }, - { "wallet", "settxfee", settxfee, true, {"amount"} }, - { "wallet", "signmessage", signmessage, true, {"address","message"} }, - { "wallet", "walletlock", walletlock, true, {} }, - { "wallet", "walletpassphrasechange", walletpassphrasechange, true, {"oldpassphrase","newpassphrase"} }, - { "wallet", "walletpassphrase", walletpassphrase, true, {"passphrase","timeout"} }, - - { "generating", "generate", generate, true, {"nblocks","maxtries"} }, + { "rawtransactions", "fundrawtransaction", fundrawtransaction, {"hexstring","options"} }, + { "hidden", "resendwallettransactions", resendwallettransactions, {} }, + { "wallet", "abandontransaction", abandontransaction, {"txid"} }, + { "wallet", "addmultisigaddress", addmultisigaddress, {"nrequired","keys","account"} }, + { "wallet", "backupwallet", backupwallet, {"destination"} }, + { "wallet", "encryptwallet", encryptwallet, {"passphrase"} }, + { "wallet", "getaccountaddress", getaccountaddress, {"account"} }, + { "wallet", "getaccount", getaccount, {"address"} }, + { "wallet", "getaddressesbyaccount", getaddressesbyaccount, {"account"} }, + { "wallet", "getbalance", getbalance, {"account","minconf","include_watchonly"} }, + { "wallet", "getnewaddress", getnewaddress, {"account"} }, + { "wallet", "getrawchangeaddress", getrawchangeaddress, {} }, + { "wallet", "getreceivedbyaccount", getreceivedbyaccount, {"account","minconf"} }, + { "wallet", "getreceivedbyaddress", getreceivedbyaddress, {"address","minconf"} }, + { "wallet", "gettransaction", gettransaction, {"txid","include_watchonly"} }, + { "wallet", "getunconfirmedbalance", getunconfirmedbalance, {} }, + { "wallet", "getwalletinfo", getwalletinfo, {} }, + { "wallet", "keypoolrefill", keypoolrefill, {"newsize"} }, + { "wallet", "listaccounts", listaccounts, {"minconf","include_watchonly"} }, + { "wallet", "listaddressgroupings", listaddressgroupings, {} }, + { "wallet", "listlockunspent", listlockunspent, {} }, + { "wallet", "listreceivedbyaccount", listreceivedbyaccount, {"minconf","include_empty","include_watchonly"} }, + { "wallet", "listreceivedbyaddress", listreceivedbyaddress, {"minconf","include_empty","include_watchonly"} }, + { "wallet", "listsinceblock", listsinceblock, {"blockhash","target_confirmations","include_watchonly"} }, + { "wallet", "listtransactions", listtransactions, {"account","count","skip","include_watchonly"} }, + { "wallet", "listunspent", listunspent, {"minconf","maxconf","addresses","include_unsafe"} }, + { "wallet", "listwallets", listwallets, {} }, + { "wallet", "lockunspent", lockunspent, {"unlock","transactions"} }, + { "wallet", "move", movecmd, {"fromaccount","toaccount","amount","minconf","comment"} }, + { "wallet", "rescanblockchain", rescanblockchain, {"start_height", "stop_height"} }, + { "wallet", "sendfrom", sendfrom, {"fromaccount","toaddress","amount","minconf","comment","comment_to"} }, + { "wallet", "sendmany", sendmany, {"fromaccount","amounts","minconf","comment","subtractfeefrom"} }, + { "wallet", "sendtoaddress", sendtoaddress, {"address","amount","comment","comment_to","subtractfeefromamount"} }, + { "wallet", "setaccount", setaccount, {"address","account"} }, + { "wallet", "settxfee", settxfee, {"amount"} }, + { "wallet", "signmessage", signmessage, {"address","message"} }, + { "wallet", "walletlock", walletlock, {} }, + { "wallet", "walletpassphrasechange", walletpassphrasechange, {"oldpassphrase","newpassphrase"} }, + { "wallet", "walletpassphrase", walletpassphrase, {"passphrase","timeout"} }, + { "generating", "generate", generate, {"nblocks","maxtries"} }, }; // clang-format on