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

@@ -19,10 +19,11 @@ int GetTxSpendSize(const CWallet& wallet, const CWalletTx& wtx, unsigned int out
class COutput
{
public:
const CWalletTx *tx;
/** The outpoint identifying this UTXO */
COutPoint outpoint;
/** Index in tx->vout. */
int i;
/** The output itself */
CTxOut txout;
/**
* Depth in block chain.
@@ -54,8 +55,8 @@ public:
bool from_me;
COutput(const CWallet& wallet, const CWalletTx& wtx, int iIn, int depth, int input_bytes, bool spendable, bool solvable, bool safe, int64_t time, bool from_me)
: tx(&wtx),
i(iIn),
: outpoint(COutPoint(wtx.GetHash(), iIn)),
txout(wtx.tx->vout.at(iIn)),
depth(depth),
input_bytes(input_bytes),
spendable(spendable),
@@ -69,7 +70,7 @@ public:
inline CInputCoin GetInputCoin() const
{
return CInputCoin(tx->tx, i, input_bytes);
return CInputCoin(outpoint, txout, input_bytes);
}
};
@@ -100,6 +101,7 @@ CAmount GetAvailableBalance(const CWallet& wallet, const CCoinControl* coinContr
* Find non-change parent output.
*/
const CTxOut& FindNonChangeParentOutput(const CWallet& wallet, const CTransaction& tx, int output) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet);
const CTxOut& FindNonChangeParentOutput(const CWallet& wallet, const COutPoint& outpoint) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet);
/**
* Return list of available coins and locked coins grouped by non-change output address.