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.
This commit is contained in:
jwinterm
2026-11-11 17:10:53 -05:00
parent a5bdf85cfc
commit 9c5b461e95
2 changed files with 9 additions and 9 deletions
+8 -8
View File
@@ -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<bool> 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<void> updateSubaddressList({required int accountIndex}) async {
await subaddressList.update(accountIndex: accountIndex);
address = subaddressList.subaddresses.isNotEmpty
? subaddressList.subaddresses.first.address
: getAddress();
+1 -1
View File
@@ -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);