5 #ifndef BITCOIN_WALLET_COINSELECTION_H
6 #define BITCOIN_WALLET_COINSELECTION_H
23 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");
71 uint64_t max_ancestors_)
75 uint64_t max_ancestors_, uint64_t max_descendants_)
93 int depth,
size_t ancestors,
size_t descendants)
97 size_t ancestors,
size_t descendants)
99 Insert(output, depth, from_me, ancestors, descendants);
102 size_t ancestors,
size_t descendants);
115 const Amount &target_value,
const Amount &cost_of_change,
116 std::set<CInputCoin> &out_set,
Amount &value_ret,
117 const Amount not_input_fees);
121 std::set<CInputCoin> &setCoinsRet,
Amount &nValueRet);
static constexpr Amount COIN
Fee rate in satoshis per kilobyte: Amount / kB.
An outpoint - a combination of a transaction hash and an index n into its vout.
An output of a transaction.
static constexpr Amount MIN_CHANGE
target minimum change amount
static const Amount MIN_FINAL_CHANGE
final minimum change amount after paying for fees
bool KnapsackSolver(const Amount nTargetValue, std::vector< OutputGroup > &groups, std::set< CInputCoin > &setCoinsRet, Amount &nValueRet)
bool SelectCoinsBnB(std::vector< OutputGroup > &utxo_pool, const Amount &target_value, const Amount &cost_of_change, std::set< CInputCoin > &out_set, Amount &value_ret, const Amount not_input_fees)
This is the Branch and Bound Coin Selection algorithm designed by Murch.
std::shared_ptr< const CTransaction > CTransactionRef
static constexpr Amount zero()
CoinEligibilityFilter(int conf_mine_, int conf_theirs_, uint64_t max_ancestors_)
const uint64_t max_ancestors
const uint64_t max_descendants
CoinEligibilityFilter(int conf_mine_, int conf_theirs_, uint64_t max_ancestors_, uint64_t max_descendants_)
std::vector< CInputCoin > m_outputs
std::vector< CInputCoin >::iterator Discard(const CInputCoin &output)
void SetFees(const CFeeRate effective_feerate, const CFeeRate long_term_feerate)
Update the OutputGroup's fee, long_term_fee, and effective_value based on the given feerates.
OutputGroup(const CInputCoin &output, int depth, bool from_me, size_t ancestors, size_t descendants)
OutputGroup GetPositiveOnlyGroup()
OutputGroup(std::vector< CInputCoin > &&outputs, bool from_me, Amount value, int depth, size_t ancestors, size_t descendants)
bool EligibleForSpending(const CoinEligibilityFilter &eligibility_filter) const
void Insert(const CInputCoin &output, int depth, bool from_me, size_t ancestors, size_t descendants)