diff --git a/src/wallet/spend.cpp b/src/wallet/spend.cpp index 089afd15d02..99ef293874c 100644 --- a/src/wallet/spend.cpp +++ b/src/wallet/spend.cpp @@ -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) std::unordered_map, SaltedTxidHasher> tx_safe_cache; for (const auto& [outpoint, txo] : wallet.GetTXOs()) { - const CWalletTx& wtx = txo.GetWalletTx(); const CTxOut& output = txo.GetTxOut(); if (tx_safe_cache.contains(outpoint.hash) && !tx_safe_cache.at(outpoint.hash).first) { @@ -347,20 +346,21 @@ CoinsResult AvailableCoins(const CWallet& wallet, continue; } - if (wallet.IsTxImmatureCoinBase(wtx) && !params.include_immature_coinbase) + if (wallet.IsTXOInImmatureCoinBase(txo) && !params.include_immature_coinbase) continue; isminetype mine = wallet.IsMine(output); assert(mine != ISMINE_NO); - int nDepth = wallet.GetTxDepthInMainChain(wtx); + int nDepth = wallet.GetTxStateDepthInMainChain(txo.GetState()); if (nDepth < 0) continue; // Perform tx level checks if we haven't already come across outputs from this tx before. if (!tx_safe_cache.contains(outpoint.hash)) { 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 // 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; } - bool tx_from_me = CheckIsFromMeMap(wtx.m_from_me, ISMINE_ALL); + bool tx_from_me = CheckIsFromMeMap(txo.GetTxFromMe(), ISMINE_ALL); std::unique_ptr provider = wallet.GetSolvingProvider(output.scriptPubKey); diff --git a/src/wallet/transaction.h b/src/wallet/transaction.h index 584ab9ec19c..f6f3fee95e7 100644 --- a/src/wallet/transaction.h +++ b/src/wallet/transaction.h @@ -385,7 +385,6 @@ struct WalletTxOrderComparator { class WalletTXO { private: - const CWalletTx& m_wtx; const CTxOut& m_output; isminetype m_ismine; TxState m_tx_state; @@ -394,9 +393,8 @@ private: int64_t m_tx_time; public: - WalletTXO(const CWalletTx& wtx, const CTxOut& output, const isminetype ismine, const TxState& state, bool coinbase, const std::map& tx_from_me, int64_t tx_time) - : m_wtx(wtx), - m_output(output), + WalletTXO(const CTxOut& output, const isminetype ismine, const TxState& state, bool coinbase, const std::map& tx_from_me, int64_t tx_time) + : m_output(output), m_ismine(ismine), m_tx_state(state), m_tx_coinbase(coinbase), @@ -404,8 +402,6 @@ public: m_tx_time(tx_time) {} - const CWalletTx& GetWalletTx() const { return m_wtx; } - const CTxOut& GetTxOut() const { return m_output; } isminetype GetIsMine() const { return m_ismine; } diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 40bf097dbc8..acd527d63c2 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -4685,7 +4685,7 @@ void CWallet::RefreshSingleTxTXOs(const CWalletTx& wtx) it->second.SetIsMine(ismine); it->second.SetState(wtx.GetState()); } 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); } }