diff --git a/lib/services/coins/epiccash/epiccash_wallet.dart b/lib/services/coins/epiccash/epiccash_wallet.dart index 129fd2f95..b4b264b39 100644 --- a/lib/services/coins/epiccash/epiccash_wallet.dart +++ b/lib/services/coins/epiccash/epiccash_wallet.dart @@ -94,23 +94,6 @@ Future executeNative(Map arguments) async { final SendPort sendPort = arguments['sendPort'] as SendPort; final function = arguments['function'] as String; try { - if (function == "scanOutPuts") { - final wallet = arguments['wallet'] as String?; - final startHeight = arguments['startHeight'] as int?; - final numberOfBlocks = arguments['numberOfBlocks'] as int?; - Map result = {}; - if (!(wallet == null || startHeight == null || numberOfBlocks == null)) { - var outputs = await epiccash.LibEpiccash.scanOutputs( - wallet: wallet, - startHeight: startHeight, - numberOfBlocks: numberOfBlocks, - ); - result['outputs'] = outputs; - sendPort.send(result); - return; - } - } - Logging.instance.log( "Error Arguments for $function not formatted correctly", level: LogLevel.Fatal); @@ -235,7 +218,6 @@ class EpicCashWallet extends CoinServiceAPI final wallet = await _secureStore.read(key: '${_walletId}_wallet'); const int refreshFromNode = 1; if (!syncMutex.isLocked) { - await epiccash.LibEpiccash.getWalletBalances( wallet: wallet!, refreshFromNode: refreshFromNode, @@ -247,20 +229,6 @@ class EpicCashWallet extends CoinServiceAPI return ""; } - Future scanOutPuts() async { - final String wallet = - (await _secureStore.read(key: '${_walletId}_wallet'))!; - final int lastScannedBlock = - epicGetLastScannedBlock() ?? await getRestoreHeight(); - final int scanChunkSize = 10000; - - return await epiccash.LibEpiccash.scanOutputs( - wallet: wallet, - startHeight: lastScannedBlock, - numberOfBlocks: scanChunkSize, - ); - } - Future< ({ double awaitingFinalization, @@ -855,107 +823,6 @@ class EpicCashWallet extends CoinServiceAPI // TODO: refresh anything that needs to be refreshed/updated due to epicbox info changed } -// Future _startScans() async { -// try { -// //First stop the current listener -// if (ListenerManager.pointer != null) { -// Logging.instance -// .log("LISTENER HANDLER IS NOT NULL ....", level: LogLevel.Info); -// Logging.instance -// .log("STOPPING ANY WALLET LISTENER ....", level: LogLevel.Info); -// epicboxListenerStop(ListenerManager.pointer!); -// } -// final wallet = await _secureStore.read(key: '${_walletId}_wallet'); -// -// // max number of blocks to scan per loop iteration -// const scanChunkSize = 10000; -// -// // force firing of scan progress event -// await getSyncPercent; -// -// // fetch current chain height and last scanned block (should be the -// // restore height if full rescan or a wallet restore) -// int chainHeight = await this.chainHeight; -// int lastScannedBlock = -// epicGetLastScannedBlock() ?? await getRestoreHeight(); -// -// // loop while scanning in chain in chunks (of blocks?) -// while (lastScannedBlock < chainHeight) { -// Logging.instance.log( -// "chainHeight: $chainHeight, lastScannedBlock: $lastScannedBlock", -// level: LogLevel.Info, -// ); -// -// // final int nextScannedBlock = await m.protect(() async { -// final result = await m.protect(() async { -// return await epiccash.LibEpiccash.scanOutputs( -// wallet: wallet!, -// startHeight: lastScannedBlock, -// numberOfBlocks: scanChunkSize, -// ); -// -// // // ReceivePort? receivePort; -// // try { -// // // receivePort = await getIsolate({ -// // // "function": "scanOutPuts", -// // // "wallet": wallet!, -// // // "startHeight": lastScannedBlock, -// // // "numberOfBlocks": scanChunkSize, -// // // }, name: walletName); -// // -// // // get response -// // final message = await receivePort.first; -// // -// // // check for error message -// // if (message is String) { -// // throw Exception("scanOutPuts isolate failed: $message"); -// // } -// // -// // // attempt to grab next scanned block number -// // final nextScanned = int.tryParse(message['outputs'] as String); -// // if (nextScanned == null) { -// // throw Exception( -// // "scanOutPuts failed to parse next scanned block number from: $message", -// // ); -// // } -// // -// // return nextScanned; -// // } catch (_) { -// // rethrow; -// // } finally { -// // if (receivePort != null) { -// // // kill isolate -// // stop(receivePort); -// // } -// // } -// }); -// -// // update local cache -// await epicUpdateLastScannedBlock(result as int); -// -// // force firing of scan progress event -// await getSyncPercent; -// -// // update while loop condition variables -// chainHeight = await this.chainHeight; -// lastScannedBlock = nextScannedBlock; -// } -// -// Logging.instance.log( -// "_startScans successfully at the tip", -// level: LogLevel.Info, -// ); -// //Once scanner completes restart listener -// await listenToEpicbox(); -// } catch (e, s) { -// Logging.instance.log( -// "_startScans failed: $e\n$s", -// level: LogLevel.Error, -// ); -// rethrow; -// } -// } - Future _startScans() async { try { //First stop the current listener @@ -987,42 +854,11 @@ class EpicCashWallet extends CoinServiceAPI level: LogLevel.Info, ); - final int nextScannedBlock = await m.protect(() async { - ReceivePort? receivePort; - try { - receivePort = await getIsolate({ - "function": "scanOutPuts", - "wallet": wallet!, - "startHeight": lastScannedBlock, - "numberOfBlocks": scanChunkSize, - }, name: walletName); - - // get response - final message = await receivePort.first; - - // check for error message - if (message is String) { - throw Exception("scanOutPuts isolate failed: $message"); - } - - // attempt to grab next scanned block number - final nextScanned = int.tryParse(message['outputs'] as String); - if (nextScanned == null) { - throw Exception( - "scanOutPuts failed to parse next scanned block number from: $message", - ); - } - - return nextScanned; - } catch (_) { - rethrow; - } finally { - if (receivePort != null) { - // kill isolate - stop(receivePort); - } - } - }); + int nextScannedBlock = int.parse(await epiccash.LibEpiccash.scanOutputs( + wallet: wallet!, + startHeight: lastScannedBlock, + numberOfBlocks: scanChunkSize, + )); // update local cache await epicUpdateLastScannedBlock(nextScannedBlock); @@ -1139,7 +975,7 @@ class EpicCashWallet extends CoinServiceAPI try { final config = await getRealConfig(); int? latestHeight = - await epiccash.LibEpiccash.getChainHeight(config: config); + await epiccash.LibEpiccash.getChainHeight(config: config); await updateCachedChainHeight(latestHeight); if (latestHeight > storedChainHeight) { @@ -1456,11 +1292,11 @@ class EpicCashWallet extends CoinServiceAPI bool get isConnected => _isConnected; Future _refreshTransactions() async { - final wallet = await _secureStore.read(key: '${_walletId}_wallet'); const refreshFromNode = 1; - var transactions = await epiccash.LibEpiccash.getTransactions(wallet: wallet!, refreshFromNode: refreshFromNode); + var transactions = await epiccash.LibEpiccash.getTransactions( + wallet: wallet!, refreshFromNode: refreshFromNode); final List> txnsData = []; @@ -1487,7 +1323,8 @@ class EpicCashWallet extends CoinServiceAPI String? slateId = tx.txSlateId == "null" ? null : tx.txSlateId; String address = slatesToCommits[slateId] - ?[tx.txType == EpicTransactionType.TxReceived ? "from" : "to"] as String? ?? + ?[tx.txType == EpicTransactionType.TxReceived ? "from" : "to"] + as String? ?? ""; String? commitId = slatesToCommits[slateId]?['commitId'] as String?; int? numberOfMessages = tx.messages?.messages.length;