mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-22 19:49:22 +00:00
some cleanup
This commit is contained in:
parent
3eaec03b6c
commit
df984ca515
19 changed files with 202 additions and 1034 deletions
|
@ -4,11 +4,20 @@ import 'dart:convert';
|
|||
import 'package:cw_zano/api/convert_utf8_to_string.dart';
|
||||
import 'package:cw_zano/api/model/get_recent_txs_and_info_params.dart';
|
||||
import 'package:cw_zano/api/model/transfer_params.dart';
|
||||
import 'package:cw_zano/api/structs/utf8_box.dart';
|
||||
import 'package:cw_zano/api/zano_api.dart';
|
||||
import 'package:ffi/ffi.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
// create_wallet
|
||||
// bool setup_node(char *address, char *login, char *password, bool use_ssl, bool is_light_wallet, char *error)
|
||||
final _setupNodeNative =
|
||||
zanoApi.lookup<NativeFunction<_setup_node>>('setup_node').asFunction<_SetupNode>();
|
||||
typedef _setup_node = Int8 Function(
|
||||
Pointer<Utf8>, Pointer<Utf8>?, Pointer<Utf8>?, Int8, Int8, Pointer<Utf8>);
|
||||
typedef _SetupNode = int Function(
|
||||
Pointer<Utf8>, Pointer<Utf8>?, Pointer<Utf8>?, int, int, Pointer<Utf8>);
|
||||
|
||||
// char * create_wallet(char *path, char *password, char *language, int32_t networkType, char *error)
|
||||
final _createWalletNative =
|
||||
zanoApi.lookup<NativeFunction<_create_wallet>>('create_wallet').asFunction<_CreateWallet>();
|
||||
typedef _create_wallet = Pointer<Utf8> Function(
|
||||
|
@ -16,66 +25,67 @@ typedef _create_wallet = Pointer<Utf8> Function(
|
|||
typedef _CreateWallet = Pointer<Utf8> Function(
|
||||
Pointer<Utf8>, Pointer<Utf8>, Pointer<Utf8>, int, Pointer<Utf8>);
|
||||
|
||||
// async_call
|
||||
// char* async_call(char* method_name, uint64_t instance_id, char* params)
|
||||
final _asyncCallNative =
|
||||
zanoApi.lookup<NativeFunction<_async_call>>('async_call').asFunction<_AsyncCall>();
|
||||
typedef _async_call = Pointer<Utf8> Function(Pointer<Utf8>, Int64, Pointer<Utf8>);
|
||||
typedef _AsyncCall = Pointer<Utf8> Function(
|
||||
Pointer<Utf8> methodName, int hWallet, Pointer<Utf8> params);
|
||||
|
||||
// get_wallet_status
|
||||
// char* get_wallet_status(uint64_t hwallet)
|
||||
final _getWalletStatusNative = zanoApi
|
||||
.lookup<NativeFunction<_get_wallet_status>>('get_wallet_status')
|
||||
.asFunction<_GetWalletStatus>();
|
||||
typedef _get_wallet_status = Pointer<Utf8> Function(Int64);
|
||||
typedef _GetWalletStatus = Pointer<Utf8> Function(int hWallet);
|
||||
|
||||
// get_wallet_info
|
||||
// char *get_wallet_info(uint64_t hwallet)
|
||||
final _getWalletInfoNative = zanoApi
|
||||
.lookup<NativeFunction<_get_wallet_info>>('get_wallet_info')
|
||||
.asFunction<_GetWalletInfo>();
|
||||
typedef _get_wallet_info = Pointer<Utf8> Function(Int64);
|
||||
typedef _GetWalletInfo = Pointer<Utf8> Function(int hWallet);
|
||||
|
||||
// get_connectivity_status
|
||||
// char* get_connectivity_status()
|
||||
final _getConnectivityStatusNative = zanoApi
|
||||
.lookup<NativeFunction<_get_connectivity_status>>('get_connectivity_status')
|
||||
.asFunction<_GetConnectivityStatus>();
|
||||
typedef _get_connectivity_status = Pointer<Utf8> Function();
|
||||
typedef _GetConnectivityStatus = Pointer<Utf8> Function();
|
||||
|
||||
// get_version
|
||||
// char* get_version()
|
||||
final _getVersionNative =
|
||||
zanoApi.lookup<NativeFunction<_get_version>>('get_version').asFunction<_GetVersion>();
|
||||
typedef _get_version = Pointer<Utf8> Function();
|
||||
typedef _GetVersion = Pointer<Utf8> Function();
|
||||
|
||||
// load_wallet
|
||||
// char * load_wallet(char *path, char *password, int32_t nettype)
|
||||
final _loadWalletNative =
|
||||
zanoApi.lookup<NativeFunction<_load_wallet>>('load_wallet').asFunction<_LoadWallet>();
|
||||
typedef _load_wallet = Pointer<Utf8> Function(Pointer<Utf8>, Pointer<Utf8>, Int8);
|
||||
typedef _LoadWallet = Pointer<Utf8> Function(Pointer<Utf8>, Pointer<Utf8>, int);
|
||||
|
||||
// try_pull_result
|
||||
// char* try_pull_result(uint64_t job_id)
|
||||
final _tryPullResultNative = zanoApi
|
||||
.lookup<NativeFunction<_try_pull_result>>('try_pull_result')
|
||||
.asFunction<_TryPullResult>();
|
||||
typedef _try_pull_result = Pointer<Utf8> Function(Int64);
|
||||
typedef _TryPullResult = Pointer<Utf8> Function(int hWallet);
|
||||
|
||||
// close_wallet
|
||||
// void close_wallet(uint64_t hwallet)
|
||||
final _closeWalletNative =
|
||||
zanoApi.lookup<NativeFunction<_close_wallet>>('close_wallet').asFunction<_closeWalletStatus>();
|
||||
typedef _close_wallet = Void Function(Int64);
|
||||
typedef _closeWalletStatus = void Function(int hWallet);
|
||||
|
||||
// get_current_tx_fee
|
||||
// uint64_t get_current_tx_fee(uint64_t priority)
|
||||
final _getCurrentTxFeeNative = zanoApi
|
||||
.lookup<NativeFunction<_get_current_tx_fee>>('get_current_tx_fee')
|
||||
.asFunction<_getCurrentTxFee>();
|
||||
typedef _get_current_tx_fee = Int64 Function(Int64);
|
||||
typedef _getCurrentTxFee = int Function(int priority);
|
||||
|
||||
// char * restore_wallet_from_seed(char *path, char *password, char *seed, int32_t networkType, uint64_t restoreHeight, char *error)
|
||||
final _restoreWalletFromSeedNative = zanoApi
|
||||
.lookup<NativeFunction<_restore_wallet_from_seed>>('restore_wallet_from_seed')
|
||||
.asFunction<_RestoreWalletFromSeed>();
|
||||
|
@ -84,7 +94,86 @@ typedef _restore_wallet_from_seed = Pointer<Utf8> Function(
|
|||
typedef _RestoreWalletFromSeed = Pointer<Utf8> Function(
|
||||
Pointer<Utf8>, Pointer<Utf8>, Pointer<Utf8>, int, int, Pointer<Utf8>);
|
||||
|
||||
String doAsyncCall({required String methodName, required int hWallet, required String params}) {
|
||||
// char* set_password(uint64_t hwallet, char *password, Utf8Box &error)
|
||||
final _setPasswordNative =
|
||||
zanoApi.lookup<NativeFunction<_set_password>>('set_password').asFunction<_SetPassword>();
|
||||
typedef _set_password = Pointer<Utf8> Function(Int64 hWallet, Pointer<Utf8> password, Pointer<Utf8Box> error);
|
||||
typedef _SetPassword = Pointer<Utf8> Function(int hWallet, Pointer<Utf8> password, Pointer<Utf8Box> error);
|
||||
|
||||
String setPassword({required int hWallet, required String password}) {
|
||||
final passwordPointer = password.toNativeUtf8();
|
||||
final errorMessagePointer = calloc<Utf8Box>();
|
||||
final result =
|
||||
convertUTF8ToString(pointer: _setPasswordNative(hWallet, passwordPointer, errorMessagePointer));
|
||||
calloc.free(passwordPointer);
|
||||
|
||||
/*if (!changed) {
|
||||
final message = errorMessagePointer.ref.getValue();
|
||||
calloc.free(errorMessagePointer);
|
||||
throw Exception(message);
|
||||
}*/
|
||||
|
||||
calloc.free(errorMessagePointer);
|
||||
return result;
|
||||
}
|
||||
|
||||
// is_wallet_exist(char *path)
|
||||
final _isWalletExistNative = zanoApi
|
||||
.lookup<NativeFunction<_is_wallet_exist>>('is_wallet_exist')
|
||||
.asFunction<_IsWalletExist>();
|
||||
typedef _is_wallet_exist = Int8 Function(Pointer<Utf8>);
|
||||
typedef _IsWalletExist = int Function(Pointer<Utf8>);
|
||||
|
||||
bool isWalletExist({required String path}) {
|
||||
final pathPointer = path.toNativeUtf8();
|
||||
final isExist = _isWalletExistNative(pathPointer) != 0;
|
||||
calloc.free(pathPointer);
|
||||
return isExist;
|
||||
}
|
||||
|
||||
bool setupNode({
|
||||
required String address,
|
||||
String? login,
|
||||
String? password,
|
||||
bool useSSL = false,
|
||||
bool isLightWallet = false,
|
||||
/*String? socksProxyAddress*/
|
||||
}) {
|
||||
final addressPointer = address.toNativeUtf8();
|
||||
Pointer<Utf8>? loginPointer;
|
||||
Pointer<Utf8>? socksProxyAddressPointer;
|
||||
Pointer<Utf8>? passwordPointer;
|
||||
|
||||
if (login != null) {
|
||||
loginPointer = login.toNativeUtf8();
|
||||
}
|
||||
|
||||
if (password != null) {
|
||||
passwordPointer = password.toNativeUtf8();
|
||||
}
|
||||
|
||||
final errorMessagePointer = ''.toNativeUtf8();
|
||||
debugPrint(
|
||||
"setup_node address $address login $login password $password useSSL $useSSL isLightWallet $isLightWallet");
|
||||
final isSetupNode = _setupNodeNative(addressPointer, loginPointer, passwordPointer,
|
||||
_boolToInt(useSSL), _boolToInt(isLightWallet), errorMessagePointer) !=
|
||||
0;
|
||||
debugPrint("setup_node result $isSetupNode");
|
||||
|
||||
calloc.free(addressPointer);
|
||||
|
||||
if (loginPointer != null) {
|
||||
calloc.free(loginPointer);
|
||||
}
|
||||
|
||||
if (passwordPointer != null) {
|
||||
calloc.free(passwordPointer);
|
||||
}
|
||||
|
||||
return isSetupNode;
|
||||
}
|
||||
|
||||
String asyncCall({required String methodName, required int hWallet, required String params}) {
|
||||
final methodNamePointer = methodName.toNativeUtf8();
|
||||
final paramsPointer = params.toNativeUtf8();
|
||||
|
||||
|
@ -118,7 +207,7 @@ String createWallet(
|
|||
|
||||
Future<String> invokeMethod(int hWallet, String methodName, String params) async {
|
||||
debugPrint('invoke method $methodName params $params');
|
||||
final invokeResult = doAsyncCall(
|
||||
final invokeResult = asyncCall(
|
||||
methodName: 'invoke',
|
||||
hWallet: hWallet,
|
||||
params: json.encode({
|
||||
|
@ -140,7 +229,7 @@ Future<String> store(int hWallet) async {
|
|||
}
|
||||
|
||||
Future<String> transfer(int hWallet, TransferParams params) async {
|
||||
final invokeResult = await doAsyncCall(
|
||||
final invokeResult = await asyncCall(
|
||||
methodName: 'invoke',
|
||||
hWallet: hWallet,
|
||||
params: '{"method": "transfer","params": ${jsonEncode(params)}}',
|
||||
|
@ -166,7 +255,10 @@ Future<String> getRecentTxsAndInfo(
|
|||
'get_recent_txs_and_info',
|
||||
json.encode(
|
||||
GetRecentTxsAndInfoParams(
|
||||
offset: offset, count: count, updateProvisionInfo: updateProvisionInfo),
|
||||
offset: offset,
|
||||
count: count,
|
||||
updateProvisionInfo: updateProvisionInfo,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@ -218,6 +310,7 @@ String restoreWalletFromSeed(String path, String password, String seed) {
|
|||
final result = convertUTF8ToString(
|
||||
pointer: _restoreWalletFromSeedNative(
|
||||
pathPointer, passwordPointer, seedPointer, 0, 0, errorMessagePointer));
|
||||
debugPrint('restore wallet from seed result $result');
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -238,3 +331,5 @@ String tryPullResult(int jobId) {
|
|||
debugPrint('try_pull_result result $result');
|
||||
return result;
|
||||
}
|
||||
|
||||
int _boolToInt(bool value) => value ? 1 : 0;
|
||||
|
|
4
cw_zano/lib/api/consts.dart
Normal file
4
cw_zano/lib/api/consts.dart
Normal file
|
@ -0,0 +1,4 @@
|
|||
class Consts {
|
||||
static const errorWrongSeed = 'WRONG_SEED';
|
||||
static const errorAlreadyExists = 'ALREADY_EXISTS';
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
class CwZano {
|
||||
static const MethodChannel _channel = const MethodChannel('cw_zano');
|
||||
|
||||
static Future<String> get platformVersion async {
|
||||
final String version =
|
||||
await _channel.invokeMethod<String>('getPlatformVersion') ?? '';
|
||||
return version;
|
||||
}
|
||||
}
|
6
cw_zano/lib/api/exceptions/already_exists_exception.dart
Normal file
6
cw_zano/lib/api/exceptions/already_exists_exception.dart
Normal file
|
@ -0,0 +1,6 @@
|
|||
import 'package:cw_zano/api/consts.dart';
|
||||
import 'package:cw_zano/api/exceptions/api_exception.dart';
|
||||
|
||||
class AlreadyExistsException extends ApiException {
|
||||
AlreadyExistsException(String message): super(Consts.errorAlreadyExists, message);
|
||||
}
|
9
cw_zano/lib/api/exceptions/api_exception.dart
Normal file
9
cw_zano/lib/api/exceptions/api_exception.dart
Normal file
|
@ -0,0 +1,9 @@
|
|||
class ApiException implements Exception {
|
||||
final String code;
|
||||
final String message;
|
||||
|
||||
ApiException(this.code, this.message);
|
||||
|
||||
@override
|
||||
String toString() => '${this.runtimeType}(code: $code, message: $message)';
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
import 'package:cw_zano/api/exceptions/api_exception.dart';
|
||||
|
||||
class RestoreFromSeedException extends ApiException {
|
||||
RestoreFromSeedException(String code, String message): super(code, message);
|
||||
}
|
5
cw_zano/lib/api/exceptions/transfer_exception.dart
Normal file
5
cw_zano/lib/api/exceptions/transfer_exception.dart
Normal file
|
@ -0,0 +1,5 @@
|
|||
import 'package:cw_zano/api/exceptions/api_exception.dart';
|
||||
|
||||
class TransferException extends ApiException {
|
||||
TransferException(String code, String message): super(code, message);
|
||||
}
|
6
cw_zano/lib/api/exceptions/wrong_seed_exception.dart
Normal file
6
cw_zano/lib/api/exceptions/wrong_seed_exception.dart
Normal file
|
@ -0,0 +1,6 @@
|
|||
import 'package:cw_zano/api/consts.dart';
|
||||
import 'package:cw_zano/api/exceptions/api_exception.dart';
|
||||
|
||||
class WrongSeedException extends ApiException {
|
||||
WrongSeedException(String message): super(Consts.errorWrongSeed, message);
|
||||
}
|
|
@ -1,151 +0,0 @@
|
|||
import 'dart:ffi';
|
||||
import 'package:cw_zano/api/structs/ut8_box.dart';
|
||||
import 'package:ffi/ffi.dart';
|
||||
|
||||
// typedef create_wallet = Pointer<Utf8> Function(
|
||||
// Pointer<Utf8>, Pointer<Utf8>, Pointer<Utf8>, Int32, Pointer<Utf8>);
|
||||
|
||||
typedef restore_wallet_from_seed = Int8 Function(
|
||||
Pointer<Utf8>, Pointer<Utf8>, Pointer<Utf8>, Int32, Int64, Pointer<Utf8>);
|
||||
|
||||
typedef restore_wallet_from_keys = Int8 Function(
|
||||
Pointer<Utf8>,
|
||||
Pointer<Utf8>,
|
||||
Pointer<Utf8>,
|
||||
Pointer<Utf8>,
|
||||
Pointer<Utf8>,
|
||||
Pointer<Utf8>,
|
||||
Int32,
|
||||
Int64,
|
||||
Pointer<Utf8>);
|
||||
|
||||
typedef is_wallet_exist = Int8 Function(Pointer<Utf8>);
|
||||
|
||||
//typedef load_wallet = Int8 Function(Pointer<Utf8>, Pointer<Utf8>, Int8);
|
||||
|
||||
typedef error_string = Pointer<Utf8> Function();
|
||||
|
||||
typedef get_filename = Pointer<Utf8> Function();
|
||||
|
||||
typedef get_seed = Pointer<Utf8> Function();
|
||||
|
||||
typedef get_address = Pointer<Utf8> Function(Int32, Int32);
|
||||
|
||||
typedef get_full_balance = Pointer<Int64> Function(Int32);
|
||||
|
||||
typedef get_unlocked_balance = Pointer<Int64> Function(Int32);
|
||||
|
||||
typedef get_full_balanace = Int64 Function(Int32);
|
||||
|
||||
typedef get_unlocked_balanace = Int64 Function(Int32);
|
||||
|
||||
typedef get_current_height = Int64 Function();
|
||||
|
||||
typedef get_node_height = Int64 Function();
|
||||
|
||||
typedef is_connected = Int8 Function();
|
||||
|
||||
typedef setup_node = Int8 Function(Pointer<Utf8>, Pointer<Utf8>?,
|
||||
Pointer<Utf8>?, Int8, Int8, Pointer<Utf8>);
|
||||
|
||||
typedef start_refresh = Void Function();
|
||||
|
||||
typedef connect_to_node = Int8 Function();
|
||||
|
||||
typedef set_refresh_from_block_height = Void Function(Int64);
|
||||
|
||||
typedef set_recovering_from_seed = Void Function(Int8);
|
||||
|
||||
typedef store_c = Void Function(Pointer<Utf8>);
|
||||
|
||||
typedef set_password = Int8 Function(
|
||||
Pointer<Utf8> password, Pointer<Utf8Box> error);
|
||||
|
||||
typedef set_listener = Void Function();
|
||||
|
||||
typedef get_syncing_height = Int64 Function();
|
||||
|
||||
typedef is_needed_to_refresh = Int8 Function();
|
||||
|
||||
// typedef is_new_transaction_exist = Int8 Function();
|
||||
|
||||
// typedef subaddrress_size = Int32 Function();
|
||||
|
||||
// typedef subaddrress_refresh = Void Function(Int32);
|
||||
|
||||
// typedef subaddress_get_all = Pointer<Int64> Function();
|
||||
|
||||
// typedef subaddress_add_new = Void Function(
|
||||
// Int32 accountIndex, Pointer<Utf8> label);
|
||||
|
||||
// typedef subaddress_set_label = Void Function(
|
||||
// Int32 accountIndex, Int32 addressIndex, Pointer<Utf8> label);
|
||||
|
||||
// typedef account_size = Int32 Function();
|
||||
|
||||
// typedef account_refresh = Void Function();
|
||||
|
||||
// typedef account_get_all = Pointer<Int64> Function();
|
||||
|
||||
// typedef account_add_new = Void Function(Pointer<Utf8> label);
|
||||
|
||||
// typedef account_set_label = Void Function(
|
||||
// Int32 accountIndex, Pointer<Utf8> label);
|
||||
|
||||
//typedef transactions_refresh = Void Function();
|
||||
|
||||
//typedef get_tx_key = Pointer<Utf8>? Function(Pointer<Utf8> txId);
|
||||
|
||||
//typedef transactions_count = Int64 Function();
|
||||
|
||||
//typedef transactions_get_all = Pointer<Int64> Function();
|
||||
|
||||
// typedef transaction_create = Int8 Function(
|
||||
// Pointer<Utf8> address,
|
||||
// Pointer<Utf8> assetType,
|
||||
// Pointer<Utf8> paymentId,
|
||||
// Pointer<Utf8> amount,
|
||||
// Int8 priorityRaw,
|
||||
// Pointer<Utf8Box> error,
|
||||
// Pointer<PendingTransactionRaw> pendingTransaction);
|
||||
|
||||
// typedef transaction_create_mult_dest = Int8 Function(
|
||||
// Pointer<Pointer<Utf8>> addresses,
|
||||
// Pointer<Utf8> assetType,
|
||||
// Pointer<Utf8> paymentId,
|
||||
// Pointer<Pointer<Utf8>> amounts,
|
||||
// Int32 size,
|
||||
// Int8 priorityRaw,
|
||||
// Pointer<Utf8Box> error,
|
||||
// Pointer<PendingTransactionRaw> pendingTransaction);
|
||||
|
||||
// typedef transaction_commit = Int8 Function(
|
||||
// Pointer<PendingTransactionRaw>, Pointer<Utf8Box>);
|
||||
|
||||
typedef secret_view_key = Pointer<Utf8> Function();
|
||||
|
||||
typedef public_view_key = Pointer<Utf8> Function();
|
||||
|
||||
typedef secret_spend_key = Pointer<Utf8> Function();
|
||||
|
||||
typedef public_spend_key = Pointer<Utf8> Function();
|
||||
|
||||
typedef close_current_wallet = Void Function();
|
||||
|
||||
typedef on_startup = Void Function();
|
||||
|
||||
typedef rescan_blockchain = Void Function();
|
||||
|
||||
typedef asset_types = Pointer<Pointer<Utf8>> Function();
|
||||
|
||||
typedef asset_types_size = Int32 Function();
|
||||
|
||||
typedef get_rate = Pointer<Int64> Function();
|
||||
|
||||
typedef size_of_rate = Int32 Function();
|
||||
|
||||
typedef update_rate = Void Function();
|
||||
|
||||
typedef set_trusted_daemon = Void Function(Int8 trusted);
|
||||
|
||||
typedef trusted_daemon = Int8 Function();
|
|
@ -1,149 +0,0 @@
|
|||
import 'dart:ffi';
|
||||
import 'package:cw_zano/api/structs/ut8_box.dart';
|
||||
import 'package:ffi/ffi.dart';
|
||||
|
||||
typedef CreateWallet = Pointer<Utf8> Function(
|
||||
Pointer<Utf8>, Pointer<Utf8>, Pointer<Utf8>, int, Pointer<Utf8>);
|
||||
|
||||
typedef RestoreWalletFromSeed = int Function(
|
||||
Pointer<Utf8>, Pointer<Utf8>, Pointer<Utf8>, int, int, Pointer<Utf8>);
|
||||
|
||||
typedef RestoreWalletFromKeys = int Function(
|
||||
Pointer<Utf8>,
|
||||
Pointer<Utf8>,
|
||||
Pointer<Utf8>,
|
||||
Pointer<Utf8>,
|
||||
Pointer<Utf8>,
|
||||
Pointer<Utf8>,
|
||||
int,
|
||||
int,
|
||||
Pointer<Utf8>);
|
||||
|
||||
typedef IsWalletExist = int Function(Pointer<Utf8>);
|
||||
|
||||
//typedef LoadWallet = int Function(Pointer<Utf8>, Pointer<Utf8>, int);
|
||||
|
||||
typedef ErrorString = Pointer<Utf8> Function();
|
||||
|
||||
typedef GetFilename = Pointer<Utf8> Function();
|
||||
|
||||
typedef GetSeed = Pointer<Utf8> Function();
|
||||
|
||||
typedef GetAddress = Pointer<Utf8> Function(int, int);
|
||||
|
||||
typedef GetZanoFullBalance = Pointer<Int64> Function(int);
|
||||
|
||||
typedef GetZanoUnlockedBalance = Pointer<Int64> Function(int);
|
||||
|
||||
typedef GetFullBalance = int Function(int);
|
||||
|
||||
typedef GetUnlockedBalance = int Function(int);
|
||||
|
||||
typedef GetCurrentHeight = int Function();
|
||||
|
||||
typedef GetNodeHeight = int Function();
|
||||
|
||||
typedef IsConnected = int Function();
|
||||
|
||||
typedef SetupNode = int Function(Pointer<Utf8>, Pointer<Utf8>?, Pointer<Utf8>?,
|
||||
int, int, Pointer<Utf8>);
|
||||
|
||||
typedef StartRefresh = void Function();
|
||||
|
||||
typedef ConnectToNode = int Function();
|
||||
|
||||
typedef SetRefreshFromBlockHeight = void Function(int);
|
||||
|
||||
typedef SetRecoveringFromSeed = void Function(int);
|
||||
|
||||
typedef Store = void Function(Pointer<Utf8>);
|
||||
|
||||
typedef SetPassword = int Function(
|
||||
Pointer<Utf8> password, Pointer<Utf8Box> error);
|
||||
|
||||
typedef SetListener = void Function();
|
||||
|
||||
typedef GetSyncingHeight = int Function();
|
||||
|
||||
typedef IsNeededToRefresh = int Function();
|
||||
|
||||
typedef IsNewTransactionExist = int Function();
|
||||
|
||||
typedef SubaddressSize = int Function();
|
||||
|
||||
typedef SubaddressRefresh = void Function(int);
|
||||
|
||||
typedef SubaddressGetAll = Pointer<Int64> Function();
|
||||
|
||||
typedef SubaddressAddNew = void Function(int accountIndex, Pointer<Utf8> label);
|
||||
|
||||
typedef SubaddressSetLabel = void Function(
|
||||
int accountIndex, int addressIndex, Pointer<Utf8> label);
|
||||
|
||||
typedef AccountSize = int Function();
|
||||
|
||||
typedef AccountRefresh = void Function();
|
||||
|
||||
typedef AccountGetAll = Pointer<Int64> Function();
|
||||
|
||||
typedef AccountAddNew = void Function(Pointer<Utf8> label);
|
||||
|
||||
typedef AccountSetLabel = void Function(int accountIndex, Pointer<Utf8> label);
|
||||
|
||||
typedef TransactionsRefresh = void Function();
|
||||
|
||||
typedef GetTxKey = Pointer<Utf8>? Function(Pointer<Utf8> txId);
|
||||
|
||||
typedef TransactionsCount = int Function();
|
||||
|
||||
typedef TransactionsGetAll = Pointer<Int64> Function();
|
||||
|
||||
// typedef TransactionCreate = int Function(
|
||||
// Pointer<Utf8> address,
|
||||
// Pointer<Utf8> assetType,
|
||||
// Pointer<Utf8> paymentId,
|
||||
// Pointer<Utf8> amount,
|
||||
// int priorityRaw,
|
||||
// Pointer<Utf8Box> error,
|
||||
// Pointer<PendingTransactionRaw> pendingTransaction);
|
||||
|
||||
// typedef TransactionCreateMultDest = int Function(
|
||||
// Pointer<Pointer<Utf8>> addresses,
|
||||
// Pointer<Utf8> assetType,
|
||||
// Pointer<Utf8> paymentId,
|
||||
// Pointer<Pointer<Utf8>> amounts,
|
||||
// int size,
|
||||
// int priorityRaw,
|
||||
// Pointer<Utf8Box> error,
|
||||
// Pointer<PendingTransactionRaw> pendingTransaction);
|
||||
|
||||
// typedef TransactionCommit = int Function(
|
||||
// Pointer<PendingTransactionRaw>, Pointer<Utf8Box>);
|
||||
|
||||
typedef SecretViewKey = Pointer<Utf8> Function();
|
||||
|
||||
typedef PublicViewKey = Pointer<Utf8> Function();
|
||||
|
||||
typedef SecretSpendKey = Pointer<Utf8> Function();
|
||||
|
||||
typedef PublicSpendKey = Pointer<Utf8> Function();
|
||||
|
||||
typedef CloseCurrentWallet = void Function();
|
||||
|
||||
typedef OnStartup = void Function();
|
||||
|
||||
typedef RescanBlockchainAsync = void Function();
|
||||
|
||||
typedef AssetTypes = Pointer<Pointer<Utf8>> Function();
|
||||
|
||||
typedef AssetTypesSize = int Function();
|
||||
|
||||
typedef GetRate = Pointer<Int64> Function();
|
||||
|
||||
typedef SizeOfRate = int Function();
|
||||
|
||||
typedef UpdateRate = void Function();
|
||||
|
||||
typedef SetTrustedDaemon = void Function(int);
|
||||
|
||||
typedef TrustedDaemon = int Function();
|
|
@ -1,142 +1,16 @@
|
|||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:ffi';
|
||||
|
||||
import 'package:cw_core/crypto_currency.dart';
|
||||
import 'package:cw_zano/api/calls.dart' as calls;
|
||||
import 'package:cw_zano/api/model/get_wallet_info_result.dart';
|
||||
import 'package:cw_zano/api/model/get_wallet_status_result.dart';
|
||||
import 'package:cw_zano/api/model/zano_wallet_keys.dart';
|
||||
import 'package:cw_zano/zano_balance.dart';
|
||||
import 'package:cw_zano/zano_wallet.dart';
|
||||
import 'package:ffi/ffi.dart';
|
||||
import 'package:cw_zano/api/structs/ut8_box.dart';
|
||||
import 'package:cw_zano/api/convert_utf8_to_string.dart';
|
||||
import 'package:cw_zano/api/signatures.dart';
|
||||
import 'package:cw_zano/api/types.dart';
|
||||
import 'package:cw_zano/api/zano_api.dart';
|
||||
import 'package:cw_zano/api/calls.dart' as calls;
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:mobx/mobx.dart' as mobx;
|
||||
|
||||
int _boolToInt(bool value) => value ? 1 : 0;
|
||||
|
||||
final getFileNameNative =
|
||||
zanoApi.lookup<NativeFunction<get_filename>>('get_filename').asFunction<GetFilename>();
|
||||
|
||||
/*final getSeedNative =
|
||||
zanoApi.lookup<NativeFunction<get_seed>>('seed').asFunction<GetSeed>();*/
|
||||
|
||||
final getAddressNative =
|
||||
zanoApi.lookup<NativeFunction<get_address>>('get_address').asFunction<GetAddress>();
|
||||
|
||||
final getFullBalanceNative = zanoApi
|
||||
.lookup<NativeFunction<get_full_balanace>>('get_full_balance')
|
||||
.asFunction<GetFullBalance>();
|
||||
|
||||
final getUnlockedBalanceNative = zanoApi
|
||||
.lookup<NativeFunction<get_unlocked_balanace>>('get_unlocked_balance')
|
||||
.asFunction<GetUnlockedBalance>();
|
||||
|
||||
/**final getCurrentHeightNative = zanoApi
|
||||
.lookup<NativeFunction<get_current_height>>('get_current_height')
|
||||
.asFunction<GetCurrentHeight>();*/
|
||||
|
||||
// final getNodeHeightNative = zanoApi
|
||||
// .lookup<NativeFunction<get_node_height>>('get_node_height')
|
||||
// .asFunction<GetNodeHeight>();
|
||||
|
||||
final isConnectedNative =
|
||||
zanoApi.lookup<NativeFunction<is_connected>>('is_connected').asFunction<IsConnected>();
|
||||
|
||||
final setupNodeNative =
|
||||
zanoApi.lookup<NativeFunction<setup_node>>('setup_node').asFunction<SetupNode>();
|
||||
|
||||
// final startRefreshNative = zanoApi
|
||||
// .lookup<NativeFunction<start_refresh>>('start_refresh')
|
||||
// .asFunction<StartRefresh>();
|
||||
|
||||
final connecToNodeNative =
|
||||
zanoApi.lookup<NativeFunction<connect_to_node>>('connect_to_node').asFunction<ConnectToNode>();
|
||||
|
||||
final setRefreshFromBlockHeightNative = zanoApi
|
||||
.lookup<NativeFunction<set_refresh_from_block_height>>('set_refresh_from_block_height')
|
||||
.asFunction<SetRefreshFromBlockHeight>();
|
||||
|
||||
// final setRecoveringFromSeedNative = zanoApi
|
||||
// .lookup<NativeFunction<set_recovering_from_seed>>('set_recovering_from_seed')
|
||||
// .asFunction<SetRecoveringFromSeed>();
|
||||
|
||||
|
||||
final storeNative = zanoApi.lookup<NativeFunction<store_c>>('store').asFunction<Store>();
|
||||
|
||||
final setPasswordNative =
|
||||
zanoApi.lookup<NativeFunction<set_password>>('set_password').asFunction<SetPassword>();
|
||||
|
||||
/**final setListenerNative = zanoApi
|
||||
.lookup<NativeFunction<set_listener>>('set_listener')
|
||||
.asFunction<SetListener>();*/
|
||||
|
||||
final getSyncingHeightNative = zanoApi
|
||||
.lookup<NativeFunction<get_syncing_height>>('get_syncing_height')
|
||||
.asFunction<GetSyncingHeight>();
|
||||
|
||||
final isNeededToRefreshNative = zanoApi
|
||||
.lookup<NativeFunction<is_needed_to_refresh>>('is_needed_to_refresh')
|
||||
.asFunction<IsNeededToRefresh>();
|
||||
|
||||
// final isNewTransactionExistNative = zanoApi
|
||||
// .lookup<NativeFunction<is_new_transaction_exist>>('is_new_transaction_exist')
|
||||
// .asFunction<IsNewTransactionExist>();
|
||||
|
||||
final getSecretViewKeyNative =
|
||||
zanoApi.lookup<NativeFunction<secret_view_key>>('secret_view_key').asFunction<SecretViewKey>();
|
||||
|
||||
final getPublicViewKeyNative =
|
||||
zanoApi.lookup<NativeFunction<public_view_key>>('public_view_key').asFunction<PublicViewKey>();
|
||||
|
||||
final getSecretSpendKeyNative = zanoApi
|
||||
.lookup<NativeFunction<secret_spend_key>>('secret_spend_key')
|
||||
.asFunction<SecretSpendKey>();
|
||||
|
||||
final getPublicSpendKeyNative = zanoApi
|
||||
.lookup<NativeFunction<secret_view_key>>('public_spend_key')
|
||||
.asFunction<PublicSpendKey>();
|
||||
|
||||
final closeCurrentWalletNative = zanoApi
|
||||
.lookup<NativeFunction<close_current_wallet>>('close_current_wallet')
|
||||
.asFunction<CloseCurrentWallet>();
|
||||
|
||||
final onStartupNative =
|
||||
zanoApi.lookup<NativeFunction<on_startup>>('on_startup').asFunction<OnStartup>();
|
||||
|
||||
final rescanBlockchainAsyncNative = zanoApi
|
||||
.lookup<NativeFunction<rescan_blockchain>>('rescan_blockchain')
|
||||
.asFunction<RescanBlockchainAsync>();
|
||||
|
||||
// final setTrustedDaemonNative = zanoApi
|
||||
// .lookup<NativeFunction<set_trusted_daemon>>('set_trusted_daemon')
|
||||
// .asFunction<SetTrustedDaemon>();
|
||||
|
||||
final trustedDaemonNative =
|
||||
zanoApi.lookup<NativeFunction<trusted_daemon>>('trusted_daemon').asFunction<TrustedDaemon>();
|
||||
|
||||
int getSyncingHeight() => getSyncingHeightNative();
|
||||
|
||||
bool isNeededToRefresh() => isNeededToRefreshNative() != 0;
|
||||
|
||||
//bool isNewTransactionExist() => isNewTransactionExistNative() != 0;
|
||||
|
||||
String getFilename() => convertUTF8ToString(pointer: getFileNameNative());
|
||||
|
||||
/**String getSeed() => convertUTF8ToString(pointer: getSeedNative());*/
|
||||
|
||||
String getAddress({int accountIndex = 0, int addressIndex = 0}) =>
|
||||
convertUTF8ToString(pointer: getAddressNative(accountIndex, addressIndex));
|
||||
|
||||
int getFullBalance({int accountIndex = 0}) => getFullBalanceNative(accountIndex);
|
||||
|
||||
int getUnlockedBalance({int accountIndex = 0}) => getUnlockedBalanceNative(accountIndex);
|
||||
|
||||
int getCurrentHeight(int hWallet) {
|
||||
final json = calls.getWalletStatus(hWallet);
|
||||
final walletStatus = GetWalletStatusResult.fromJson(jsonDecode(json) as Map<String, dynamic>);
|
||||
|
@ -149,126 +23,6 @@ int getNodeHeightSync(int hWallet) {
|
|||
return walletStatus.currentDaemonHeight;
|
||||
}
|
||||
|
||||
// int getWalletInfo(int hWallet) {
|
||||
// final json = calls.getWalletInfo(hWallet);
|
||||
// final walletInfo = GetWalletInfoResult.fromJson(jsonDecode(json) as Map<String, dynamic>);
|
||||
// zanoSeed = walletInfo.wiExtended.seed;
|
||||
// zanoKeys = ZanoWalletKeys(
|
||||
// privateSpendKey: walletInfo.wiExtended.spendPrivateKey,
|
||||
// privateViewKey: walletInfo.wiExtended.viewPrivateKey,
|
||||
// publicSpendKey: walletInfo.wiExtended.spendPublicKey,
|
||||
// publicViewKey: walletInfo.wiExtended.viewPublicKey,
|
||||
// );
|
||||
// return 0;
|
||||
// }
|
||||
|
||||
// int getTxFee(int priority) {
|
||||
// return calls.getCurrentTxFee(priority);
|
||||
// }
|
||||
|
||||
bool isConnectedSync() => isConnectedNative() != 0;
|
||||
|
||||
bool setupNodeSync({
|
||||
required String address,
|
||||
String? login,
|
||||
String? password,
|
||||
bool useSSL = false,
|
||||
bool isLightWallet = false,
|
||||
/*String? socksProxyAddress*/
|
||||
}) {
|
||||
final addressPointer = address.toNativeUtf8();
|
||||
Pointer<Utf8>? loginPointer;
|
||||
Pointer<Utf8>? socksProxyAddressPointer;
|
||||
Pointer<Utf8>? passwordPointer;
|
||||
|
||||
if (login != null) {
|
||||
loginPointer = login.toNativeUtf8();
|
||||
}
|
||||
|
||||
if (password != null) {
|
||||
passwordPointer = password.toNativeUtf8();
|
||||
}
|
||||
|
||||
/*if (socksProxyAddress != null) {
|
||||
socksProxyAddressPointer = socksProxyAddress.toNativeUtf8();
|
||||
}*/
|
||||
|
||||
final errorMessagePointer = ''.toNativeUtf8();
|
||||
debugPrint(
|
||||
"setup_node address $address login $login password $password useSSL $useSSL isLightWallet $isLightWallet");
|
||||
// TODO: here can be ZERO! upd: no
|
||||
final isSetupNode = setupNodeNative(
|
||||
addressPointer,
|
||||
loginPointer,
|
||||
passwordPointer,
|
||||
_boolToInt(useSSL),
|
||||
_boolToInt(isLightWallet),
|
||||
/*socksProxyAddressPointer,*/
|
||||
errorMessagePointer) !=
|
||||
0;
|
||||
debugPrint("setup_node result $isSetupNode");
|
||||
|
||||
calloc.free(addressPointer);
|
||||
|
||||
if (loginPointer != null) {
|
||||
calloc.free(loginPointer);
|
||||
}
|
||||
|
||||
if (passwordPointer != null) {
|
||||
calloc.free(passwordPointer);
|
||||
}
|
||||
|
||||
// TODO: fix it
|
||||
/**if (!isSetupNode) {
|
||||
throw SetupWalletException(
|
||||
message: convertUTF8ToString(pointer: errorMessagePointer));
|
||||
}*/
|
||||
|
||||
return isSetupNode;
|
||||
}
|
||||
|
||||
//void startRefreshSync() => startRefreshNative();
|
||||
|
||||
Future<bool> connectToNode() async => connecToNodeNative() != 0;
|
||||
|
||||
void setRefreshFromBlockHeight({required int height}) => setRefreshFromBlockHeightNative(height);
|
||||
|
||||
// void setRecoveringFromSeed({required bool isRecovery}) =>
|
||||
// setRecoveringFromSeedNative(_boolToInt(isRecovery));
|
||||
|
||||
void storeSync(int hWallet) {
|
||||
calls.store(hWallet);
|
||||
// TODO: fixit
|
||||
/*final pathPointer = ''.toNativeUtf8();
|
||||
storeNative(pathPointer);
|
||||
calloc.free(pathPointer);*/
|
||||
}
|
||||
|
||||
void setPasswordSync(String password) {
|
||||
final passwordPointer = password.toNativeUtf8();
|
||||
final errorMessagePointer = calloc<Utf8Box>();
|
||||
final changed = setPasswordNative(passwordPointer, errorMessagePointer) != 0;
|
||||
calloc.free(passwordPointer);
|
||||
|
||||
if (!changed) {
|
||||
final message = errorMessagePointer.ref.getValue();
|
||||
calloc.free(errorMessagePointer);
|
||||
throw Exception(message);
|
||||
}
|
||||
|
||||
calloc.free(errorMessagePointer);
|
||||
}
|
||||
|
||||
void closeCurrentWallet() => closeCurrentWalletNative();
|
||||
|
||||
String getSecretViewKey() => convertUTF8ToString(pointer: getSecretViewKeyNative());
|
||||
|
||||
String getPublicViewKey() => convertUTF8ToString(pointer: getPublicViewKeyNative());
|
||||
|
||||
String getSecretSpendKey() => convertUTF8ToString(pointer: getSecretSpendKeyNative());
|
||||
|
||||
String getPublicSpendKey() => convertUTF8ToString(pointer: getPublicSpendKeyNative());
|
||||
|
||||
class SyncListener {
|
||||
SyncListener(this.onNewBlock, this.onNewTransaction)
|
||||
: _cachedBlockchainHeight = 0,
|
||||
|
@ -300,15 +54,8 @@ class SyncListener {
|
|||
onNewTransaction?.call();
|
||||
}*/
|
||||
|
||||
///var syncHeight = getSyncingHeight();
|
||||
var syncHeight = getCurrentHeight(hWallet);
|
||||
|
||||
if (syncHeight <= 0) {
|
||||
syncHeight = getCurrentHeight(hWallet);
|
||||
}
|
||||
|
||||
//getWalletInfo(hWallet);
|
||||
|
||||
final json = calls.getWalletInfo(hWallet);
|
||||
final result = GetWalletInfoResult.fromJson(jsonDecode(json) as Map<String, dynamic>);
|
||||
wallet.seed = result.wiExtended.seed;
|
||||
|
@ -324,8 +71,6 @@ class SyncListener {
|
|||
wallet.balance = mobx.ObservableMap.of(
|
||||
{CryptoCurrency.zano: ZanoBalance(total: balance.total, unlocked: balance.unlocked)});
|
||||
|
||||
///getTxFee(hWallet);
|
||||
|
||||
if (_initialSyncHeight <= 0) {
|
||||
_initialSyncHeight = syncHeight;
|
||||
}
|
||||
|
@ -360,59 +105,3 @@ SyncListener setListeners(
|
|||
/**setListenerNative();*/
|
||||
return listener;
|
||||
}
|
||||
|
||||
void onStartup() => onStartupNative();
|
||||
|
||||
void _storeSync(int hWallet) => storeSync(hWallet);
|
||||
|
||||
bool _setupNodeSync(Map args) {
|
||||
final address = args['address'] as String;
|
||||
final login = (args['login'] ?? '') as String;
|
||||
final password = (args['password'] ?? '') as String;
|
||||
final useSSL = args['useSSL'] as bool;
|
||||
final isLightWallet = args['isLightWallet'] as bool;
|
||||
/*final socksProxyAddress = (args['socksProxyAddress'] ?? '') as String;*/
|
||||
|
||||
return setupNodeSync(
|
||||
address: address,
|
||||
login: login,
|
||||
password: password,
|
||||
useSSL: useSSL,
|
||||
isLightWallet: isLightWallet, /*socksProxyAddress: socksProxyAddress*/
|
||||
);
|
||||
}
|
||||
|
||||
bool _isConnected(Object _) => isConnectedSync();
|
||||
|
||||
//int _getNodeHeight(Object _) => getNodeHeightSync();
|
||||
|
||||
//void startRefresh() => startRefreshSync();
|
||||
|
||||
Future<bool> setupNode(
|
||||
{required String address,
|
||||
String? login,
|
||||
String? password,
|
||||
bool useSSL = false,
|
||||
/*String? socksProxyAddress,*/
|
||||
bool isLightWallet = false}) =>
|
||||
compute<Map<String, Object?>, bool>(_setupNodeSync, {
|
||||
'address': address,
|
||||
'login': login,
|
||||
'password': password,
|
||||
'useSSL': useSSL,
|
||||
'isLightWallet': isLightWallet,
|
||||
//'socksProxyAddress': socksProxyAddress
|
||||
});
|
||||
|
||||
Future<void> store(int hWallet) => compute<int, void>(_storeSync, 0);
|
||||
|
||||
Future<bool> isConnected() => compute(_isConnected, 0);
|
||||
|
||||
//Future<int> getNodeHeight() => compute(_getNodeHeight, 0);
|
||||
|
||||
void rescanBlockchainAsync() => rescanBlockchainAsyncNative();
|
||||
|
||||
// Future setTrustedDaemon(bool trusted) async =>
|
||||
// setTrustedDaemonNative(_boolToInt(trusted));
|
||||
|
||||
Future<bool> trustedDaemon() async => trustedDaemonNative() != 0;
|
||||
|
|
|
@ -1,255 +0,0 @@
|
|||
import 'dart:ffi';
|
||||
import 'package:ffi/ffi.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:cw_zano/api/convert_utf8_to_string.dart';
|
||||
import 'package:cw_zano/api/signatures.dart';
|
||||
import 'package:cw_zano/api/types.dart';
|
||||
import 'package:cw_zano/api/zano_api.dart';
|
||||
import 'package:cw_zano/api/exceptions/wallet_restore_from_keys_exception.dart';
|
||||
|
||||
// final createWalletNative = zanoApi
|
||||
// .lookup<NativeFunction<create_wallet>>('create_wallet')
|
||||
// .asFunction<CreateWallet>();
|
||||
|
||||
final restoreWalletFromSeedNative = zanoApi
|
||||
.lookup<NativeFunction<restore_wallet_from_seed>>(
|
||||
'restore_wallet_from_seed')
|
||||
.asFunction<RestoreWalletFromSeed>();
|
||||
|
||||
final restoreWalletFromKeysNative = zanoApi
|
||||
.lookup<NativeFunction<restore_wallet_from_keys>>(
|
||||
'restore_wallet_from_keys')
|
||||
.asFunction<RestoreWalletFromKeys>();
|
||||
|
||||
final isWalletExistNative = zanoApi
|
||||
.lookup<NativeFunction<is_wallet_exist>>('is_wallet_exist')
|
||||
.asFunction<IsWalletExist>();
|
||||
|
||||
// final loadWalletNative = zanoApi
|
||||
// .lookup<NativeFunction<load_wallet>>('load_wallet')
|
||||
// .asFunction<LoadWallet>();
|
||||
|
||||
final errorStringNative = zanoApi
|
||||
.lookup<NativeFunction<error_string>>('error_string')
|
||||
.asFunction<ErrorString>();
|
||||
|
||||
/*String createWalletSync(
|
||||
{required String path,
|
||||
required String password,
|
||||
required String language,
|
||||
int nettype = 0}) {
|
||||
final pathPointer = path.toNativeUtf8();
|
||||
final passwordPointer = password.toNativeUtf8();
|
||||
final languagePointer = language.toNativeUtf8();
|
||||
final errorMessagePointer = ''.toNativeUtf8();
|
||||
debugPrint("create_wallet path $path password $password language $language");
|
||||
final result = convertUTF8ToString(pointer: createWalletNative(pathPointer, passwordPointer,
|
||||
languagePointer, nettype, errorMessagePointer));
|
||||
//debugPrint("create_wallet $result");
|
||||
|
||||
calloc.free(pathPointer);
|
||||
calloc.free(passwordPointer);
|
||||
calloc.free(languagePointer);
|
||||
|
||||
return result;
|
||||
/*if (hWallet == 0) {
|
||||
throw WalletCreationException(
|
||||
message: convertUTF8ToString(pointer: errorMessagePointer));
|
||||
}
|
||||
|
||||
return hWallet;
|
||||
// setupNodeSync(address: "node.moneroworld.com:18089");*/
|
||||
}*/
|
||||
|
||||
bool isWalletExistSync({required String path}) {
|
||||
final pathPointer = path.toNativeUtf8();
|
||||
final isExist = isWalletExistNative(pathPointer) != 0;
|
||||
|
||||
calloc.free(pathPointer);
|
||||
|
||||
return isExist;
|
||||
}
|
||||
|
||||
// void restoreWalletFromSeedSync(
|
||||
// {required String path,
|
||||
// required String password,
|
||||
// required String seed,
|
||||
// int nettype = 0,
|
||||
// int restoreHeight = 0}) {
|
||||
// final pathPointer = path.toNativeUtf8();
|
||||
// final passwordPointer = password.toNativeUtf8();
|
||||
// final seedPointer = seed.toNativeUtf8();
|
||||
// final errorMessagePointer = ''.toNativeUtf8();
|
||||
// final isWalletRestored = restoreWalletFromSeedNative(
|
||||
// pathPointer,
|
||||
// passwordPointer,
|
||||
// seedPointer,
|
||||
// nettype,
|
||||
// restoreHeight,
|
||||
// errorMessagePointer) !=
|
||||
// 0;
|
||||
|
||||
// calloc.free(pathPointer);
|
||||
// calloc.free(passwordPointer);
|
||||
// calloc.free(seedPointer);
|
||||
|
||||
// if (!isWalletRestored) {
|
||||
// throw WalletRestoreFromSeedException(
|
||||
// message: convertUTF8ToString(pointer: errorMessagePointer));
|
||||
// }
|
||||
// }
|
||||
|
||||
void restoreWalletFromKeysSync(
|
||||
{required String path,
|
||||
required String password,
|
||||
required String language,
|
||||
required String address,
|
||||
required String viewKey,
|
||||
required String spendKey,
|
||||
int nettype = 0,
|
||||
int restoreHeight = 0}) {
|
||||
final pathPointer = path.toNativeUtf8();
|
||||
final passwordPointer = password.toNativeUtf8();
|
||||
final languagePointer = language.toNativeUtf8();
|
||||
final addressPointer = address.toNativeUtf8();
|
||||
final viewKeyPointer = viewKey.toNativeUtf8();
|
||||
final spendKeyPointer = spendKey.toNativeUtf8();
|
||||
final errorMessagePointer = ''.toNativeUtf8();
|
||||
final isWalletRestored = restoreWalletFromKeysNative(
|
||||
pathPointer,
|
||||
passwordPointer,
|
||||
languagePointer,
|
||||
addressPointer,
|
||||
viewKeyPointer,
|
||||
spendKeyPointer,
|
||||
nettype,
|
||||
restoreHeight,
|
||||
errorMessagePointer) !=
|
||||
0;
|
||||
|
||||
calloc.free(pathPointer);
|
||||
calloc.free(passwordPointer);
|
||||
calloc.free(languagePointer);
|
||||
calloc.free(addressPointer);
|
||||
calloc.free(viewKeyPointer);
|
||||
calloc.free(spendKeyPointer);
|
||||
|
||||
if (!isWalletRestored) {
|
||||
throw WalletRestoreFromKeysException(
|
||||
message: convertUTF8ToString(pointer: errorMessagePointer));
|
||||
}
|
||||
}
|
||||
|
||||
// void loadWallet(
|
||||
// {required String path, required String password, int nettype = 0}) {
|
||||
// final pathPointer = path.toNativeUtf8();
|
||||
// final passwordPointer = password.toNativeUtf8();
|
||||
// final loaded = loadWalletNative(pathPointer, passwordPointer, nettype) != 0;
|
||||
// calloc.free(pathPointer);
|
||||
// calloc.free(passwordPointer);
|
||||
|
||||
// if (!loaded) {
|
||||
// throw WalletOpeningException(
|
||||
// message: convertUTF8ToString(pointer: errorStringNative()));
|
||||
// }
|
||||
// }
|
||||
|
||||
// String _createWallet(Map<String, dynamic> args) {
|
||||
// final path = args['path'] as String;
|
||||
// final password = args['password'] as String;
|
||||
// final language = args['language'] as String;
|
||||
|
||||
// return createWalletSync(path: path, password: password, language: language);
|
||||
// }
|
||||
|
||||
// void _restoreFromSeed(Map<String, dynamic> args) {
|
||||
// final path = args['path'] as String;
|
||||
// final password = args['password'] as String;
|
||||
// final seed = args['seed'] as String;
|
||||
// final restoreHeight = args['restoreHeight'] as int;
|
||||
|
||||
// restoreWalletFromSeedSync(
|
||||
// path: path, password: password, seed: seed, restoreHeight: restoreHeight);
|
||||
// }
|
||||
|
||||
void _restoreFromKeys(Map<String, dynamic> args) {
|
||||
final path = args['path'] as String;
|
||||
final password = args['password'] as String;
|
||||
final language = args['language'] as String;
|
||||
final restoreHeight = args['restoreHeight'] as int;
|
||||
final address = args['address'] as String;
|
||||
final viewKey = args['viewKey'] as String;
|
||||
final spendKey = args['spendKey'] as String;
|
||||
|
||||
restoreWalletFromKeysSync(
|
||||
path: path,
|
||||
password: password,
|
||||
language: language,
|
||||
restoreHeight: restoreHeight,
|
||||
address: address,
|
||||
viewKey: viewKey,
|
||||
spendKey: spendKey);
|
||||
}
|
||||
|
||||
// Future<void> _openWallet(Map<String, String> args) async => loadWallet(
|
||||
// path: args['path'] as String, password: args['password'] as String);
|
||||
|
||||
bool _isWalletExist(String path) => isWalletExistSync(path: path);
|
||||
|
||||
// void openWallet(
|
||||
// {required String path,
|
||||
// required String password,
|
||||
// int nettype = 0}) async =>
|
||||
// loadWallet(path: path, password: password, nettype: nettype);
|
||||
|
||||
// Future<void> openWalletAsync(Map<String, String> args) async =>
|
||||
// compute(_openWallet, args);
|
||||
|
||||
// Future<String> createWallet(
|
||||
// {required String path,
|
||||
// required String password,
|
||||
// required String language,
|
||||
// int nettype = 0}) async =>
|
||||
// compute<Map<String, dynamic>, String>(_createWallet, {
|
||||
// 'path': path,
|
||||
// 'password': password,
|
||||
// 'language': language,
|
||||
// 'nettype': nettype
|
||||
// });
|
||||
|
||||
// Future<void> restoreFromSeed(
|
||||
// {required String path,
|
||||
// required String password,
|
||||
// required String seed,
|
||||
// int nettype = 0,
|
||||
// int restoreHeight = 0}) async =>
|
||||
// compute<Map<String, Object>, void>(_restoreFromSeed, {
|
||||
// 'path': path,
|
||||
// 'password': password,
|
||||
// 'seed': seed,
|
||||
// 'nettype': nettype,
|
||||
// 'restoreHeight': restoreHeight
|
||||
// });
|
||||
|
||||
Future<void> restoreFromKeys(
|
||||
{required String path,
|
||||
required String password,
|
||||
required String language,
|
||||
required String address,
|
||||
required String viewKey,
|
||||
required String spendKey,
|
||||
int nettype = 0,
|
||||
int restoreHeight = 0}) async =>
|
||||
compute<Map<String, Object>, void>(_restoreFromKeys, {
|
||||
'path': path,
|
||||
'password': password,
|
||||
'language': language,
|
||||
'address': address,
|
||||
'viewKey': viewKey,
|
||||
'spendKey': spendKey,
|
||||
'nettype': nettype,
|
||||
'restoreHeight': restoreHeight
|
||||
});
|
||||
|
||||
Future<bool> isWalletExist({required String path}) =>
|
||||
compute(_isWalletExist, path);
|
|
@ -1,5 +1,6 @@
|
|||
import 'dart:convert';
|
||||
|
||||
import 'package:cw_zano/api/exceptions/transfer_exception.dart';
|
||||
import 'package:cw_zano/api/model/destination.dart';
|
||||
import 'package:cw_zano/api/model/transfer_params.dart';
|
||||
import 'package:cw_zano/api/model/transfer_result.dart';
|
||||
|
@ -11,7 +12,8 @@ import 'package:cw_zano/zano_wallet.dart';
|
|||
|
||||
class PendingZanoTransaction with PendingTransaction {
|
||||
PendingZanoTransaction(
|
||||
{required this.fee,
|
||||
{required this.zanoWallet,
|
||||
required this.fee,
|
||||
required this.intAmount,
|
||||
//required this.stringAmount,
|
||||
required this.hWallet,
|
||||
|
@ -19,6 +21,7 @@ class PendingZanoTransaction with PendingTransaction {
|
|||
required this.assetId,
|
||||
required this.comment});
|
||||
|
||||
final ZanoWalletBase zanoWallet;
|
||||
final int hWallet;
|
||||
final int intAmount;
|
||||
//final String stringAmount;
|
||||
|
@ -52,7 +55,7 @@ class PendingZanoTransaction with PendingTransaction {
|
|||
TransferParams(
|
||||
destinations: [
|
||||
Destination(
|
||||
amount: intAmount.toString(), //stringAmount,
|
||||
amount: intAmount.toString(),
|
||||
address: address,
|
||||
assetId: assetId,
|
||||
)
|
||||
|
@ -66,22 +69,23 @@ class PendingZanoTransaction with PendingTransaction {
|
|||
));
|
||||
print('transfer result $result');
|
||||
final map = jsonDecode(result);
|
||||
if (map["result"] != null && map["result"]["result"] != null ) {
|
||||
if (map['result'] != null && map['result']['result'] != null ) {
|
||||
transferResult = TransferResult.fromJson(
|
||||
map["result"]["result"] as Map<String, dynamic>,
|
||||
map['result']['result'] as Map<String, dynamic>,
|
||||
);
|
||||
await zanoWallet.fetchTransactions();
|
||||
} else if (map['result'] != null && map['result']['error'] != null) {
|
||||
final String code;
|
||||
if (map['result']['error']['code'] is int) {
|
||||
code = (map['result']['error']['code'] as int).toString();
|
||||
} else if (map['result']['error']['code'] is String) {
|
||||
code = map['result']['error']['code'] as String;
|
||||
} else {
|
||||
code = '';
|
||||
}
|
||||
final message = map['result']['error']['message'] as String;
|
||||
print('transfer error $code $message');
|
||||
throw TransferException(code, message);
|
||||
}
|
||||
// try {
|
||||
// zano_transaction_history.commitTransactionFromPointerAddress(
|
||||
// address: pendingTransactionDescription.pointerAddress);
|
||||
// } catch (e) {
|
||||
// final message = e.toString();
|
||||
|
||||
// if (message.contains('Reason: double spend')) {
|
||||
// throw DoubleSpendException();
|
||||
// }
|
||||
|
||||
// rethrow;
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,37 +32,6 @@ class ZanoTransactionInfo extends TransactionInfo {
|
|||
assetType = 'ZANO', // TODO: FIXIT:
|
||||
recipientAddress = history.remoteAddresses.isNotEmpty ? history.remoteAddresses.first : '';
|
||||
|
||||
/*ZanoTransactionInfo.fromMap(Map<String, Object> map)
|
||||
: id = (map['hash'] ?? '') as String,
|
||||
height = (map['height'] ?? 0) as int,
|
||||
direction =
|
||||
parseTransactionDirectionFromNumber(map['direction'] as String) ??
|
||||
TransactionDirection.incoming,
|
||||
date = DateTime.fromMillisecondsSinceEpoch(
|
||||
int.parse(map['timestamp'] as String? ?? '0') * 1000),
|
||||
isPending = parseBoolFromString(map['isPending'] as String),
|
||||
amount = map['amount'] as int,
|
||||
accountIndex = int.parse(map['accountIndex'] as String),
|
||||
addressIndex = map['addressIndex'] as int,
|
||||
confirmations = map['confirmations'] as int,
|
||||
key = getTxKey((map['hash'] ?? '') as String),
|
||||
fee = map['fee'] as int? ?? 0;*/
|
||||
|
||||
/*ZanoTransactionInfo.fromRow(TransactionInfoRow row)
|
||||
: id = row.getHash(),
|
||||
height = row.blockHeight,
|
||||
direction = parseTransactionDirectionFromInt(row.direction) ??
|
||||
TransactionDirection.incoming,
|
||||
date = DateTime.fromMillisecondsSinceEpoch(row.getDatetime() * 1000),
|
||||
isPending = row.isPending != 0,
|
||||
amount = row.getAmount(),
|
||||
accountIndex = row.subaddrAccount,
|
||||
addressIndex = row.subaddrIndex,
|
||||
confirmations = row.confirmations,
|
||||
key = null, //getTxKey(row.getHash()),
|
||||
fee = row.fee,
|
||||
assetType = row.getAssetType();*/
|
||||
|
||||
final String id;
|
||||
final int height;
|
||||
final TransactionDirection direction;
|
||||
|
|
|
@ -25,6 +25,7 @@ import 'package:cw_zano/zano_transaction_history.dart';
|
|||
import 'package:cw_zano/zano_transaction_info.dart';
|
||||
import 'package:cw_zano/zano_wallet_addresses.dart';
|
||||
import 'package:ffi/ffi.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
|
||||
part 'zano_wallet.g.dart';
|
||||
|
@ -103,10 +104,10 @@ abstract class ZanoWalletBase
|
|||
await updateTransactions();
|
||||
|
||||
if (walletInfo.isRecovery) {
|
||||
///zano_wallet.setRecoveringFromSeed(isRecovery: walletInfo.isRecovery);
|
||||
debugPrint('setRecoveringFromSeed isRecovery ${walletInfo.isRecovery}');
|
||||
|
||||
if (zano_wallet.getCurrentHeight(hWallet) <= 1) {
|
||||
zano_wallet.setRefreshFromBlockHeight(height: walletInfo.restoreHeight);
|
||||
debugPrint('setRefreshFromBlockHeight height ${walletInfo.restoreHeight}');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -128,7 +129,7 @@ abstract class ZanoWalletBase
|
|||
Future<void> connectToNode({required Node node}) async {
|
||||
try {
|
||||
syncStatus = ConnectingSyncStatus();
|
||||
await zano_wallet.setupNode(
|
||||
await calls.setupNode(
|
||||
address: "195.201.107.230:33336", // node.uriRaw,
|
||||
login: "", // node.login,
|
||||
password: "", // node.password,
|
||||
|
@ -153,8 +154,7 @@ abstract class ZanoWalletBase
|
|||
|
||||
try {
|
||||
syncStatus = AttemptingSyncStatus();
|
||||
//zano_wallet.startRefresh();
|
||||
print("start refresh");
|
||||
debugPrint("startRefresh");
|
||||
_setListeners();
|
||||
_listener?.start(this, hWallet);
|
||||
} catch (e) {
|
||||
|
@ -172,31 +172,11 @@ abstract class ZanoWalletBase
|
|||
? output.extractedAddress!
|
||||
: output.address;
|
||||
final stringAmount = output.sendAll ? null : output.cryptoAmount!.replaceAll(',', '.');
|
||||
//final int? formattedAmount = output.sendAll ? null : output.formattedCryptoAmount;
|
||||
final fee = calculateEstimatedFee(creds.priority);
|
||||
// final result = await calls.transfer(
|
||||
// hWallet,
|
||||
// TransferParams(
|
||||
// destinations: [
|
||||
// Destination(
|
||||
// amount: amount!,
|
||||
// address: address,
|
||||
// assetId: assetId,
|
||||
// )
|
||||
// ],
|
||||
// fee: fee,
|
||||
// mixin: zanoMixin,
|
||||
// paymentId: '', // TODO: fixit
|
||||
// comment: output.note ?? '',
|
||||
// pushPayer: false,
|
||||
// hideReceiver: false,
|
||||
// ));
|
||||
final intAmount = (double.parse(stringAmount!) * pow(10, 12)).toInt();
|
||||
// final description = PendingTransactionDescription(
|
||||
// amount: iAmount, fee: fee, hash: '', pointerAddress: 0);
|
||||
final transaction = PendingZanoTransaction(fee: fee, intAmount: intAmount,
|
||||
hWallet: hWallet, address: address, assetId: assetId,
|
||||
comment: output.note ?? '');
|
||||
comment: output.note ?? '', zanoWallet: this);
|
||||
return transaction;
|
||||
|
||||
/*final _credentials = credentials as ZanoTransactionCreationCredentials;
|
||||
|
@ -277,7 +257,7 @@ abstract class ZanoWalletBase
|
|||
Future<void> save() async {
|
||||
await walletAddresses.updateAddressesInBox();
|
||||
await backupWalletFiles(name);
|
||||
await zano_wallet.store(hWallet);
|
||||
await calls.store(hWallet);
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -306,13 +286,9 @@ abstract class ZanoWalletBase
|
|||
|
||||
@override
|
||||
Future<void> changePassword(String password) async {
|
||||
zano_wallet.setPasswordSync(password);
|
||||
calls.setPassword(hWallet: hWallet, password: password);
|
||||
}
|
||||
|
||||
//Future<int> getNodeHeight() async => zano_wallet.getNodeHeight();
|
||||
|
||||
Future<bool> isConnected() async => zano_wallet.isConnected();
|
||||
|
||||
Future<void> setAsRecovered() async {
|
||||
walletInfo.isRecovery = false;
|
||||
await walletInfo.save();
|
||||
|
@ -322,8 +298,8 @@ abstract class ZanoWalletBase
|
|||
Future<void> rescan({required int height}) async {
|
||||
walletInfo.restoreHeight = height;
|
||||
walletInfo.isRecovery = true;
|
||||
zano_wallet.setRefreshFromBlockHeight(height: height);
|
||||
zano_wallet.rescanBlockchainAsync();
|
||||
debugPrint('setRefreshFromBlockHeight height $height');
|
||||
debugPrint('rescanBlockchainAsync');
|
||||
await startSync();
|
||||
_askForUpdateBalance();
|
||||
/**walletAddresses.accountList.update();*/
|
||||
|
@ -332,9 +308,6 @@ abstract class ZanoWalletBase
|
|||
await walletInfo.save();
|
||||
}
|
||||
|
||||
String getTransactionAddress(int accountIndex, int addressIndex) =>
|
||||
zano_wallet.getAddress(accountIndex: accountIndex, addressIndex: addressIndex);
|
||||
|
||||
Future<void> _refreshTransactions() async {
|
||||
final result = await calls.getRecentTxsAndInfo(hWallet: hWallet, offset: 0, count: 30);
|
||||
final map = jsonDecode(result);
|
||||
|
@ -403,36 +376,17 @@ abstract class ZanoWalletBase
|
|||
|
||||
if (currentHeight <= 1) {
|
||||
final height = _getHeightByDate(walletInfo.date);
|
||||
///zano_wallet.setRecoveringFromSeed(isRecovery: true);
|
||||
zano_wallet.setRefreshFromBlockHeight(height: height);
|
||||
debugPrint('setRecoveringFromSeed isRecovery true');
|
||||
debugPrint('setRefreshFromBlockHeight height $height');
|
||||
}
|
||||
}
|
||||
|
||||
// int _getHeightDistance(DateTime date) {
|
||||
// final distance =
|
||||
// DateTime.now().millisecondsSinceEpoch - date.millisecondsSinceEpoch;
|
||||
// final daysTmp = (distance / 86400).round();
|
||||
// final days = daysTmp < 1 ? 1 : daysTmp;
|
||||
|
||||
// return days * 1000;
|
||||
// }
|
||||
|
||||
int _getHeightByDate(DateTime date) {
|
||||
// TODO: !!! 12/10 commented
|
||||
return 0;
|
||||
// final nodeHeight = zano_wallet.getNodeHeightSync();
|
||||
// final heightDistance = _getHeightDistance(date);
|
||||
|
||||
// if (nodeHeight <= 0) {
|
||||
// return 0;
|
||||
// }
|
||||
|
||||
// return nodeHeight - heightDistance;
|
||||
}
|
||||
|
||||
void _askForUpdateBalance() {
|
||||
print("ask for update balance");
|
||||
//balance.addAll(getZanoBalance());
|
||||
debugPrint('askForUpdateBalance');
|
||||
}
|
||||
|
||||
Future<void> _askForUpdateTransactionHistory() async => await updateTransactions();
|
||||
|
|
|
@ -11,8 +11,11 @@ import 'package:cw_core/wallet_info.dart';
|
|||
import 'package:cw_core/wallet_service.dart';
|
||||
import 'package:cw_core/wallet_type.dart';
|
||||
import 'package:cw_zano/api/calls.dart' as calls;
|
||||
import 'package:cw_zano/api/consts.dart';
|
||||
import 'package:cw_zano/api/exceptions/already_exists_exception.dart';
|
||||
import 'package:cw_zano/api/exceptions/restore_from_seed_exception.dart';
|
||||
import 'package:cw_zano/api/exceptions/wrong_seed_exception.dart';
|
||||
import 'package:cw_zano/api/model/create_wallet_result.dart';
|
||||
import 'package:cw_zano/api/wallet_manager.dart' as zano_wallet_manager;
|
||||
import 'package:cw_zano/zano_balance.dart';
|
||||
import 'package:cw_zano/zano_wallet.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
|
@ -106,7 +109,7 @@ class ZanoWalletService extends WalletService<ZanoNewWalletCredentials,
|
|||
Future<bool> isWalletExit(String name) async {
|
||||
try {
|
||||
final path = await pathForWallet(name: name, type: getType());
|
||||
return zano_wallet_manager.isWalletExist(path: path);
|
||||
return calls.isWalletExist(path: path);
|
||||
} catch (e) {
|
||||
// TODO: Implement Exception for wallet list service.
|
||||
print('ZanoWalletsManager Error: $e');
|
||||
|
@ -188,25 +191,7 @@ class ZanoWalletService extends WalletService<ZanoNewWalletCredentials,
|
|||
|
||||
@override
|
||||
Future<ZanoWallet> restoreFromKeys(ZanoRestoreWalletFromKeysCredentials credentials) async {
|
||||
try {
|
||||
final path = await pathForWallet(name: credentials.name, type: getType());
|
||||
await zano_wallet_manager.restoreFromKeys(
|
||||
path: path,
|
||||
password: credentials.password!,
|
||||
language: credentials.language,
|
||||
restoreHeight: credentials.height!,
|
||||
address: credentials.address,
|
||||
viewKey: credentials.viewKey,
|
||||
spendKey: credentials.spendKey);
|
||||
final wallet = ZanoWallet(credentials.walletInfo!);
|
||||
await wallet.init();
|
||||
|
||||
return wallet;
|
||||
} catch (e) {
|
||||
// TODO: Implement Exception for wallet list service.
|
||||
print('ZanoWalletsManager Error: $e');
|
||||
rethrow;
|
||||
}
|
||||
throw UnimplementedError("Restore from keys not implemented");
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -216,12 +201,20 @@ class ZanoWalletService extends WalletService<ZanoNewWalletCredentials,
|
|||
await wallet.connectToNode(node: Node());
|
||||
final path = await pathForWallet(name: credentials.name, type: getType());
|
||||
final result = calls.restoreWalletFromSeed(path, credentials.password!, credentials.mnemonic);
|
||||
print('restore wallet from seed result $result');
|
||||
final map = json.decode(result) as Map<String, dynamic>;
|
||||
final map = json.decode(result) as Map<String, dynamic>;
|
||||
if (map['result'] != null) {
|
||||
final createWalletResult =
|
||||
CreateWalletResult.fromJson(map['result'] as Map<String, dynamic>);
|
||||
_parseCreateWalletResult(createWalletResult, wallet);
|
||||
} else if (map['error'] != null) {
|
||||
final code = map['error']['code'] as String;
|
||||
final message = map['error']['message'] as String;
|
||||
if (code == Consts.errorWrongSeed) {
|
||||
throw WrongSeedException(message);
|
||||
} else if (code == Consts.errorAlreadyExists) {
|
||||
throw AlreadyExistsException(message);
|
||||
}
|
||||
throw RestoreFromSeedException(code, message);
|
||||
}
|
||||
await calls.store(hWallet);
|
||||
await wallet.init();
|
||||
|
|
|
@ -218,7 +218,7 @@ class CWZano extends Zano {
|
|||
|
||||
@override
|
||||
void onStartup() {
|
||||
monero_wallet_api.onStartup();
|
||||
debugPrint("onStartup");
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -232,11 +232,11 @@ class CWZano extends Zano {
|
|||
return ZanoWalletService(walletInfoSource);
|
||||
}
|
||||
|
||||
@override
|
||||
String getTransactionAddress(Object wallet, int accountIndex, int addressIndex) {
|
||||
final zanoWallet = wallet as ZanoWallet;
|
||||
return zanoWallet.getTransactionAddress(accountIndex, addressIndex);
|
||||
}
|
||||
// @override
|
||||
// String getTransactionAddress(Object wallet, int accountIndex, int addressIndex) {
|
||||
// final zanoWallet = wallet as ZanoWallet;
|
||||
// return zanoWallet.getTransactionAddress(accountIndex, addressIndex);
|
||||
// }
|
||||
|
||||
@override
|
||||
CryptoCurrency assetOfTransaction(TransactionInfo tx) {
|
||||
|
|
|
@ -19,11 +19,8 @@ import 'package:cw_zano/zano_wallet_service.dart';
|
|||
import 'package:cw_zano/zano_wallet.dart';
|
||||
import 'package:cw_zano/zano_transaction_info.dart';
|
||||
import 'package:cw_zano/zano_transaction_history.dart';
|
||||
import 'package:cw_core/account.dart' as monero_account;
|
||||
import 'package:cw_zano/api/wallet.dart' as monero_wallet_api;
|
||||
import 'package:cw_zano/mnemonics/english.dart';
|
||||
import 'package:cw_zano/zano_transaction_creation_credentials.dart';
|
||||
import 'package:cw_zano/api/balance_list.dart';
|
||||
|
||||
part 'cw_zano.dart';
|
||||
|
||||
|
@ -95,7 +92,7 @@ abstract class Zano {
|
|||
|
||||
ZanoWalletDetails getZanoWalletDetails(Object wallet);
|
||||
|
||||
String getTransactionAddress(Object wallet, int accountIndex, int addressIndex);
|
||||
// String getTransactionAddress(Object wallet, int accountIndex, int addressIndex);
|
||||
|
||||
int getHeightByDate({required DateTime date});
|
||||
Future<int> getCurrentHeight();
|
||||
|
|
Loading…
Reference in a new issue