aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/spend.h
diff options
context:
space:
mode:
authorAndrew Chow <achow101-github@achow101.com>2022-01-18 19:08:42 -0500
committerAndrew Chow <achow101-github@achow101.com>2022-03-23 14:32:07 -0400
commit14d04d5ad15ae56df56edee7ca9a202b52037889 (patch)
tree086d701ed87f5b028256d3179e348f0228c468e0 /src/wallet/spend.h
parent0ba4d1916e26e2a5d603edcdb7625463989d25b6 (diff)
downloadbitcoin-14d04d5ad15ae56df56edee7ca9a202b52037889.tar.xz
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.
Diffstat (limited to 'src/wallet/spend.h')
-rw-r--r--src/wallet/spend.h14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/wallet/spend.h b/src/wallet/spend.h
index 029560a16c..141ec833ee 100644
--- a/src/wallet/spend.h
+++ b/src/wallet/spend.h
@@ -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.