Merge pull request #529 from cake-tech/CW-182-allow-trusted-nodes

Cw 182 allow trusted nodes
This commit is contained in:
Omar Hatem 2022-12-04 02:17:35 +02:00 committed by GitHub
commit dc60123f79
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
29 changed files with 123 additions and 17 deletions

View file

@ -17,6 +17,7 @@ class Node extends HiveObject with Keyable {
{this.login,
this.password,
this.useSSL,
this.trusted = false,
String? uri,
WalletType? type,}) {
if (uri != null) {
@ -31,7 +32,8 @@ class Node extends HiveObject with Keyable {
: uriRaw = map['uri'] as String? ?? '',
login = map['login'] as String?,
password = map['password'] as String?,
useSSL = map['useSSL'] as bool?;
useSSL = map['useSSL'] as bool?,
trusted = map['trusted'] as bool? ?? false;
static const typeId = 1;
static const boxName = 'Nodes';
@ -51,6 +53,9 @@ class Node extends HiveObject with Keyable {
@HiveField(4)
bool? useSSL;
@HiveField(5)
bool trusted;
bool get isSSL => useSSL ?? false;
Uri get uri {
@ -104,28 +109,28 @@ class Node extends HiveObject with Keyable {
final rpcUri = isSSL ? Uri.https(uri.authority, path) : Uri.http(uri.authority, path);
final realm = 'monero-rpc';
final body = {
'jsonrpc': '2.0',
'id': '0',
'jsonrpc': '2.0',
'id': '0',
'method': 'get_info'
};
try {
final authenticatingClient = HttpClient();
authenticatingClient.addCredentials(
rpcUri,
realm,
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<String, dynamic>;