From 925b58be506874e043098c12497df61929f0b8c0 Mon Sep 17 00:00:00 2001 From: julian Date: Fri, 29 Nov 2024 17:05:35 -0600 Subject: [PATCH] fix frost wallet init address error --- .../wallet/impl/bitcoin_frost_wallet.dart | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/lib/wallets/wallet/impl/bitcoin_frost_wallet.dart b/lib/wallets/wallet/impl/bitcoin_frost_wallet.dart index 313f1afb6..c1701d8b7 100644 --- a/lib/wallets/wallet/impl/bitcoin_frost_wallet.dart +++ b/lib/wallets/wallet/impl/bitcoin_frost_wallet.dart @@ -85,12 +85,26 @@ class BitcoinFrostWallet extends Wallet await mainDB.isar.frostWalletInfo.put(frostWalletInfo); }); - final address = await _generateAddress( - change: 0, - index: kFrostSecureStartingIndex, - serializedKeys: serializedKeys, - secure: true, - ); + Address? address; + int index = kFrostSecureStartingIndex; + while (address == null) { + try { + address = await _generateAddress( + change: 0, + index: index, + serializedKeys: serializedKeys, + secure: true, + ); + } on FrostdartException catch (e) { + if (e.errorCode == 72) { + // rust doesn't like the addressDerivationData + index++; + continue; + } else { + rethrow; + } + } + } await mainDB.putAddresses([address]); } catch (e, s) {