diff --git a/assets/zano_node_list.yml b/assets/zano_node_list.yml index 3ab03b6c9..be79fe477 100644 --- a/assets/zano_node_list.yml +++ b/assets/zano_node_list.yml @@ -1,4 +1,4 @@ - - uri: zano.org + uri: 195.201.107.230:33340 is_default: true - useSSL: true \ No newline at end of file + useSSL: false \ No newline at end of file diff --git a/cw_zano/lib/zano_wallet.dart b/cw_zano/lib/zano_wallet.dart index a11535e9c..a6468e4d5 100644 --- a/cw_zano/lib/zano_wallet.dart +++ b/cw_zano/lib/zano_wallet.dart @@ -44,6 +44,7 @@ abstract class ZanoWalletBase extends WalletBase create({required WalletCredentials credentials}) async { final wallet = ZanoWallet(credentials.walletInfo!, credentials.password!); - await wallet.connectToNode(node: Node()); + await wallet.connectToNode(node: Node()..uriRaw = DO_NOT_MERGE_hardcodedNodeUri); final path = await pathForWallet(name: credentials.name, type: credentials.walletInfo!.type); final createWalletResult = await wallet.createWallet(path, credentials.password!); await wallet.parseCreateWalletResult(createWalletResult); @@ -133,7 +134,7 @@ abstract class ZanoWalletBase extends WalletBase restore({required ZanoRestoreWalletFromSeedCredentials credentials}) async { final wallet = ZanoWallet(credentials.walletInfo!, credentials.password!); - await wallet.connectToNode(node: Node()); + await wallet.connectToNode(node: Node()..uriRaw = DO_NOT_MERGE_hardcodedNodeUri); final path = await pathForWallet(name: credentials.name, type: credentials.walletInfo!.type); final createWalletResult = await wallet.restoreWalletFromSeed(path, credentials.password!, credentials.mnemonic); await wallet.parseCreateWalletResult(createWalletResult); @@ -144,7 +145,7 @@ abstract class ZanoWalletBase extends WalletBase open({required String name, required String password, required WalletInfo walletInfo}) async { final path = await pathForWallet(name: name, type: walletInfo.type); final wallet = ZanoWallet(walletInfo, password); - await wallet.connectToNode(node: Node()); + await wallet.connectToNode(node: Node()..uriRaw = DO_NOT_MERGE_hardcodedNodeUri); final createWalletResult = await wallet.loadWallet(path, password); await wallet.parseCreateWalletResult(createWalletResult); await wallet.init(createWalletResult.wi.address); @@ -183,7 +184,7 @@ abstract class ZanoWalletBase extends WalletBase connectToNode({required Node node}) async { syncStatus = ConnectingSyncStatus(); - await setupNode(); + await setupNode(node.uriRaw); syncStatus = ConnectedSyncStatus(); } diff --git a/cw_zano/lib/zano_wallet_api.dart b/cw_zano/lib/zano_wallet_api.dart index 0c83c7722..7c0f2ac52 100644 --- a/cw_zano/lib/zano_wallet_api.dart +++ b/cw_zano/lib/zano_wallet_api.dart @@ -28,7 +28,6 @@ import 'package:monero/zano.dart' as zano; import 'package:monero/src/generated_bindings_zano.g.dart' as zanoapi; mixin ZanoWalletApi { - static const _defaultNodeUri = '195.201.107.230:33340'; static const _statusDelivered = 'delivered'; static const _maxInvokeAttempts = 10; static const _maxReopenAttempts = 5; @@ -47,21 +46,18 @@ mixin ZanoWalletApi { int getCurrentTxFee(TransactionPriority priority) => zano.PlainWallet_getCurrentTxFee(priority.raw); - String getOpenedWallets() => zano.PlainWallet_getOpenWallets(); - String getConnectivityStatus() => zano.PlainWallet_getConnectivityStatus(); - void setPassword(String password) => zano.PlainWallet_resetWalletPassword(hWallet, password); - void closeWallet([int? walletToClose]) { + void closeWallet([int? walletToClose]) async { info('close_wallet ${walletToClose ?? hWallet}'); - final result = zano.PlainWallet_closeWallet(walletToClose ?? hWallet); + final result = await _closeWallet(walletToClose ?? hWallet); info('close_wallet result $result'); } - Future setupNode() async { - info('init $_defaultNodeUri'); + Future setupNode(String nodeUri) async { + info('init $nodeUri'); // pathForWallet(name: , type: type) - final result = zano.PlainWallet_init(_defaultNodeUri, "", 0); + final result = zano.PlainWallet_init(nodeUri, "", 0); info('init result $result'); return result == "OK"; } @@ -89,31 +85,14 @@ mixin ZanoWalletApi { } Future invokeMethod(String methodName, Object params) async { - - // var invokeResult = zano.PlainWallet_syncCall( - // 'invoke', - // hWallet, - // jsonEncode( - // { - // "method": "$methodName", - // "params": params, - // }, - // ), - // ); final request = jsonEncode({ "method": methodName, "params": params, }); final invokeResult = await callSyncMethod('invoke', hWallet, request); - // final invokeResult = zano.PlainWallet_syncCall( - // 'invoke', - // hWallet, - // request, - // ); - // print("zano: <<< ${invokeResult}"); Map map; try { - map = jsonDecode(invokeResult) as Map; + map = jsonDecode(invokeResult); } catch (e) { if (invokeResult.contains(Consts.errorWalletWrongId)) throw ZanoWalletException('Wrong wallet id'); error('exception in parsing json in invokeMethod: $invokeResult'); @@ -325,7 +304,6 @@ mixin ZanoWalletApi { } final result = CreateWalletResult.fromJson(map!['result'] as Map); info('load_wallet3 ${result.name} ${result.wi.address}'); - zano.PlainWallet_init(_defaultNodeUri, path, 0); return result; } @@ -470,4 +448,11 @@ Future _getWalletInfo(int hWallet) async { json = ""; } return json; +} + +Future _closeWallet(int hWallet) async { + final str = await Isolate.run(() async { + return zano.PlainWallet_closeWallet(hWallet); + }); + return str; } \ No newline at end of file diff --git a/lib/entities/default_settings_migration.dart b/lib/entities/default_settings_migration.dart index f245ac426..0768591a1 100644 --- a/lib/entities/default_settings_migration.dart +++ b/lib/entities/default_settings_migration.dart @@ -46,7 +46,7 @@ const solanaDefaultNodeUri = 'rpc.ankr.com'; const tronDefaultNodeUri = 'trx.nownodes.io'; const newCakeWalletBitcoinUri = 'btc-electrum.cakewallet.com:50002'; const wowneroDefaultNodeUri = 'node3.monerodevs.org:34568'; -const zanoDefaultNodeUri = 'zano.org'; +const zanoDefaultNodeUri = '195.201.107.230:33340'; const moneroWorldNodeUri = '.moneroworld.com'; Future defaultSettingsMigration( diff --git a/lib/reactions/on_current_node_change.dart b/lib/reactions/on_current_node_change.dart index 730fba674..4b49d05ad 100644 --- a/lib/reactions/on_current_node_change.dart +++ b/lib/reactions/on_current_node_change.dart @@ -1,6 +1,5 @@ import 'package:cw_core/utils/print_verbose.dart'; import 'package:mobx/mobx.dart'; -import 'package:cw_core/node.dart'; import 'package:cake_wallet/store/app_store.dart'; ReactionDisposer? _onCurrentNodeChangeReaction;