mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-03 17:40:43 +00:00
Fixes for 4.0.94. Changed version for 4.0.94.
This commit is contained in:
parent
647577497d
commit
84ad97c0b0
5 changed files with 26 additions and 29 deletions
|
@ -1,8 +0,0 @@
|
|||
class WalletLoadingException implements Exception {
|
||||
WalletLoadingException({this.message});
|
||||
|
||||
final String message;
|
||||
|
||||
@override
|
||||
String toString() => message;
|
||||
}
|
8
cw_monero/lib/exceptions/wallet_opening_exception.dart
Normal file
8
cw_monero/lib/exceptions/wallet_opening_exception.dart
Normal file
|
@ -0,0 +1,8 @@
|
|||
class WalletOpeningException implements Exception {
|
||||
WalletOpeningException({this.message});
|
||||
|
||||
final String message;
|
||||
|
||||
@override
|
||||
String toString() => message;
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
import 'dart:ffi';
|
||||
import 'package:cw_monero/exceptions/wallet_opening_exception.dart';
|
||||
import 'package:cw_monero/wallet.dart';
|
||||
import 'package:ffi/ffi.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
@ -7,7 +8,6 @@ import 'package:cw_monero/signatures.dart';
|
|||
import 'package:cw_monero/types.dart';
|
||||
import 'package:cw_monero/monero_api.dart';
|
||||
import 'package:cw_monero/exceptions/wallet_creation_exception.dart';
|
||||
import 'package:cw_monero/exceptions/wallet_loading_exception.dart';
|
||||
import 'package:cw_monero/exceptions/wallet_restore_from_keys_exception.dart';
|
||||
import 'package:cw_monero/exceptions/wallet_restore_from_seed_exception.dart';
|
||||
|
||||
|
@ -146,7 +146,7 @@ void loadWallet({String path, String password, int nettype = 0}) {
|
|||
free(passwordPointer);
|
||||
|
||||
if (!loaded) {
|
||||
throw WalletLoadingException(
|
||||
throw WalletOpeningException(
|
||||
message: convertUTF8ToString(pointer: errorStringNative()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ import 'package:cake_wallet/core/wallet_base.dart';
|
|||
import 'package:hive/hive.dart';
|
||||
import 'package:cw_monero/wallet_manager.dart' as monero_wallet_manager;
|
||||
import 'package:cw_monero/wallet.dart' as monero_wallet;
|
||||
import 'package:cw_monero/exceptions/wallet_loading_exception.dart';
|
||||
import 'package:cw_monero/exceptions/wallet_opening_exception.dart';
|
||||
import 'package:cake_wallet/monero/monero_wallet.dart';
|
||||
import 'package:cake_wallet/core/wallet_credentials.dart';
|
||||
import 'package:cake_wallet/core/wallet_service.dart';
|
||||
|
@ -56,7 +56,7 @@ class MoneroWalletService extends WalletService<
|
|||
|
||||
final Box<WalletInfo> walletInfoSource;
|
||||
|
||||
static void _removeCache(String name) async {
|
||||
static Future<void> _removeCache(String name) async {
|
||||
final path = await pathForWallet(name: name, type: WalletType.monero);
|
||||
final cacheFile = File(path);
|
||||
|
||||
|
@ -65,6 +65,9 @@ class MoneroWalletService extends WalletService<
|
|||
}
|
||||
}
|
||||
|
||||
static bool walletFilesExist(String path) =>
|
||||
!File(path).existsSync() && !File('$path.keys').existsSync();
|
||||
|
||||
@override
|
||||
Future<MoneroWallet> create(MoneroNewWalletCredentials credentials) async {
|
||||
try {
|
||||
|
@ -104,7 +107,7 @@ class MoneroWalletService extends WalletService<
|
|||
try {
|
||||
final path = await pathForWallet(name: name, type: WalletType.monero);
|
||||
|
||||
if (!File(path).existsSync()) {
|
||||
if (walletFilesExist(path)) {
|
||||
await repairOldAndroidWallet(name);
|
||||
}
|
||||
|
||||
|
@ -118,17 +121,9 @@ class MoneroWalletService extends WalletService<
|
|||
final isValid = wallet.validate();
|
||||
|
||||
if (!isValid) {
|
||||
// if (wallet.seed?.isNotEmpty ?? false) {
|
||||
// let restore from seed in this case;
|
||||
// final seed = wallet.seed;
|
||||
// final credentials = MoneroRestoreWalletFromSeedCredentials(
|
||||
// name: name, password: password, mnemonic: seed, height: 2000000)
|
||||
// ..walletInfo = walletInfo;
|
||||
// await remove(name);
|
||||
// return restoreFromSeed(credentials);
|
||||
// }
|
||||
|
||||
throw MoneroWalletLoadingException();
|
||||
await _removeCache(name);
|
||||
wallet.close();
|
||||
return openWallet(name, password);
|
||||
}
|
||||
|
||||
await wallet.init();
|
||||
|
@ -137,8 +132,11 @@ class MoneroWalletService extends WalletService<
|
|||
} catch (e) {
|
||||
// TODO: Implement Exception for wallet list service.
|
||||
|
||||
if (e.message == 'std::bad_alloc') {
|
||||
_removeCache(name);
|
||||
if (e.toString().contains('bad_alloc') ||
|
||||
(e is WalletOpeningException &&
|
||||
(e.message == 'std::bad_alloc' ||
|
||||
e.message.contains('bad_alloc')))) {
|
||||
await _removeCache(name);
|
||||
return openWallet(name, password);
|
||||
}
|
||||
|
||||
|
@ -219,7 +217,7 @@ class MoneroWalletService extends WalletService<
|
|||
final dir = Directory(oldAndroidWalletDirPath);
|
||||
|
||||
if (!dir.existsSync()) {
|
||||
throw MoneroWalletLoadingException();
|
||||
return;
|
||||
}
|
||||
|
||||
final newWalletDirPath =
|
||||
|
@ -238,7 +236,6 @@ class MoneroWalletService extends WalletService<
|
|||
});
|
||||
} catch (e) {
|
||||
print(e.toString());
|
||||
throw MoneroWalletLoadingException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ description: Cake Wallet.
|
|||
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
|
||||
# Read more about iOS versioning at
|
||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
||||
version: 4.0.92+23
|
||||
version: 4.0.94+25
|
||||
|
||||
environment:
|
||||
sdk: ">=2.7.0 <3.0.0"
|
||||
|
|
Loading…
Reference in a new issue