|
7 | 7 | #include <policy/rbf.h> |
8 | 8 | #include <rpc/util.h> |
9 | 9 | #include <rpc/blockchain.h> |
| 10 | +#include <util/transaction_identifier.h> |
10 | 11 | #include <util/vector.h> |
11 | 12 | #include <wallet/receive.h> |
12 | 13 | #include <wallet/rpc/util.h> |
@@ -34,11 +35,10 @@ static void WalletTxToJSON(const CWallet& wallet, const CWalletTx& wtx, UniValue |
34 | 35 | } else { |
35 | 36 | entry.pushKV("trusted", CachedTxIsTrusted(wallet, wtx)); |
36 | 37 | } |
37 | | - uint256 hash = wtx.GetHash(); |
38 | | - entry.pushKV("txid", hash.GetHex()); |
| 38 | + entry.pushKV("txid", wtx.GetHash().GetHex()); |
39 | 39 | entry.pushKV("wtxid", wtx.GetWitnessHash().GetHex()); |
40 | 40 | UniValue conflicts(UniValue::VARR); |
41 | | - for (const uint256& conflict : wallet.GetTxConflicts(wtx)) |
| 41 | + for (const Txid& conflict : wallet.GetTxConflicts(wtx)) |
42 | 42 | conflicts.push_back(conflict.GetHex()); |
43 | 43 | entry.pushKV("walletconflicts", std::move(conflicts)); |
44 | 44 | UniValue mempool_conflicts(UniValue::VARR); |
@@ -67,7 +67,7 @@ struct tallyitem |
67 | 67 | { |
68 | 68 | CAmount nAmount{0}; |
69 | 69 | int nConf{std::numeric_limits<int>::max()}; |
70 | | - std::vector<uint256> txids; |
| 70 | + std::vector<Txid> txids; |
71 | 71 | bool fIsWatchonly{false}; |
72 | 72 | tallyitem() = default; |
73 | 73 | }; |
@@ -100,8 +100,7 @@ static UniValue ListReceived(const CWallet& wallet, const UniValue& params, cons |
100 | 100 |
|
101 | 101 | // Tally |
102 | 102 | std::map<CTxDestination, tallyitem> mapTally; |
103 | | - for (const std::pair<const uint256, CWalletTx>& pairWtx : wallet.mapWallet) { |
104 | | - const CWalletTx& wtx = pairWtx.second; |
| 103 | + for (const auto& [_, wtx] : wallet.mapWallet) { |
105 | 104 |
|
106 | 105 | int nDepth = wallet.GetTxDepthInMainChain(wtx); |
107 | 106 | if (nDepth < nMinDepth) |
@@ -169,7 +168,7 @@ static UniValue ListReceived(const CWallet& wallet, const UniValue& params, cons |
169 | 168 | obj.pushKV("label", label); |
170 | 169 | UniValue transactions(UniValue::VARR); |
171 | 170 | if (it != mapTally.end()) { |
172 | | - for (const uint256& _item : (*it).second.txids) { |
| 171 | + for (const Txid& _item : (*it).second.txids) { |
173 | 172 | transactions.push_back(_item.GetHex()); |
174 | 173 | } |
175 | 174 | } |
@@ -650,8 +649,7 @@ RPCHelpMan listsinceblock() |
650 | 649 |
|
651 | 650 | UniValue transactions(UniValue::VARR); |
652 | 651 |
|
653 | | - for (const std::pair<const uint256, CWalletTx>& pairWtx : wallet.mapWallet) { |
654 | | - const CWalletTx& tx = pairWtx.second; |
| 652 | + for (const auto& [_, tx] : wallet.mapWallet) { |
655 | 653 |
|
656 | 654 | if (depth == -1 || abs(wallet.GetTxDepthInMainChain(tx)) < depth) { |
657 | 655 | ListTransactions(wallet, tx, 0, true, transactions, filter, filter_label, include_change); |
@@ -760,7 +758,7 @@ RPCHelpMan gettransaction() |
760 | 758 |
|
761 | 759 | LOCK(pwallet->cs_wallet); |
762 | 760 |
|
763 | | - uint256 hash(ParseHashV(request.params[0], "txid")); |
| 761 | + Txid hash{Txid::FromUint256(ParseHashV(request.params[0], "txid"))}; |
764 | 762 |
|
765 | 763 | isminefilter filter = ISMINE_SPENDABLE; |
766 | 764 |
|
@@ -833,7 +831,7 @@ RPCHelpMan abandontransaction() |
833 | 831 |
|
834 | 832 | LOCK(pwallet->cs_wallet); |
835 | 833 |
|
836 | | - uint256 hash(ParseHashV(request.params[0], "txid")); |
| 834 | + Txid hash{Txid::FromUint256(ParseHashV(request.params[0], "txid"))}; |
837 | 835 |
|
838 | 836 | if (!pwallet->mapWallet.count(hash)) { |
839 | 837 | throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid or non-wallet transaction id"); |
|
0 commit comments