mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-23 12:09:43 +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();
|
_listener?.stop();
|
||||||
_onAccountChangeReaction?.reaction.dispose();
|
_onAccountChangeReaction?.reaction.dispose();
|
||||||
_autoSaveTimer?.cancel();
|
_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
|
@override
|
||||||
|
@ -357,6 +340,21 @@ abstract class MoneroWalletBase
|
||||||
@override
|
@override
|
||||||
Future<void> renameWalletFiles(String newWalletName) async {
|
Future<void> renameWalletFiles(String newWalletName) async {
|
||||||
final currentWalletDirPath = await pathForWalletDir(name: name, type: type);
|
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 {
|
try {
|
||||||
// -- rename the waller folder --
|
// -- rename the waller folder --
|
||||||
final currentWalletDir = Directory(await pathForWalletDir(name: name, type: type));
|
final currentWalletDir = Directory(await pathForWalletDir(name: name, type: type));
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
|
import 'dart:ffi';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
import 'dart:isolate';
|
||||||
import 'package:cw_core/monero_wallet_utils.dart';
|
import 'package:cw_core/monero_wallet_utils.dart';
|
||||||
import 'package:cw_core/pathForWallet.dart';
|
import 'package:cw_core/pathForWallet.dart';
|
||||||
import 'package:cw_core/unspent_coins_info.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_core/get_height_by_date.dart';
|
||||||
import 'package:cw_monero/api/exceptions/wallet_opening_exception.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' as monero_wallet_manager;
|
||||||
|
import 'package:cw_monero/api/wallet_manager.dart';
|
||||||
import 'package:cw_monero/monero_wallet.dart';
|
import 'package:cw_monero/monero_wallet.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
import 'package:hive/hive.dart';
|
import 'package:hive/hive.dart';
|
||||||
import 'package:polyseed/polyseed.dart';
|
import 'package:polyseed/polyseed.dart';
|
||||||
|
import 'package:monero/monero.dart' as monero;
|
||||||
|
|
||||||
class MoneroNewWalletCredentials extends WalletCredentials {
|
class MoneroNewWalletCredentials extends WalletCredentials {
|
||||||
MoneroNewWalletCredentials(
|
MoneroNewWalletCredentials(
|
||||||
|
@ -174,6 +178,22 @@ class MoneroWalletService extends WalletService<MoneroNewWalletCredentials,
|
||||||
@override
|
@override
|
||||||
Future<void> remove(String wallet) async {
|
Future<void> remove(String wallet) async {
|
||||||
final path = await pathForWalletDir(name: wallet, type: getType());
|
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 file = Directory(path);
|
||||||
final isExist = file.existsSync();
|
final isExist = file.existsSync();
|
||||||
|
|
||||||
|
|
|
@ -7,18 +7,18 @@
|
||||||
#include "generated_plugin_registrant.h"
|
#include "generated_plugin_registrant.h"
|
||||||
|
|
||||||
#include <connectivity_plus/connectivity_plus_windows_plugin.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 <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 <permission_handler_windows/permission_handler_windows_plugin.h>
|
||||||
#include <url_launcher_windows/url_launcher_windows.h>
|
#include <url_launcher_windows/url_launcher_windows.h>
|
||||||
|
|
||||||
void RegisterPlugins(flutter::PluginRegistry* registry) {
|
void RegisterPlugins(flutter::PluginRegistry* registry) {
|
||||||
ConnectivityPlusWindowsPluginRegisterWithRegistrar(
|
ConnectivityPlusWindowsPluginRegisterWithRegistrar(
|
||||||
registry->GetRegistrarForPlugin("ConnectivityPlusWindowsPlugin"));
|
registry->GetRegistrarForPlugin("ConnectivityPlusWindowsPlugin"));
|
||||||
|
FlutterLocalAuthenticationPluginCApiRegisterWithRegistrar(
|
||||||
|
registry->GetRegistrarForPlugin("FlutterLocalAuthenticationPluginCApi"));
|
||||||
FlutterSecureStorageWindowsPluginRegisterWithRegistrar(
|
FlutterSecureStorageWindowsPluginRegisterWithRegistrar(
|
||||||
registry->GetRegistrarForPlugin("FlutterSecureStorageWindowsPlugin"));
|
registry->GetRegistrarForPlugin("FlutterSecureStorageWindowsPlugin"));
|
||||||
LocalAuthPluginRegisterWithRegistrar(
|
|
||||||
registry->GetRegistrarForPlugin("LocalAuthPlugin"));
|
|
||||||
PermissionHandlerWindowsPluginRegisterWithRegistrar(
|
PermissionHandlerWindowsPluginRegisterWithRegistrar(
|
||||||
registry->GetRegistrarForPlugin("PermissionHandlerWindowsPlugin"));
|
registry->GetRegistrarForPlugin("PermissionHandlerWindowsPlugin"));
|
||||||
UrlLauncherWindowsRegisterWithRegistrar(
|
UrlLauncherWindowsRegisterWithRegistrar(
|
||||||
|
|
|
@ -4,8 +4,8 @@
|
||||||
|
|
||||||
list(APPEND FLUTTER_PLUGIN_LIST
|
list(APPEND FLUTTER_PLUGIN_LIST
|
||||||
connectivity_plus
|
connectivity_plus
|
||||||
|
flutter_local_authentication
|
||||||
flutter_secure_storage_windows
|
flutter_secure_storage_windows
|
||||||
local_auth_windows
|
|
||||||
permission_handler_windows
|
permission_handler_windows
|
||||||
url_launcher_windows
|
url_launcher_windows
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue