mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-24 18:23:26 -03:00
rpc: fix getrawtransaction segfault
The crash would happen when querying a mempool transaction with verbosity=2, while pruning.
Github-Pull: #29003
Rebased-From: 494a926d05
This commit is contained in:
parent
b86285df1f
commit
041228d293
1 changed files with 2 additions and 3 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue