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. Change target covers at least change fees and adds a random value on top of it. The random value is between 50ksat and min(2 * payment_value, 1milsat) When payment_value <= 25ksat, the value is just 50ksat.

Synopsis

Declared in <wallet/coinselection.h>

[[nodiscard]]
CAmount
GenerateChangeTarget(
    CAmount payment_value,
    CAmount change_fee,
    FastRandomContext& rng);

Description

Making change amounts similar to the payment value may help disguise which output(s) are payments are which ones are change. 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 ("unnecessary input" heuristic).

Return Value

The randomly‐chosen change target amount.

Note

The return value should not be discarded.

Parameters

Name

Description

payment_value [in]

Average payment value of the transaction output(s).

change_fee [in]

Fee for creating a change output.

rng [in]

Randomness source used to pick the random component of the target.

Created with MrDocs