diff --git a/src/index/base.cpp b/src/index/base.cpp index 5820448bb7f..160c5fa8cd6 100644 --- a/src/index/base.cpp +++ b/src/index/base.cpp @@ -504,9 +504,9 @@ void BaseIndex::SetBestBlockIndex(const CBlockIndex* block) { assert(!m_chainstate->m_blockman.IsPruneMode() || AllowPrune()); - if (AllowPrune() && block) { + if (AllowPrune()) { node::PruneLockInfo prune_lock; - prune_lock.height_first = block->nHeight; + prune_lock.height_first = block ? block->nHeight : 0; WITH_LOCK(::cs_main, m_chainstate->m_blockman.UpdatePruneLock(GetName(), prune_lock)); } diff --git a/test/functional/feature_pruning.py b/test/functional/feature_pruning.py index 0a8f8e44029..db06f24d929 100755 --- a/test/functional/feature_pruning.py +++ b/test/functional/feature_pruning.py @@ -470,6 +470,11 @@ class PruneTest(BitcoinTestFramework): self.connect_nodes(0, 5) self.sync_blocks([self.nodes[0], self.nodes[5]], wait=5, timeout=300) + self.log.info("Test prune with a new index") + self.restart_node(0, extra_args=["-prune=550", "-blockfilterindex=1"]) + node = self.nodes[0] + self.wait_until(lambda: node.getindexinfo()["basic block filter index"]["best_block_height"] >= 10, timeout=300) + if self.is_wallet_compiled(): self.log.info("Test wallet re-scan") self.test_wallet_rescan()