Skip to content

Commit

Permalink
fix cw wallet listeners on restore
Browse files Browse the repository at this point in the history
  • Loading branch information
julian-CStack committed Sep 30, 2024
1 parent bb0ecfe commit e052b57
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 5 additions & 3 deletions lib/wallets/wallet/impl/monero_wallet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,11 @@ class MoneroWallet extends CryptonoteWallet with CwBasedInterface {
walletInfo.address = wallet.walletAddresses.address;
await DB.instance
.add<WalletInfo>(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(
Expand All @@ -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",
Expand Down
4 changes: 3 additions & 1 deletion lib/wallets/wallet/impl/wownero_wallet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,9 @@ class WowneroWallet extends CryptonoteWallet with CwBasedInterface {
.add<WalletInfo>(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(
Expand All @@ -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",
Expand Down

0 comments on commit e052b57

Please sign in to comment.