refactor: Use Txid in CMerkleBlock

This commit is contained in:
MarcoFalke
2023-11-28 17:03:19 +01:00
parent 26b7bcf10e
commit fa02c08c93
5 changed files with 15 additions and 14 deletions

View File

@@ -41,13 +41,13 @@ static RPCHelpMan gettxoutproof()
RPCExamples{""},
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
{
std::set<uint256> setTxids;
std::set<Txid> setTxids;
UniValue txids = request.params[0].get_array();
if (txids.empty()) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Parameter 'txids' cannot be empty");
}
for (unsigned int idx = 0; idx < txids.size(); idx++) {
auto ret = setTxids.insert(ParseHashV(txids[idx], "txid"));
auto ret{setTxids.insert(Txid::FromUint256(ParseHashV(txids[idx], "txid")))};
if (!ret.second) {
throw JSONRPCError(RPC_INVALID_PARAMETER, std::string("Invalid parameter, duplicated txid: ") + txids[idx].get_str());
}
@@ -69,7 +69,7 @@ static RPCHelpMan gettxoutproof()
// Loop through txids and try to find which block they're in. Exit loop once a block is found.
for (const auto& tx : setTxids) {
const Coin& coin = AccessByTxid(active_chainstate.CoinsTip(), Txid::FromUint256(tx));
const Coin& coin{AccessByTxid(active_chainstate.CoinsTip(), tx)};
if (!coin.IsSpent()) {
pblockindex = active_chainstate.m_chain[coin.nHeight];
break;