Skip to content

Commit 3201035

Browse files
committed
[autoprune] allow wallet in pruned mode
1 parent ce56f56 commit 3201035

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

src/init.cpp

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -714,16 +714,12 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
714714
nMaxConnections = nFD - MIN_CORE_FILEDESCRIPTORS;
715715

716716
// if using block pruning, then disable txindex
717-
// also disable the wallet (for now, until SPV support is implemented in wallet)
718717
if (GetArg("-prune", 0)) {
719718
if (GetBoolArg("-txindex", false))
720719
return InitError(_("Prune mode is incompatible with -txindex."));
721720
#ifdef ENABLE_WALLET
722-
if (!GetBoolArg("-disablewallet", false)) {
723-
if (SoftSetBoolArg("-disablewallet", true))
724-
LogPrintf("%s : parameter interaction: -prune -> setting -disablewallet=1\n", __func__);
725-
else
726-
return InitError(_("Can't run with a wallet in prune mode."));
721+
if (GetBoolArg("-rescan", false)) {
722+
return InitError(_("Rescans are not possible in pruned mode. You will need to use -reindex which will download the whole blockchain again."));
727723
}
728724
#endif
729725
}
@@ -1316,6 +1312,19 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
13161312
}
13171313
if (chainActive.Tip() && chainActive.Tip() != pindexRescan)
13181314
{
1315+
//We can't rescan beyond non-pruned blocks, stop and throw an error
1316+
//this might happen if a user uses a old wallet within a pruned node
1317+
// or if he ran -disablewallet for a longer time, then decided to re-enable
1318+
if (fPruneMode)
1319+
{
1320+
CBlockIndex *block = chainActive.Tip();
1321+
while (block && block->pprev && (block->pprev->nStatus & BLOCK_HAVE_DATA) && pindexRescan != block)
1322+
block = block->pprev;
1323+
1324+
if (pindexRescan != block)
1325+
return InitError(_("Prune: last wallet synchronisation goes beyond pruned data. You need to -reindex (download the whole blockchain again in case of pruned node)"));
1326+
}
1327+
13191328
uiInterface.InitMessage(_("Rescanning..."));
13201329
LogPrintf("Rescanning last %i blocks (from block %i)...\n", chainActive.Height() - pindexRescan->nHeight, pindexRescan->nHeight);
13211330
nStart = GetTimeMillis();

0 commit comments

Comments
 (0)