mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-19 05:45:05 +01:00
rpc: fix getrawtransaction segfault
The crash would happen when querying a mempool transaction with verbosity=2, while pruning.
This commit is contained in:
parent
6d5790956f
commit
494a926d05
@ -396,7 +396,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;
|
||||
}
|
||||
@ -405,8 +405,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 ||
|
||||
!(chainman.m_blockman.UndoReadFromDisk(blockUndo, *blockindex) && chainman.m_blockman.ReadBlockFromDisk(block, *blockindex))) {
|
||||
TxToJSON(*tx, hash_block, result, chainman.ActiveChainstate());
|
||||
return result;
|
||||
|
Loading…
Reference in New Issue
Block a user