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");
67 CoinEligibilityFilter(
int conf_mine,
int conf_theirs, uint64_t max_ancestors) : conf_mine(conf_mine), conf_theirs(conf_theirs), max_ancestors(max_ancestors), max_descendants(max_ancestors) {}
68 CoinEligibilityFilter(
int conf_mine,
int conf_theirs, uint64_t max_ancestors, uint64_t max_descendants) : conf_mine(conf_mine), conf_theirs(conf_theirs), max_ancestors(max_ancestors), max_descendants(max_descendants) {}
77 size_t m_ancestors{0};
78 size_t m_descendants{0};
84 OutputGroup(std::vector<CInputCoin>&& outputs,
bool from_me,
CAmount value,
int depth,
size_t ancestors,
size_t descendants)
85 : m_outputs(
std::move(outputs))
89 , m_ancestors(ancestors)
90 , m_descendants(descendants)
93 Insert(output, depth, from_me, ancestors, descendants);
95 void Insert(
const CInputCoin& output,
int depth,
bool from_me,
size_t ancestors,
size_t descendants);
96 std::vector<CInputCoin>::iterator Discard(
const CInputCoin& output);
100 void SetFees(
const CFeeRate effective_feerate,
const CFeeRate long_term_feerate);
107 bool KnapsackSolver(
const CAmount& nTargetValue, std::vector<OutputGroup>& groups, std::set<CInputCoin>& setCoinsRet,
CAmount& nValueRet);
109 #endif // BITCOIN_WALLET_COINSELECTION_H std::shared_ptr< const CTransaction > CTransactionRef
bool SelectCoinsBnB(std::vector< OutputGroup > &utxo_pool, const CAmount &target_value, const CAmount &cost_of_change, std::set< CInputCoin > &out_set, CAmount &value_ret, CAmount not_input_fees)
bool KnapsackSolver(const CAmount &nTargetValue, std::vector< OutputGroup > &groups, std::set< CInputCoin > &setCoinsRet, CAmount &nValueRet)
static const CAmount COIN
static constexpr CAmount MIN_CHANGE
target minimum change amount
const uint64_t max_descendants
CoinEligibilityFilter(int conf_mine, int conf_theirs, uint64_t max_ancestors)
int64_t CAmount
Amount in satoshis (Can be negative)
OutputGroup(std::vector< CInputCoin > &&outputs, bool from_me, CAmount value, int depth, size_t ancestors, size_t descendants)
const uint64_t max_ancestors
std::vector< CInputCoin > m_outputs
An output of a transaction.
An outpoint - a combination of a transaction hash and an index n into its vout.
static const CAmount MIN_FINAL_CHANGE
final minimum change amount after paying for fees
CoinEligibilityFilter(int conf_mine, int conf_theirs, uint64_t max_ancestors, uint64_t max_descendants)
OutputGroup(const CInputCoin &output, int depth, bool from_me, size_t ancestors, size_t descendants)
Fee rate in satoshis per kilobyte: CAmount / kB.