aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2018-04-23 20:23:11 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2018-04-23 20:23:18 +0200
commitd3f04c0e81a649fd7db1ff38bbc96b3eb18312d8 (patch)
treec9fbafb991148df04c29ab89071341f55b7c2dce
parent84efa9a0f7525637e09ad3dacc1ef5afefd509b3 (diff)
parent1f838394bfd87cc9b28229824568b1d767e8ed6f (diff)
downloadbitcoin-d3f04c0e81a649fd7db1ff38bbc96b3eb18312d8.tar.xz
Merge #13030: [bugfix] [wallet] Fix zapwallettxes/multiwallet interaction.
1f83839 [wallet] [tests] Test disallowed multiwallet params (John Newbery) 3476e3c [wallet] Fix zapwallettxes/multiwallet interaction. (John Newbery) Pull request description: `-zapwallettxes` should be disallowed when starting bitcoin in multiwallet mode. There's code in `WalletInit::ParameterInteraction()` to disallow `-zapwallettxes` when running in multiwallet mode. This code functioned as expected when passing the parameter `-zapwallettxes=1`, but not when passing the parameter `-zapwallettxes` (ie without the value specified). Fix that and add a test. The new test in the _[wallet] [tests] Test disallowed multiwallet params_ commit reproduces the bug and should fail against master. Fixes #12505 Tree-SHA512: 6cd921717e9c7d2773ca84c946c310c2adec8430e37cbecdb33a620f510db3058a72bd328411812ba415111bc52a3367b332c9d15a37a92ccfd7ae785d2f32ab
-rw-r--r--src/wallet/init.cpp10
-rwxr-xr-xtest/functional/wallet_multiwallet.py13
2 files changed, 18 insertions, 5 deletions
diff --git a/src/wallet/init.cpp b/src/wallet/init.cpp
index 8b834e4626..5091477dfd 100644
--- a/src/wallet/init.cpp
+++ b/src/wallet/init.cpp
@@ -118,19 +118,19 @@ bool WalletInit::ParameterInteraction() const
}
}
- int zapwallettxes = gArgs.GetArg("-zapwallettxes", 0);
+ bool zapwallettxes = gArgs.GetBoolArg("-zapwallettxes", false);
// -zapwallettxes implies dropping the mempool on startup
- if (zapwallettxes != 0 && gArgs.SoftSetBoolArg("-persistmempool", false)) {
- LogPrintf("%s: parameter interaction: -zapwallettxes=%s -> setting -persistmempool=0\n", __func__, zapwallettxes);
+ if (zapwallettxes && gArgs.SoftSetBoolArg("-persistmempool", false)) {
+ LogPrintf("%s: parameter interaction: -zapwallettxes enabled -> setting -persistmempool=0\n", __func__);
}
// -zapwallettxes implies a rescan
- if (zapwallettxes != 0) {
+ if (zapwallettxes) {
if (is_multiwallet) {
return InitError(strprintf("%s is only allowed with a single wallet file", "-zapwallettxes"));
}
if (gArgs.SoftSetBoolArg("-rescan", true)) {
- LogPrintf("%s: parameter interaction: -zapwallettxes=%s -> setting -rescan=1\n", __func__, zapwallettxes);
+ LogPrintf("%s: parameter interaction: -zapwallettxes enabled -> setting -rescan=1\n", __func__);
}
}
diff --git a/test/functional/wallet_multiwallet.py b/test/functional/wallet_multiwallet.py
index 0a24d34398..60bf2e7e13 100755
--- a/test/functional/wallet_multiwallet.py
+++ b/test/functional/wallet_multiwallet.py
@@ -91,6 +91,19 @@ class MultiWalletTest(BitcoinTestFramework):
open(not_a_dir, 'a').close()
self.nodes[0].assert_start_raises_init_error(['-walletdir=' + not_a_dir], 'Error: Specified -walletdir "' + not_a_dir + '" is not a directory')
+ self.log.info("Do not allow -zapwallettxes with multiwallet")
+ self.nodes[0].assert_start_raises_init_error(['-zapwallettxes', '-wallet=w1', '-wallet=w2'], "Error: -zapwallettxes is only allowed with a single wallet file")
+ self.nodes[0].assert_start_raises_init_error(['-zapwallettxes=1', '-wallet=w1', '-wallet=w2'], "Error: -zapwallettxes is only allowed with a single wallet file")
+ self.nodes[0].assert_start_raises_init_error(['-zapwallettxes=2', '-wallet=w1', '-wallet=w2'], "Error: -zapwallettxes is only allowed with a single wallet file")
+
+ self.log.info("Do not allow -salvagewallet with multiwallet")
+ self.nodes[0].assert_start_raises_init_error(['-salvagewallet', '-wallet=w1', '-wallet=w2'], "Error: -salvagewallet is only allowed with a single wallet file")
+ self.nodes[0].assert_start_raises_init_error(['-salvagewallet=1', '-wallet=w1', '-wallet=w2'], "Error: -salvagewallet is only allowed with a single wallet file")
+
+ self.log.info("Do not allow -upgradewallet with multiwallet")
+ self.nodes[0].assert_start_raises_init_error(['-upgradewallet', '-wallet=w1', '-wallet=w2'], "Error: -upgradewallet is only allowed with a single wallet file")
+ self.nodes[0].assert_start_raises_init_error(['-upgradewallet=1', '-wallet=w1', '-wallet=w2'], "Error: -upgradewallet is only allowed with a single wallet file")
+
# if wallets/ doesn't exist, datadir should be the default wallet dir
wallet_dir2 = data_dir('walletdir')
os.rename(wallet_dir(), wallet_dir2)