mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-10 21:04: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:ffi';
|
||||
import 'dart:isolate';
|
||||
|
||||
import 'package:cw_monero/api/account_list.dart';
|
||||
import 'package:cw_monero/api/exceptions/setup_wallet_exception.dart';
|
||||
import 'package:monero/monero.dart' as monero;
|
||||
import 'package:mutex/mutex.dart';
|
||||
|
||||
int getSyncingHeight() {
|
||||
// final height = monero.MONERO_cw_WalletListener_height(getWlptr());
|
||||
|
@ -10,6 +13,7 @@ int getSyncingHeight() {
|
|||
// print("height: $height / $h2");
|
||||
return h2;
|
||||
}
|
||||
|
||||
bool isNeededToRefresh() {
|
||||
final ret = monero.MONERO_cw_WalletListener_isNeedToRefresh(getWlptr());
|
||||
monero.MONERO_cw_WalletListener_resetNeedToRefresh(getWlptr());
|
||||
|
@ -21,11 +25,13 @@ bool isNewTransactionExist() {
|
|||
monero.MONERO_cw_WalletListener_resetIsNewTransactionExist(getWlptr());
|
||||
return ret;
|
||||
}
|
||||
|
||||
String getFilename() => monero.Wallet_filename(wptr!);
|
||||
|
||||
String getSeed() {
|
||||
// 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 != "") {
|
||||
return cakepolyseed;
|
||||
}
|
||||
|
@ -37,11 +43,15 @@ String getSeed() {
|
|||
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!);
|
||||
|
||||
|
@ -66,14 +76,12 @@ bool setupNodeSync(
|
|||
daemonPassword: $password ?? ''
|
||||
}
|
||||
''');
|
||||
monero.Wallet_init(
|
||||
wptr!,
|
||||
monero.Wallet_init(wptr!,
|
||||
daemonAddress: address,
|
||||
useSsl: useSSL,
|
||||
proxyAddress: socksProxyAddress ?? '',
|
||||
daemonUsername: login ?? '',
|
||||
daemonPassword: password ?? ''
|
||||
);
|
||||
daemonPassword: password ?? '');
|
||||
// monero.Wallet_init3(wptr!, argv0: '', defaultLogBaseName: 'moneroc', console: true);
|
||||
|
||||
final status = monero.Wallet_status(wptr!);
|
||||
|
@ -96,18 +104,26 @@ Future<bool> connectToNode() async {
|
|||
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() {
|
||||
monero.Wallet_store(wptr!);
|
||||
final storeMutex = Mutex();
|
||||
void storeSync() async {
|
||||
await storeMutex.acquire();
|
||||
final addr = wptr!.address;
|
||||
Isolate.run(() {
|
||||
monero.Wallet_store(Pointer.fromAddress(addr));
|
||||
});
|
||||
storeMutex.release();
|
||||
}
|
||||
|
||||
void setPasswordSync(String password) {
|
||||
monero.Wallet_setPassword(wptr!, password: password);
|
||||
|
||||
|
||||
final status = monero.Wallet_status(wptr!);
|
||||
if (status == 0) {
|
||||
throw Exception(monero.Wallet_errorString(wptr!));
|
||||
|
@ -132,7 +148,6 @@ class SyncListener {
|
|||
_lastKnownBlockHeight = 0,
|
||||
_initialSyncHeight = 0;
|
||||
|
||||
|
||||
void Function(int, int, double) onNewBlock;
|
||||
void Function() onNewTransaction;
|
||||
|
||||
|
@ -236,7 +251,7 @@ Future<void> setupNode(
|
|||
bool isLightWallet = false}) async =>
|
||||
_setupNodeSync({
|
||||
'address': address,
|
||||
'login': login ,
|
||||
'login': login,
|
||||
'password': password,
|
||||
'useSSL': useSSL,
|
||||
'isLightWallet': isLightWallet,
|
||||
|
@ -252,10 +267,12 @@ Future<int> getNodeHeight() async => _getNodeHeight(0);
|
|||
void rescanBlockchainAsync() => monero.Wallet_rescanBlockchainAsync(wptr!);
|
||||
|
||||
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!);
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import 'dart:ffi';
|
||||
import 'dart:isolate';
|
||||
|
||||
import 'package:cw_monero/api/account_list.dart';
|
||||
import 'package:cw_monero/api/exceptions/wallet_creation_exception.dart';
|
||||
|
@ -190,7 +191,10 @@ void loadWallet(
|
|||
try {
|
||||
if (wptr == null || path != _lastOpenedWallet) {
|
||||
if (wptr != null) {
|
||||
monero.Wallet_store(wptr!);
|
||||
final addr = wptr!.address;
|
||||
Isolate.run(() {
|
||||
monero.Wallet_store(Pointer.fromAddress(addr));
|
||||
});
|
||||
}
|
||||
wptr = monero.WalletManager_openWallet(wmPtr,
|
||||
path: path, password: password);
|
||||
|
|
|
@ -26,6 +26,7 @@ dependencies:
|
|||
git:
|
||||
url: https://git.mrcyjanek.net/mrcyjanek/monero.dart
|
||||
ref: 6a17a405a1a260fa228b2f4fc94044088a4335ac
|
||||
mutex: ^3.1.0
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
|
|
@ -10,7 +10,7 @@ if [[ ! -d "monero_c" ]];
|
|||
then
|
||||
git clone https://github.com/mrcyjanek/monero_c --branch rewrite-wip
|
||||
cd monero_c
|
||||
git checkout 6781419926d38e045680035a6c2dfcfe32fa22a2
|
||||
git checkout 4a9142a36f1fca90372216f40e799fabb38e27d7
|
||||
git reset --hard
|
||||
git submodule update --init --force --recursive
|
||||
./apply_patches.sh monero
|
||||
|
|
Loading…
Reference in a new issue