Skip to content

Commit

Permalink
Properly forbid -salvagewallet and -zapwallettxes for multi wallet.
Browse files Browse the repository at this point in the history
  • Loading branch information
morcos authored and random-zebra committed Jun 2, 2021
1 parent 41a7335 commit 5bd1bd7
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/wallet/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -658,12 +658,14 @@ bool CWallet::ParameterInteraction()
gArgs.SoftSetArg("-wallet", DEFAULT_WALLET_DAT);
const bool is_multiwallet = gArgs.GetArgs("-wallet").size() > 1;

if (gArgs.GetBoolArg("-salvagewallet", false) && gArgs.SoftSetBoolArg("-rescan", true)) {
if (gArgs.GetBoolArg("-salvagewallet", false)) {
if (is_multiwallet) {
return UIError(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__);
if (gArgs.SoftSetBoolArg("-rescan", true)) {
LogPrintf("%s: parameter interaction: -salvagewallet=1 -> setting -rescan=1\n", __func__);
}
}

int zapwallettxes = gArgs.GetArg("-zapwallettxes", 0);
Expand All @@ -673,11 +675,13 @@ bool CWallet::ParameterInteraction()
}

// -zapwallettxes implies a rescan
if (zapwallettxes != 0 && gArgs.SoftSetBoolArg("-rescan", true)) {
if (zapwallettxes != 0) {
if (is_multiwallet) {
return UIError(strprintf(_("%s is only allowed with a single wallet file"), "-zapwallettxes"));
}
LogPrintf("%s: parameter interaction: -zapwallettxes=<mode> -> setting -rescan=1\n", __func__);
if (gArgs.SoftSetBoolArg("-rescan", true)) {
LogPrintf("%s: parameter interaction: -zapwallettxes=<mode> -> setting -rescan=1\n", __func__);
}
}

if (is_multiwallet) {
Expand Down

0 comments on commit 5bd1bd7

Please sign in to comment.