fix cw wallet listeners on restore

This commit is contained in:
julian 2024-09-27 14:31:05 -06:00
parent 34e7b0e2a8
commit 828718e679
2 changed files with 8 additions and 4 deletions

View file

@ -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(
@ -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",

View file

@ -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(
@ -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",