From 9c5b461e951c073479d82dfe3c00fdf077aac734 Mon Sep 17 00:00:00 2001 From: jwinterm Date: Wed, 11 Nov 2026 17:10:53 -0500 Subject: [PATCH] fix(wownero): await the subaddress update before validating a wallet Build 16 hung on "Loading wallet" after the PIN. f08ae897e made the subaddress list's update() async, but openWallet() still called a synchronous validate(), which read the list before update() filled it, saw no subaddresses, reset nothing (the backup lookup uses the Monero wallet directory) and reopened the wallet, forever. validate() now awaits the update and openWallet() awaits validate(). init(), updateAddressesInBox() and updateSubaddressList() await it too, as upstream's Monero code does, so the address book and the receive address are built from a filled list. --- cw_wownero/lib/wownero_wallet_addresses.dart | 16 ++++++++-------- cw_wownero/lib/wownero_wallet_service.dart | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/cw_wownero/lib/wownero_wallet_addresses.dart b/cw_wownero/lib/wownero_wallet_addresses.dart index 9558ec194..28ceed5e4 100644 --- a/cw_wownero/lib/wownero_wallet_addresses.dart +++ b/cw_wownero/lib/wownero_wallet_addresses.dart @@ -73,7 +73,7 @@ abstract class WowneroWalletAddressesBase extends WalletAddresses with Store { account = accountList.accounts.isEmpty ? Account(id: 0, label: "Primary address") : accountList.accounts.first; - updateSubaddressList(accountIndex: account?.id ?? 0); + await updateSubaddressList(accountIndex: account?.id ?? 0); await updateAddressesInBox(); } @@ -85,8 +85,8 @@ abstract class WowneroWalletAddressesBase extends WalletAddresses with Store { addressesMap.clear(); addressInfos.clear(); - accountList.accounts.forEach((account) { - _subaddressList.update(accountIndex: account.id); + for (final account in accountList.accounts) { + await _subaddressList.update(accountIndex: account.id); _subaddressList.subaddresses.forEach((subaddress) { addressesMap[subaddress.address] = subaddress.label; addressInfos[account.id] ??= []; @@ -97,7 +97,7 @@ abstract class WowneroWalletAddressesBase extends WalletAddresses with Store { address: subaddress.address, label: subaddress.label)); }); - }); + } await saveAddressesInBox(); } catch (e) { @@ -105,7 +105,7 @@ abstract class WowneroWalletAddressesBase extends WalletAddresses with Store { } } - bool validate() { + Future validate() async { accountList.update(); final accountListLength = accountList.accounts.length; @@ -113,7 +113,7 @@ abstract class WowneroWalletAddressesBase extends WalletAddresses with Store { return false; } - subaddressList.update(accountIndex: accountList.accounts.first.id); + await subaddressList.update(accountIndex: accountList.accounts.first.id); final subaddressListLength = subaddressList.subaddresses.length; if (subaddressListLength <= 0) { @@ -123,8 +123,8 @@ abstract class WowneroWalletAddressesBase extends WalletAddresses with Store { return true; } - void updateSubaddressList({required int accountIndex}) { - subaddressList.update(accountIndex: accountIndex); + Future updateSubaddressList({required int accountIndex}) async { + await subaddressList.update(accountIndex: accountIndex); address = subaddressList.subaddresses.isNotEmpty ? subaddressList.subaddresses.first.address : getAddress(); diff --git a/cw_wownero/lib/wownero_wallet_service.dart b/cw_wownero/lib/wownero_wallet_service.dart index 08683f277..4749e238a 100644 --- a/cw_wownero/lib/wownero_wallet_service.dart +++ b/cw_wownero/lib/wownero_wallet_service.dart @@ -157,7 +157,7 @@ class WowneroWalletService extends WalletService< unspentCoinsInfo: unspentCoinsInfoSource, password: password); - final isValid = wallet.walletAddresses.validate(); + final isValid = await wallet.walletAddresses.validate(); if (!isValid) { await restoreOrResetWalletFiles(name);