From c80a498ae532ad4a8e8027cd8f1057785608b3fc Mon Sep 17 00:00:00 2001 From: Jonas Schnelli Date: Thu, 9 May 2019 13:56:01 +0200 Subject: Fix RPC/pruneblockchain returned prune height Github-Pull: #15991 Rebased-From: 97f517dd851450b1ede1eb6b20f77691883a7737 --- src/rpc/blockchain.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 6fa472d442..bd35163074 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1030,7 +1030,12 @@ static UniValue pruneblockchain(const JSONRPCRequest& request) } PruneBlockFilesManual(height); - return uint64_t(height); + const CBlockIndex* block = ::chainActive.Tip(); + assert(block); + while (block->pprev && (block->pprev->nStatus & BLOCK_HAVE_DATA)) { + block = block->pprev; + } + return uint64_t(block->nHeight); } static UniValue gettxoutsetinfo(const JSONRPCRequest& request) -- cgit v1.2.3