diff --git a/doc/release-notes.md b/doc/release-notes.md --- a/doc/release-notes.md +++ b/doc/release-notes.md @@ -9,3 +9,4 @@ - Code standard updated to c++14. - Remove `depends` from transaction objects provided by `getblocktemplate`. - The option to reuse exisiting receiving addresses has been removed from the wallet. + - Remove safe mode. diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -274,7 +274,6 @@ 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 @@ -174,7 +174,6 @@ rpc/misc.h \ rpc/protocol.h \ rpc/rawtransaction.h \ - rpc/safemode.h \ rpc/server.h \ rpc/tojson.h \ rpc/register.h \ @@ -267,7 +266,6 @@ 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,7 +28,6 @@ #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" @@ -663,16 +662,9 @@ "-checkpoints", strprintf("Only accept block chain matching " "built-in checkpoints (default: %d)", DEFAULT_CHECKPOINTS_ENABLED)); - strUsage += HelpMessageOpt( - "-disablesafemode", strprintf("Disable safemode, override a real " - "safe mode event (default: %d)", - DEFAULT_DISABLE_SAFEMODE)); strUsage += HelpMessageOpt("-deprecatedrpc=", "Allows deprecated RPC method(s) to be used"); - strUsage += HelpMessageOpt( - "-testsafemode", - strprintf("Force safe mode (default: %d)", DEFAULT_TESTSAFEMODE)); strUsage += HelpMessageOpt("-dropmessagestest=", "Randomly drop 1 of every network messages"); diff --git a/src/rpc/protocol.h b/src/rpc/protocol.h --- a/src/rpc/protocol.h +++ b/src/rpc/protocol.h @@ -45,8 +45,6 @@ //! General application defined errors //!< std::exception thrown in command handling RPC_MISC_ERROR = -1, - //!< Server is in safe mode, and command is not allowed in safe mode - RPC_FORBIDDEN_BY_SAFE_MODE = -2, //!< Unexpected type was passed as parameter RPC_TYPE_ERROR = -3, //!< Invalid address or key @@ -117,6 +115,11 @@ RPC_WALLET_NOT_SPECIFIED = -19, //!< Backwards compatible aliases RPC_WALLET_INVALID_ACCOUNT_NAME = RPC_WALLET_INVALID_LABEL_NAME, + + //! Unused reserved codes, kept around for backwards compatibility. Do not + //! reuse. + //!< Server is in safe mode, and command is not allowed in safe mode + RPC_FORBIDDEN_BY_SAFE_MODE = -2, }; UniValue JSONRPCRequestObj(const std::string &strMethod, const UniValue ¶ms, diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -17,7 +17,6 @@ #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" @@ -1266,7 +1265,6 @@ HelpExampleRpc("sendrawtransaction", "\"signedhex\"")); } - ObserveSafeMode(); LOCK(cs_main); RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VBOOL}); diff --git a/src/rpc/safemode.h b/src/rpc/safemode.h deleted file mode 100644 --- a/src/rpc/safemode.h +++ /dev/null @@ -1,12 +0,0 @@ -// 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 deleted file mode 100644 --- a/src/rpc/safemode.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#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/wallet/rpcdump.cpp b/src/wallet/rpcdump.cpp --- a/src/wallet/rpcdump.cpp +++ b/src/wallet/rpcdump.cpp @@ -9,7 +9,6 @@ #include "dstencode.h" #include "init.h" #include "merkleblock.h" -#include "rpc/safemode.h" #include "rpc/server.h" #include "rpcwallet.h" #include "script/script.h" @@ -184,7 +183,6 @@ HelpExampleRpc("abortrescan", "")); } - ObserveSafeMode(); if (!pwallet->IsScanning() || pwallet->IsAbortingRescan()) { return false; } diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -16,7 +16,6 @@ #include "rpc/mining.h" #include "rpc/misc.h" #include "rpc/rawtransaction.h" -#include "rpc/safemode.h" #include "rpc/server.h" #include "timedata.h" #include "util.h" @@ -533,8 +532,6 @@ "outpost\"")); } - ObserveSafeMode(); - // Make sure the results are valid at least up to the most recent block // the user could have gotten from another RPC command prior to now pwallet->BlockUntilSyncedToCurrentChain(); @@ -610,8 +607,6 @@ HelpExampleRpc("listaddressgroupings", "")); } - ObserveSafeMode(); - // Make sure the results are valid at least up to the most recent block // the user could have gotten from another RPC command prior to now pwallet->BlockUntilSyncedToCurrentChain(); @@ -752,8 +747,6 @@ "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\", 6")); } - ObserveSafeMode(); - // Make sure the results are valid at least up to the most recent block // the user could have gotten from another RPC command prior to now pwallet->BlockUntilSyncedToCurrentChain(); @@ -835,7 +828,6 @@ "\nAs a json rpc call\n" + HelpExampleRpc("getreceivedbylabel", "\"tabby\", 6")); } - ObserveSafeMode(); // Make sure the results are valid at least up to the most recent block // the user could have gotten from another RPC command prior to now @@ -934,8 +926,6 @@ HelpExampleRpc("getbalance", "\"*\", 6")); } - ObserveSafeMode(); - // Make sure the results are valid at least up to the most recent block // the user could have gotten from another RPC command prior to now pwallet->BlockUntilSyncedToCurrentChain(); @@ -977,8 +967,6 @@ "Returns the server's total unconfirmed balance\n"); } - ObserveSafeMode(); - // Make sure the results are valid at least up to the most recent block // the user could have gotten from another RPC command prior to now pwallet->BlockUntilSyncedToCurrentChain(); @@ -1031,7 +1019,6 @@ "\"timotei\", \"akiko\", 0.01, 6, \"happy birthday!\"")); } - ObserveSafeMode(); LOCK2(cs_main, pwallet->cs_wallet); std::string strFrom = LabelFromValue(request.params[0]); @@ -1120,8 +1107,6 @@ "0.01, 6, \"donation\", \"seans outpost\"")); } - ObserveSafeMode(); - // Make sure the results are valid at least up to the most recent block // the user could have gotten from another RPC command prior to now pwallet->BlockUntilSyncedToCurrentChain(); @@ -1250,8 +1235,6 @@ " 6, \"testing\"")); } - ObserveSafeMode(); - // Make sure the results are valid at least up to the most recent block // the user could have gotten from another RPC command prior to now pwallet->BlockUntilSyncedToCurrentChain(); @@ -1642,8 +1625,6 @@ "6, true, true, \"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\"")); } - ObserveSafeMode(); - // Make sure the results are valid at least up to the most recent block // the user could have gotten from another RPC command prior to now pwallet->BlockUntilSyncedToCurrentChain(); @@ -1694,8 +1675,6 @@ HelpExampleRpc("listreceivedbylabel", "6, true, true")); } - ObserveSafeMode(); - // Make sure the results are valid at least up to the most recent block // the user could have gotten from another RPC command prior to now pwallet->BlockUntilSyncedToCurrentChain(); @@ -1925,8 +1904,6 @@ HelpExampleRpc("listtransactions", "\"*\", 20, 100")); } - ObserveSafeMode(); - // Make sure the results are valid at least up to the most recent block // the user could have gotten from another RPC command prior to now pwallet->BlockUntilSyncedToCurrentChain(); @@ -2048,8 +2025,6 @@ HelpExampleRpc("listaccounts", "6")); } - ObserveSafeMode(); - // Make sure the results are valid at least up to the most recent block // the user could have gotten from another RPC command prior to now pwallet->BlockUntilSyncedToCurrentChain(); @@ -2223,8 +2198,6 @@ "\", 6")); } - ObserveSafeMode(); - // Make sure the results are valid at least up to the most recent block // the user could have gotten from another RPC command prior to now pwallet->BlockUntilSyncedToCurrentChain(); @@ -2410,8 +2383,6 @@ "\"")); } - ObserveSafeMode(); - // Make sure the results are valid at least up to the most recent block // the user could have gotten from another RPC command prior to now pwallet->BlockUntilSyncedToCurrentChain(); @@ -2488,8 +2459,6 @@ "bf5d48d\"")); } - ObserveSafeMode(); - // Make sure the results are valid at least up to the most recent block // the user could have gotten from another RPC command prior to now pwallet->BlockUntilSyncedToCurrentChain(); @@ -3020,7 +2989,6 @@ "\nAs a json rpc call\n" + HelpExampleRpc("listlockunspent", "")); } - ObserveSafeMode(); LOCK2(cs_main, pwallet->cs_wallet); std::vector vOutpts; @@ -3126,8 +3094,6 @@ HelpExampleRpc("getwalletinfo", "")); } - ObserveSafeMode(); - // Make sure the results are valid at least up to the most recent block // the user could have gotten from another RPC command prior to now pwallet->BlockUntilSyncedToCurrentChain(); @@ -3333,8 +3299,6 @@ "6, 9999999, [] , true, { \"minimumAmount\": 0.005 } ")); } - ObserveSafeMode(); - int nMinDepth = 1; if (request.params.size() > 0 && !request.params[0].isNull()) { RPCTypeCheckArgument(request.params[0], UniValue::VNUM); @@ -3544,7 +3508,6 @@ HelpExampleCli("sendrawtransaction", "\"signedtransactionhex\"")); } - ObserveSafeMode(); RPCTypeCheck(request.params, {UniValue::VSTR}); // Make sure the results are valid at least up to the most recent block diff --git a/src/warnings.h b/src/warnings.h --- a/src/warnings.h +++ b/src/warnings.h @@ -17,8 +17,6 @@ * Format a string that describes several potential problems detected by the * core. * strFor can have three values: - * - "rpc": get critical warnings, which should put the client in safe mode if - * non-empty * - "statusbar": get all warnings * - "gui": get all warnings, translated (where possible) for GUI * This function only returns the highest priority warning of the set selected @@ -26,6 +24,4 @@ */ std::string GetWarnings(const std::string &strFor); -static const bool DEFAULT_TESTSAFEMODE = false; - #endif // BITCOIN_WARNINGS_H diff --git a/src/warnings.cpp b/src/warnings.cpp --- a/src/warnings.cpp +++ b/src/warnings.cpp @@ -35,7 +35,6 @@ std::string GetWarnings(const std::string &strFor) { std::string strStatusBar; - std::string strRPC; std::string strGUI; const std::string uiAlertSeperator = "
"; @@ -48,9 +47,6 @@ "do not use for mining or merchant applications"); } - if (gArgs.GetBoolArg("-testsafemode", DEFAULT_TESTSAFEMODE)) - strStatusBar = strRPC = strGUI = "testsafemode enabled"; - // Misc warnings like out of disk space and clock is wrong if (strMiscWarning != "") { strStatusBar = strMiscWarning; @@ -58,16 +54,15 @@ } if (fLargeWorkForkFound) { - strStatusBar = strRPC = "Warning: The network does not appear to fully " - "agree! Some miners appear to be experiencing " - "issues."; + strStatusBar = "Warning: The network does not appear to fully agree! " + "Some miners appear to be experiencing issues."; strGUI += (strGUI.empty() ? "" : uiAlertSeperator) + _("Warning: The network does not appear to fully agree! Some " "miners appear to be experiencing issues."); } else if (fLargeWorkInvalidChainFound) { - strStatusBar = strRPC = "Warning: We do not appear to fully agree with " - "our peers! You may need to upgrade, or other " - "nodes may need to upgrade."; + strStatusBar = "Warning: We do not appear to fully agree with our " + "peers! You may need to upgrade, or other nodes may " + "need to upgrade."; strGUI += (strGUI.empty() ? "" : uiAlertSeperator) + _("Warning: We do not appear to fully agree with our peers! You " @@ -78,8 +73,6 @@ return strGUI; else if (strFor == "statusbar") return strStatusBar; - else if (strFor == "rpc") - return strRPC; assert(!"GetWarnings(): invalid parameter"); return "error"; } diff --git a/test/functional/feature_pruning.py b/test/functional/feature_pruning.py --- a/test/functional/feature_pruning.py +++ b/test/functional/feature_pruning.py @@ -159,7 +159,7 @@ self.stop_node(1) self.start_node(1, extra_args=[ "-maxreceivebuffer=20000", "-blockmaxsize=5000", "-checkblocks=5", - "-disablesafemode", "-noparkdeepreorg", "-maxreorgdepth=-1"]) + "-noparkdeepreorg", "-maxreorgdepth=-1"]) height = self.nodes[1].getblockcount() self.log.info("Current block height: {}".format(height)) @@ -187,7 +187,7 @@ self.stop_node(1) self.start_node(1, extra_args=[ "-maxreceivebuffer=20000", "-blockmaxsize=5000", "-checkblocks=5", - "-disablesafemode", "-noparkdeepreorg", "-maxreorgdepth=-1"]) + "-noparkdeepreorg", "-maxreorgdepth=-1"]) self.log.info("Generating new longer chain of 300 more blocks") self.nodes[1].generate(300)