mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-02-08 18:49:28 +08:00
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:
@@ -58,8 +58,12 @@ struct CoinsResult {
|
||||
void Shuffle(FastRandomContext& rng_fast);
|
||||
void Add(OutputType type, const COutput& out);
|
||||
|
||||
CAmount GetTotalAmount() { return total_amount; }
|
||||
std::optional<CAmount> GetEffectiveTotalAmount() { return total_effective_amount; }
|
||||
CAmount GetTotalAmount() const { return total_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:
|
||||
/** Sum of all available coins raw value */
|
||||
|
||||
Reference in New Issue
Block a user