[#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. == Synopsis Declared in `<wallet/coinselection.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:CAmount.adoc[CAmount] GetChange( xref:CAmount.adoc[CAmount] min_viable_change, xref:CAmount.adoc[CAmount] change_fee) const; ---- == Description The change amount is not 100% precise due to discrepancies in fee calculation. The final change amount (if any) should be corrected after calculating the final tx fees. When there is a discrepancy, most of the time the final change would be slightly bigger than estimated. Following are the possible factors of discrepancy: + non‐input fees always include segwit flags + input fee estimation always include segwit stack size + 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. == Parameters [cols="1,4"] |=== | Name| Description | *min_viable_change* [in] | Minimum amount for change output, if change would be less then we forgo change | *change_fee* [in] | Fees to include change output in the tx |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#