fix: check isOnline before offlineMode in Xelis exit()
What changed, and why it matters
This is a small, defensive bug fix in the Xelis cryptocurrency wallet's shutdown code. Before the change, the wallet always tried to put itself into 'offline mode' when exiting, even if it was already offline. After the change, it first checks whether the wallet is actually online and only then switches to offline mode. The main risk is avoiding unnecessary or incorrect state changes during shutdown, which could potentially cause crashes, resource leaks, or confusion in wallet state. There is no direct evidence of a security vulnerability being exploited.
Treat as a routine stability/defensive fix. Review whether calling offlineMode on an already-offline wallet previously caused exceptions, inconsistent state, or resource leaks. No urgent security response is indicated by the diff alone.
Security signals we found
Defensive state check added before state transition
Potential redundant/incorrect offlineMode call prevented
No input validation, injection, or cryptographic issue visible
No explicit security disclosure or CVE referenced
Evidence from the diff
The patch modifies lib/wallets/wallet/intermediate/lib_xelis_wallet.dart in the exit() method. Previously, libXelis.offlineMode(wallet!) was called unconditionally if wallet was non-null. Now, it is guarded by await libXelis.isOnline(wallet!). This prevents calling offlineMode on a wallet that is already offline. The change is defensive and likely prevents state-management errors, redundant calls, or exceptions during wallet teardown. No explicit security bug, exploit primitive, or attacker-controlled input is visible in the diff.
Changed components
lib/wallets/wallet/intermediate/lib_xelis_wallet.dartXelis wallet exit/shutdown pathInspect captured patch +1 / −1
diff --git a/lib/wallets/wallet/intermediate/lib_xelis_wallet.dart b/lib/wallets/wallet/intermediate/lib_xelis_wallet.dart
index 0cfac6d..eb81802 100644
--- a/lib/wallets/wallet/intermediate/lib_xelis_wallet.dart
+++ b/lib/wallets/wallet/intermediate/lib_xelis_wallet.dart
@@ -169,7 +169,7 @@ abstract class LibXelisWallet<T extends ElectrumCurrency>
await _eventSubscription?.cancel();
_eventSubscription = null;
- if (wallet != null) {
+ if (wallet != null && await libXelis.isOnline(wallet!)) {
await libXelis.offlineMode(wallet!);
}
await super.exit();
Why this scored 30/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.