diff options
author | S3RK <1466284+S3RK@users.noreply.github.com> | 2022-07-06 09:00:26 +0200 |
---|---|---|
committer | S3RK <1466284+S3RK@users.noreply.github.com> | 2022-08-15 09:35:20 +0200 |
commit | 15e97a6886902ebb378829993a972dc52558aa92 (patch) | |
tree | 7d4ec454757eefa0fb795301c47bfbc6d8dd1402 /src/wallet/coinselection.h | |
parent | 72cad28da05cfce9e4950f2dc5a709da41d251f4 (diff) | |
download | bitcoin-15e97a6886902ebb378829993a972dc52558aa92.tar.xz |
wallet: add SelectionResult::GetChange
Diffstat (limited to 'src/wallet/coinselection.h')
-rw-r--r-- | src/wallet/coinselection.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/wallet/coinselection.h b/src/wallet/coinselection.h index d1038a117a..dd52241e2a 100644 --- a/src/wallet/coinselection.h +++ b/src/wallet/coinselection.h @@ -303,6 +303,8 @@ public: /** Get the sum of the input values */ [[nodiscard]] CAmount GetSelectedValue() const; + [[nodiscard]] CAmount GetSelectedEffectiveValue() const; + void Clear(); void AddInput(const OutputGroup& group); @@ -320,6 +322,25 @@ public: bool operator<(SelectionResult other) const; + /** Get the amount for the change output after paying needed fees. + * + * 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 + * + * @param[in] min_viable_change Minimum amount for change output, if change would be less then we forgo change + * @param[in] change_fee Fees to include change output in the tx + * @returns Amount for change output, 0 when there is no change. + * + */ + CAmount GetChange(const CAmount min_viable_change, const CAmount change_fee) const; + CAmount GetTarget() const { return m_target; } SelectionAlgorithm GetAlgo() const { return m_algo; } |