5 #ifndef BITCOIN_WALLET_COINSELECTION_H 6 #define BITCOIN_WALLET_COINSELECTION_H 24 throw std::invalid_argument(
"tx should not be null");
25 if (i >= tx->vout.size())
26 throw std::out_of_range(
"The output index is out of range");
164 void Insert(
const CInputCoin& output,
int depth,
bool from_me,
size_t ancestors,
size_t descendants,
bool positive_only);
169 bool SelectCoinsBnB(std::vector<OutputGroup>& utxo_pool,
const CAmount& selection_target,
const CAmount& cost_of_change, std::set<CInputCoin>& out_set,
CAmount& value_ret);
172 bool KnapsackSolver(
const CAmount& nTargetValue, std::vector<OutputGroup>& groups, std::set<CInputCoin>& setCoinsRet,
CAmount& nValueRet);
174 #endif // BITCOIN_WALLET_COINSELECTION_H std::shared_ptr< const CTransaction > CTransactionRef
bool SelectCoinsBnB(std::vector< OutputGroup > &utxo_pool, const CAmount &selection_target, const CAmount &cost_of_change, std::set< CInputCoin > &out_set, CAmount &value_ret)
CoinSelectionParams(size_t change_output_size, size_t change_spend_size, CFeeRate effective_feerate, CFeeRate long_term_feerate, CFeeRate discard_feerate, size_t tx_noinputs_size, bool avoid_partial)
CFeeRate m_effective_feerate
The targeted feerate of the transaction being built.
bool m_from_me
Whether the UTXOs were sent by the wallet to itself.
const int conf_theirs
Minimum number of confirmations for outputs received from a different wallet.
bool KnapsackSolver(const CAmount &nTargetValue, std::vector< OutputGroup > &groups, std::set< CInputCoin > &setCoinsRet, CAmount &nValueRet)
size_t change_output_size
Size of a change output in bytes, determined by the output type.
size_t m_descendants
The maximum count of descendants of a single UTXO in this output group.
void Insert(const CInputCoin &output, int depth, bool from_me, size_t ancestors, size_t descendants, bool positive_only)
static const CAmount COIN
static constexpr CAmount MIN_CHANGE
target minimum change amount
const uint64_t max_descendants
Maximum number of descendants that a single UTXO in the OutputGroup may have.
CoinEligibilityFilter(int conf_mine, int conf_theirs, uint64_t max_ancestors)
CoinEligibilityFilter(int conf_mine, int conf_theirs, uint64_t max_ancestors, uint64_t max_descendants, bool include_partial)
int64_t CAmount
Amount in satoshis (Can be negative)
size_t change_spend_size
Size of the input to spend a change output in virtual bytes.
CAmount fee
The fee to spend these UTXOs at the effective feerate.
Parameters for filtering which OutputGroups we may use in coin selection.
const uint64_t max_ancestors
Maximum number of unconfirmed ancestors aggregated across all UTXOs in an OutputGroup.
bool m_avoid_partial_spends
When true, always spend all (up to OUTPUT_GROUP_MAX_ENTRIES) or none of the outputs associated with t...
CFeeRate m_effective_feerate
The target feerate of the transaction we're trying to build.
A group of UTXOs paid to the same output script.
std::vector< CInputCoin > m_outputs
The list of UTXOs contained in this output group.
CAmount long_term_fee
The fee to spend these UTXOs at the long term feerate.
bool m_subtract_fee_outputs
Indicate that we are subtracting the fee from outputs.
CAmount m_change_fee
Cost of creating the change output.
An output of a transaction.
An outpoint - a combination of a transaction hash and an index n into its vout.
CAmount m_value
The total value of the UTXOs in sum.
static const CAmount MIN_FINAL_CHANGE
final minimum change amount after paying for fees
size_t tx_noinputs_size
Size of the transaction before coin selection, consisting of the header and recipient output(s)...
size_t m_ancestors
The aggregated count of unconfirmed ancestors of all UTXOs in this group.
int m_depth
The minimum number of confirmations the UTXOs in the group have.
const bool m_include_partial_groups
When avoid_reuse=true and there are full groups (OUTPUT_GROUP_MAX_ENTRIES), whether or not to use any...
OutputGroup(const CoinSelectionParams ¶ms)
CoinEligibilityFilter(int conf_mine, int conf_theirs, uint64_t max_ancestors, uint64_t max_descendants)
CAmount m_cost_of_change
Cost of creating the change output + cost of spending the change output in the future.
CFeeRate m_discard_feerate
If the cost to spend a change output at the discard feerate exceeds its value, drop it to fees...
bool EligibleForSpending(const CoinEligibilityFilter &eligibility_filter) const
const int conf_mine
Minimum number of confirmations for outputs that we sent to ourselves.
CAmount effective_value
The value of the UTXOs after deducting the cost of spending them at the effective feerate...
CAmount GetSelectionAmount() const
Parameters for one iteration of Coin Selection.
Fee rate in satoshis per kilobyte: CAmount / kB.
bool m_subtract_fee_outputs
Indicate that we are subtracting the fee from outputs.
CFeeRate m_long_term_feerate
The feerate estimate used to estimate an upper bound on what should be sufficient to spend the change...
CFeeRate m_long_term_feerate
The feerate for spending a created change output eventually (i.e.