mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-03-22 23:28:53 +00:00
store crash fix
This commit is contained in:
parent
ae1fe4023d
commit
2d883f8f3f
4 changed files with 50 additions and 28 deletions
|
@ -1,8 +1,11 @@
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
import 'dart:ffi';
|
||||||
|
import 'dart:isolate';
|
||||||
|
|
||||||
import 'package:cw_monero/api/account_list.dart';
|
import 'package:cw_monero/api/account_list.dart';
|
||||||
import 'package:cw_monero/api/exceptions/setup_wallet_exception.dart';
|
import 'package:cw_monero/api/exceptions/setup_wallet_exception.dart';
|
||||||
import 'package:monero/monero.dart' as monero;
|
import 'package:monero/monero.dart' as monero;
|
||||||
|
import 'package:mutex/mutex.dart';
|
||||||
|
|
||||||
int getSyncingHeight() {
|
int getSyncingHeight() {
|
||||||
// final height = monero.MONERO_cw_WalletListener_height(getWlptr());
|
// final height = monero.MONERO_cw_WalletListener_height(getWlptr());
|
||||||
|
@ -10,6 +13,7 @@ int getSyncingHeight() {
|
||||||
// print("height: $height / $h2");
|
// print("height: $height / $h2");
|
||||||
return h2;
|
return h2;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isNeededToRefresh() {
|
bool isNeededToRefresh() {
|
||||||
final ret = monero.MONERO_cw_WalletListener_isNeedToRefresh(getWlptr());
|
final ret = monero.MONERO_cw_WalletListener_isNeedToRefresh(getWlptr());
|
||||||
monero.MONERO_cw_WalletListener_resetNeedToRefresh(getWlptr());
|
monero.MONERO_cw_WalletListener_resetNeedToRefresh(getWlptr());
|
||||||
|
@ -21,11 +25,13 @@ bool isNewTransactionExist() {
|
||||||
monero.MONERO_cw_WalletListener_resetIsNewTransactionExist(getWlptr());
|
monero.MONERO_cw_WalletListener_resetIsNewTransactionExist(getWlptr());
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
String getFilename() => monero.Wallet_filename(wptr!);
|
String getFilename() => monero.Wallet_filename(wptr!);
|
||||||
|
|
||||||
String getSeed() {
|
String getSeed() {
|
||||||
// monero.Wallet_setCacheAttribute(wptr!, key: "cakewallet.seed", value: seed);
|
// monero.Wallet_setCacheAttribute(wptr!, key: "cakewallet.seed", value: seed);
|
||||||
final cakepolyseed = monero.Wallet_getCacheAttribute(wptr!, key: "cakewallet.seed");
|
final cakepolyseed =
|
||||||
|
monero.Wallet_getCacheAttribute(wptr!, key: "cakewallet.seed");
|
||||||
if (cakepolyseed != "") {
|
if (cakepolyseed != "") {
|
||||||
return cakepolyseed;
|
return cakepolyseed;
|
||||||
}
|
}
|
||||||
|
@ -37,11 +43,15 @@ String getSeed() {
|
||||||
return legacy;
|
return legacy;
|
||||||
}
|
}
|
||||||
|
|
||||||
String getAddress({int accountIndex = 0, int addressIndex = 1}) => monero.Wallet_address(wptr!, accountIndex: accountIndex, addressIndex: addressIndex);
|
String getAddress({int accountIndex = 0, int addressIndex = 1}) =>
|
||||||
|
monero.Wallet_address(wptr!,
|
||||||
|
accountIndex: accountIndex, addressIndex: addressIndex);
|
||||||
|
|
||||||
int getFullBalance({int accountIndex = 0}) => monero.Wallet_balance(wptr!, accountIndex: accountIndex);
|
int getFullBalance({int accountIndex = 0}) =>
|
||||||
|
monero.Wallet_balance(wptr!, accountIndex: accountIndex);
|
||||||
|
|
||||||
int getUnlockedBalance({int accountIndex = 0}) => monero.Wallet_unlockedBalance(wptr!, accountIndex: accountIndex);
|
int getUnlockedBalance({int accountIndex = 0}) =>
|
||||||
|
monero.Wallet_unlockedBalance(wptr!, accountIndex: accountIndex);
|
||||||
|
|
||||||
int getCurrentHeight() => monero.Wallet_blockChainHeight(wptr!);
|
int getCurrentHeight() => monero.Wallet_blockChainHeight(wptr!);
|
||||||
|
|
||||||
|
@ -66,14 +76,12 @@ bool setupNodeSync(
|
||||||
daemonPassword: $password ?? ''
|
daemonPassword: $password ?? ''
|
||||||
}
|
}
|
||||||
''');
|
''');
|
||||||
monero.Wallet_init(
|
monero.Wallet_init(wptr!,
|
||||||
wptr!,
|
|
||||||
daemonAddress: address,
|
daemonAddress: address,
|
||||||
useSsl: useSSL,
|
useSsl: useSSL,
|
||||||
proxyAddress: socksProxyAddress ?? '',
|
proxyAddress: socksProxyAddress ?? '',
|
||||||
daemonUsername: login ?? '',
|
daemonUsername: login ?? '',
|
||||||
daemonPassword: password ?? ''
|
daemonPassword: password ?? '');
|
||||||
);
|
|
||||||
// monero.Wallet_init3(wptr!, argv0: '', defaultLogBaseName: 'moneroc', console: true);
|
// monero.Wallet_init3(wptr!, argv0: '', defaultLogBaseName: 'moneroc', console: true);
|
||||||
|
|
||||||
final status = monero.Wallet_status(wptr!);
|
final status = monero.Wallet_status(wptr!);
|
||||||
|
@ -96,18 +104,26 @@ Future<bool> connectToNode() async {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setRefreshFromBlockHeight({required int height}) => monero.Wallet_setRefreshFromBlockHeight(wptr!, refresh_from_block_height: height);
|
void setRefreshFromBlockHeight({required int height}) =>
|
||||||
|
monero.Wallet_setRefreshFromBlockHeight(wptr!,
|
||||||
|
refresh_from_block_height: height);
|
||||||
|
|
||||||
void setRecoveringFromSeed({required bool isRecovery}) => monero.Wallet_setRecoveringFromSeed(wptr!, recoveringFromSeed: isRecovery);
|
void setRecoveringFromSeed({required bool isRecovery}) =>
|
||||||
|
monero.Wallet_setRecoveringFromSeed(wptr!, recoveringFromSeed: isRecovery);
|
||||||
|
|
||||||
void storeSync() {
|
final storeMutex = Mutex();
|
||||||
monero.Wallet_store(wptr!);
|
void storeSync() async {
|
||||||
|
await storeMutex.acquire();
|
||||||
|
final addr = wptr!.address;
|
||||||
|
Isolate.run(() {
|
||||||
|
monero.Wallet_store(Pointer.fromAddress(addr));
|
||||||
|
});
|
||||||
|
storeMutex.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
void setPasswordSync(String password) {
|
void setPasswordSync(String password) {
|
||||||
monero.Wallet_setPassword(wptr!, password: password);
|
monero.Wallet_setPassword(wptr!, password: password);
|
||||||
|
|
||||||
|
|
||||||
final status = monero.Wallet_status(wptr!);
|
final status = monero.Wallet_status(wptr!);
|
||||||
if (status == 0) {
|
if (status == 0) {
|
||||||
throw Exception(monero.Wallet_errorString(wptr!));
|
throw Exception(monero.Wallet_errorString(wptr!));
|
||||||
|
@ -132,7 +148,6 @@ class SyncListener {
|
||||||
_lastKnownBlockHeight = 0,
|
_lastKnownBlockHeight = 0,
|
||||||
_initialSyncHeight = 0;
|
_initialSyncHeight = 0;
|
||||||
|
|
||||||
|
|
||||||
void Function(int, int, double) onNewBlock;
|
void Function(int, int, double) onNewBlock;
|
||||||
void Function() onNewTransaction;
|
void Function() onNewTransaction;
|
||||||
|
|
||||||
|
@ -236,7 +251,7 @@ Future<void> setupNode(
|
||||||
bool isLightWallet = false}) async =>
|
bool isLightWallet = false}) async =>
|
||||||
_setupNodeSync({
|
_setupNodeSync({
|
||||||
'address': address,
|
'address': address,
|
||||||
'login': login ,
|
'login': login,
|
||||||
'password': password,
|
'password': password,
|
||||||
'useSSL': useSSL,
|
'useSSL': useSSL,
|
||||||
'isLightWallet': isLightWallet,
|
'isLightWallet': isLightWallet,
|
||||||
|
@ -252,10 +267,12 @@ Future<int> getNodeHeight() async => _getNodeHeight(0);
|
||||||
void rescanBlockchainAsync() => monero.Wallet_rescanBlockchainAsync(wptr!);
|
void rescanBlockchainAsync() => monero.Wallet_rescanBlockchainAsync(wptr!);
|
||||||
|
|
||||||
String getSubaddressLabel(int accountIndex, int addressIndex) {
|
String getSubaddressLabel(int accountIndex, int addressIndex) {
|
||||||
return monero.Wallet_getSubaddressLabel(wptr!, accountIndex: accountIndex, addressIndex: addressIndex);
|
return monero.Wallet_getSubaddressLabel(wptr!,
|
||||||
|
accountIndex: accountIndex, addressIndex: addressIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future setTrustedDaemon(bool trusted) async => monero.Wallet_setTrustedDaemon(wptr!, arg: trusted);
|
Future setTrustedDaemon(bool trusted) async =>
|
||||||
|
monero.Wallet_setTrustedDaemon(wptr!, arg: trusted);
|
||||||
|
|
||||||
Future<bool> trustedDaemon() async => monero.Wallet_trustedDaemon(wptr!);
|
Future<bool> trustedDaemon() async => monero.Wallet_trustedDaemon(wptr!);
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import 'dart:ffi';
|
import 'dart:ffi';
|
||||||
|
import 'dart:isolate';
|
||||||
|
|
||||||
import 'package:cw_monero/api/account_list.dart';
|
import 'package:cw_monero/api/account_list.dart';
|
||||||
import 'package:cw_monero/api/exceptions/wallet_creation_exception.dart';
|
import 'package:cw_monero/api/exceptions/wallet_creation_exception.dart';
|
||||||
|
@ -190,7 +191,10 @@ void loadWallet(
|
||||||
try {
|
try {
|
||||||
if (wptr == null || path != _lastOpenedWallet) {
|
if (wptr == null || path != _lastOpenedWallet) {
|
||||||
if (wptr != null) {
|
if (wptr != null) {
|
||||||
monero.Wallet_store(wptr!);
|
final addr = wptr!.address;
|
||||||
|
Isolate.run(() {
|
||||||
|
monero.Wallet_store(Pointer.fromAddress(addr));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
wptr = monero.WalletManager_openWallet(wmPtr,
|
wptr = monero.WalletManager_openWallet(wmPtr,
|
||||||
path: path, password: password);
|
path: path, password: password);
|
||||||
|
|
|
@ -26,6 +26,7 @@ dependencies:
|
||||||
git:
|
git:
|
||||||
url: https://git.mrcyjanek.net/mrcyjanek/monero.dart
|
url: https://git.mrcyjanek.net/mrcyjanek/monero.dart
|
||||||
ref: 6a17a405a1a260fa228b2f4fc94044088a4335ac
|
ref: 6a17a405a1a260fa228b2f4fc94044088a4335ac
|
||||||
|
mutex: ^3.1.0
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
|
|
@ -10,7 +10,7 @@ if [[ ! -d "monero_c" ]];
|
||||||
then
|
then
|
||||||
git clone https://github.com/mrcyjanek/monero_c --branch rewrite-wip
|
git clone https://github.com/mrcyjanek/monero_c --branch rewrite-wip
|
||||||
cd monero_c
|
cd monero_c
|
||||||
git checkout 6781419926d38e045680035a6c2dfcfe32fa22a2
|
git checkout 4a9142a36f1fca90372216f40e799fabb38e27d7
|
||||||
git reset --hard
|
git reset --hard
|
||||||
git submodule update --init --force --recursive
|
git submodule update --init --force --recursive
|
||||||
./apply_patches.sh monero
|
./apply_patches.sh monero
|
||||||
|
|
Loading…
Reference in a new issue