What changed, and why it matters
This commit changes how the app converts a crypto amount into a fiat money value. It swaps strict number parsing for safer versions that fall back to zero when the input is invalid, instead of crashing. This is a defensive fix that prevents unhandled exceptions if a user's entered amount cannot be parsed as a number.
Treat as a minor hardening change. Review whether silently defaulting to zero is acceptable UX, or whether invalid input should instead show an error and block quote creation. No urgent security patch appears required.
Security signals we found
Input parsing hardened from throwing to non-throwing with fallback
Potential silent failure path introduced (zero fiat value on bad input)
Change is in financial transaction view model (buy/sell quote)
Evidence from the diff
In lib/view_model/buy/buy_sell_view_model.dart, the fiat value calculation replaced Money.safeParse with Money.trySafeParse and double.parse with double.tryParse(… ?? 0). The change means malformed or empty numeric strings from amountForQuote(quote) no longer throw FormatException; they are treated as 0. This hardens the buy/sell quote flow against crashes caused by unexpected input formatting, but it may also silently mask data-quality issues by producing a zero fiat value.
Changed components
lib/view_model/buy/buy_sell_view_model.dartBuy/sell fiat quote calculationInspect captured patch +2 / −2
diff --git a/lib/view_model/buy/buy_sell_view_model.dart b/lib/view_model/buy/buy_sell_view_model.dart
index 7122be97..5e87267c 100644
--- a/lib/view_model/buy/buy_sell_view_model.dart
+++ b/lib/view_model/buy/buy_sell_view_model.dart
@@ -180,9 +180,9 @@ abstract class BuySellViewModelBase extends WalletChangeListenerViewModel with S
return null;
}
- return Money.safeParse(
+ return Money.trySafeParse(
(fiatConversionStore.prices[cryptoCurrency]! *
- double.parse(amountForQuote(quote).toString()))
+ (double.tryParse(amountForQuote(quote).toString())??0))
.toStringAsFixed(2),
fiatCurrency);
}
Why this scored 34/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.