mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-10 21:04:53 +00:00
Merge branch 'main' of https://github.com/cake-tech/cake_wallet into v4.11.0_v1.8.0
This commit is contained in:
commit
b544ebc660
3 changed files with 13 additions and 29 deletions
|
@ -1,14 +1,16 @@
|
||||||
import 'dart:ffi';
|
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/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_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_keys_exception.dart';
|
||||||
import 'package:cw_monero/api/exceptions/wallet_restore_from_seed_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
|
final createWalletNative = moneroApi
|
||||||
.lookup<NativeFunction<create_wallet>>('create_wallet')
|
.lookup<NativeFunction<create_wallet>>('create_wallet')
|
||||||
|
@ -175,6 +177,8 @@ void restoreWalletFromSpendKeySync(
|
||||||
calloc.free(languagePointer);
|
calloc.free(languagePointer);
|
||||||
calloc.free(spendKeyPointer);
|
calloc.free(spendKeyPointer);
|
||||||
|
|
||||||
|
storeSync();
|
||||||
|
|
||||||
if (!isWalletRestored) {
|
if (!isWalletRestored) {
|
||||||
throw WalletRestoreFromKeysException(
|
throw WalletRestoreFromKeysException(
|
||||||
message: convertUTF8ToString(pointer: errorMessagePointer));
|
message: convertUTF8ToString(pointer: errorMessagePointer));
|
||||||
|
|
|
@ -97,8 +97,7 @@ abstract class MoneroWalletBase
|
||||||
ObservableMap<CryptoCurrency, MoneroBalance> balance;
|
ObservableMap<CryptoCurrency, MoneroBalance> balance;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get seed => _seed;
|
String get seed => monero_wallet.getSeed();
|
||||||
String _seed = monero_wallet.getSeed();
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
MoneroWalletKeys get keys => MoneroWalletKeys(
|
MoneroWalletKeys get keys => MoneroWalletKeys(
|
||||||
|
@ -114,11 +113,7 @@ abstract class MoneroWalletBase
|
||||||
Timer? _autoSaveTimer;
|
Timer? _autoSaveTimer;
|
||||||
List<MoneroUnspent> unspentCoins;
|
List<MoneroUnspent> unspentCoins;
|
||||||
|
|
||||||
Future<void> init({String seedFallback = ""}) async {
|
Future<void> init() async {
|
||||||
if (_seed.isEmpty) {
|
|
||||||
_seed = seedFallback;
|
|
||||||
}
|
|
||||||
|
|
||||||
await walletAddresses.init();
|
await walletAddresses.init();
|
||||||
balance = ObservableMap<CryptoCurrency, MoneroBalance>.of(<CryptoCurrency, MoneroBalance>{
|
balance = ObservableMap<CryptoCurrency, MoneroBalance>.of(<CryptoCurrency, MoneroBalance>{
|
||||||
currency: MoneroBalance(
|
currency: MoneroBalance(
|
||||||
|
|
|
@ -2,7 +2,6 @@ import 'dart:io';
|
||||||
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';
|
||||||
import 'package:cw_core/utils/file.dart';
|
|
||||||
import 'package:cw_core/wallet_base.dart';
|
import 'package:cw_core/wallet_base.dart';
|
||||||
import 'package:cw_core/wallet_credentials.dart';
|
import 'package:cw_core/wallet_credentials.dart';
|
||||||
import 'package:cw_core/wallet_info.dart';
|
import 'package:cw_core/wallet_info.dart';
|
||||||
|
@ -134,12 +133,7 @@ class MoneroWalletService extends WalletService<
|
||||||
return openWallet(name, password);
|
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;
|
return wallet;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -295,8 +289,6 @@ class MoneroWalletService extends WalletService<
|
||||||
restoreHeight: height,
|
restoreHeight: height,
|
||||||
spendKey: spendKey);
|
spendKey: spendKey);
|
||||||
|
|
||||||
await writeData(path: "$path.seed", password: password, data: seed);
|
|
||||||
|
|
||||||
final wallet = MoneroWallet(
|
final wallet = MoneroWallet(
|
||||||
walletInfo: walletInfo, unspentCoinsInfo: unspentCoinsInfoSource);
|
walletInfo: walletInfo, unspentCoinsInfo: unspentCoinsInfoSource);
|
||||||
await wallet.init();
|
await wallet.init();
|
||||||
|
@ -304,13 +296,6 @@ class MoneroWalletService extends WalletService<
|
||||||
return wallet;
|
return wallet;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<String> _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<void> repairOldAndroidWallet(String name) async {
|
Future<void> repairOldAndroidWallet(String name) async {
|
||||||
try {
|
try {
|
||||||
if (!Platform.isAndroid) {
|
if (!Platform.isAndroid) {
|
||||||
|
|
Loading…
Reference in a new issue