From f52b950650cd5383f59567fd2ac981d9b464c208 Mon Sep 17 00:00:00 2001 From: sneurlax Date: Mon, 22 Jan 2024 21:24:30 -0600 Subject: [PATCH] avoid updating wallet info before finishing opening remove unused var --- lib/wallets/wallet/impl/monero_wallet.dart | 7 +++++++ lib/wallets/wallet/intermediate/cryptonote_wallet.dart | 2 ++ .../wallet/wallet_mixin_interfaces/cw_based_interface.dart | 3 +++ 3 files changed, 12 insertions(+) diff --git a/lib/wallets/wallet/impl/monero_wallet.dart b/lib/wallets/wallet/impl/monero_wallet.dart index 1dad7355a..5e4bc2940 100644 --- a/lib/wallets/wallet/impl/monero_wallet.dart +++ b/lib/wallets/wallet/impl/monero_wallet.dart @@ -55,6 +55,7 @@ class MoneroWallet extends CryptonoteWallet with CwBasedInterface { @override Future exitCwWallet() async { + walletOpen = false; (cwWalletBase as MoneroWalletBase?)?.onNewBlock = null; (cwWalletBase as MoneroWalletBase?)?.onNewTransaction = null; (cwWalletBase as MoneroWalletBase?)?.syncStatusChanged = null; @@ -63,6 +64,8 @@ class MoneroWallet extends CryptonoteWallet with CwBasedInterface { @override Future open() async { + walletOpen = false; + String? password; try { password = await cwKeysStorage.getWalletPassword(walletName: walletId); @@ -87,6 +90,8 @@ class MoneroWallet extends CryptonoteWallet with CwBasedInterface { const Duration(seconds: 193), (_) async => await cwWalletBase?.save(), ); + + walletOpen = true; } @override @@ -152,6 +157,8 @@ class MoneroWallet extends CryptonoteWallet with CwBasedInterface { @override Future updateTransactions() async { + if (!walletOpen) return; + await (cwWalletBase as MoneroWalletBase?)?.updateTransactions(); final transactions = (cwWalletBase as MoneroWalletBase?)?.transactionHistory?.transactions; diff --git a/lib/wallets/wallet/intermediate/cryptonote_wallet.dart b/lib/wallets/wallet/intermediate/cryptonote_wallet.dart index ab988eb23..72c49e342 100644 --- a/lib/wallets/wallet/intermediate/cryptonote_wallet.dart +++ b/lib/wallets/wallet/intermediate/cryptonote_wallet.dart @@ -7,6 +7,8 @@ abstract class CryptonoteWallet extends Wallet with MnemonicInterface { CryptonoteWallet(T currency) : super(currency); + bool walletOpen = false; + // ========== Overrides ====================================================== @override diff --git a/lib/wallets/wallet/wallet_mixin_interfaces/cw_based_interface.dart b/lib/wallets/wallet/wallet_mixin_interfaces/cw_based_interface.dart index 9dc0c0b7d..7f4508d80 100644 --- a/lib/wallets/wallet/wallet_mixin_interfaces/cw_based_interface.dart +++ b/lib/wallets/wallet/wallet_mixin_interfaces/cw_based_interface.dart @@ -244,6 +244,8 @@ mixin CwBasedInterface on CryptonoteWallet @override Future updateBalance() async { + if (!walletOpen) return; + final total = await totalBalance; final available = await availableBalance; @@ -300,6 +302,7 @@ mixin CwBasedInterface on CryptonoteWallet @override Future exit() async { if (!_hasCalledExit) { + walletOpen = false; _hasCalledExit = true; autoSaveTimer?.cancel(); await exitCwWallet();