diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index 21d49fda9d..4ab8a8661b 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -310,7 +310,7 @@ static RPCHelpMan getrawtransaction() LOCK(cs_main); blockindex = chainman.m_blockman.LookupBlockIndex(hash_block); } - if (verbosity == 1) { + if (verbosity == 1 || !blockindex) { TxToJSON(*tx, hash_block, result, chainman.ActiveChainstate()); return result; } @@ -319,8 +319,7 @@ static RPCHelpMan getrawtransaction() CBlock block; const bool is_block_pruned{WITH_LOCK(cs_main, return chainman.m_blockman.IsBlockPruned(blockindex))}; - if (tx->IsCoinBase() || - !blockindex || is_block_pruned || + if (tx->IsCoinBase() || is_block_pruned || !(UndoReadFromDisk(blockUndo, blockindex) && ReadBlockFromDisk(block, blockindex, Params().GetConsensus()))) { TxToJSON(*tx, hash_block, result, chainman.ActiveChainstate()); return result;