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

Get the amount for the change output after paying needed fees&period;

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:CAmount.adoc[CAmount]
GetChange(
    xref:CAmount.adoc[CAmount] min&lowbar;viable&lowbar;change,
    xref:CAmount.adoc[CAmount] change&lowbar;fee) const;
----

== Description

The change amount is not 100% precise due to discrepancies in fee calculation&period; The final change amount (if any) should be corrected after calculating the final tx fees&period; When there is a discrepancy, most of the time the final change would be slightly bigger than estimated&period;

Following are the possible factors of discrepancy&colon; &plus; non&hyphen;input fees always include segwit flags &plus; input fee estimation always include segwit stack size &plus; input fees are rounded individually and not collectively, which leads to small rounding errors

* input counter size is always assumed to be 1vbyte

== Return Value

Amount for change output, 0 when there is no change&period;

== Parameters

[cols="1,4"]
|===
| Name| Description
| *min&lowbar;viable&lowbar;change* [in]
| Minimum amount for change output, if change would be less then we forgo change
| *change&lowbar;fee* [in]
| Fees to include change output in the tx
|===


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