@@ -714,16 +714,12 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
714
714
nMaxConnections = nFD - MIN_CORE_FILEDESCRIPTORS;
715
715
716
716
// if using block pruning, then disable txindex
717
- // also disable the wallet (for now, until SPV support is implemented in wallet)
718
717
if (GetArg (" -prune" , 0 )) {
719
718
if (GetBoolArg (" -txindex" , false ))
720
719
return InitError (_ (" Prune mode is incompatible with -txindex." ));
721
720
#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." ));
727
723
}
728
724
#endif
729
725
}
@@ -1316,6 +1312,19 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
1316
1312
}
1317
1313
if (chainActive.Tip () && chainActive.Tip () != pindexRescan)
1318
1314
{
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
+
1319
1328
uiInterface.InitMessage (_ (" Rescanning..." ));
1320
1329
LogPrintf (" Rescanning last %i blocks (from block %i)...\n " , chainActive.Height () - pindexRescan->nHeight , pindexRescan->nHeight );
1321
1330
nStart = GetTimeMillis ();
0 commit comments