wallet: fix, make 'total_effective_amount' optional actually optional

this is not needed for the remaining commits but good to fix
and came up in #25269 review.

Co-authored-by: furszy <matiasfurszyfer@protonmail.com>
This commit is contained in:
stratospher
2026-01-14 14:17:02 +05:30
parent 9d2b8fddad
commit fefa3be782
2 changed files with 3 additions and 3 deletions

View File

@@ -223,7 +223,7 @@ void CoinsResult::Erase(const std::unordered_set<COutPoint, SaltedOutpointHasher
// update cached amounts
total_amount -= coin.txout.nValue;
if (coin.HasEffectiveValue()) total_effective_amount = *total_effective_amount - coin.GetEffectiveValue();
if (coin.HasEffectiveValue() && total_effective_amount.has_value()) total_effective_amount = *total_effective_amount - coin.GetEffectiveValue();
return true;
});
vec.erase(remove_it, vec.end());

View File

@@ -59,13 +59,13 @@ struct CoinsResult {
void Add(OutputType type, const COutput& out);
CAmount GetTotalAmount() { return total_amount; }
std::optional<CAmount> GetEffectiveTotalAmount() {return total_effective_amount; }
std::optional<CAmount> GetEffectiveTotalAmount() { return total_effective_amount; }
private:
/** Sum of all available coins raw value */
CAmount total_amount{0};
/** Sum of all available coins effective value (each output value minus fees required to spend it) */
std::optional<CAmount> total_effective_amount{0};
std::optional<CAmount> total_effective_amount;
};
struct CoinFilterParams {