[#wallet-SelectionResult]
= xref:wallet.adoc[wallet]::SelectionResult
:relfileprefix: ../
:mrdocs:

The set of inputs chosen by a coin selection algorithm, along with its metrics&period;

== Synopsis

Declared in `&lt;wallet&sol;coinselection&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
struct SelectionResult;
----

== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:wallet/SelectionResult/2constructor-0e.adoc[`SelectionResult`]         [.small]#[constructor]#
| Constructors
| xref:wallet/SelectionResult/AddInput.adoc[`AddInput`] 
| Add all outputs of a group to the selection&period;
| xref:wallet/SelectionResult/AddInputs.adoc[`AddInputs`] 
| Add a set of inputs to the selection&period;
| xref:wallet/SelectionResult/Clear.adoc[`Clear`] 
| Remove all selected inputs and reset the result&period;
| xref:wallet/SelectionResult/GetAlgo.adoc[`GetAlgo`] 
| Return the algorithm that produced this result&period;
| xref:wallet/SelectionResult/GetAlgoCompleted.adoc[`GetAlgoCompleted`] 
| Get m&lowbar;algo&lowbar;completed
| xref:wallet/SelectionResult/GetChange.adoc[`GetChange`] 
| Get the amount for the change output after paying needed fees&period;
| xref:wallet/SelectionResult/GetInputSet.adoc[`GetInputSet`] 
| Get m&lowbar;selected&lowbar;inputs
| xref:wallet/SelectionResult/GetSelectedEffectiveValue.adoc[`GetSelectedEffectiveValue`] 
| Return the sum of the effective values of the selected inputs&period;
| xref:wallet/SelectionResult/GetSelectedValue.adoc[`GetSelectedValue`] 
| Get the sum of the input values
| xref:wallet/SelectionResult/GetSelectionsEvaluated.adoc[`GetSelectionsEvaluated`] 
| Get selections&lowbar;evaluated
| xref:wallet/SelectionResult/GetShuffledInputVector.adoc[`GetShuffledInputVector`] 
| Get the vector of COutputs that will be used to fill in a CTransaction&apos;s vin
| xref:wallet/SelectionResult/GetTarget.adoc[`GetTarget`] 
| Return the selection target&period;
| xref:wallet/SelectionResult/GetTotalBumpFees.adoc[`GetTotalBumpFees`] 
| Return the total ancestor bump fees of the selected inputs&period;
| xref:wallet/SelectionResult/GetWaste.adoc[`GetWaste`] 
| Return the previously computed waste for this result&period;
| xref:wallet/SelectionResult/GetWeight.adoc[`GetWeight`] 
| Return the total weight of the selected inputs&period;
| xref:wallet/SelectionResult/Merge.adoc[`Merge`] 
| Combines the
| xref:wallet/SelectionResult/RecalculateWaste.adoc[`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&period; If change exists, waste &equals; change&lowbar;cost &plus; inputs &ast; (effective&lowbar;feerate &hyphen; long&lowbar;term&lowbar;feerate) &hyphen; bump&lowbar;fee&lowbar;group&lowbar;discount If no change, waste &equals; excess &plus; inputs &ast; (effective&lowbar;feerate &hyphen; long&lowbar;term&lowbar;feerate) &hyphen; bump&lowbar;fee&lowbar;group&lowbar;discount where excess &equals; selected&lowbar;effective&lowbar;value &hyphen; target change&lowbar;cost &equals; effective&lowbar;feerate &ast; change&lowbar;output&lowbar;size &plus; long&lowbar;term&lowbar;feerate &ast; change&lowbar;spend&lowbar;size
| xref:wallet/SelectionResult/SetAlgoCompleted.adoc[`SetAlgoCompleted`] 
| Tracks that algorithm was able to exhaustively search the entire combination space before hitting limit of tries
| xref:wallet/SelectionResult/SetBumpFeeDiscount.adoc[`SetBumpFeeDiscount`] 
| How much individual inputs overestimated the bump fees for shared ancestries
| xref:wallet/SelectionResult/SetSelectionsEvaluated.adoc[`SetSelectionsEvaluated`] 
| Record the number of selections that were evaluated
| xref:wallet/SelectionResult/operator_lt.adoc[`operator&lt;`] 
| Order results by preference for choosing between selections&period;
|===


== Non-Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:wallet/AttemptSelection.adoc[`AttemptSelection`]
| Attempt to find a valid input set that preserves privacy by not mixing OutputTypes&period; `ChooseSelectionResult()` will be called on each OutputType individually and the best the solution (according to the waste metric) will be chosen&period; If a valid input cannot be found from any single OutputType, fallback to running `ChooseSelectionResult()` over all available coins&period;
| xref:wallet/AutomaticCoinSelection.adoc[`AutomaticCoinSelection`]
| Select a set of coins such that nTargetValue is met&semi; never select unconfirmed coins if they are not ours
| xref:wallet/ChooseSelectionResult.adoc[`ChooseSelectionResult`]
| Attempt to find a valid input set that meets the provided eligibility filter and target&period; Multiple coin selection algorithms will be run and the input set that produces the least waste (according to the waste metric) will be chosen&period;
| xref:wallet/CoinGrinder.adoc[`CoinGrinder`]
| Select coins using the CoinGrinder deterministic search algorithm&period;
| xref:wallet/KnapsackSolver.adoc[`KnapsackSolver`]
| Select coins using the original Knapsack approximation, used as a fallback&period;
| xref:wallet/SelectCoins.adoc[`SelectCoins`]
| Select all coins from coin&lowbar;control, and if coin&lowbar;control &apos;m&lowbar;allow&lowbar;other&lowbar;inputs&equals;true&apos;, call &apos;AutomaticCoinSelection&apos; to select a set of coins such that nTargetValue &hyphen; pre&lowbar;set&lowbar;inputs&period;total&lowbar;amount is met&period;
| xref:wallet/SelectCoinsBnB.adoc[`SelectCoinsBnB`]
| Select coins using the Branch and Bound algorithm to find a changeless solution&period;
| xref:wallet/SelectCoinsSRD.adoc[`SelectCoinsSRD`]
| Select coins by Single Random Draw (SRD)&period; 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&lowbar;LOWER&period; 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&period; Due to this greedy approach, SRD can fail to discover possible solutions in pathological cases&period;
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
