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

Choose a random change target for each transaction to make it harder to fingerprint the Core wallet based on the change output values of transactions it creates&period; Change target covers at least change fees and adds a random value on top of it&period; The random value is between 50ksat and min(2 &ast; payment&lowbar;value, 1milsat) When payment&lowbar;value &lt;&equals; 25ksat, the value is just 50ksat&period;

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
&lsqb;&lsqb;nodiscard&rsqb;&rsqb;
xref:CAmount.adoc[CAmount]
GenerateChangeTarget(
    xref:CAmount.adoc[CAmount] payment&lowbar;value,
    xref:CAmount.adoc[CAmount] change&lowbar;fee,
    xref:FastRandomContext.adoc[FastRandomContext]& rng);
----

== Description

Making change amounts similar to the payment value may help disguise which output(s) are payments are which ones are change&period; Using double the payment value may increase the number of inputs needed (and thus be more expensive in fees), but breaks analysis techniques which assume the coins selected are just sufficient to cover the payment amount (&quot;unnecessary input&quot; heuristic)&period;

== Return Value

The randomly&hyphen;chosen change target amount&period;

[NOTE]
====
The return value https://en.cppreference.com/cpp/language/attributes/nodiscard[should not be discarded^].
====
== Parameters

[cols="1,4"]
|===
| Name| Description
| *payment&lowbar;value* [in]
| Average payment value of the transaction output(s)&period;
| *change&lowbar;fee* [in]
| Fee for creating a change output&period;
| *rng* [in]
| Randomness source used to pick the random component of the target&period;
|===


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