mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-11-17 17:57:40 +00:00
26 lines
708 B
Dart
26 lines
708 B
Dart
import 'dart:convert';
|
|
|
|
import 'package:http/http.dart' as http;
|
|
import 'package:stackwallet/utilities/logger.dart';
|
|
|
|
Future<bool> testEpicBoxNodeConnection(Uri uri) async {
|
|
try {
|
|
final client = http.Client();
|
|
final response = await client.get(
|
|
uri,
|
|
headers: {'Content-Type': 'application/json'},
|
|
).timeout(const Duration(milliseconds: 1200),
|
|
onTimeout: () async => http.Response('Error', 408));
|
|
|
|
final json = jsonDecode(response.body);
|
|
|
|
if (response.statusCode == 200 && json["node_version"] != null) {
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
} catch (e, s) {
|
|
Logging.instance.log("$e\n$s", level: LogLevel.Warning);
|
|
return false;
|
|
}
|
|
}
|