From af7d883854e8c724bd3e1529c50f0bf49025538c Mon Sep 17 00:00:00 2001 From: Daira Hopwood Date: Thu, 14 Apr 2022 14:53:29 +0100 Subject: [PATCH] Make `-reindex` and `-reindex-chainstate` imply `-rescan` (provided that the wallet is enabled and pruning is disabled, and unless `-rescan=0` is specified explicitly). Signed-off-by: Daira Hopwood --- doc/release-notes.md | 6 ++++++ src/init.cpp | 19 +++++++++++++++++++ src/wallet/wallet.cpp | 2 +- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/doc/release-notes.md b/doc/release-notes.md index a29094b51..80f711263 100644 --- a/doc/release-notes.md +++ b/doc/release-notes.md @@ -4,3 +4,9 @@ release-notes at release time) Notable changes =============== +Option handling +--------------- + +- The `-reindex` and `-reindex-chainstate` options now imply `-rescan` + (provided that the wallet is enabled and pruning is disabled, and unless + `-rescan=0` is specified explicitly). diff --git a/src/init.cpp b/src/init.cpp index bee50a6a9..6793f9c61 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -360,8 +360,13 @@ std::string HelpMessage(HelpMessageMode mode) strUsage += HelpMessageOpt("-prune=", strprintf(_("Reduce storage requirements by pruning (deleting) old blocks. This mode disables wallet support and is incompatible with -txindex. " "Warning: Reverting this setting requires re-downloading the entire blockchain. " "(default: 0 = disable pruning blocks, >%u = target size in MiB to use for block files)"), MIN_DISK_SPACE_FOR_BLOCK_FILES / 1024 / 1024)); +#ifdef ENABLE_WALLET + strUsage += HelpMessageOpt("-reindex-chainstate", _("Rebuild chain state from the currently indexed blocks (implies -rescan unless pruning or unless -rescan=0 is explicitly specified")); + strUsage += HelpMessageOpt("-reindex", _("Rebuild chain state and block index from the blk*.dat files on disk (implies -rescan unless pruning or unless -rescan=0 is explicitly specified)")); +#else strUsage += HelpMessageOpt("-reindex-chainstate", _("Rebuild chain state from the currently indexed blocks")); strUsage += HelpMessageOpt("-reindex", _("Rebuild chain state and block index from the blk*.dat files on disk")); +#endif #ifndef WIN32 strUsage += HelpMessageOpt("-sysperms", _("Create new files with system default permissions, instead of umask 077 (only effective with disabled wallet functionality)")); #endif @@ -929,6 +934,9 @@ void InitParameterInteraction() LogPrintf("%s: parameter interaction: -externalip set -> setting -discover=0\n", __func__); } +#ifdef ENABLE_WALLET + // -rescan only affects the wallet. + if (GetBoolArg("-salvagewallet", false)) { // Rewrite just private keys: rescan to find transactions if (SoftSetBoolArg("-rescan", true)) @@ -940,6 +948,17 @@ void InitParameterInteraction() LogPrintf("%s: parameter interaction: -zapwallettxes= -> setting -rescan=1\n", __func__); } + if (GetBoolArg("-reindex", false) && !GetArg("-prune", 0)) { + if (SoftSetBoolArg("-rescan", true)) + LogPrintf("%s: parameter interaction: -reindex=1 and not pruning -> setting -rescan=1\n", __func__); + } + + if (GetBoolArg("-reindex-chainstate", false) && !GetArg("-prune", 0)) { + if (SoftSetBoolArg("-rescan", true)) + LogPrintf("%s: parameter interaction: -reindex-chainstate=1 and not pruning -> setting -rescan=1\n", __func__); + } +#endif + // disable walletbroadcast and whitelistrelay in blocksonly mode if (GetBoolArg("-blocksonly", DEFAULT_BLOCKSONLY)) { if (SoftSetBoolArg("-whitelistrelay", false)) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 04f16cf96..9f72a0028 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -6317,7 +6317,7 @@ std::string CWallet::GetWalletHelpString(bool showDebug) strUsage += HelpMessageOpt("-paytxfee=", strprintf(_("Fee (in %s/kB) to add to transactions you send (default: %s)"), CURRENCY_UNIT, FormatMoney(payTxFee.GetFeePerK()))); strUsage += HelpMessageOpt("-rescan", _("Rescan the block chain for missing wallet transactions on startup")); - strUsage += HelpMessageOpt("-salvagewallet", _("Attempt to recover private keys from a corrupt wallet on startup")); + strUsage += HelpMessageOpt("-salvagewallet", _("Attempt to recover private keys from a corrupt wallet on startup (implies -rescan)")); strUsage += HelpMessageOpt("-sendfreetransactions", strprintf(_("Send transactions as zero-fee transactions if possible (default: %u)"), DEFAULT_SEND_FREE_TRANSACTIONS)); strUsage += HelpMessageOpt("-spendzeroconfchange", strprintf(_("Spend unconfirmed change when sending transactions (default: %u)"), DEFAULT_SPEND_ZEROCONF_CHANGE)); strUsage += HelpMessageOpt("-txconfirmtarget=", strprintf(_("If paytxfee is not set, include enough fee so transactions begin confirmation on average within n blocks (default: %u)"), DEFAULT_TX_CONFIRM_TARGET));