add plain/tor network flags to node data

This commit is contained in:
julian 2024-11-25 13:33:58 -06:00
parent f38efd35e9
commit 6cfe9e9c0f
25 changed files with 90 additions and 3 deletions

View file

@ -9,6 +9,7 @@
*/
import 'package:hive/hive.dart';
import '../utilities/default_nodes.dart';
import '../utilities/flutter_secure_storage_interface.dart';
@ -38,6 +39,10 @@ class NodeModel {
final bool isDown;
// @HiveField(10)
final bool? trusted;
// @HiveField(11)
final bool torEnabled;
// @HiveField(12)
final bool plainEnabled;
NodeModel({
required this.host,
@ -49,6 +54,8 @@ class NodeModel {
required this.coinName,
required this.isFailover,
required this.isDown,
required this.torEnabled,
required this.plainEnabled,
this.loginName,
this.trusted,
});
@ -64,6 +71,8 @@ class NodeModel {
bool? isFailover,
bool? isDown,
bool? trusted,
bool? torEnabled,
bool? plainEnabled,
}) {
return NodeModel(
host: host ?? this.host,
@ -77,6 +86,8 @@ class NodeModel {
isFailover: isFailover ?? this.isFailover,
isDown: isDown ?? this.isDown,
trusted: trusted ?? this.trusted,
torEnabled: torEnabled ?? this.torEnabled,
plainEnabled: plainEnabled ?? this.plainEnabled,
);
}
@ -98,6 +109,8 @@ class NodeModel {
map['isFailover'] = isFailover;
map['isDown'] = isDown;
map['trusted'] = trusted;
map['torEnabled'] = torEnabled;
map['plainEnabled'] = plainEnabled;
return map;
}

View file

@ -28,13 +28,15 @@ class NodeModelAdapter extends TypeAdapter<NodeModel> {
isFailover: fields[8] as bool,
isDown: fields[9] as bool,
trusted: fields[10] as bool?,
torEnabled: fields[11] as bool? ?? true,
plainEnabled: fields[12] as bool? ?? true,
);
}
@override
void write(BinaryWriter writer, NodeModel obj) {
writer
..writeByte(11)
..writeByte(13)
..writeByte(0)
..write(obj.id)
..writeByte(1)
@ -56,7 +58,11 @@ class NodeModelAdapter extends TypeAdapter<NodeModel> {
..writeByte(9)
..write(obj.isDown)
..writeByte(10)
..write(obj.trusted);
..write(obj.trusted)
..writeByte(11)
..write(obj.torEnabled)
..writeByte(12)
..write(obj.plainEnabled);
}
@override

View file

@ -1272,6 +1272,8 @@ abstract class SWB {
loginName: node['loginName'] as String?,
isFailover: node['isFailover'] as bool,
isDown: node['isDown'] as bool,
torEnabled: node['torEnabled'] as bool? ?? true,
plainEnabled: node['plainEnabled'] as bool? ?? true,
),
node["password"] as String?,
true,

View file

@ -12,6 +12,7 @@ import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:http/http.dart';
import '../app_config.dart';
import '../db/hive/db.dart';
import '../models/node_model.dart';
@ -253,7 +254,9 @@ class NodeService extends ChangeNotifier {
enabled: true,
coinName: coin.identifier,
isFailover: true,
torEnabled: nodeMap["torEnabled"] == "true",
isDown: nodeMap["isDown"] == "true",
plainEnabled: nodeMap["plainEnabled"] == "true",
);
final currentNode = getNodeById(id: nodeMap["id"] as String);
if (currentNode != null) {

View file

@ -77,6 +77,8 @@ class Banano extends NanoCurrency {
coinName: identifier,
isFailover: true,
isDown: false,
torEnabled: true,
plainEnabled: true,
);
default:

View file

@ -239,6 +239,8 @@ class Bitcoin extends Bip39HDCurrency
coinName: identifier,
isFailover: true,
isDown: false,
torEnabled: true,
plainEnabled: true,
);
case CryptoCurrencyNetwork.test:
@ -252,6 +254,8 @@ class Bitcoin extends Bip39HDCurrency
coinName: identifier,
isFailover: true,
isDown: false,
torEnabled: true,
plainEnabled: true,
);
case CryptoCurrencyNetwork.test4:
@ -265,6 +269,8 @@ class Bitcoin extends Bip39HDCurrency
coinName: identifier,
isFailover: true,
isDown: false,
torEnabled: true,
plainEnabled: true,
);
default:

View file

@ -73,6 +73,8 @@ class BitcoinFrost extends FrostCurrency {
coinName: identifier,
isFailover: true,
isDown: false,
torEnabled: true,
plainEnabled: true,
);
case CryptoCurrencyNetwork.test:
@ -86,6 +88,8 @@ class BitcoinFrost extends FrostCurrency {
coinName: identifier,
isFailover: true,
isDown: false,
torEnabled: true,
plainEnabled: true,
);
case CryptoCurrencyNetwork.test4:
@ -99,6 +103,8 @@ class BitcoinFrost extends FrostCurrency {
coinName: identifier,
isFailover: true,
isDown: false,
torEnabled: true,
plainEnabled: true,
);
default:

View file

@ -298,6 +298,8 @@ class Bitcoincash extends Bip39HDCurrency with ElectrumXCurrencyInterface {
coinName: identifier,
isFailover: true,
isDown: false,
torEnabled: true,
plainEnabled: true,
);
case CryptoCurrencyNetwork.test:
@ -311,6 +313,8 @@ class Bitcoincash extends Bip39HDCurrency with ElectrumXCurrencyInterface {
coinName: identifier,
isFailover: true,
isDown: false,
torEnabled: true,
plainEnabled: true,
);
default:

View file

@ -77,6 +77,8 @@ class Cardano extends Bip39Currency {
coinName: identifier,
isFailover: true,
isDown: false,
torEnabled: true,
plainEnabled: true,
);
default:
@ -91,7 +93,8 @@ class Cardano extends Bip39Currency {
int get fractionDigits => 6;
@override
String get genesisHash => "f0f7892b5c333cffc4b3c4344de48af4cc63f55e44936196f365a9ef2244134f";
String get genesisHash =>
"f0f7892b5c333cffc4b3c4344de48af4cc63f55e44936196f365a9ef2244134f";
@override
bool get hasBuySupport => false;

View file

@ -189,6 +189,8 @@ class Dash extends Bip39HDCurrency with ElectrumXCurrencyInterface {
coinName: identifier,
isFailover: true,
isDown: false,
torEnabled: true,
plainEnabled: true,
);
default:

View file

@ -189,6 +189,8 @@ class Dogecoin extends Bip39HDCurrency with ElectrumXCurrencyInterface {
coinName: identifier,
isFailover: true,
isDown: false,
torEnabled: true,
plainEnabled: true,
);
case CryptoCurrencyNetwork.test:
@ -202,6 +204,8 @@ class Dogecoin extends Bip39HDCurrency with ElectrumXCurrencyInterface {
coinName: identifier,
isFailover: true,
isDown: false,
torEnabled: true,
plainEnabled: true,
);
default:

View file

@ -289,6 +289,8 @@ class Ecash extends Bip39HDCurrency with ElectrumXCurrencyInterface {
coinName: identifier,
isFailover: true,
isDown: false,
torEnabled: true,
plainEnabled: true,
);
default:

View file

@ -80,6 +80,8 @@ class Epiccash extends Bip39Currency {
coinName: identifier,
isFailover: true,
isDown: false,
torEnabled: true,
plainEnabled: true,
);
default:

View file

@ -57,6 +57,8 @@ class Ethereum extends Bip39Currency {
coinName: identifier,
isFailover: true,
isDown: false,
torEnabled: true,
plainEnabled: true,
);
@override

View file

@ -231,6 +231,8 @@ class Firo extends Bip39HDCurrency with ElectrumXCurrencyInterface {
coinName: identifier,
isFailover: true,
isDown: false,
torEnabled: true,
plainEnabled: true,
);
case CryptoCurrencyNetwork.test:
@ -257,6 +259,8 @@ class Firo extends Bip39HDCurrency with ElectrumXCurrencyInterface {
coinName: identifier,
isFailover: true,
isDown: false,
torEnabled: true,
plainEnabled: true,
);
default:

View file

@ -220,6 +220,8 @@ class Litecoin extends Bip39HDCurrency with ElectrumXCurrencyInterface {
coinName: identifier,
isFailover: true,
isDown: false,
torEnabled: true,
plainEnabled: true,
);
case CryptoCurrencyNetwork.test:
@ -233,6 +235,8 @@ class Litecoin extends Bip39HDCurrency with ElectrumXCurrencyInterface {
coinName: identifier,
isFailover: true,
isDown: false,
torEnabled: true,
plainEnabled: true,
);
default:

View file

@ -72,6 +72,8 @@ class Monero extends CryptonoteCurrency {
isFailover: true,
isDown: false,
trusted: true,
torEnabled: true,
plainEnabled: true,
);
default:

View file

@ -102,6 +102,8 @@ class Namecoin extends Bip39HDCurrency with ElectrumXCurrencyInterface {
coinName: identifier,
isFailover: true,
isDown: false,
torEnabled: true,
plainEnabled: true,
);
// case CryptoCurrencyNetwork.test:
// TODO: [prio=low] Add testnet support.

View file

@ -77,6 +77,8 @@ class Nano extends NanoCurrency {
coinName: identifier,
isFailover: true,
isDown: false,
torEnabled: true,
plainEnabled: true,
);
default:

View file

@ -97,6 +97,8 @@ class Particl extends Bip39HDCurrency with ElectrumXCurrencyInterface {
coinName: identifier,
isFailover: true,
isDown: false,
torEnabled: true,
plainEnabled: true,
);
// case CryptoCurrencyNetwork.test:
// TODO: [prio=low] Add testnet.

View file

@ -103,6 +103,8 @@ class Peercoin extends Bip39HDCurrency with ElectrumXCurrencyInterface {
coinName: identifier,
isFailover: true,
isDown: false,
torEnabled: true,
plainEnabled: true,
);
case CryptoCurrencyNetwork.test:
@ -116,6 +118,8 @@ class Peercoin extends Bip39HDCurrency with ElectrumXCurrencyInterface {
coinName: identifier,
isFailover: true,
isDown: false,
torEnabled: true,
plainEnabled: true,
);
default:

View file

@ -55,6 +55,8 @@ class Solana extends Bip39Currency {
coinName: identifier,
isFailover: true,
isDown: false,
torEnabled: true,
plainEnabled: true,
);
default:
throw Exception("Unsupported network: $network");

View file

@ -68,6 +68,8 @@ class Stellar extends Bip39Currency {
coinName: identifier,
isFailover: true,
isDown: false,
torEnabled: true,
plainEnabled: true,
);
case CryptoCurrencyNetwork.test:
@ -81,6 +83,8 @@ class Stellar extends Bip39Currency {
coinName: identifier,
isFailover: true,
isDown: false,
torEnabled: true,
plainEnabled: true,
);
default:

View file

@ -118,6 +118,8 @@ class Tezos extends Bip39Currency {
coinName: identifier,
isFailover: true,
isDown: false,
torEnabled: true,
plainEnabled: true,
);
default:

View file

@ -72,6 +72,8 @@ class Wownero extends CryptonoteCurrency {
isFailover: true,
isDown: false,
trusted: true,
torEnabled: true,
plainEnabled: true,
);
default: