diff --git a/src/rest.cpp b/src/rest.cpp --- a/src/rest.cpp +++ b/src/rest.cpp @@ -395,8 +395,8 @@ } CTransactionRef tx; - uint256 hashBlock = uint256(); - if (!GetTransaction(config.GetChainParams().GetConsensus(), txid, tx, + BlockHash hashBlock; + if (!GetTransaction(txid, tx, config.GetChainParams().GetConsensus(), hashBlock, true)) { return RESTERR(req, HTTP_NOT_FOUND, hashStr + " not found"); } diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -2099,8 +2099,8 @@ Amount tx_total_in = Amount::zero(); for (const CTxIn &in : tx->vin) { CTransactionRef tx_in; - uint256 hashBlock; - if (!GetTransaction(params, in.prevout.GetTxId(), tx_in, + BlockHash hashBlock; + if (!GetTransaction(in.prevout.GetTxId(), tx_in, params, hashBlock, false)) { throw JSONRPCError(RPC_INTERNAL_ERROR, std::string("Unexpected internal error " diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -204,7 +204,7 @@ CTransactionRef tx; BlockHash hash_block; - if (!GetTransaction(params.GetConsensus(), txid, tx, hash_block, true, + if (!GetTransaction(txid, tx, params.GetConsensus(), hash_block, true, blockindex)) { std::string errmsg; if (blockindex) { @@ -324,7 +324,7 @@ if (pblockindex == nullptr) { CTransactionRef tx; - if (!GetTransaction(params, oneTxId, tx, hashBlock, false) || + if (!GetTransaction(oneTxId, tx, params, hashBlock, false) || hashBlock.IsNull()) { throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Transaction not yet in block"); diff --git a/src/validation.h b/src/validation.h --- a/src/validation.h +++ b/src/validation.h @@ -420,9 +420,10 @@ /** * Retrieve a transaction (from memory pool, or from disk, if possible). */ -bool GetTransaction(const Consensus::Params ¶ms, const TxId &txid, - CTransactionRef &tx, uint256 &hashBlock, - bool fAllowSlow = false, CBlockIndex *blockIndex = nullptr); +bool GetTransaction(const TxId &txid, CTransactionRef &txOut, + const Consensus::Params ¶ms, BlockHash &hashBlock, + bool fAllowSlow = false, + const CBlockIndex *const blockIndex = nullptr); /** * Find the best known block, and make it the tip of the block chain diff --git a/src/validation.cpp b/src/validation.cpp --- a/src/validation.cpp +++ b/src/validation.cpp @@ -905,10 +905,10 @@ * placed in hashBlock. If blockIndex is provided, the transaction is fetched * from the corresponding block. */ -bool GetTransaction(const Consensus::Params ¶ms, const TxId &txid, - CTransactionRef &txOut, uint256 &hashBlock, bool fAllowSlow, - CBlockIndex *blockIndex) { - CBlockIndex *pindexSlow = blockIndex; +bool GetTransaction(const TxId &txid, CTransactionRef &txOut, + const Consensus::Params ¶ms, BlockHash &hashBlock, + bool fAllowSlow, const CBlockIndex *const blockIndex) { + CBlockIndex const *pindexSlow = blockIndex; LOCK(cs_main);