Skip to content

Commit 8f16e00

Browse files
committed
Avoid reloading the block before calling blockheaderToJSON, the loaded block is incomplete and makes it crash
1 parent 3c8d3a2 commit 8f16e00

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

src/rpc/blockchain.cpp

+1-7
Original file line numberDiff line numberDiff line change
@@ -280,13 +280,7 @@ UniValue blockheaderToJSON(const CBlockIndex* tip, const CBlockIndex* blockindex
280280

281281
UniValue blockToJSON(const CBlock& block, const CBlockIndex* tip, const CBlockIndex* blockindex, bool txDetails)
282282
{
283-
UniValue result;
284-
if (blockindex->trimmed()) {
285-
CBlockIndex tmp = CBlockIndex(block.GetBlockHeader());
286-
result = blockheaderToJSON(tip, &tmp);
287-
} else {
288-
result = blockheaderToJSON(tip, blockindex);
289-
}
283+
UniValue result = blockheaderToJSON(tip, blockindex);
290284

291285
result.pushKV("strippedsize", (int)::GetSerializeSize(block, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS));
292286
result.pushKV("size", (int)::GetSerializeSize(block, PROTOCOL_VERSION));

0 commit comments

Comments
 (0)