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

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;

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:util/Result.adoc[util::Result&lt;SelectionResult&gt;]
SelectCoinsSRD(
    std::vector&lt;OutputGroup&gt; const& utxo&lowbar;pool,
    xref:CAmount.adoc[CAmount] target&lowbar;value,
    xref:CAmount.adoc[CAmount] change&lowbar;fee,
    xref:FastRandomContext.adoc[FastRandomContext]& rng,
    int max&lowbar;selection&lowbar;weight);
----

== Return Value

If successful, a valid SelectionResult, otherwise, util&colon;&colon;Error

== Parameters

[cols="1,4"]
|===
| Name| Description
| *utxo&lowbar;pool* [in]
| The positive effective value OutputGroups eligible for selection
| *target&lowbar;value* [in]
| The target value to select for
| *change&lowbar;fee* [in]
| The cost of adding the change output to the transaction at the transaction’s feerate&period;
| *rng* [in]
| The randomness source to shuffle coins
| *max&lowbar;selection&lowbar;weight* [in]
| The maximum allowed weight for a selection result to be valid
|===


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