From 1f015f6afaf74224aeda3ca181ef3adefc6fc8e3 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Tue, 31 Jan 2017 23:28:33 +0100 Subject: [PATCH 1/2] Add a flag for enabling experimental features --- src/init.cpp | 4 ++++ src/main.cpp | 1 + src/main.h | 1 + 3 files changed, 6 insertions(+) diff --git a/src/init.cpp b/src/init.cpp index 0df20e242..67df0e99b 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -416,6 +416,7 @@ std::string HelpMessage(HelpMessageMode mode) debugCategories += ", qt"; strUsage += HelpMessageOpt("-debug=", strprintf(_("Output debugging information (default: %u, supplying is optional)"), 0) + ". " + _("If is not supplied or if = 1, output all debugging information.") + " " + _(" can be:") + " " + debugCategories + "."); + strUsage += HelpMessageOpt("-experimentalfeatures", _("Enable use of experimental features")); strUsage += HelpMessageOpt("-help-debug", _("Show all debugging options (usage: --help -help-debug)")); strUsage += HelpMessageOpt("-logips", strprintf(_("Include IP addresses in debug output (default: %u)"), 0)); strUsage += HelpMessageOpt("-logtimestamps", strprintf(_("Prepend debug output with timestamp (default: %u)"), 1)); @@ -750,6 +751,9 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) // ********************************************************* Step 2: parameter interactions const CChainParams& chainparams = Params(); + // Set this early so that experimental features are correctly enabled/disabled + fExperimentalMode = GetBoolArg("-experimentalfeatures", false); + // Set this early so that parameter interactions go to console fPrintToConsole = GetBoolArg("-printtoconsole", false); fLogTimestamps = GetBoolArg("-logtimestamps", true); diff --git a/src/main.cpp b/src/main.cpp index 74344696d..207c0d458 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -56,6 +56,7 @@ int64_t nTimeBestReceived = 0; CWaitableCriticalSection csBestBlock; CConditionVariable cvBlockChange; int nScriptCheckThreads = 0; +bool fExperimentalMode = false; bool fImporting = false; bool fReindex = false; bool fTxIndex = false; diff --git a/src/main.h b/src/main.h index fd99d28e5..bc6af6484 100644 --- a/src/main.h +++ b/src/main.h @@ -116,6 +116,7 @@ extern uint64_t nLastBlockSize; extern const std::string strMessageMagic; extern CWaitableCriticalSection csBestBlock; extern CConditionVariable cvBlockChange; +extern bool fExperimentalMode; extern bool fImporting; extern bool fReindex; extern int nScriptCheckThreads; From b8eb37757b1cd1e9b765f007aa8571df3de71666 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Wed, 8 Feb 2017 12:46:01 +0000 Subject: [PATCH 2/2] Require -experimentalmode for wallet encryption --- qa/rpc-tests/keypool.py | 2 +- qa/rpc-tests/wallet_nullifiers.py | 2 +- src/init.cpp | 7 +++++++ src/wallet/rpcwallet.cpp | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/qa/rpc-tests/keypool.py b/qa/rpc-tests/keypool.py index 1f8979692..38d6874dc 100755 --- a/qa/rpc-tests/keypool.py +++ b/qa/rpc-tests/keypool.py @@ -98,7 +98,7 @@ def main(): os.makedirs(options.tmpdir) initialize_chain(options.tmpdir) - nodes = start_nodes(1, options.tmpdir, extra_args=[['-developerencryptwallet']]) + nodes = start_nodes(1, options.tmpdir, extra_args=[['-experimentalfeatures', '-developerencryptwallet']]) run_test(nodes, options.tmpdir) diff --git a/qa/rpc-tests/wallet_nullifiers.py b/qa/rpc-tests/wallet_nullifiers.py index ce18f8d51..93f5a499d 100755 --- a/qa/rpc-tests/wallet_nullifiers.py +++ b/qa/rpc-tests/wallet_nullifiers.py @@ -12,7 +12,7 @@ class WalletNullifiersTest (BitcoinTestFramework): def setup_nodes(self): return start_nodes(4, self.options.tmpdir, - extra_args=[['-developerencryptwallet']] * 4) + extra_args=[['-experimentalfeatures', '-developerencryptwallet']] * 4) def run_test (self): # add zaddr to node 0 diff --git a/src/init.cpp b/src/init.cpp index 67df0e99b..85ee47921 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -754,6 +754,13 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) // Set this early so that experimental features are correctly enabled/disabled fExperimentalMode = GetBoolArg("-experimentalfeatures", false); + // Fail early if user has set experimental options without the global flag + if (!fExperimentalMode) { + if (mapArgs.count("-developerencryptwallet")) { + return InitError(_("Wallet encryption requires -experimentalfeatures.")); + } + } + // Set this early so that parameter interactions go to console fPrintToConsole = GetBoolArg("-printtoconsole", false); fLogTimestamps = GetBoolArg("-logtimestamps", true); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 060b0dd94..b3ec08463 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -2002,7 +2002,7 @@ Value encryptwallet(const Array& params, bool fHelp) if (!EnsureWalletIsAvailable(fHelp)) return Value::null; - auto fEnableWalletEncryption = GetBoolArg("-developerencryptwallet", false); + auto fEnableWalletEncryption = fExperimentalMode && GetBoolArg("-developerencryptwallet", false); std::string strWalletEncryptionDisabledMsg = ""; if (!fEnableWalletEncryption) {