mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-08 10:31:50 -05:00
moveonly: move COutput to coinselection.h
This commit is contained in:
parent
42e974e15c
commit
f0821230b8
4 changed files with 63 additions and 63 deletions
|
@ -432,4 +432,9 @@ bool SelectionResult::operator<(SelectionResult other) const
|
||||||
// As this operator is only used in std::min_element, we want the result that has more inputs when waste are equal.
|
// As this operator is only used in std::min_element, we want the result that has more inputs when waste are equal.
|
||||||
return *m_waste < *other.m_waste || (*m_waste == *other.m_waste && m_selected_inputs.size() > other.m_selected_inputs.size());
|
return *m_waste < *other.m_waste || (*m_waste == *other.m_waste && m_selected_inputs.size() > other.m_selected_inputs.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string COutput::ToString() const
|
||||||
|
{
|
||||||
|
return strprintf("COutput(%s, %d, %d) [%s]", outpoint.hash.ToString(), outpoint.n, depth, FormatMoney(txout.nValue));
|
||||||
|
}
|
||||||
} // namespace wallet
|
} // namespace wallet
|
||||||
|
|
|
@ -72,6 +72,64 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class COutput
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/** The outpoint identifying this UTXO */
|
||||||
|
COutPoint outpoint;
|
||||||
|
|
||||||
|
/** The output itself */
|
||||||
|
CTxOut txout;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Depth in block chain.
|
||||||
|
* If > 0: the tx is on chain and has this many confirmations.
|
||||||
|
* If = 0: the tx is waiting confirmation.
|
||||||
|
* If < 0: a conflicting tx is on chain and has this many confirmations. */
|
||||||
|
int depth;
|
||||||
|
|
||||||
|
/** Pre-computed estimated size of this output as a fully-signed input in a transaction. Can be -1 if it could not be calculated */
|
||||||
|
int input_bytes;
|
||||||
|
|
||||||
|
/** Whether we have the private keys to spend this output */
|
||||||
|
bool spendable;
|
||||||
|
|
||||||
|
/** Whether we know how to spend this output, ignoring the lack of keys */
|
||||||
|
bool solvable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether this output is considered safe to spend. Unconfirmed transactions
|
||||||
|
* from outside keys and unconfirmed replacement transactions are considered
|
||||||
|
* unsafe and will not be used to fund new spending transactions.
|
||||||
|
*/
|
||||||
|
bool safe;
|
||||||
|
|
||||||
|
/** The time of the transaction containing this output as determined by CWalletTx::nTimeSmart */
|
||||||
|
int64_t time;
|
||||||
|
|
||||||
|
/** Whether the transaction containing this output is sent from the owning wallet */
|
||||||
|
bool from_me;
|
||||||
|
|
||||||
|
COutput(const COutPoint& outpoint, const CTxOut& txout, int depth, int input_bytes, bool spendable, bool solvable, bool safe, int64_t time, bool from_me)
|
||||||
|
: outpoint(outpoint),
|
||||||
|
txout(txout),
|
||||||
|
depth(depth),
|
||||||
|
input_bytes(input_bytes),
|
||||||
|
spendable(spendable),
|
||||||
|
solvable(solvable),
|
||||||
|
safe(safe),
|
||||||
|
time(time),
|
||||||
|
from_me(from_me)
|
||||||
|
{}
|
||||||
|
|
||||||
|
std::string ToString() const;
|
||||||
|
|
||||||
|
inline CInputCoin GetInputCoin() const
|
||||||
|
{
|
||||||
|
return CInputCoin(outpoint, txout, input_bytes);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/** Parameters for one iteration of Coin Selection. */
|
/** Parameters for one iteration of Coin Selection. */
|
||||||
struct CoinSelectionParams
|
struct CoinSelectionParams
|
||||||
{
|
{
|
||||||
|
|
|
@ -29,11 +29,6 @@ int GetTxSpendSize(const CWallet& wallet, const CWalletTx& wtx, unsigned int out
|
||||||
return CalculateMaximumSignedInputSize(wtx.tx->vout[out], &wallet, use_max_sig);
|
return CalculateMaximumSignedInputSize(wtx.tx->vout[out], &wallet, use_max_sig);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string COutput::ToString() const
|
|
||||||
{
|
|
||||||
return strprintf("COutput(%s, %d, %d) [%s]", outpoint.hash.ToString(), outpoint.n, depth, FormatMoney(txout.nValue));
|
|
||||||
}
|
|
||||||
|
|
||||||
int CalculateMaximumSignedInputSize(const CTxOut& txout, const SigningProvider* provider, bool use_max_sig)
|
int CalculateMaximumSignedInputSize(const CTxOut& txout, const SigningProvider* provider, bool use_max_sig)
|
||||||
{
|
{
|
||||||
CMutableTransaction txn;
|
CMutableTransaction txn;
|
||||||
|
|
|
@ -16,64 +16,6 @@ namespace wallet {
|
||||||
* size of the input spend. This should only be set when watch-only outputs are allowed */
|
* size of the input spend. This should only be set when watch-only outputs are allowed */
|
||||||
int GetTxSpendSize(const CWallet& wallet, const CWalletTx& wtx, unsigned int out, bool use_max_sig = false);
|
int GetTxSpendSize(const CWallet& wallet, const CWalletTx& wtx, unsigned int out, bool use_max_sig = false);
|
||||||
|
|
||||||
class COutput
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/** The outpoint identifying this UTXO */
|
|
||||||
COutPoint outpoint;
|
|
||||||
|
|
||||||
/** The output itself */
|
|
||||||
CTxOut txout;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Depth in block chain.
|
|
||||||
* If > 0: the tx is on chain and has this many confirmations.
|
|
||||||
* If = 0: the tx is waiting confirmation.
|
|
||||||
* If < 0: a conflicting tx is on chain and has this many confirmations. */
|
|
||||||
int depth;
|
|
||||||
|
|
||||||
/** Pre-computed estimated size of this output as a fully-signed input in a transaction. Can be -1 if it could not be calculated */
|
|
||||||
int input_bytes;
|
|
||||||
|
|
||||||
/** Whether we have the private keys to spend this output */
|
|
||||||
bool spendable;
|
|
||||||
|
|
||||||
/** Whether we know how to spend this output, ignoring the lack of keys */
|
|
||||||
bool solvable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Whether this output is considered safe to spend. Unconfirmed transactions
|
|
||||||
* from outside keys and unconfirmed replacement transactions are considered
|
|
||||||
* unsafe and will not be used to fund new spending transactions.
|
|
||||||
*/
|
|
||||||
bool safe;
|
|
||||||
|
|
||||||
/** The time of the transaction containing this output as determined by CWalletTx::nTimeSmart */
|
|
||||||
int64_t time;
|
|
||||||
|
|
||||||
/** Whether the transaction containing this output is sent from the owning wallet */
|
|
||||||
bool from_me;
|
|
||||||
|
|
||||||
COutput(const COutPoint& outpoint, const CTxOut& txout, int depth, int input_bytes, bool spendable, bool solvable, bool safe, int64_t time, bool from_me)
|
|
||||||
: outpoint(outpoint),
|
|
||||||
txout(txout),
|
|
||||||
depth(depth),
|
|
||||||
input_bytes(input_bytes),
|
|
||||||
spendable(spendable),
|
|
||||||
solvable(solvable),
|
|
||||||
safe(safe),
|
|
||||||
time(time),
|
|
||||||
from_me(from_me)
|
|
||||||
{}
|
|
||||||
|
|
||||||
std::string ToString() const;
|
|
||||||
|
|
||||||
inline CInputCoin GetInputCoin() const
|
|
||||||
{
|
|
||||||
return CInputCoin(outpoint, txout, input_bytes);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
//Get the marginal bytes of spending the specified output
|
//Get the marginal bytes of spending the specified output
|
||||||
int CalculateMaximumSignedInputSize(const CTxOut& txout, const CWallet* pwallet, bool use_max_sig = false);
|
int CalculateMaximumSignedInputSize(const CTxOut& txout, const CWallet* pwallet, bool use_max_sig = false);
|
||||||
int CalculateMaximumSignedInputSize(const CTxOut& txout, const SigningProvider* pwallet, bool use_max_sig = false);
|
int CalculateMaximumSignedInputSize(const CTxOut& txout, const SigningProvider* pwallet, bool use_max_sig = false);
|
||||||
|
|
Loading…
Add table
Reference in a new issue