Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/coinselection.h
Show First 20 Lines • Show All 69 Lines • ▼ Show 20 Lines | CoinEligibilityFilter(int conf_mine_, int conf_theirs_, | ||||
: conf_mine(conf_mine_), conf_theirs(conf_theirs_), | : conf_mine(conf_mine_), conf_theirs(conf_theirs_), | ||||
max_ancestors(max_ancestors_), max_descendants(max_ancestors_) {} | max_ancestors(max_ancestors_), max_descendants(max_ancestors_) {} | ||||
CoinEligibilityFilter(int conf_mine_, int conf_theirs_, | CoinEligibilityFilter(int conf_mine_, int conf_theirs_, | ||||
uint64_t max_ancestors_, uint64_t max_descendants_) | uint64_t max_ancestors_, uint64_t max_descendants_) | ||||
: conf_mine(conf_mine_), conf_theirs(conf_theirs_), | : conf_mine(conf_mine_), conf_theirs(conf_theirs_), | ||||
max_ancestors(max_ancestors_), max_descendants(max_descendants_) {} | max_ancestors(max_ancestors_), max_descendants(max_descendants_) {} | ||||
}; | }; | ||||
struct OutputGroup { | |||||
std::vector<CInputCoin> m_outputs; | |||||
bool m_from_me{true}; | |||||
Amount m_value = Amount::zero(); | |||||
int m_depth{999}; | |||||
size_t m_ancestors{0}; | |||||
size_t m_descendants{0}; | |||||
Amount effective_value = Amount::zero(); | |||||
Amount fee = Amount::zero(); | |||||
Amount long_term_fee = Amount::zero(); | |||||
OutputGroup() {} | |||||
OutputGroup(std::vector<CInputCoin> &&outputs, bool from_me, Amount value, | |||||
int depth, size_t ancestors, size_t descendants) | |||||
: m_outputs(std::move(outputs)), m_from_me(from_me), m_value(value), | |||||
m_depth(depth), m_ancestors(ancestors), m_descendants(descendants) {} | |||||
OutputGroup(const CInputCoin &output, int depth, bool from_me, | |||||
size_t ancestors, size_t descendants) | |||||
: OutputGroup() { | |||||
Insert(output, depth, from_me, ancestors, descendants); | |||||
} | |||||
void Insert(const CInputCoin &output, int depth, bool from_me, | |||||
size_t ancestors, size_t descendants); | |||||
std::vector<CInputCoin>::iterator Discard(const CInputCoin &output); | |||||
bool | |||||
EligibleForSpending(const CoinEligibilityFilter &eligibility_filter) const; | |||||
}; | |||||
bool SelectCoinsBnB(std::vector<CInputCoin> &utxo_pool, | bool SelectCoinsBnB(std::vector<CInputCoin> &utxo_pool, | ||||
const Amount &target_value, const Amount &cost_of_change, | const Amount &target_value, const Amount &cost_of_change, | ||||
std::set<CInputCoin> &out_set, Amount &value_ret, | std::set<CInputCoin> &out_set, Amount &value_ret, | ||||
const Amount not_input_fees); | const Amount not_input_fees); | ||||
// Original coin selection algorithm as a fallback | // Original coin selection algorithm as a fallback | ||||
bool KnapsackSolver(const Amount nTargetValue, std::vector<CInputCoin> &vCoins, | bool KnapsackSolver(const Amount nTargetValue, std::vector<CInputCoin> &vCoins, | ||||
std::set<CInputCoin> &setCoinsRet, Amount &nValueRet); | std::set<CInputCoin> &setCoinsRet, Amount &nValueRet); | ||||
#endif // BITCOIN_WALLET_COINSELECTION_H | #endif // BITCOIN_WALLET_COINSELECTION_H |