@@ -303,6 +303,8 @@ struct SelectionResult
303
303
/* * Get the sum of the input values */
304
304
[[nodiscard]] CAmount GetSelectedValue () const ;
305
305
306
+ [[nodiscard]] CAmount GetSelectedEffectiveValue () const ;
307
+
306
308
void Clear ();
307
309
308
310
void AddInput (const OutputGroup& group);
@@ -320,6 +322,25 @@ struct SelectionResult
320
322
321
323
bool operator <(SelectionResult other) const ;
322
324
325
+ /* * Get the amount for the change output after paying needed fees.
326
+ *
327
+ * The change amount is not 100% precise due to discrepancies in fee calculation.
328
+ * The final change amount (if any) should be corrected after calculating the final tx fees.
329
+ * When there is a discrepancy, most of the time the final change would be slightly bigger than estimated.
330
+ *
331
+ * Following are the possible factors of discrepancy:
332
+ * + non-input fees always include segwit flags
333
+ * + input fee estimation always include segwit stack size
334
+ * + input fees are rounded individually and not collectively, which leads to small rounding errors
335
+ * - input counter size is always assumed to be 1vbyte
336
+ *
337
+ * @param[in] min_viable_change Minimum amount for change output, if change would be less then we forgo change
338
+ * @param[in] change_fee Fees to include change output in the tx
339
+ * @returns Amount for change output, 0 when there is no change.
340
+ *
341
+ */
342
+ CAmount GetChange (const CAmount min_viable_change, const CAmount change_fee) const ;
343
+
323
344
CAmount GetTarget () const { return m_target; }
324
345
325
346
SelectionAlgorithm GetAlgo () const { return m_algo; }
0 commit comments