From 5e9743cdb95dbef72f1bb73ea337167eeb1aec9b Mon Sep 17 00:00:00 2001 From: fosse Date: Mon, 16 Oct 2023 10:08:37 -0400 Subject: [PATCH] write migration for existing bitcoin and nano wallets --- lib/entities/default_settings_migration.dart | 16 +++++++++++++++- lib/main.dart | 2 +- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/entities/default_settings_migration.dart b/lib/entities/default_settings_migration.dart index d116e4dae..b65d944fd 100644 --- a/lib/entities/default_settings_migration.dart +++ b/lib/entities/default_settings_migration.dart @@ -175,7 +175,7 @@ Future defaultSettingsMigration( sharedPreferences: sharedPreferences, nodes: nodes); break; case 24: - // TODO: await updateBtcAndNanoWalletInfos() + await updateBtcNanoWalletInfos(walletInfoSource); break; default: @@ -526,6 +526,20 @@ Future changeDefaultMoneroNode( } } +Future updateBtcNanoWalletInfos(Box walletsInfoSource) async { + for (WalletInfo walletInfo in walletsInfoSource.values) { + if (walletInfo.type == WalletType.nano || walletInfo.type == WalletType.bitcoin) { + walletInfo.derivationInfo = DerivationInfo( + derivationPath: walletInfo.derivationPath, + derivationType: walletInfo.derivationType, + address: walletInfo.address, + height: walletInfo.restoreHeight, + ); + await walletInfo.save(); + } + } +} + Future checkCurrentNodes( Box nodeSource, Box powNodeSource, SharedPreferences sharedPreferences) async { final currentMoneroNodeId = sharedPreferences.getInt(PreferencesKey.currentNodeIdKey); diff --git a/lib/main.dart b/lib/main.dart index 6a766bb32..eff29547b 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -166,7 +166,7 @@ Future initializeAppConfigs() async { transactionDescriptions: transactionDescriptions, secureStorage: secureStorage, anonpayInvoiceInfo: anonpayInvoiceInfo, - initialMigrationVersion: 23); + initialMigrationVersion: 24); } Future initialSetup(