From 1a1f46c2285994908df9c11991c1f363c9733087 Mon Sep 17 00:00:00 2001 From: Musa Haruna Date: Wed, 22 Oct 2025 10:21:55 +0100 Subject: [PATCH] refactor/doc: Add blockman param to `GetTransaction` doc comment and reorder out param --- src/node/transaction.cpp | 2 +- src/node/transaction.h | 3 ++- src/rest.cpp | 2 +- src/rpc/rawtransaction.cpp | 2 +- src/rpc/txoutproof.cpp | 2 +- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/node/transaction.cpp b/src/node/transaction.cpp index 7bb92872914..99e502fbe35 100644 --- a/src/node/transaction.cpp +++ b/src/node/transaction.cpp @@ -123,7 +123,7 @@ TransactionError BroadcastTransaction(NodeContext& node, const CTransactionRef t return TransactionError::OK; } -CTransactionRef GetTransaction(const CBlockIndex* const block_index, const CTxMemPool* const mempool, const Txid& hash, uint256& hashBlock, const BlockManager& blockman) +CTransactionRef GetTransaction(const CBlockIndex* const block_index, const CTxMemPool* const mempool, const Txid& hash, const BlockManager& blockman, uint256& hashBlock) { if (mempool && !block_index) { CTransactionRef ptx = mempool->get(hash); diff --git a/src/node/transaction.h b/src/node/transaction.h index 2a4115817b9..77f599a3dbd 100644 --- a/src/node/transaction.h +++ b/src/node/transaction.h @@ -60,10 +60,11 @@ static const CAmount DEFAULT_MAX_BURN_AMOUNT{0}; * @param[in] block_index The block to read from disk, or nullptr * @param[in] mempool If provided, check mempool for tx * @param[in] hash The txid + * @param[in] blockman Used to access and read blocks from disk * @param[out] hashBlock The block hash, if the tx was found via -txindex or block_index * @returns The tx if found, otherwise nullptr */ -CTransactionRef GetTransaction(const CBlockIndex* const block_index, const CTxMemPool* const mempool, const Txid& hash, uint256& hashBlock, const BlockManager& blockman); +CTransactionRef GetTransaction(const CBlockIndex* const block_index, const CTxMemPool* const mempool, const Txid& hash, const BlockManager& blockman, uint256& hashBlock); } // namespace node #endif // BITCOIN_NODE_TRANSACTION_H diff --git a/src/rest.cpp b/src/rest.cpp index 7750bdc8d82..eb4e52f17cf 100644 --- a/src/rest.cpp +++ b/src/rest.cpp @@ -829,7 +829,7 @@ static bool rest_tx(const std::any& context, HTTPRequest* req, const std::string const NodeContext* const node = GetNodeContext(context, req); if (!node) return false; uint256 hashBlock = uint256(); - const CTransactionRef tx{GetTransaction(/*block_index=*/nullptr, node->mempool.get(), *hash, hashBlock, node->chainman->m_blockman)}; + const CTransactionRef tx{GetTransaction(/*block_index=*/nullptr, node->mempool.get(), *hash, node->chainman->m_blockman, hashBlock)}; if (!tx) { return RESTERR(req, HTTP_NOT_FOUND, hashStr + " not found"); } diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index 1a8edc594fe..5e03a4d59f9 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -351,7 +351,7 @@ static RPCHelpMan getrawtransaction() } uint256 hash_block; - const CTransactionRef tx = GetTransaction(blockindex, node.mempool.get(), txid, hash_block, chainman.m_blockman); + const CTransactionRef tx = GetTransaction(blockindex, node.mempool.get(), txid, chainman.m_blockman, hash_block); if (!tx) { std::string errmsg; if (blockindex) { diff --git a/src/rpc/txoutproof.cpp b/src/rpc/txoutproof.cpp index 2d98053d4d6..24cb8599e7c 100644 --- a/src/rpc/txoutproof.cpp +++ b/src/rpc/txoutproof.cpp @@ -86,7 +86,7 @@ static RPCHelpMan gettxoutproof() } if (pblockindex == nullptr) { - const CTransactionRef tx = GetTransaction(/*block_index=*/nullptr, /*mempool=*/nullptr, *setTxids.begin(), hashBlock, chainman.m_blockman); + const CTransactionRef tx = GetTransaction(/*block_index=*/nullptr, /*mempool=*/nullptr, *setTxids.begin(), chainman.m_blockman, hashBlock); if (!tx || hashBlock.IsNull()) { throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Transaction not yet in block"); }