What changed, and why it matters
This commit adds a safety check in two cryptocurrency wallet files. Before refreshing the list of spendable coins (UTXOs), the code now verifies the wallet object actually exists. If it doesn't, it logs a warning and returns early instead of crashing. The title 'downgrade errors to warnings' suggests this is a defensive change to prevent null-pointer crashes during wallet operations.
Treat as a routine stability/defensive fix. Review whether `onUTXOsChanged` can be triggered after wallet teardown and ensure no UTXO state becomes stale or inconsistent due to the early return. No immediate security response is indicated from the diff alone.
Security signals we found
Null-pointer dereference crash path removed
Defensive guard added around wallet object access
Logging downgrade from error to warning suggests prior crash/error behavior
No input validation, authentication, or cryptographic changes
Evidence from the diff
The patch adds a null guard at the start of onUTXOsChanged in both lib_monero_wallet.dart and lib_salvium_wallet.dart. If wallet == null, it logs a warning via Logging.instance.w(...) and returns before calling csMonero.getOutputs(wallet!, refresh: true) / csSalvium.getOutputs(wallet!, refresh: true). The non-null assertion operator ! on wallet would previously have thrown a runtime exception if wallet were null. This change prevents that crash path.
Changed components
lib/wallets/wallet/intermediate/lib_monero_wallet.dartlib/wallets/wallet/intermediate/lib_salvium_wallet.dartMonero/Wownero wallet UTXO refresh flowSalvium wallet UTXO refresh flowInspect captured patch +17 / −0
diff --git a/lib/wallets/wallet/intermediate/lib_monero_wallet.dart b/lib/wallets/wallet/intermediate/lib_monero_wallet.dart
index 9f88a62..e5f91c4 100644
--- a/lib/wallets/wallet/intermediate/lib_monero_wallet.dart
+++ b/lib/wallets/wallet/intermediate/lib_monero_wallet.dart
@@ -827,6 +827,15 @@ abstract class LibMoneroWallet<T extends CryptonoteCurrency>
final _utxosUpdateLock = Mutex();
Future<void> onUTXOsChanged(List<UTXO> utxos) async {
+ if (wallet == null) {
+ Logging.instance.w(
+ "onUTXOsChanged triggered while cs_monero wallet is null. If this "
+ "occurs while not in a monero/wownero wallet this warning can be "
+ "ignored.",
+ );
+ return;
+ }
+
await _utxosUpdateLock.protect(() async {
final cwUtxos = await csMonero.getOutputs(wallet!, refresh: true);
diff --git a/lib/wallets/wallet/intermediate/lib_salvium_wallet.dart b/lib/wallets/wallet/intermediate/lib_salvium_wallet.dart
index 89c9b30..4081c90 100644
--- a/lib/wallets/wallet/intermediate/lib_salvium_wallet.dart
+++ b/lib/wallets/wallet/intermediate/lib_salvium_wallet.dart
@@ -797,6 +797,14 @@ abstract class LibSalviumWallet<T extends CryptonoteCurrency>
final _utxosUpdateLock = Mutex();
Future<void> onUTXOsChanged(List<UTXO> utxos) async {
+ if (wallet == null) {
+ Logging.instance.w(
+ "onUTXOsChanged triggered while cs_salvium wallet is null. If this "
+ "occurs while not in a salvium wallet this warning can be ignored.",
+ );
+ return;
+ }
+
await _utxosUpdateLock.protect(() async {
final cwUtxos = await csSalvium.getOutputs(wallet!, refresh: true);
Why this scored 26/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.