wallet: introduce GetAppropriateTotal() in CoinsResult
returns the total amount (if SFFO), otherwise the effective amount. previously, this was the logic in calculating PreSelectedInputs::total_amount when PreSelectedInputs::Insert() was called. return optional to force callers to explicitly handle the case when effective amount optional is not set.
This commit is contained in:
1 parent
d8ea921d01
commit
e5474079f1
1 file changed
+6
-2
+6
-2
@@ -58,8 +58,12 @@ struct CoinsResult {
|
|||||||
void Shuffle(FastRandomContext& rng_fast);
|
void Shuffle(FastRandomContext& rng_fast);
|
||||||
void Add(OutputType type, const COutput& out);
|
void Add(OutputType type, const COutput& out);
|
||||||
|
|
||||||
CAmount GetTotalAmount() { return total_amount; }
|
CAmount GetTotalAmount() const { return total_amount; }
|
||||||
std::optional<CAmount> GetEffectiveTotalAmount() { return total_effective_amount; }
|
std::optional<CAmount> GetEffectiveTotalAmount() const { return total_effective_amount; }
|
||||||
|
// Returns the appropriate total based on whether fees are being subtracted from outputs
|
||||||
|
std::optional<CAmount> GetAppropriateTotal(bool subtract_fee_outputs) const {
|
||||||
|
return subtract_fee_outputs ? total_amount : total_effective_amount;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/** Sum of all available coins raw value */
|
/** Sum of all available coins raw value */
|
||||||
|
|||||||
Reference in new issue
Block a user