From e3101d98af18695e9618e5dca2c54837f39e7116 Mon Sep 17 00:00:00 2001 From: likho Date: Fri, 3 Feb 2023 20:34:19 +0200 Subject: [PATCH 1/6] Update Epicbox config to match latest epic version --- lib/services/coins/epiccash/epiccash_wallet.dart | 6 ++++-- lib/utilities/default_nodes.dart | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/services/coins/epiccash/epiccash_wallet.dart b/lib/services/coins/epiccash/epiccash_wallet.dart index 86ed2979b..4c4cdf8e6 100644 --- a/lib/services/coins/epiccash/epiccash_wallet.dart +++ b/lib/services/coins/epiccash/epiccash_wallet.dart @@ -1271,8 +1271,10 @@ class EpicCashWallet extends CoinServiceAPI Future updateEpicboxConfig(String host, int port) async { String stringConfig = jsonEncode({ - "domain": host, - "port": port, + "epicbox_domain": host, + "epicbox_port": port, + "epicbox_protocol_unsecure": false, + "epicbox_address_index": 0, }); await _secureStore.write( key: '${_walletId}_epicboxConfig', value: stringConfig); diff --git a/lib/utilities/default_nodes.dart b/lib/utilities/default_nodes.dart index d3e0f7abe..6e8cc53cb 100644 --- a/lib/utilities/default_nodes.dart +++ b/lib/utilities/default_nodes.dart @@ -257,7 +257,9 @@ abstract class DefaultNodes { } static final String defaultEpicBoxConfig = jsonEncode({ - "domain": "209.127.179.199", - "port": 13420, + "epicbox_domain": "epicbox.epic.tech", + "epicbox_port": 443, + "epicbox_protocol_unsecure": false, + "epicbox_address_index": 0, }); } From 0ddc8080e1197cb597a3e4f61f3113f9a12a3417 Mon Sep 17 00:00:00 2001 From: likho Date: Mon, 13 Feb 2023 16:49:25 +0200 Subject: [PATCH 2/6] Update listen for slates functionality --- .../coins/epiccash/epiccash_wallet.dart | 249 +++--------------- 1 file changed, 42 insertions(+), 207 deletions(-) diff --git a/lib/services/coins/epiccash/epiccash_wallet.dart b/lib/services/coins/epiccash/epiccash_wallet.dart index 4c4cdf8e6..0f074fd98 100644 --- a/lib/services/coins/epiccash/epiccash_wallet.dart +++ b/lib/services/coins/epiccash/epiccash_wallet.dart @@ -86,46 +86,6 @@ Future executeNative(Map arguments) async { sendPort.send(result); return; } - } else if (function == "getPendingSlates") { - final wallet = arguments['wallet'] as String?; - final secretKeyIndex = arguments['secretKeyIndex'] as int?; - final slates = arguments['slates'] as String; - Map result = {}; - - if (!(wallet == null || secretKeyIndex == null)) { - Logging.instance - .log("SECRET_KEY_INDEX_IS $secretKeyIndex", level: LogLevel.Info); - result['result'] = - await getPendingSlates(wallet, secretKeyIndex, slates); - sendPort.send(result); - return; - } - } else if (function == "subscribeRequest") { - final wallet = arguments['wallet'] as String?; - final secretKeyIndex = arguments['secretKeyIndex'] as int?; - final epicboxConfig = arguments['epicboxConfig'] as String?; - Map result = {}; - - if (!(wallet == null || - secretKeyIndex == null || - epicboxConfig == null)) { - Logging.instance - .log("SECRET_KEY_INDEX_IS $secretKeyIndex", level: LogLevel.Info); - result['result'] = - await getSubscribeRequest(wallet, secretKeyIndex, epicboxConfig); - sendPort.send(result); - return; - } - } else if (function == "processSlates") { - final wallet = arguments['wallet'] as String?; - final slates = arguments['slates']; - Map result = {}; - - if (!(wallet == null || slates == null)) { - result['result'] = await processSlates(wallet, slates.toString()); - sendPort.send(result); - return; - } } else if (function == "getWalletInfo") { final wallet = arguments['wallet'] as String?; final refreshFromNode = arguments['refreshFromNode'] as int?; @@ -216,6 +176,17 @@ Future executeNative(Map arguments) async { sendPort.send(result); return; } + } else if (function == "listenForSlates") { + final wallet = arguments['wallet'] as String?; + final epicboxConfig = arguments['epicboxConfig'] as String?; + + Map result = {}; + if (!(wallet == null || epicboxConfig == null)) { + var res = await epicboxListen(wallet, epicboxConfig); + result['result'] = res; + sendPort.send(result); + return; + } } Logging.instance.log( "Error Arguments for $function not formatted correctly", @@ -988,6 +959,8 @@ class EpicCashWallet extends CoinServiceAPI await _prefs.init(); await updateNode(false); await _refreshBalance(); + //Open Epicbox listener in the background + await listenForSlates(); // TODO: is there anything else that should be set up here whenever this wallet is first loaded again? } @@ -1082,6 +1055,9 @@ class EpicCashWallet extends CoinServiceAPI epicUpdateChangeIndex(0), ]); + //Open Epicbox listener in the background + await listenForSlates(); + final initialReceivingAddress = await _getReceivingAddressForIndex(0); await db.putAddress(initialReceivingAddress); @@ -1395,6 +1371,9 @@ class EpicCashWallet extends CoinServiceAPI //Store Epic box address info await storeEpicboxInfo(); + + //Open Epicbox listener in the background + await listenForSlates(); } catch (e, s) { Logging.instance .log("Error recovering wallet $e\n$s", level: LogLevel.Error); @@ -1557,173 +1536,28 @@ class EpicCashWallet extends CoinServiceAPI } } - Future processAllSlates() async { - final int? receivingIndex = epicGetReceivingIndex(); - for (int currentReceivingIndex = 0; - receivingIndex != null && currentReceivingIndex <= receivingIndex; - currentReceivingIndex++) { - final currentAddress = - await _getReceivingAddressForIndex(currentReceivingIndex); - final wallet = await _secureStore.read(key: '${_walletId}_wallet'); - final epicboxConfig = - await _secureStore.read(key: '${_walletId}_epicboxConfig'); - dynamic subscribeRequest; - await m.protect(() async { - ReceivePort receivePort = await getIsolate({ - "function": "subscribeRequest", - "wallet": wallet, - "secretKeyIndex": currentReceivingIndex, - "epicboxConfig": epicboxConfig, - }, name: walletName); + Future listenForSlates() async { + final wallet = await _secureStore.read(key: '${_walletId}_wallet'); + final epicboxConfig = + await _secureStore.read(key: '${_walletId}_epicboxConfig'); - var result = await receivePort.first; - if (result is String) { - Logging.instance - .log("this is a message $result", level: LogLevel.Error); - stop(receivePort); - throw Exception("subscribeRequest isolate failed"); - } - subscribeRequest = jsonDecode(result['result'] as String); - stop(receivePort); - Logging.instance.log('Closing subscribeRequest! $subscribeRequest', - level: LogLevel.Info); - }); - // TODO, once server adds signature, give this signature to the getSlates method. - Logging.instance - .log(subscribeRequest['signature'], level: LogLevel.Info); // - final unprocessedSlates = await getSlates( - currentAddress.value, subscribeRequest['signature'] as String); - if (unprocessedSlates == null || unprocessedSlates is! List) { - Logging.instance.log( - "index $currentReceivingIndex at ${await currentReceivingAddress} does not have any slates", - level: LogLevel.Info); - continue; - } - for (var slate in unprocessedSlates) { - final encoded = jsonEncode([slate]); + await m.protect(() async { + Logging.instance.log("CALLING LISTEN FOR SLATES", level: LogLevel.Info); + ReceivePort receivePort = await getIsolate({ + "function": "listenForSlates", + "wallet": wallet, + "epicboxConfig": epicboxConfig, + }, name: walletName); + + var result = await receivePort.first; + if (result is String) { Logging.instance - .log("Received Slates is $encoded", level: LogLevel.Info); - - //Decrypt Slates - dynamic slates; - dynamic response; - await m.protect(() async { - ReceivePort receivePort = await getIsolate({ - "function": "getPendingSlates", - "wallet": wallet!, - "secretKeyIndex": currentReceivingIndex, - "slates": encoded, - }, name: walletName); - - var result = await receivePort.first; - if (result is String) { - Logging.instance - .log("this is a message $slates", level: LogLevel.Info); - stop(receivePort); - throw Exception("getPendingSlates isolate failed"); - } - slates = result['result']; - stop(receivePort); - }); - - var decoded = jsonDecode(slates as String); - - for (var decodedSlate in decoded as List) { - //Process slates - var decodedResponse = json.decode(decodedSlate as String); - String slateMessage = decodedResponse[0] as String; - await putSlatesToCommits(slateMessage, encoded); - String slateSender = decodedResponse[1] as String; - Logging.instance.log("SLATE_MESSAGE $slateMessage", - printFullLength: true, level: LogLevel.Info); - Logging.instance - .log("SLATE_SENDER $slateSender", level: LogLevel.Info); - await m.protect(() async { - ReceivePort receivePort = await getIsolate({ - "function": "processSlates", - "wallet": wallet!, - "slates": slateMessage - }, name: walletName); - - var message = await receivePort.first; - if (message is String) { - Logging.instance.log("this is PROCESS_SLATES message $message", - level: LogLevel.Error); - stop(receivePort); - throw Exception("processSlates isolate failed"); - } - - try { - final String response = message['result'] as String; - if (response == "") { - Logging.instance.log("response: ${response.runtimeType}", - level: LogLevel.Info); - await deleteSlate(currentAddress.value, - subscribeRequest['signature'] as String, slate as String); - } - - if (response - .contains("Error Wallet store error: DB Not Found Error")) { - //Already processed - to be deleted - Logging.instance - .log("DELETING_PROCESSED_SLATE", level: LogLevel.Info); - final slateDelete = await deleteSlate(currentAddress.value, - subscribeRequest['signature'] as String, slate as String); - Logging.instance.log("DELETE_SLATE_RESPONSE $slateDelete", - level: LogLevel.Info); - } else { - var decodedResponse = json.decode(response); - final processStatus = json.decode(decodedResponse[0] as String); - String slateStatus = processStatus['status'] as String; - if (slateStatus == "PendingProcessing") { - //Encrypt slate - String encryptedSlate = await getEncryptedSlate( - wallet, - slateSender, - currentReceivingIndex, - epicboxConfig!, - decodedResponse[1] as String); - - final postSlateToServer = - await postSlate(slateSender, encryptedSlate); - - await deleteSlate(currentAddress.value, - subscribeRequest['signature'] as String, slate as String); - Logging.instance.log("POST_SLATE_RESPONSE $postSlateToServer", - level: LogLevel.Info); - } else { - //Finalise Slate - final processSlate = - json.decode(decodedResponse[1] as String); - Logging.instance.log( - "PROCESSED_SLATE_TO_FINALIZE $processSlate", - level: LogLevel.Info); - final tx = json.decode(processSlate[0] as String); - Logging.instance.log("TX_IS $tx", level: LogLevel.Info); - String txSlateId = tx[0]['tx_slate_id'] as String; - Logging.instance - .log("TX_SLATE_ID_IS $txSlateId", level: LogLevel.Info); - final postToNode = await postSlateToNode(wallet, txSlateId); - await deleteSlate(currentAddress.value, - subscribeRequest['signature'] as String, slate as String); - Logging.instance.log("POST_SLATE_RESPONSE $postToNode", - level: LogLevel.Info); - //Post Slate to Node - Logging.instance.log("Finalise slate", level: LogLevel.Info); - } - } - } catch (e, s) { - Logging.instance.log("$e\n$s", level: LogLevel.Info); - return false; - } - stop(receivePort); - Logging.instance - .log('Closing processSlates! $response', level: LogLevel.Info); - }); - } + .log("this is a message $result", level: LogLevel.Error); + stop(receivePort); + throw Exception("subscribeRequest isolate failed"); } - } - return true; + stop(receivePort); + }); } Future processAllCancels() async { @@ -1850,8 +1684,9 @@ class EpicCashWallet extends CoinServiceAPI return; } - await processAllSlates(); - await processAllCancels(); + // await listenForSlates(); + // await processAllSlates(); + // await processAllCancels(); unawaited(startSync()); @@ -1889,7 +1724,7 @@ class EpicCashWallet extends CoinServiceAPI ), ); refreshMutex = false; - + // await listenForSlates(); if (shouldAutoSync) { timer ??= Timer.periodic(const Duration(seconds: 60), (timer) async { Logging.instance.log( From a378ff751bf41f68d94c5919b980dc26219576ca Mon Sep 17 00:00:00 2001 From: likho Date: Mon, 13 Feb 2023 17:46:34 +0200 Subject: [PATCH 3/6] Remove all things epicpost --- .../coins/epiccash/epiccash_wallet.dart | 287 ------------------ 1 file changed, 287 deletions(-) diff --git a/lib/services/coins/epiccash/epiccash_wallet.dart b/lib/services/coins/epiccash/epiccash_wallet.dart index 0f074fd98..fd492a555 100644 --- a/lib/services/coins/epiccash/epiccash_wallet.dart +++ b/lib/services/coins/epiccash/epiccash_wallet.dart @@ -291,204 +291,6 @@ Future _getChainHeightWrapper(String config) async { return chainHeight; } -const String EPICPOST_ADDRESS = 'https://epicpost.stackwallet.com'; - -Future postSlate(String receiveAddress, String slate) async { - Logging.instance.log("postSlate", level: LogLevel.Info); - final Client client = Client(); - try { - final uri = Uri.parse("$EPICPOST_ADDRESS/postSlate"); - - final epicpost = await client.post( - uri, - headers: {'Content-Type': 'application/json'}, - body: jsonEncode({ - "jsonrpc": "2.0", - "id": "0", - 'receivingAddress': receiveAddress, - 'slate': slate - }), - ); - - // TODO: should the following be removed for security reasons in production? - Logging.instance.log(epicpost.statusCode.toString(), level: LogLevel.Info); - Logging.instance.log(epicpost.body.toString(), level: LogLevel.Info); - final response = jsonDecode(epicpost.body.toString()); - if (response['status'] == 'success') { - return true; - } else { - return false; - } - } catch (e, s) { - Logging.instance.log("$e $s", level: LogLevel.Error); - return false; - } -} - -Future getSlates(String receiveAddress, String signature) async { - Logging.instance.log("getslates", level: LogLevel.Info); - final Client client = Client(); - try { - final uri = Uri.parse("$EPICPOST_ADDRESS/getSlates"); - - final epicpost = await client.post( - uri, - headers: {'Content-Type': 'application/json'}, - body: jsonEncode({ - "jsonrpc": "2.0", - "id": "0", - 'receivingAddress': receiveAddress, - 'signature': signature, - }), - ); - - // TODO: should the following be removed for security reasons in production? - Logging.instance.log(epicpost.statusCode.toString(), level: LogLevel.Info); - Logging.instance.log(epicpost.body.toString(), level: LogLevel.Info); - final response = jsonDecode(epicpost.body.toString()); - if (response['status'] == 'success') { - return response['slates']; - } else { - return response['error']; - } - } catch (e, s) { - Logging.instance.log("$e $s", level: LogLevel.Error); - return 'Error $e $s'; - } -} - -Future postCancel(String receiveAddress, String slateId, - String? signature, String sendersAddress) async { - Logging.instance.log("postCancel", level: LogLevel.Info); - final Client client = Client(); - try { - final uri = Uri.parse("$EPICPOST_ADDRESS/postCancel"); - - final body = jsonEncode({ - "jsonrpc": "2.0", - "id": "0", - 'receivingAddress': receiveAddress, - "signature": signature, - 'slate': slateId, - "sendersAddress": sendersAddress, - }); - final epicPost = await client.post( - uri, - headers: {'Content-Type': 'application/json'}, - body: body, - ); - // TODO: should the following be removed for security reasons in production? - Logging.instance.log(epicPost.statusCode.toString(), level: LogLevel.Info); - Logging.instance.log(epicPost.body.toString(), level: LogLevel.Info); - final response = jsonDecode(epicPost.body.toString()); - if (response['status'] == 'success') { - return true; - } else { - return false; - } - } catch (e, s) { - Logging.instance.log("$e $s", level: LogLevel.Error); - return false; - } -} - -Future getCancels(String receiveAddress, String signature) async { - Logging.instance.log("getCancels", level: LogLevel.Info); - final Client client = Client(); - try { - final uri = Uri.parse("$EPICPOST_ADDRESS/getCancels"); - - final epicpost = await client.post( - uri, - headers: {'Content-Type': 'application/json'}, - body: jsonEncode({ - "jsonrpc": "2.0", - "id": "0", - 'receivingAddress': receiveAddress, - 'signature': signature, - }), - ); - // TODO: should the following be removed for security reasons in production? - Logging.instance.log(epicpost.statusCode.toString(), level: LogLevel.Info); - Logging.instance.log(epicpost.body.toString(), level: LogLevel.Info); - final response = jsonDecode(epicpost.body.toString()); - if (response['status'] == 'success') { - return response['canceled_slates']; - } else { - return response['error']; - } - } catch (e, s) { - Logging.instance.log("$e $s", level: LogLevel.Error); - return 'Error $e $s'; - } -} - -Future deleteCancels( - String receiveAddress, String signature, String slate) async { - Logging.instance.log("deleteCancels", level: LogLevel.Info); - final Client client = Client(); - try { - final uri = Uri.parse("$EPICPOST_ADDRESS/deleteCancels"); - - final epicpost = await client.post( - uri, - headers: {'Content-Type': 'application/json'}, - body: jsonEncode({ - "jsonrpc": "2.0", - "id": "0", - 'receivingAddress': receiveAddress, - 'signature': signature, - 'slate': slate, - }), - ); - // TODO: should the following be removed for security reasons in production? - Logging.instance.log(epicpost.statusCode.toString(), level: LogLevel.Info); - Logging.instance.log(epicpost.body.toString(), level: LogLevel.Info); - final response = jsonDecode(epicpost.body.toString()); - if (response['status'] == 'success') { - return true; - } else { - return false; - } - } catch (e, s) { - Logging.instance.log("$e $s", level: LogLevel.Error); - return 'Error $e $s'; - } -} - -Future deleteSlate( - String receiveAddress, String signature, String slate) async { - Logging.instance.log("deleteSlate", level: LogLevel.Info); - final Client client = Client(); - try { - final uri = Uri.parse("$EPICPOST_ADDRESS/deleteSlate"); - - final epicpost = await client.post( - uri, - headers: {'Content-Type': 'application/json'}, - body: jsonEncode({ - "jsonrpc": "2.0", - "id": "0", - 'receivingAddress': receiveAddress, - 'signature': signature, - 'slate': slate, - }), - ); - // TODO: should the following be removed for security reasons in production? - Logging.instance.log(epicpost.statusCode.toString(), level: LogLevel.Info); - Logging.instance.log(epicpost.body.toString(), level: LogLevel.Info); - final response = jsonDecode(epicpost.body.toString()); - if (response['status'] == 'success') { - return true; - } else { - return false; - } - } catch (e, s) { - Logging.instance.log("$e $s", level: LogLevel.Info); - return 'Error $e $s'; - } -} - class EpicCashWallet extends CoinServiceAPI with WalletCache, WalletDB, EpicCashHive { static const integrationTestFlag = @@ -665,9 +467,6 @@ class EpicCashWallet extends CoinServiceAPI try { result = await cancelPendingTransaction(txSlateId); Logging.instance.log("result?: $result", level: LogLevel.Info); - if (!(result.toLowerCase().contains("error"))) { - await postCancel(receiveAddress, txSlateId, signature, sendersAddress); - } } catch (e, s) { Logging.instance.log("$e, $s", level: LogLevel.Error); } @@ -768,16 +567,6 @@ class EpicCashWallet extends CoinServiceAPI String errorMessage = decodeData[1] as String; throw Exception("Transaction failed with error code $errorMessage"); } else { - //If it's HTTP send no need to post to epicbox - if (!(receiverAddress.startsWith("http://") || - receiverAddress.startsWith("https://"))) { - final postSlateRequest = decodeData[1]; - final postToServer = await postSlate( - txData['addresss'] as String, postSlateRequest as String); - Logging.instance - .log("POST_SLATE_IS $postToServer", level: LogLevel.Info); - } - final txCreateResult = decodeData[0]; // //TODO: second problem final transaction = json.decode(txCreateResult as String); @@ -1560,82 +1349,6 @@ class EpicCashWallet extends CoinServiceAPI }); } - Future processAllCancels() async { - Logging.instance.log("processAllCancels", level: LogLevel.Info); - final wallet = await _secureStore.read(key: '${_walletId}_wallet'); - final epicboxConfig = - await _secureStore.read(key: '${_walletId}_epicboxConfig'); - final int? receivingIndex = epicGetReceivingIndex(); - - for (int currentReceivingIndex = 0; - receivingIndex != null && currentReceivingIndex <= receivingIndex; - currentReceivingIndex++) { - final receiveAddress = - await _getReceivingAddressForIndex(currentReceivingIndex); - - dynamic subscribeRequest; - await m.protect(() async { - ReceivePort receivePort = await getIsolate({ - "function": "subscribeRequest", - "wallet": wallet!, - "secretKeyIndex": currentReceivingIndex, - "epicboxConfig": epicboxConfig, - }, name: walletName); - - var result = await receivePort.first; - if (result is String) { - Logging.instance - .log("this is a message $result", level: LogLevel.Info); - stop(receivePort); - throw Exception("subscribeRequest isolate failed"); - } - subscribeRequest = jsonDecode(result['result'] as String); - stop(receivePort); - Logging.instance.log('Closing subscribeRequest! $subscribeRequest', - level: LogLevel.Info); - }); - String? signature = subscribeRequest['signature'] as String?; - final cancels = await getCancels(receiveAddress.value, signature!); - - final slatesToCommits = await getSlatesToCommits(); - for (final cancel in cancels as List) { - final txSlateId = cancel.keys.first as String; - if (slatesToCommits[txSlateId] == null) { - continue; - } - final cancelRequestSender = ((cancel as Map).values.first) as String; - final receiveAddressFromMap = - slatesToCommits[txSlateId]['to'] as String; - final sendersAddressFromMap = - slatesToCommits[txSlateId]['from'] as String; - final commitId = slatesToCommits[txSlateId]['commitId'] as String; - - if (sendersAddressFromMap != cancelRequestSender) { - Logging.instance.log("this was not signed by the correct address", - level: LogLevel.Error); - continue; - } - - try { - await cancelPendingTransaction(txSlateId); - final tx = await db - .getTransactions(walletId) - .filter() - .txidEqualTo(commitId) - .findFirst(); - if ((tx?.isCancelled ?? false) == true) { - await deleteCancels(receiveAddressFromMap, signature, txSlateId); - } - } catch (e, s) { - Logging.instance.log("$e, $s", level: LogLevel.Error); - return false; - } - } - continue; - } - return true; - } - /// Refreshes display data for the wallet @override Future refresh() async { From e9b2b547b25d6967bca72240fbf19f013afff6c7 Mon Sep 17 00:00:00 2001 From: sneurlax Date: Wed, 15 Feb 2023 13:23:09 -0600 Subject: [PATCH 4/6] flutter_libepiccash ref update --- crypto_plugins/flutter_libepiccash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crypto_plugins/flutter_libepiccash b/crypto_plugins/flutter_libepiccash index 9a150d8cd..e71995ada 160000 --- a/crypto_plugins/flutter_libepiccash +++ b/crypto_plugins/flutter_libepiccash @@ -1 +1 @@ -Subproject commit 9a150d8cd2c3625424b0059e6b7306f3659fdbe0 +Subproject commit e71995ada3a0675fbce94609e56a7d335f59437c From 6645febe368fad496a814cccbbd74035b656fddf Mon Sep 17 00:00:00 2001 From: likho Date: Thu, 16 Feb 2023 13:41:09 +0200 Subject: [PATCH 5/6] Fix cancel error --- .../coins/epiccash/epiccash_wallet.dart | 45 ------------------- lib/utilities/default_nodes.dart | 2 +- 2 files changed, 1 insertion(+), 46 deletions(-) diff --git a/lib/services/coins/epiccash/epiccash_wallet.dart b/lib/services/coins/epiccash/epiccash_wallet.dart index f0a10dfdb..2e31196dd 100644 --- a/lib/services/coins/epiccash/epiccash_wallet.dart +++ b/lib/services/coins/epiccash/epiccash_wallet.dart @@ -423,46 +423,6 @@ class EpicCashWallet extends CoinServiceAPI late SecureStorageInterface _secureStore; Future cancelPendingTransactionAndPost(String txSlateId) async { - final wallet = await _secureStore.read(key: '${_walletId}_wallet'); - final int? receivingIndex = epicGetReceivingIndex(); - final epicboxConfig = - await _secureStore.read(key: '${_walletId}_epicboxConfig'); - - final slatesToCommits = await getSlatesToCommits(); - final receiveAddress = slatesToCommits[txSlateId]['to'] as String; - final sendersAddress = slatesToCommits[txSlateId]['from'] as String; - - int? currentReceivingIndex; - for (int i = 0; i <= receivingIndex!; i++) { - final indexesAddress = await _getReceivingAddressForIndex(i); - if (indexesAddress.value == sendersAddress) { - currentReceivingIndex = i; - break; - } - } - - dynamic subscribeRequest; - await m.protect(() async { - ReceivePort receivePort = await getIsolate({ - "function": "subscribeRequest", - "wallet": wallet, - "secretKeyIndex": currentReceivingIndex!, - "epicboxConfig": epicboxConfig, - }, name: walletName); - - var result = await receivePort.first; - if (result is String) { - Logging.instance.log("this is a message $result", level: LogLevel.Info); - stop(receivePort); - throw Exception("subscribeRequest isolate failed"); - } - subscribeRequest = jsonDecode(result['result'] as String); - stop(receivePort); - Logging.instance.log('Closing subscribeRequest! $subscribeRequest', - level: LogLevel.Info); - }); - // TODO, once server adds signature, give this signature to the getSlates method. - String? signature = subscribeRequest['signature'] as String?; String? result; try { result = await cancelPendingTransaction(txSlateId); @@ -1425,10 +1385,6 @@ class EpicCashWallet extends CoinServiceAPI return; } - // await listenForSlates(); - // await processAllSlates(); - // await processAllCancels(); - unawaited(startSync()); GlobalEventBus.instance.fire(RefreshPercentChangedEvent(0.0, walletId)); @@ -1465,7 +1421,6 @@ class EpicCashWallet extends CoinServiceAPI ), ); refreshMutex = false; - // await listenForSlates(); if (shouldAutoSync) { timer ??= Timer.periodic(const Duration(seconds: 60), (timer) async { Logging.instance.log( diff --git a/lib/utilities/default_nodes.dart b/lib/utilities/default_nodes.dart index 6e8cc53cb..83f6b9556 100644 --- a/lib/utilities/default_nodes.dart +++ b/lib/utilities/default_nodes.dart @@ -257,7 +257,7 @@ abstract class DefaultNodes { } static final String defaultEpicBoxConfig = jsonEncode({ - "epicbox_domain": "epicbox.epic.tech", + "epicbox_domain": "epicbox.fastepic.eu", "epicbox_port": 443, "epicbox_protocol_unsecure": false, "epicbox_address_index": 0, From a28f299c50965abaf78ca0584044de41d2b3ce2d Mon Sep 17 00:00:00 2001 From: likho Date: Thu, 16 Feb 2023 16:48:06 +0200 Subject: [PATCH 6/6] Revert to default epicbox node --- lib/utilities/default_nodes.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/utilities/default_nodes.dart b/lib/utilities/default_nodes.dart index 83f6b9556..6e8cc53cb 100644 --- a/lib/utilities/default_nodes.dart +++ b/lib/utilities/default_nodes.dart @@ -257,7 +257,7 @@ abstract class DefaultNodes { } static final String defaultEpicBoxConfig = jsonEncode({ - "epicbox_domain": "epicbox.fastepic.eu", + "epicbox_domain": "epicbox.epic.tech", "epicbox_port": 443, "epicbox_protocol_unsecure": false, "epicbox_address_index": 0,