wallet: Replace CWalletTx in COutput with COutPoint and CTxOut

Instead of having a pointer to the CWalletTx in COutput, we can just
store the COutPoint and the CTxOut as those are the only things we need
from the CWalletTx. Other things CWalletTx used to provide were time and
fIsFromMe but these are also being stored by COutput.
This commit is contained in:
Andrew Chow
2022-01-18 19:08:42 -05:00
parent 0ba4d1916e
commit 14d04d5ad1
6 changed files with 30 additions and 22 deletions

View File

@@ -115,10 +115,10 @@ WalletTxOut MakeWalletTxOut(const CWallet& wallet,
const COutput& output) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet)
{
WalletTxOut result;
result.txout = output.tx->tx->vout[output.i];
result.txout = output.txout;
result.time = output.time;
result.depth_in_main_chain = output.depth;
result.is_spent = wallet.IsSpent(output.tx->GetHash(), output.i);
result.is_spent = wallet.IsSpent(output.outpoint.hash, output.outpoint.n);
return result;
}
@@ -430,7 +430,7 @@ public:
for (const auto& entry : ListCoins(*m_wallet)) {
auto& group = result[entry.first];
for (const auto& coin : entry.second) {
group.emplace_back(COutPoint(coin.tx->GetHash(), coin.i),
group.emplace_back(coin.outpoint,
MakeWalletTxOut(*m_wallet, coin));
}
}