From 842b958f8b35c3325d6f9dd703d036175ecc7cd1 Mon Sep 17 00:00:00 2001 From: Konstantin Ullrich Date: Fri, 21 Nov 2025 16:10:37 +0100 Subject: [PATCH] feat: add Wownero wallet seed backup during migration step 54 (#2667) * feat: add Wownero wallet seed backup during migration step 54 * feat: add Haven wallet seed backup support in configure tool interface --- lib/entities/default_settings_migration.dart | 10 ++++++++++ lib/main.dart | 2 +- lib/wownero/cw_wownero.dart | 16 ++++++++++++++++ tool/configure.dart | 8 ++++++++ 4 files changed, 35 insertions(+), 1 deletion(-) diff --git a/lib/entities/default_settings_migration.dart b/lib/entities/default_settings_migration.dart index 9f2ac0bce..9e57fd873 100644 --- a/lib/entities/default_settings_migration.dart +++ b/lib/entities/default_settings_migration.dart @@ -5,6 +5,7 @@ import 'package:cake_wallet/core/secure_storage.dart'; import 'package:cake_wallet/entities/exchange_api_mode.dart'; import 'package:cake_wallet/entities/fiat_api_mode.dart'; import 'package:cake_wallet/entities/haven_seed_store.dart'; +import 'package:cake_wallet/wownero/wownero.dart'; import 'package:cw_core/cake_hive.dart'; import 'package:cw_core/pathForWallet.dart'; import 'package:cake_wallet/entities/secret_store_key.dart'; @@ -555,6 +556,9 @@ Future defaultSettingsMigration( currentNodePreferenceKey: PreferencesKey.currentArbitrumNodeIdKey, ); break; + case 54: + await _backupWowneroSeeds(havenSeedStore); + break; default: break; @@ -740,6 +744,12 @@ Future disableServiceStatusFiatDisabled(SharedPreferences sharedPreference } } +Future _backupWowneroSeeds(Box havenSeedStore) async { + final future = wownero?.backupSeeds(havenSeedStore); + if (future != null) await future; + return; +} + Future _updateMoneroPriority(SharedPreferences sharedPreferences) async { final currentPriority = await sharedPreferences.getInt(PreferencesKey.moneroTransactionPriority) ?? diff --git a/lib/main.dart b/lib/main.dart index 77430f08f..6d96e6787 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -266,7 +266,7 @@ Future initializeAppConfigs({bool loadWallet = true}) async { payjoinSessionSource: payjoinSessionSource, anonpayInvoiceInfo: anonpayInvoiceInfo, havenSeedStore: havenSeedStore, - initialMigrationVersion: 53, + initialMigrationVersion: 54, ); } diff --git a/lib/wownero/cw_wownero.dart b/lib/wownero/cw_wownero.dart index 99c5405f8..364272835 100644 --- a/lib/wownero/cw_wownero.dart +++ b/lib/wownero/cw_wownero.dart @@ -365,4 +365,20 @@ class CWWownero extends Wownero { Map> debugCallLength() { return wownero_wallet_api.debugCallLength(); } + + @override + Future backupSeeds(Box havenSeedStore) async { + final wallets = await WalletInfo.selectList('type = ?', [WalletType.wownero.index]); + final unspentCoinsInfo = await CakeHive.openBox(UnspentCoinsInfo.boxName); + for (final w in wallets) { + final walletService = WowneroWalletService(unspentCoinsInfo); + final flutterSecureStorage = secureStorageShared; + final keyService = KeyService(flutterSecureStorage); + final password = await keyService.getWalletPassword(walletName: w.name); + final wallet = await walletService.openWallet(w.name, password); + await havenSeedStore.add(HavenSeedStore(id: wallet.id, seed: wallet.seed)); + wallet.close(); + } + await havenSeedStore.flush(); + } } diff --git a/tool/configure.dart b/tool/configure.dart index 47b337940..f04f009ef 100644 --- a/tool/configure.dart +++ b/tool/configure.dart @@ -517,6 +517,13 @@ import 'package:cw_core/transaction_info.dart'; import 'package:cw_core/balance.dart'; import 'package:cw_core/output_info.dart'; import 'package:cake_wallet/view_model/send/output.dart'; +import 'package:cw_core/crypto_currency.dart'; +import 'package:cake_wallet/core/key_service.dart'; +import 'package:cake_wallet/core/secure_storage.dart'; +import 'package:cake_wallet/entities/haven_seed_store.dart'; +import 'package:cw_core/cake_hive.dart'; +import 'package:cw_core/wallet_info.dart'; +import 'package:cw_core/wallet_type.dart'; import 'package:cw_core/wallet_service.dart'; import 'package:hive/hive.dart'; import 'package:polyseed/polyseed.dart';"""; @@ -650,6 +657,7 @@ abstract class Wownero { Map pendingTransactionInfo(Object transaction); String getLegacySeed(Object wallet, String langName); Map> debugCallLength(); + Future backupSeeds(Box havenSeedStore); } abstract class WowneroSubaddressList {