Skip to content

Commit f082123

Browse files
committed
moveonly: move COutput to coinselection.h
1 parent 42e974e commit f082123

File tree

4 files changed

+63
-63
lines changed

4 files changed

+63
-63
lines changed

src/wallet/coinselection.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,4 +432,9 @@ bool SelectionResult::operator<(SelectionResult other) const
432432
// As this operator is only used in std::min_element, we want the result that has more inputs when waste are equal.
433433
return *m_waste < *other.m_waste || (*m_waste == *other.m_waste && m_selected_inputs.size() > other.m_selected_inputs.size());
434434
}
435+
436+
std::string COutput::ToString() const
437+
{
438+
return strprintf("COutput(%s, %d, %d) [%s]", outpoint.hash.ToString(), outpoint.n, depth, FormatMoney(txout.nValue));
439+
}
435440
} // namespace wallet

src/wallet/coinselection.h

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,64 @@ class CInputCoin {
7272
}
7373
};
7474

75+
class COutput
76+
{
77+
public:
78+
/** The outpoint identifying this UTXO */
79+
COutPoint outpoint;
80+
81+
/** The output itself */
82+
CTxOut txout;
83+
84+
/**
85+
* Depth in block chain.
86+
* If > 0: the tx is on chain and has this many confirmations.
87+
* If = 0: the tx is waiting confirmation.
88+
* If < 0: a conflicting tx is on chain and has this many confirmations. */
89+
int depth;
90+
91+
/** Pre-computed estimated size of this output as a fully-signed input in a transaction. Can be -1 if it could not be calculated */
92+
int input_bytes;
93+
94+
/** Whether we have the private keys to spend this output */
95+
bool spendable;
96+
97+
/** Whether we know how to spend this output, ignoring the lack of keys */
98+
bool solvable;
99+
100+
/**
101+
* Whether this output is considered safe to spend. Unconfirmed transactions
102+
* from outside keys and unconfirmed replacement transactions are considered
103+
* unsafe and will not be used to fund new spending transactions.
104+
*/
105+
bool safe;
106+
107+
/** The time of the transaction containing this output as determined by CWalletTx::nTimeSmart */
108+
int64_t time;
109+
110+
/** Whether the transaction containing this output is sent from the owning wallet */
111+
bool from_me;
112+
113+
COutput(const COutPoint& outpoint, const CTxOut& txout, int depth, int input_bytes, bool spendable, bool solvable, bool safe, int64_t time, bool from_me)
114+
: outpoint(outpoint),
115+
txout(txout),
116+
depth(depth),
117+
input_bytes(input_bytes),
118+
spendable(spendable),
119+
solvable(solvable),
120+
safe(safe),
121+
time(time),
122+
from_me(from_me)
123+
{}
124+
125+
std::string ToString() const;
126+
127+
inline CInputCoin GetInputCoin() const
128+
{
129+
return CInputCoin(outpoint, txout, input_bytes);
130+
}
131+
};
132+
75133
/** Parameters for one iteration of Coin Selection. */
76134
struct CoinSelectionParams
77135
{

src/wallet/spend.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,6 @@ int GetTxSpendSize(const CWallet& wallet, const CWalletTx& wtx, unsigned int out
2929
return CalculateMaximumSignedInputSize(wtx.tx->vout[out], &wallet, use_max_sig);
3030
}
3131

32-
std::string COutput::ToString() const
33-
{
34-
return strprintf("COutput(%s, %d, %d) [%s]", outpoint.hash.ToString(), outpoint.n, depth, FormatMoney(txout.nValue));
35-
}
36-
3732
int CalculateMaximumSignedInputSize(const CTxOut& txout, const SigningProvider* provider, bool use_max_sig)
3833
{
3934
CMutableTransaction txn;

src/wallet/spend.h

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -16,64 +16,6 @@ namespace wallet {
1616
* size of the input spend. This should only be set when watch-only outputs are allowed */
1717
int GetTxSpendSize(const CWallet& wallet, const CWalletTx& wtx, unsigned int out, bool use_max_sig = false);
1818

19-
class COutput
20-
{
21-
public:
22-
/** The outpoint identifying this UTXO */
23-
COutPoint outpoint;
24-
25-
/** The output itself */
26-
CTxOut txout;
27-
28-
/**
29-
* Depth in block chain.
30-
* If > 0: the tx is on chain and has this many confirmations.
31-
* If = 0: the tx is waiting confirmation.
32-
* If < 0: a conflicting tx is on chain and has this many confirmations. */
33-
int depth;
34-
35-
/** Pre-computed estimated size of this output as a fully-signed input in a transaction. Can be -1 if it could not be calculated */
36-
int input_bytes;
37-
38-
/** Whether we have the private keys to spend this output */
39-
bool spendable;
40-
41-
/** Whether we know how to spend this output, ignoring the lack of keys */
42-
bool solvable;
43-
44-
/**
45-
* Whether this output is considered safe to spend. Unconfirmed transactions
46-
* from outside keys and unconfirmed replacement transactions are considered
47-
* unsafe and will not be used to fund new spending transactions.
48-
*/
49-
bool safe;
50-
51-
/** The time of the transaction containing this output as determined by CWalletTx::nTimeSmart */
52-
int64_t time;
53-
54-
/** Whether the transaction containing this output is sent from the owning wallet */
55-
bool from_me;
56-
57-
COutput(const COutPoint& outpoint, const CTxOut& txout, int depth, int input_bytes, bool spendable, bool solvable, bool safe, int64_t time, bool from_me)
58-
: outpoint(outpoint),
59-
txout(txout),
60-
depth(depth),
61-
input_bytes(input_bytes),
62-
spendable(spendable),
63-
solvable(solvable),
64-
safe(safe),
65-
time(time),
66-
from_me(from_me)
67-
{}
68-
69-
std::string ToString() const;
70-
71-
inline CInputCoin GetInputCoin() const
72-
{
73-
return CInputCoin(outpoint, txout, input_bytes);
74-
}
75-
};
76-
7719
//Get the marginal bytes of spending the specified output
7820
int CalculateMaximumSignedInputSize(const CTxOut& txout, const CWallet* pwallet, bool use_max_sig = false);
7921
int CalculateMaximumSignedInputSize(const CTxOut& txout, const SigningProvider* pwallet, bool use_max_sig = false);

0 commit comments

Comments
 (0)