Browse Source

wallet: Forbid -salvagewallet, -zapwallettxes, and -upgradewallet with multiple wallets

0.15
Luke Dashjr 8 years ago
parent
commit
9cbe8c80ba
  1. 17
      src/wallet/wallet.cpp

17
src/wallet/wallet.cpp

@ -440,8 +440,6 @@ bool CWallet::Verify() @@ -440,8 +440,6 @@ bool CWallet::Verify()
if (GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET))
return true;
SoftSetArg("-wallet", DEFAULT_WALLET_DAT);
uiInterface.InitMessage(_("Verifying wallet(s)..."));
for (const std::string& walletFile : gArgs.GetArgs("-wallet")) {
@ -3968,6 +3966,9 @@ void CWallet::postInitProcess(CScheduler& scheduler) @@ -3968,6 +3966,9 @@ void CWallet::postInitProcess(CScheduler& scheduler)
bool CWallet::ParameterInteraction()
{
SoftSetArg("-wallet", DEFAULT_WALLET_DAT);
const bool is_multiwallet = gArgs.GetArgs("-wallet").size() > 1;
if (GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET))
return true;
@ -3976,15 +3977,27 @@ bool CWallet::ParameterInteraction() @@ -3976,15 +3977,27 @@ bool CWallet::ParameterInteraction()
}
if (GetBoolArg("-salvagewallet", false) && SoftSetBoolArg("-rescan", true)) {
if (is_multiwallet) {
return InitError(strprintf("%s is only allowed with a single wallet file", "-salvagewallet"));
}
// Rewrite just private keys: rescan to find transactions
LogPrintf("%s: parameter interaction: -salvagewallet=1 -> setting -rescan=1\n", __func__);
}
// -zapwallettx implies a rescan
if (GetBoolArg("-zapwallettxes", false) && SoftSetBoolArg("-rescan", true)) {
if (is_multiwallet) {
return InitError(strprintf("%s is only allowed with a single wallet file", "-zapwallettxes"));
}
LogPrintf("%s: parameter interaction: -zapwallettxes=<mode> -> setting -rescan=1\n", __func__);
}
if (is_multiwallet) {
if (GetBoolArg("-upgradewallet", false)) {
return InitError(strprintf("%s is only allowed with a single wallet file", "-upgradewallet"));
}
}
if (GetBoolArg("-sysperms", false))
return InitError("-sysperms is not allowed in combination with enabled wallet functionality");
if (GetArg("-prune", 0) && GetBoolArg("-rescan", false))

Loading…
Cancel
Save