wallet: Remove unused WalletTXO::GetWalletTx()

This commit is contained in:
Ava Chow 2024-02-20 11:54:49 -05:00
parent 531aa39036
commit bc1c12cb29
3 changed files with 7 additions and 11 deletions

View file

@ -323,7 +323,6 @@ CoinsResult AvailableCoins(const CWallet& wallet,
// Cache for whether each tx passes the tx level checks (first bool), and whether the transaction is "safe" (second bool) // Cache for whether each tx passes the tx level checks (first bool), and whether the transaction is "safe" (second bool)
std::unordered_map<uint256, std::pair<bool, bool>, SaltedTxidHasher> tx_safe_cache; std::unordered_map<uint256, std::pair<bool, bool>, SaltedTxidHasher> tx_safe_cache;
for (const auto& [outpoint, txo] : wallet.GetTXOs()) { for (const auto& [outpoint, txo] : wallet.GetTXOs()) {
const CWalletTx& wtx = txo.GetWalletTx();
const CTxOut& output = txo.GetTxOut(); const CTxOut& output = txo.GetTxOut();
if (tx_safe_cache.contains(outpoint.hash) && !tx_safe_cache.at(outpoint.hash).first) { if (tx_safe_cache.contains(outpoint.hash) && !tx_safe_cache.at(outpoint.hash).first) {
@ -347,20 +346,21 @@ CoinsResult AvailableCoins(const CWallet& wallet,
continue; continue;
} }
if (wallet.IsTxImmatureCoinBase(wtx) && !params.include_immature_coinbase) if (wallet.IsTXOInImmatureCoinBase(txo) && !params.include_immature_coinbase)
continue; continue;
isminetype mine = wallet.IsMine(output); isminetype mine = wallet.IsMine(output);
assert(mine != ISMINE_NO); assert(mine != ISMINE_NO);
int nDepth = wallet.GetTxDepthInMainChain(wtx); int nDepth = wallet.GetTxStateDepthInMainChain(txo.GetState());
if (nDepth < 0) if (nDepth < 0)
continue; continue;
// Perform tx level checks if we haven't already come across outputs from this tx before. // Perform tx level checks if we haven't already come across outputs from this tx before.
if (!tx_safe_cache.contains(outpoint.hash)) { if (!tx_safe_cache.contains(outpoint.hash)) {
tx_safe_cache[outpoint.hash] = {false, false}; tx_safe_cache[outpoint.hash] = {false, false};
const CWalletTx& wtx = *wallet.GetWalletTx(outpoint.hash);
// We should not consider coins which aren't at least in our mempool // We should not consider coins which aren't at least in our mempool
// It's possible for these to be conflicted via ancestors which we may never be able to detect // It's possible for these to be conflicted via ancestors which we may never be able to detect
@ -415,7 +415,7 @@ CoinsResult AvailableCoins(const CWallet& wallet,
continue; continue;
} }
bool tx_from_me = CheckIsFromMeMap(wtx.m_from_me, ISMINE_ALL); bool tx_from_me = CheckIsFromMeMap(txo.GetTxFromMe(), ISMINE_ALL);
std::unique_ptr<SigningProvider> provider = wallet.GetSolvingProvider(output.scriptPubKey); std::unique_ptr<SigningProvider> provider = wallet.GetSolvingProvider(output.scriptPubKey);

View file

@ -385,7 +385,6 @@ struct WalletTxOrderComparator {
class WalletTXO class WalletTXO
{ {
private: private:
const CWalletTx& m_wtx;
const CTxOut& m_output; const CTxOut& m_output;
isminetype m_ismine; isminetype m_ismine;
TxState m_tx_state; TxState m_tx_state;
@ -394,9 +393,8 @@ private:
int64_t m_tx_time; int64_t m_tx_time;
public: public:
WalletTXO(const CWalletTx& wtx, const CTxOut& output, const isminetype ismine, const TxState& state, bool coinbase, const std::map<isminefilter, bool>& tx_from_me, int64_t tx_time) WalletTXO(const CTxOut& output, const isminetype ismine, const TxState& state, bool coinbase, const std::map<isminefilter, bool>& tx_from_me, int64_t tx_time)
: m_wtx(wtx), : m_output(output),
m_output(output),
m_ismine(ismine), m_ismine(ismine),
m_tx_state(state), m_tx_state(state),
m_tx_coinbase(coinbase), m_tx_coinbase(coinbase),
@ -404,8 +402,6 @@ public:
m_tx_time(tx_time) m_tx_time(tx_time)
{} {}
const CWalletTx& GetWalletTx() const { return m_wtx; }
const CTxOut& GetTxOut() const { return m_output; } const CTxOut& GetTxOut() const { return m_output; }
isminetype GetIsMine() const { return m_ismine; } isminetype GetIsMine() const { return m_ismine; }

View file

@ -4685,7 +4685,7 @@ void CWallet::RefreshSingleTxTXOs(const CWalletTx& wtx)
it->second.SetIsMine(ismine); it->second.SetIsMine(ismine);
it->second.SetState(wtx.GetState()); it->second.SetState(wtx.GetState());
} else { } else {
auto [txo_it, _] = m_txos.emplace(outpoint, WalletTXO{wtx, txout, ismine, wtx.GetState(), wtx.IsCoinBase(), wtx.m_from_me, wtx.GetTxTime()}); auto [txo_it, _] = m_txos.emplace(outpoint, WalletTXO{txout, ismine, wtx.GetState(), wtx.IsCoinBase(), wtx.m_from_me, wtx.GetTxTime()});
wtx.m_txos.emplace(i, &txo_it->second); wtx.m_txos.emplace(i, &txo_it->second);
} }
} }