Skip to content

Commit

Permalink
Merge #874: [Config] Ignore prune mode if txindex is set
Browse files Browse the repository at this point in the history
5d49651 [Config] Ignore prune mode if txindex is set (Cave Spectre)

Pull request description:

  ### Problem
  #253 - Prune mode incompatible with txindex.
  Having prune mode on can stick the user into being unable to start their wallet.  For Qt: they receive an error stating "Prune mode is Incompatible with -txindex"

  ### Root Cause
  The error was a little heavy handed, and rejected the use of prune mode without txindex=0.  The part of this issue that makes it important to address is that you can inadvertently end up with bPrune set in your registry on windows; making it difficult to find and remove.  There is an additional issue that implies that uninstalling your wallet will not remove the registry entries; so getting bPrune=true in your registry would be quite challenging to clear out, and likely result in support tickets.

  ### Solution
  **_Note that prune mode is unsupported and likely will result in corrupting your wallet.  This is not meant to claim that prune mode is functional._**

  If Prune mode is set and txindex is not implicitly disabled [txindex=0], the wallet will not run.  This PR changes the prune mode from an error that shuts down the wallet, to a warning that ignores prune mode if txindex is enabled.   This warning will not show in a Windows pop-up, but rather in the log file and the terminal executing the daemon and/or qt.  It will also ignore the prune mode setting, changing it to '0' if it is set.

  ### Testing
  combinations of txindex=[0|1], prune=[0|1] in your config file, command line, and bPrune=true in your registry [see issue #253 for registry details]

Tree-SHA512: a660574d6791e060c11b9b3aa3ce7f1ab2813f6f7b72927972d5b04a0b91fd7abb484c552e4b51fb1b121a726e9c2b73664922a9545e3d9f12e97105580393a5
  • Loading branch information
codeofalltrades committed Nov 25, 2020
2 parents ea827dc + 5d49651 commit 2f83d92
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/init.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2019 The Bitcoin Core developers
// Copyright (c) 2015-2019 The PIVX developers
// Copyright (c) 2018-2019 The Veil developers
// Copyright (c) 2018-2020 The Veil developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

Expand Down Expand Up @@ -1000,7 +1000,7 @@ bool AppInitParameterInteraction()
// if using block pruning, then disallow txindex
if (gArgs.GetArg("-prune", 0)) {
if (gArgs.GetBoolArg("-txindex", DEFAULT_TXINDEX))
return InitError(_("Prune mode is incompatible with -txindex."));
InitWarning(_("Ignoring Prune Mode: Incompatible with -txindex."));
}

// -bind and -whitebind can't be set when not listening
Expand Down Expand Up @@ -1123,6 +1123,10 @@ bool AppInitParameterInteraction()
if (nPruneArg < 0) {
return InitError(_("Prune cannot be configured with a negative value."));
}
if (nPruneArg && gArgs.GetBoolArg("-txindex", DEFAULT_TXINDEX)) {
// We already warned them that it's getting ignored
nPruneArg = 0;
}
nPruneTarget = (uint64_t) nPruneArg * 1024 * 1024;
if (nPruneArg == 1) { // manual pruning: -prune=1
LogPrintf("Block pruning enabled. Use RPC call pruneblockchain(height) to manually prune block and undo files.\n");
Expand Down

0 comments on commit 2f83d92

Please sign in to comment.