diff --git a/cw_core/lib/node.dart b/cw_core/lib/node.dart index acf41dd9a..ff1da7026 100644 --- a/cw_core/lib/node.dart +++ b/cw_core/lib/node.dart @@ -7,7 +7,6 @@ import 'package:http/http.dart' as http; import 'package:hive/hive.dart'; import 'package:cw_core/wallet_type.dart'; import 'package:http/io_client.dart' as ioc; -//import 'package:cake_wallet/entities/digest_request.dart'; part 'node.g.dart'; @@ -97,39 +96,39 @@ class Node extends HiveObject with Keyable { Future requestMoneroNode() async { - final path = '/json_rpc'; - final rpcUri = isSSL ? Uri.https(uri.authority, path) : Uri.http(uri.authority, path); - final realm = 'monero-rpc'; - final body = { - 'jsonrpc': '2.0', - 'id': '0', - 'method': 'get_info' - }; + final path = '/json_rpc'; + final rpcUri = isSSL ? Uri.https(uri.authority, path) : Uri.http(uri.authority, path); + final realm = 'monero-rpc'; + final body = { + 'jsonrpc': '2.0', + 'id': '0', + 'method': 'get_info' + }; - try { - final authenticatingClient = HttpClient(); - - authenticatingClient.addCredentials( - rpcUri, - realm, - HttpClientDigestCredentials(login ?? '', password ?? ''), - ); - - final http.Client client = ioc.IOClient(authenticatingClient); - - final response = await client.post( - rpcUri, - headers: {'Content-Type': 'application/json'}, - body: json.encode(body), - ); - - client.close(); + try { + final authenticatingClient = HttpClient(); + + authenticatingClient.addCredentials( + rpcUri, + realm, + HttpClientDigestCredentials(login ?? '', password ?? ''), + ); + + final http.Client client = ioc.IOClient(authenticatingClient); + + final response = await client.post( + rpcUri, + headers: {'Content-Type': 'application/json'}, + body: json.encode(body), + ); + + client.close(); - final resBody = json.decode(response.body) as Map; - return !(resBody['result']['offline'] as bool); - } catch (_) { - return false; - } + final resBody = json.decode(response.body) as Map; + return !(resBody['result']['offline'] as bool); + } catch (_) { + return false; + } } Future requestElectrumServer() async {