refactor: Convert RPCs and merkleblock from uint256 to Txid

This commit is contained in:
marcofleon
2025-07-23 17:16:09 +01:00
parent 49b3d3a92a
commit 326f244724
12 changed files with 78 additions and 80 deletions

View File

@@ -353,8 +353,8 @@ static RPCHelpMan generateblock()
const auto& str{raw_txs_or_txids[i].get_str()};
CMutableTransaction mtx;
if (auto hash{uint256::FromHex(str)}) {
const auto tx{mempool.get(*hash)};
if (auto txid{Txid::FromHex(str)}) {
const auto tx{mempool.get(*txid)};
if (!tx) {
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, strprintf("Transaction %s not in mempool.", str));
}
@@ -517,7 +517,7 @@ static RPCHelpMan prioritisetransaction()
{
LOCK(cs_main);
uint256 hash(ParseHashV(request.params[0], "txid"));
auto txid{Txid::FromUint256(ParseHashV(request.params[0], "txid"))};
const auto dummy{self.MaybeArg<double>("dummy")};
CAmount nAmount = request.params[2].getInt<int64_t>();
@@ -528,12 +528,12 @@ static RPCHelpMan prioritisetransaction()
CTxMemPool& mempool = EnsureAnyMemPool(request.context);
// Non-0 fee dust transactions are not allowed for entry, and modification not allowed afterwards
const auto& tx = mempool.get(hash);
const auto& tx = mempool.get(txid);
if (mempool.m_opts.require_standard && tx && !GetDust(*tx, mempool.m_opts.dust_relay_feerate).empty()) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Priority is not supported for transactions with dust outputs.");
}
mempool.PrioritiseTransaction(hash, nAmount);
mempool.PrioritiseTransaction(txid, nAmount);
return true;
},
};
@@ -887,14 +887,14 @@ static RPCHelpMan getblocktemplate()
UniValue aCaps(UniValue::VARR); aCaps.push_back("proposal");
UniValue transactions(UniValue::VARR);
std::map<uint256, int64_t> setTxIndex;
std::map<Txid, int64_t> setTxIndex;
std::vector<CAmount> tx_fees{block_template->getTxFees()};
std::vector<CAmount> tx_sigops{block_template->getTxSigops()};
int i = 0;
for (const auto& it : block.vtx) {
const CTransaction& tx = *it;
uint256 txHash = tx.GetHash();
Txid txHash = tx.GetHash();
setTxIndex[txHash] = i++;
if (tx.IsCoinBase())