mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-11-18 10:11:03 +00:00
22 lines
No EOL
558 B
Dart
22 lines
No EOL
558 B
Dart
import 'dart:convert';
|
|
|
|
import 'package:http/http.dart' as http;
|
|
|
|
Future<bool> testStellarNodeConnection(String host) async {
|
|
|
|
final client = http.Client();
|
|
Uri uri = Uri.parse(host);
|
|
final response = await client.get(
|
|
uri,
|
|
headers: {'Content-Type': 'application/json'},
|
|
).timeout(const Duration(milliseconds: 2000),
|
|
onTimeout: () async => http.Response('Error', 408));
|
|
|
|
final json = jsonDecode(response.body);
|
|
|
|
if (response.statusCode == 200 && json["horizon_version"] != null) {
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
} |