mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 14:59:39 -04:00
Convert RPCs from uint256 to Txid
This commit is contained in:
parent
42e78f8f8a
commit
89808184a2
3 changed files with 15 additions and 15 deletions
|
@ -457,12 +457,12 @@ static RPCHelpMan getmempoolancestors()
|
|||
if (!request.params[1].isNull())
|
||||
fVerbose = request.params[1].get_bool();
|
||||
|
||||
uint256 hash = ParseHashV(request.params[0], "parameter 1");
|
||||
Txid hash = Txid::FromUint256(ParseHashV(request.params[0], "parameter 1"));
|
||||
|
||||
const CTxMemPool& mempool = EnsureAnyMemPool(request.context);
|
||||
LOCK(mempool.cs);
|
||||
|
||||
const auto entry{mempool.GetEntry(Txid::FromUint256(hash))};
|
||||
const auto entry{mempool.GetEntry(hash)};
|
||||
if (entry == nullptr) {
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Transaction not in mempool");
|
||||
}
|
||||
|
@ -479,7 +479,7 @@ static RPCHelpMan getmempoolancestors()
|
|||
UniValue o(UniValue::VOBJ);
|
||||
for (CTxMemPool::txiter ancestorIt : ancestors) {
|
||||
const CTxMemPoolEntry &e = *ancestorIt;
|
||||
const uint256& _hash = e.GetTx().GetHash();
|
||||
const Txid& _hash = e.GetTx().GetHash();
|
||||
UniValue info(UniValue::VOBJ);
|
||||
entryToJSON(mempool, info, e);
|
||||
o.pushKV(_hash.ToString(), std::move(info));
|
||||
|
@ -518,7 +518,7 @@ static RPCHelpMan getmempooldescendants()
|
|||
if (!request.params[1].isNull())
|
||||
fVerbose = request.params[1].get_bool();
|
||||
|
||||
uint256 hash = ParseHashV(request.params[0], "parameter 1");
|
||||
Txid hash = Txid::FromUint256(ParseHashV(request.params[0], "parameter 1"));
|
||||
|
||||
const CTxMemPool& mempool = EnsureAnyMemPool(request.context);
|
||||
LOCK(mempool.cs);
|
||||
|
@ -544,7 +544,7 @@ static RPCHelpMan getmempooldescendants()
|
|||
UniValue o(UniValue::VOBJ);
|
||||
for (CTxMemPool::txiter descendantIt : setDescendants) {
|
||||
const CTxMemPoolEntry &e = *descendantIt;
|
||||
const uint256& _hash = e.GetTx().GetHash();
|
||||
const Txid& _hash = e.GetTx().GetHash();
|
||||
UniValue info(UniValue::VOBJ);
|
||||
entryToJSON(mempool, info, e);
|
||||
o.pushKV(_hash.ToString(), std::move(info));
|
||||
|
@ -570,12 +570,12 @@ static RPCHelpMan getmempoolentry()
|
|||
},
|
||||
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
||||
{
|
||||
uint256 hash = ParseHashV(request.params[0], "parameter 1");
|
||||
Txid hash = Txid::FromUint256(ParseHashV(request.params[0], "parameter 1"));
|
||||
|
||||
const CTxMemPool& mempool = EnsureAnyMemPool(request.context);
|
||||
LOCK(mempool.cs);
|
||||
|
||||
const auto entry{mempool.GetEntry(Txid::FromUint256(hash))};
|
||||
const auto entry{mempool.GetEntry(hash)};
|
||||
if (entry == nullptr) {
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Transaction not in mempool");
|
||||
}
|
||||
|
@ -1072,7 +1072,7 @@ static RPCHelpMan submitpackage()
|
|||
UniValue rpc_result{UniValue::VOBJ};
|
||||
rpc_result.pushKV("package_msg", package_msg);
|
||||
UniValue tx_result_map{UniValue::VOBJ};
|
||||
std::set<uint256> replaced_txids;
|
||||
std::set<Txid> replaced_txids;
|
||||
for (const auto& tx : txns) {
|
||||
UniValue result_inner{UniValue::VOBJ};
|
||||
result_inner.pushKV("txid", tx->GetHash().GetHex());
|
||||
|
@ -1116,7 +1116,7 @@ static RPCHelpMan submitpackage()
|
|||
}
|
||||
rpc_result.pushKV("tx-results", std::move(tx_result_map));
|
||||
UniValue replaced_list(UniValue::VARR);
|
||||
for (const uint256& hash : replaced_txids) replaced_list.push_back(hash.ToString());
|
||||
for (const Txid& hash : replaced_txids) replaced_list.push_back(hash.ToString());
|
||||
rpc_result.pushKV("replaced-transactions", std::move(replaced_list));
|
||||
return rpc_result;
|
||||
},
|
||||
|
|
|
@ -351,7 +351,7 @@ static RPCHelpMan generateblock()
|
|||
const auto& str{raw_txs_or_txids[i].get_str()};
|
||||
|
||||
CMutableTransaction mtx;
|
||||
if (auto hash{uint256::FromHex(str)}) {
|
||||
if (auto hash{Txid::FromHex(str)}) {
|
||||
const auto tx{mempool.get(*hash)};
|
||||
if (!tx) {
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, strprintf("Transaction %s not in mempool.", str));
|
||||
|
@ -515,7 +515,7 @@ static RPCHelpMan prioritisetransaction()
|
|||
{
|
||||
LOCK(cs_main);
|
||||
|
||||
uint256 hash(ParseHashV(request.params[0], "txid"));
|
||||
Txid hash = Txid::FromUint256((ParseHashV(request.params[0], "txid")));
|
||||
const auto dummy{self.MaybeArg<double>("dummy")};
|
||||
CAmount nAmount = request.params[2].getInt<int64_t>();
|
||||
|
||||
|
@ -866,14 +866,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())
|
||||
|
|
|
@ -319,10 +319,10 @@ static RPCHelpMan getrawtransaction()
|
|||
const NodeContext& node = EnsureAnyNodeContext(request.context);
|
||||
ChainstateManager& chainman = EnsureChainman(node);
|
||||
|
||||
uint256 hash = ParseHashV(request.params[0], "parameter 1");
|
||||
Txid hash = Txid::FromUint256(ParseHashV(request.params[0], "parameter 1"));
|
||||
const CBlockIndex* blockindex = nullptr;
|
||||
|
||||
if (hash == chainman.GetParams().GenesisBlock().hashMerkleRoot) {
|
||||
if (hash.ToUint256() == chainman.GetParams().GenesisBlock().hashMerkleRoot) {
|
||||
// Special exception for the genesis block coinbase transaction
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "The genesis block coinbase is not considered an ordinary transaction and cannot be retrieved");
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue