aboutsummaryrefslogtreecommitdiff
path: root/src/init.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/init.cpp')
-rw-r--r--src/init.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/init.cpp b/src/init.cpp
index 12fb129073..2bfa8810c8 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -270,6 +270,7 @@ std::string HelpMessage(HelpMessageMode hmm)
strUsage += " -disablewallet " + _("Do not load the wallet and disable wallet RPC calls") + "\n";
strUsage += " -paytxfee=<amt> " + _("Fee per kB to add to transactions you send") + "\n";
strUsage += " -rescan " + _("Rescan the block chain for missing wallet transactions") + "\n";
+ strUsage += " -zapwallettxes " + _("Clear list of wallet transactions (diagnostic tool; implies -rescan)") + "\n";
strUsage += " -salvagewallet " + _("Attempt to recover private keys from a corrupt wallet.dat") + "\n";
strUsage += " -upgradewallet " + _("Upgrade wallet to latest format") + "\n";
strUsage += " -wallet=<file> " + _("Specify wallet file (within data directory)") + "\n";
@@ -454,6 +455,12 @@ bool AppInit2(boost::thread_group& threadGroup)
LogPrintf("AppInit2 : parameter interaction: -salvagewallet=1 -> setting -rescan=1\n");
}
+ // -zapwallettx implies a rescan
+ if (GetBoolArg("-zapwallettxes", false)) {
+ if (SoftSetBoolArg("-rescan", true))
+ LogPrintf("AppInit2 : parameter interaction: -zapwallettxes=1 -> setting -rescan=1\n");
+ }
+
// Make sure enough file descriptors are available
int nBind = std::max((int)mapArgs.count("-bind"), 1);
nMaxConnections = GetArg("-maxconnections", 125);
@@ -899,6 +906,20 @@ bool AppInit2(boost::thread_group& threadGroup)
pwalletMain = NULL;
LogPrintf("Wallet disabled!\n");
} else {
+ if (GetBoolArg("-zapwallettxes", false)) {
+ uiInterface.InitMessage(_("Zapping all transactions from wallet..."));
+
+ pwalletMain = new CWallet(strWalletFile);
+ DBErrors nZapWalletRet = pwalletMain->ZapWalletTx();
+ if (nZapWalletRet != DB_LOAD_OK) {
+ uiInterface.InitMessage(_("Error loading wallet.dat: Wallet corrupted"));
+ return false;
+ }
+
+ delete pwalletMain;
+ pwalletMain = NULL;
+ }
+
uiInterface.InitMessage(_("Loading wallet..."));
nStart = GetTimeMillis();