@@ -313,6 +313,7 @@ UniValue getblockstats(const JSONRPCRequest& request)
313313 " \" ins\" , (string) Selected statistic name\n "
314314 " \" outs\" , (string) Selected statistic name\n "
315315 " \" subsidy\" , (string) Selected statistic name\n "
316+ " \" powtype\" , (string) Selected statistic name\n "
316317 " \" total_out\" (string) Selected statistic name\n "
317318 " ]\n "
318319 " \n Result:\n "
@@ -402,10 +403,13 @@ UniValue getblockstats(const JSONRPCRequest& request)
402403
403404 // Read block undo data to get input values
404405 CBlockUndo blockUndo;
405- bool hasUndoData = UndoReadFromDisk (blockUndo, pindex->GetUndoPos (), pindex->pprev ->GetBlockHash ());
406- if (!hasUndoData) {
407- // If we can't read undo data, we'll calculate what we can without fees
408- LogPrintf (" Warning: Could not read block undo data for getblockstats\n " );
406+ bool hasUndoData = false ;
407+ if (pindex->pprev ) {
408+ hasUndoData = UndoReadFromDisk (blockUndo, pindex->GetUndoPos (), pindex->pprev ->GetBlockHash ());
409+ if (!hasUndoData) {
410+ // If we can't read undo data, we'll calculate what we can without fees
411+ LogPrintf (" Warning: Could not read block undo data for getblockstats\n " );
412+ }
409413 }
410414
411415 // Process each transaction
@@ -535,6 +539,7 @@ UniValue getblockstats(const JSONRPCRequest& request)
535539 stats.push_back (Pair (" avgfeerate" , ValueFromAmount (avgfeerate)));
536540 stats.push_back (Pair (" avgtxsize" , avgtxsize));
537541 stats.push_back (Pair (" blockhash" , pindex->GetBlockHash ().GetHex ()));
542+ stats.push_back (Pair (" powtype" , pindex->GetBlockHeader ().GetPoWTypeName ()));
538543 stats.push_back (Pair (" devfee" , ValueFromAmount (devfee)));
539544 stats.push_back (Pair (" feerate_percentiles" , feerate_percentiles));
540545 stats.push_back (Pair (" height" , (int64_t )pindex->nHeight ));
0 commit comments