@@ -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
}
@@ -1310,6 +1306,19 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
1310
1306
}
1311
1307
if (chainActive.Tip () && chainActive.Tip () != pindexRescan)
1312
1308
{
1309
+ // We can't rescan beyond non-pruned blocks, stop and throw an error
1310
+ // this might happen if a user uses a old wallet within a pruned node
1311
+ // or if he ran -disablewallet for a longer time, then decided to re-enable
1312
+ if (fPruneMode )
1313
+ {
1314
+ CBlockIndex *block = chainActive.Tip ();
1315
+ while (block && block->pprev && (block->pprev ->nStatus & BLOCK_HAVE_DATA) && block->pprev ->nTx > 0 && pindexRescan != block)
1316
+ block = block->pprev ;
1317
+
1318
+ if (pindexRescan != block)
1319
+ return InitError (_ (" Prune: last wallet synchronisation goes beyond pruned data. You need to -reindex (download the whole blockchain again in case of pruned node)" ));
1320
+ }
1321
+
1313
1322
uiInterface.InitMessage (_ (" Rescanning..." ));
1314
1323
LogPrintf (" Rescanning last %i blocks (from block %i)...\n " , chainActive.Height () - pindexRescan->nHeight , pindexRescan->nHeight );
1315
1324
nStart = GetTimeMillis ();
0 commit comments