mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-09-12 13:42:10 +02:00
txindex: return optional tx and block hash from FindTx
Co-authored-by: l0rinc <pap.lorinc@gmail.com>
This commit is contained in:
@@ -146,15 +146,13 @@ CTransactionRef GetTransaction(const CBlockIndex* const block_index, const CTxMe
|
||||
if (ptx) return ptx;
|
||||
}
|
||||
if (g_txindex) {
|
||||
CTransactionRef tx;
|
||||
uint256 block_hash;
|
||||
if (g_txindex->FindTx(hash, block_hash, tx)) {
|
||||
if (!block_index || block_index->GetBlockHash() == block_hash) {
|
||||
if (auto result{g_txindex->FindTx(hash)}) {
|
||||
if (!block_index || block_index->GetBlockHash() == result->block_hash) {
|
||||
// Don't return the transaction if the provided block hash doesn't match.
|
||||
// The case where a transaction appears in multiple blocks (e.g. reorgs or
|
||||
// BIP30) is handled by the block lookup below.
|
||||
hashBlock = block_hash;
|
||||
return tx;
|
||||
hashBlock = result->block_hash;
|
||||
return result->tx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user