refactor: Replace ParseHashStr with FromHex

No need to have two functions with different names that achieve the
exact same thing.
This commit is contained in:
MarcoFalke
2024-07-18 22:54:38 +02:00
parent fa90777245
commit fa7b57e5f5
7 changed files with 34 additions and 55 deletions

View File

@@ -345,13 +345,11 @@ static RPCHelpMan generateblock()
std::vector<CTransactionRef> txs;
const auto raw_txs_or_txids = request.params[1].get_array();
for (size_t i = 0; i < raw_txs_or_txids.size(); i++) {
const auto str(raw_txs_or_txids[i].get_str());
const auto& str{raw_txs_or_txids[i].get_str()};
uint256 hash;
CMutableTransaction mtx;
if (ParseHashStr(str, hash)) {
const auto tx = mempool.get(hash);
if (auto hash{uint256::FromHex(str)}) {
const auto tx{mempool.get(*hash)};
if (!tx) {
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, strprintf("Transaction %s not in mempool.", str));
}