wallet::SelectionResult

The set of inputs chosen by a coin selection algorithm, along with its metrics.

Synopsis

Declared in <wallet/coinselection.h>

struct SelectionResult;

Member Functions

NameDescription
SelectionResult [constructor]Constructors
AddInput Add all outputs of a group to the selection.
AddInputs Add a set of inputs to the selection.
Clear Remove all selected inputs and reset the result.
GetAlgo Return the algorithm that produced this result.
GetAlgoCompleted Get m_algo_completed
GetChange Get the amount for the change output after paying needed fees.
GetInputSet Get m_selected_inputs
GetSelectedEffectiveValue Return the sum of the effective values of the selected inputs.
GetSelectedValue Get the sum of the input values
GetSelectionsEvaluated Get selections_evaluated
GetShuffledInputVector Get the vector of COutputs that will be used to fill in a CTransaction's vin
GetTarget Return the selection target.
GetTotalBumpFees Return the total ancestor bump fees of the selected inputs.
GetWaste Return the previously computed waste for this result.
GetWeight Return the total weight of the selected inputs.
Merge Combines the
RecalculateWaste Calculates and stores 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) - bump_fee_group_discount If no change, waste = excess + inputs * (effective_feerate - long_term_feerate) - bump_fee_group_discount where excess = selected_effective_value - target change_cost = effective_feerate * change_output_size + long_term_feerate * change_spend_size
SetAlgoCompleted Tracks that algorithm was able to exhaustively search the entire combination space before hitting limit of tries
SetBumpFeeDiscount How much individual inputs overestimated the bump fees for shared ancestries
SetSelectionsEvaluated Record the number of selections that were evaluated
operator< Order results by preference for choosing between selections.

Non-Member Functions

NameDescription
AttemptSelectionAttempt to find a valid input set that preserves privacy by not mixing OutputTypes. ChooseSelectionResult() will be called on each OutputType individually and the best the solution (according to the waste metric) will be chosen. If a valid input cannot be found from any single OutputType, fallback to running ChooseSelectionResult() over all available coins.
AutomaticCoinSelectionSelect a set of coins such that nTargetValue is met; never select unconfirmed coins if they are not ours
ChooseSelectionResultAttempt to find a valid input set that meets the provided eligibility filter and target. Multiple coin selection algorithms will be run and the input set that produces the least waste (according to the waste metric) will be chosen.
CoinGrinderSelect coins using the CoinGrinder deterministic search algorithm.
KnapsackSolverSelect coins using the original Knapsack approximation, used as a fallback.
SelectCoinsSelect all coins from coin_control, and if coin_control 'm_allow_other_inputs=true', call 'AutomaticCoinSelection' to select a set of coins such that nTargetValue - pre_set_inputs.total_amount is met.
SelectCoinsBnBSelect coins using the Branch and Bound algorithm to find a changeless solution.
SelectCoinsSRDSelect coins by Single Random Draw (SRD). SRD selects eligible OutputGroups from a shuffled ordering until the effective value of the input set suffices to create the recipient outputs and a change output with an amount of at least CHANGE_LOWER. While the maximum selection weight is exceeded during selection, the OutputGroup with the lowest effective value is dropped from the selection before additional OutputGroups are selected. Due to this greedy approach, SRD can fail to discover possible solutions in pathological cases.