![]() |
Bitcoin Core 22.99.0
P2P Digital Currency
|
#include <consensus/amount.h>#include <policy/feerate.h>#include <primitives/transaction.h>#include <random.h>#include <optional>Go to the source code of this file.
Classes | |
| class | CInputCoin |
| A UTXO under consideration for use in funding a new transaction. More... | |
| struct | CoinSelectionParams |
| Parameters for one iteration of Coin Selection. More... | |
| struct | CoinEligibilityFilter |
| Parameters for filtering which OutputGroups we may use in coin selection. More... | |
| struct | OutputGroup |
| A group of UTXOs paid to the same output script. More... | |
Functions | |
| CAmount | GetSelectionWaste (const std::set< CInputCoin > &inputs, CAmount change_cost, CAmount target, bool use_effective_value=true) |
| Compute the waste for this result given the cost of change and the opportunity cost of spending these inputs now vs in the future. More... | |
| bool | SelectCoinsBnB (std::vector< OutputGroup > &utxo_pool, const CAmount &selection_target, const CAmount &cost_of_change, std::set< CInputCoin > &out_set, CAmount &value_ret) |
| std::optional< std::pair< std::set< CInputCoin >, CAmount > > | SelectCoinsSRD (const std::vector< OutputGroup > &utxo_pool, CAmount target_value) |
| Select coins by Single Random Draw. More... | |
| bool | KnapsackSolver (const CAmount &nTargetValue, std::vector< OutputGroup > &groups, std::set< CInputCoin > &setCoinsRet, CAmount &nValueRet) |
Variables | |
| static constexpr CAmount | MIN_CHANGE {COIN / 100} |
| target minimum change amount More... | |
| static const CAmount | MIN_FINAL_CHANGE = MIN_CHANGE/2 |
| final minimum change amount after paying for fees More... | |
| CAmount GetSelectionWaste | ( | const std::set< CInputCoin > & | inputs, |
| CAmount | change_cost, | ||
| CAmount | target, | ||
| bool | use_effective_value = true |
||
| ) |
Compute the waste for this result given the cost of change and the opportunity cost of spending these inputs now vs in the future.
If change exists, waste = change_cost + inputs * (effective_feerate - long_term_feerate) If no change, waste = excess + inputs * (effective_feerate - long_term_feerate) where excess = selected_effective_value - target change_cost = effective_feerate * change_output_size + long_term_feerate * change_spend_size
| [in] | inputs | The selected inputs |
| [in] | change_cost | The cost of creating change and spending it in the future. Only used if there is change, in which case it must be positive. Must be 0 if there is no change. |
| [in] | target | The amount targeted by the coin selection algorithm. |
| [in] | use_effective_value | Whether to use the input's effective value (when true) or the real value (when false). |
Definition at line 372 of file coinselection.cpp.
| bool KnapsackSolver | ( | const CAmount & | nTargetValue, |
| std::vector< OutputGroup > & | groups, | ||
| std::set< CInputCoin > & | setCoinsRet, | ||
| CAmount & | nValueRet | ||
| ) |
Definition at line 244 of file coinselection.cpp.
| bool SelectCoinsBnB | ( | std::vector< OutputGroup > & | utxo_pool, |
| const CAmount & | selection_target, | ||
| const CAmount & | cost_of_change, | ||
| std::set< CInputCoin > & | out_set, | ||
| CAmount & | value_ret | ||
| ) |
Definition at line 67 of file coinselection.cpp.
| std::optional< std::pair< std::set< CInputCoin >, CAmount > > SelectCoinsSRD | ( | const std::vector< OutputGroup > & | utxo_pool, |
| CAmount | target_value | ||
| ) |
Select coins by Single Random Draw.
OutputGroups are selected randomly from the eligible outputs until the target is satisfied
| [in] | utxo_pool | The positive effective value OutputGroups eligible for selection |
| [in] | target_value | The target value to select for |
Definition at line 174 of file coinselection.cpp.
target minimum change amount
Definition at line 16 of file coinselection.h.
|
static |
final minimum change amount after paying for fees
Definition at line 18 of file coinselection.h.