mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-22 19:49:22 +00:00
Only stop wallet on rename and delete
This commit is contained in:
parent
dc424b58fc
commit
701c6b2004
4 changed files with 39 additions and 21 deletions
|
@ -151,23 +151,6 @@ abstract class MoneroWalletBase
|
|||
_listener?.stop();
|
||||
_onAccountChangeReaction?.reaction.dispose();
|
||||
_autoSaveTimer?.cancel();
|
||||
|
||||
final currentWalletDirPath = await pathForWalletDir(name: name, type: type);
|
||||
if (openedWalletsByPath["$currentWalletDirPath/$name"] != null) {
|
||||
// NOTE: this is realistically only required on windows.
|
||||
print("closing wallet");
|
||||
final wmaddr = wmPtr.address;
|
||||
final waddr = openedWalletsByPath["$currentWalletDirPath/$name"]!.address;
|
||||
await Isolate.run(() {
|
||||
monero.WalletManager_closeWallet(
|
||||
Pointer.fromAddress(wmaddr),
|
||||
Pointer.fromAddress(waddr),
|
||||
true
|
||||
);
|
||||
});
|
||||
openedWalletsByPath.remove("$currentWalletDirPath/$name");
|
||||
print("wallet closed");
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -357,6 +340,21 @@ abstract class MoneroWalletBase
|
|||
@override
|
||||
Future<void> renameWalletFiles(String newWalletName) async {
|
||||
final currentWalletDirPath = await pathForWalletDir(name: name, type: type);
|
||||
if (openedWalletsByPath["$currentWalletDirPath/$name"] != null) {
|
||||
// NOTE: this is realistically only required on windows.
|
||||
print("closing wallet");
|
||||
final wmaddr = wmPtr.address;
|
||||
final waddr = openedWalletsByPath["$currentWalletDirPath/$name"]!.address;
|
||||
await Isolate.run(() {
|
||||
monero.WalletManager_closeWallet(
|
||||
Pointer.fromAddress(wmaddr),
|
||||
Pointer.fromAddress(waddr),
|
||||
true
|
||||
);
|
||||
});
|
||||
openedWalletsByPath.remove("$currentWalletDirPath/$name");
|
||||
print("wallet closed");
|
||||
}
|
||||
try {
|
||||
// -- rename the waller folder --
|
||||
final currentWalletDir = Directory(await pathForWalletDir(name: name, type: type));
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
import 'dart:ffi';
|
||||
import 'dart:io';
|
||||
import 'dart:isolate';
|
||||
import 'package:cw_core/monero_wallet_utils.dart';
|
||||
import 'package:cw_core/pathForWallet.dart';
|
||||
import 'package:cw_core/unspent_coins_info.dart';
|
||||
|
@ -10,10 +12,12 @@ import 'package:cw_core/wallet_type.dart';
|
|||
import 'package:cw_core/get_height_by_date.dart';
|
||||
import 'package:cw_monero/api/exceptions/wallet_opening_exception.dart';
|
||||
import 'package:cw_monero/api/wallet_manager.dart' as monero_wallet_manager;
|
||||
import 'package:cw_monero/api/wallet_manager.dart';
|
||||
import 'package:cw_monero/monero_wallet.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:polyseed/polyseed.dart';
|
||||
import 'package:monero/monero.dart' as monero;
|
||||
|
||||
class MoneroNewWalletCredentials extends WalletCredentials {
|
||||
MoneroNewWalletCredentials(
|
||||
|
@ -174,6 +178,22 @@ class MoneroWalletService extends WalletService<MoneroNewWalletCredentials,
|
|||
@override
|
||||
Future<void> remove(String wallet) async {
|
||||
final path = await pathForWalletDir(name: wallet, type: getType());
|
||||
if (openedWalletsByPath["$path/$wallet"] != null) {
|
||||
// NOTE: this is realistically only required on windows.
|
||||
print("closing wallet");
|
||||
final wmaddr = wmPtr.address;
|
||||
final waddr = openedWalletsByPath["$path/$wallet"]!.address;
|
||||
// await Isolate.run(() {
|
||||
monero.WalletManager_closeWallet(
|
||||
Pointer.fromAddress(wmaddr),
|
||||
Pointer.fromAddress(waddr),
|
||||
false
|
||||
);
|
||||
// });
|
||||
openedWalletsByPath.remove("$path/$wallet");
|
||||
print("wallet closed");
|
||||
}
|
||||
|
||||
final file = Directory(path);
|
||||
final isExist = file.existsSync();
|
||||
|
||||
|
|
|
@ -7,18 +7,18 @@
|
|||
#include "generated_plugin_registrant.h"
|
||||
|
||||
#include <connectivity_plus/connectivity_plus_windows_plugin.h>
|
||||
#include <flutter_local_authentication/flutter_local_authentication_plugin_c_api.h>
|
||||
#include <flutter_secure_storage_windows/flutter_secure_storage_windows_plugin.h>
|
||||
#include <local_auth_windows/local_auth_plugin.h>
|
||||
#include <permission_handler_windows/permission_handler_windows_plugin.h>
|
||||
#include <url_launcher_windows/url_launcher_windows.h>
|
||||
|
||||
void RegisterPlugins(flutter::PluginRegistry* registry) {
|
||||
ConnectivityPlusWindowsPluginRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("ConnectivityPlusWindowsPlugin"));
|
||||
FlutterLocalAuthenticationPluginCApiRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("FlutterLocalAuthenticationPluginCApi"));
|
||||
FlutterSecureStorageWindowsPluginRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("FlutterSecureStorageWindowsPlugin"));
|
||||
LocalAuthPluginRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("LocalAuthPlugin"));
|
||||
PermissionHandlerWindowsPluginRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("PermissionHandlerWindowsPlugin"));
|
||||
UrlLauncherWindowsRegisterWithRegistrar(
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
|
||||
list(APPEND FLUTTER_PLUGIN_LIST
|
||||
connectivity_plus
|
||||
flutter_local_authentication
|
||||
flutter_secure_storage_windows
|
||||
local_auth_windows
|
||||
permission_handler_windows
|
||||
url_launcher_windows
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue