From 7d60793c88d43b1633d89f456da2639b3055775f Mon Sep 17 00:00:00 2001 From: julian Date: Fri, 27 Sep 2024 14:31:05 -0600 Subject: [PATCH] fix cw wallet listeners on restore --- lib/wallets/wallet/impl/monero_wallet.dart | 8 +++++--- lib/wallets/wallet/impl/wownero_wallet.dart | 4 +++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/wallets/wallet/impl/monero_wallet.dart b/lib/wallets/wallet/impl/monero_wallet.dart index ff0dccf43..85269ac90 100644 --- a/lib/wallets/wallet/impl/monero_wallet.dart +++ b/lib/wallets/wallet/impl/monero_wallet.dart @@ -529,6 +529,11 @@ class MoneroWallet extends CryptonoteWallet with CwBasedInterface { walletInfo.address = wallet.walletAddresses.address; await DB.instance .add(boxName: WalletInfo.boxName, value: walletInfo); + cwWalletBase?.close(); + cwWalletBase = wallet as MoneroWalletBase; + cwWalletBase?.onNewBlock = onNewBlock; + cwWalletBase?.onNewTransaction = onNewTransaction; + cwWalletBase?.syncStatusChanged = syncStatusChanged; if (walletInfo.address != null) { final newReceivingAddress = await getCurrentReceivingAddress() ?? Address( @@ -547,15 +552,12 @@ class MoneroWallet extends CryptonoteWallet with CwBasedInterface { isar: mainDB.isar, ); } - cwWalletBase?.close(); - cwWalletBase = wallet as MoneroWalletBase; } catch (e, s) { Logging.instance.log("$e\n$s", level: LogLevel.Fatal); } await updateNode(); await cwWalletBase?.rescan(height: credentials.height); - cwWalletBase?.close(); } catch (e, s) { Logging.instance.log( "Exception rethrown from recoverFromMnemonic(): $e\n$s", diff --git a/lib/wallets/wallet/impl/wownero_wallet.dart b/lib/wallets/wallet/impl/wownero_wallet.dart index 06b9e5682..f79564614 100644 --- a/lib/wallets/wallet/impl/wownero_wallet.dart +++ b/lib/wallets/wallet/impl/wownero_wallet.dart @@ -577,6 +577,9 @@ class WowneroWallet extends CryptonoteWallet with CwBasedInterface { .add(boxName: WalletInfo.boxName, value: walletInfo); cwWalletBase?.close(); cwWalletBase = wallet; + cwWalletBase?.onNewBlock = onNewBlock; + cwWalletBase?.onNewTransaction = onNewTransaction; + cwWalletBase?.syncStatusChanged = syncStatusChanged; if (walletInfo.address != null) { final newReceivingAddress = await getCurrentReceivingAddress() ?? Address( @@ -601,7 +604,6 @@ class WowneroWallet extends CryptonoteWallet with CwBasedInterface { await updateNode(); await cwWalletBase?.rescan(height: credentials.height); - cwWalletBase?.close(); } catch (e, s) { Logging.instance.log( "Exception rethrown from recoverFromMnemonic(): $e\n$s",