[#wallet-AttemptSelection] = xref:wallet.adoc[wallet]::AttemptSelection :relfileprefix: ../ :mrdocs: Attempt 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. == Synopsis Declared in `<wallet/spend.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:util/Result.adoc[util::Result<SelectionResult>] AttemptSelection( xref:interfaces/Chain.adoc[interfaces::Chain]& chain, xref:CAmount.adoc[CAmount] const& nTargetValue, xref:wallet/OutputGroupTypeMap.adoc[OutputGroupTypeMap]& groups, xref:wallet/CoinSelectionParams.adoc[CoinSelectionParams] const& coin_selection_params, bool allow_mixed_output_types); ---- == Return Value If successful, a SelectionResult containing the input set If failed, returns (1) an empty error message if the target was not reached (general "Insufficient funds") or (2) a specific error message if there was something particularly wrong (e.g. a selection result that surpassed the tx max weight size). == Parameters [cols="1,4"] |=== | Name| Description | *chain* [in] | The chain interface to get information on bump fees for unconfirmed UTXOs | *nTargetValue* [in] | The target value | *groups* [in] | The grouped outputs mapped by coin eligibility filters | *coin_selection_params* [in] | Parameters for the coin selection | *allow_mixed_output_types* [in] | Relax restriction that SelectionResults must be of the same OutputType |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#