diff --git a/cw_monero/lib/api/wallet_manager.dart b/cw_monero/lib/api/wallet_manager.dart index 260b420c5..0aa694e9a 100644 --- a/cw_monero/lib/api/wallet_manager.dart +++ b/cw_monero/lib/api/wallet_manager.dart @@ -1,14 +1,16 @@ import 'dart:ffi'; -import 'package:ffi/ffi.dart'; -import 'package:flutter/foundation.dart'; + import 'package:cw_monero/api/convert_utf8_to_string.dart'; -import 'package:cw_monero/api/signatures.dart'; -import 'package:cw_monero/api/types.dart'; -import 'package:cw_monero/api/monero_api.dart'; -import 'package:cw_monero/api/exceptions/wallet_opening_exception.dart'; import 'package:cw_monero/api/exceptions/wallet_creation_exception.dart'; +import 'package:cw_monero/api/exceptions/wallet_opening_exception.dart'; import 'package:cw_monero/api/exceptions/wallet_restore_from_keys_exception.dart'; import 'package:cw_monero/api/exceptions/wallet_restore_from_seed_exception.dart'; +import 'package:cw_monero/api/monero_api.dart'; +import 'package:cw_monero/api/signatures.dart'; +import 'package:cw_monero/api/types.dart'; +import 'package:cw_monero/api/wallet.dart'; +import 'package:ffi/ffi.dart'; +import 'package:flutter/foundation.dart'; final createWalletNative = moneroApi .lookup>('create_wallet') @@ -175,6 +177,8 @@ void restoreWalletFromSpendKeySync( calloc.free(languagePointer); calloc.free(spendKeyPointer); + storeSync(); + if (!isWalletRestored) { throw WalletRestoreFromKeysException( message: convertUTF8ToString(pointer: errorMessagePointer)); diff --git a/cw_monero/lib/monero_wallet.dart b/cw_monero/lib/monero_wallet.dart index 924a987cd..71c7e3967 100644 --- a/cw_monero/lib/monero_wallet.dart +++ b/cw_monero/lib/monero_wallet.dart @@ -97,8 +97,7 @@ abstract class MoneroWalletBase ObservableMap balance; @override - String get seed => _seed; - String _seed = monero_wallet.getSeed(); + String get seed => monero_wallet.getSeed(); @override MoneroWalletKeys get keys => MoneroWalletKeys( @@ -114,11 +113,7 @@ abstract class MoneroWalletBase Timer? _autoSaveTimer; List unspentCoins; - Future init({String seedFallback = ""}) async { - if (_seed.isEmpty) { - _seed = seedFallback; - } - + Future init() async { await walletAddresses.init(); balance = ObservableMap.of({ currency: MoneroBalance( diff --git a/cw_monero/lib/monero_wallet_service.dart b/cw_monero/lib/monero_wallet_service.dart index c71d43e83..a6b3227b2 100644 --- a/cw_monero/lib/monero_wallet_service.dart +++ b/cw_monero/lib/monero_wallet_service.dart @@ -2,7 +2,6 @@ import 'dart:io'; import 'package:cw_core/monero_wallet_utils.dart'; import 'package:cw_core/pathForWallet.dart'; import 'package:cw_core/unspent_coins_info.dart'; -import 'package:cw_core/utils/file.dart'; import 'package:cw_core/wallet_base.dart'; import 'package:cw_core/wallet_credentials.dart'; import 'package:cw_core/wallet_info.dart'; @@ -134,12 +133,7 @@ class MoneroWalletService extends WalletService< return openWallet(name, password); } - if (wallet.seed.isEmpty) { - final seedFallback = await _getSeedBackup(path, password); - await wallet.init(seedFallback: seedFallback); - } else { - await wallet.init(); - } + await wallet.init(); return wallet; } catch (e) { @@ -295,8 +289,6 @@ class MoneroWalletService extends WalletService< restoreHeight: height, spendKey: spendKey); - await writeData(path: "$path.seed", password: password, data: seed); - final wallet = MoneroWallet( walletInfo: walletInfo, unspentCoinsInfo: unspentCoinsInfoSource); await wallet.init(); @@ -304,13 +296,6 @@ class MoneroWalletService extends WalletService< return wallet; } - Future _getSeedBackup(String path, String password) async { - final seedFilePath = "$path.seed"; - final seedFile = File(seedFilePath); - if (!seedFile.existsSync()) return ""; - return read(path: seedFilePath, password: password); - } - Future repairOldAndroidWallet(String name) async { try { if (!Platform.isAndroid) {