From f3612ab79bd8f8c39c5d54e13cd01b8415b4c509 Mon Sep 17 00:00:00 2001 From: julian Date: Thu, 16 Nov 2023 19:44:17 -0600 Subject: [PATCH] enforce default node addition per crypto currency --- lib/utilities/default_nodes.dart | 170 +++++++++--------- lib/wallets/crypto_currency/coins/banano.dart | 23 +++ .../crypto_currency/coins/bitcoin.dart | 36 ++++ .../crypto_currency/coins/bitcoincash.dart | 36 ++++ .../crypto_currency/coins/dogecoin.dart | 36 ++++ lib/wallets/crypto_currency/coins/ecash.dart | 23 +++ .../crypto_currency/coins/epiccash.dart | 24 +++ lib/wallets/crypto_currency/coins/firo.dart | 49 +++++ lib/wallets/crypto_currency/coins/nano.dart | 23 +++ .../crypto_currency/coins/wownero.dart | 35 +++- .../crypto_currency/crypto_currency.dart | 3 + 11 files changed, 375 insertions(+), 83 deletions(-) diff --git a/lib/utilities/default_nodes.dart b/lib/utilities/default_nodes.dart index 22984d439..d45e31d85 100644 --- a/lib/utilities/default_nodes.dart +++ b/lib/utilities/default_nodes.dart @@ -13,9 +13,10 @@ import 'package:stackwallet/utilities/enums/coin_enum.dart'; abstract class DefaultNodes { static const String defaultNodeIdPrefix = "default_"; - static String _nodeId(Coin coin) => "$defaultNodeIdPrefix${coin.name}"; + static String buildId(Coin coin) => "$defaultNodeIdPrefix${coin.name}"; static const String defaultName = "Stack Default"; + @Deprecated("old and decrepit") static List get all => [ bitcoin, litecoin, @@ -44,8 +45,8 @@ abstract class DefaultNodes { static NodeModel get bitcoin => NodeModel( host: "bitcoin.stackwallet.com", port: 50002, - name: defaultName, - id: _nodeId(Coin.bitcoin), + name: DefaultNodes.defaultName, + id: DefaultNodes.buildId(Coin.bitcoin), useSSL: true, enabled: true, coinName: Coin.bitcoin.name, @@ -56,8 +57,8 @@ abstract class DefaultNodes { static NodeModel get litecoin => NodeModel( host: "litecoin.stackwallet.com", port: 20063, - name: defaultName, - id: _nodeId(Coin.litecoin), + name: DefaultNodes.defaultName, + id: DefaultNodes.buildId(Coin.litecoin), useSSL: true, enabled: true, coinName: Coin.litecoin.name, @@ -68,8 +69,8 @@ abstract class DefaultNodes { static NodeModel get litecoinTestNet => NodeModel( host: "litecoin.stackwallet.com", port: 51002, - name: defaultName, - id: _nodeId(Coin.litecoinTestNet), + name: DefaultNodes.defaultName, + id: DefaultNodes.buildId(Coin.litecoinTestNet), useSSL: true, enabled: true, coinName: Coin.litecoinTestNet.name, @@ -80,8 +81,8 @@ abstract class DefaultNodes { static NodeModel get bitcoincash => NodeModel( host: "bitcoincash.stackwallet.com", port: 50002, - name: defaultName, - id: _nodeId(Coin.bitcoincash), + name: DefaultNodes.defaultName, + id: DefaultNodes.buildId(Coin.bitcoincash), useSSL: true, enabled: true, coinName: Coin.bitcoincash.name, @@ -92,8 +93,8 @@ abstract class DefaultNodes { static NodeModel get dogecoin => NodeModel( host: "dogecoin.stackwallet.com", port: 50022, - name: defaultName, - id: _nodeId(Coin.dogecoin), + name: DefaultNodes.defaultName, + id: DefaultNodes.buildId(Coin.dogecoin), useSSL: true, enabled: true, coinName: Coin.dogecoin.name, @@ -104,8 +105,8 @@ abstract class DefaultNodes { static NodeModel get firo => NodeModel( host: "firo.stackwallet.com", port: 50002, - name: defaultName, - id: _nodeId(Coin.firo), + name: DefaultNodes.defaultName, + id: DefaultNodes.buildId(Coin.firo), useSSL: true, enabled: true, coinName: Coin.firo.name, @@ -116,8 +117,8 @@ abstract class DefaultNodes { static NodeModel get monero => NodeModel( host: "https://monero.stackwallet.com", port: 18081, - name: defaultName, - id: _nodeId(Coin.monero), + name: DefaultNodes.defaultName, + id: DefaultNodes.buildId(Coin.monero), useSSL: true, enabled: true, coinName: Coin.monero.name, @@ -129,8 +130,8 @@ abstract class DefaultNodes { static NodeModel get wownero => NodeModel( host: "https://wownero.stackwallet.com", port: 34568, - name: defaultName, - id: _nodeId(Coin.wownero), + name: DefaultNodes.defaultName, + id: DefaultNodes.buildId(Coin.wownero), useSSL: true, enabled: true, coinName: Coin.wownero.name, @@ -142,8 +143,8 @@ abstract class DefaultNodes { static NodeModel get epicCash => NodeModel( host: "http://epiccash.stackwallet.com", port: 3413, - name: defaultName, - id: _nodeId(Coin.epicCash), + name: DefaultNodes.defaultName, + id: DefaultNodes.buildId(Coin.epicCash), useSSL: false, enabled: true, coinName: Coin.epicCash.name, @@ -154,8 +155,8 @@ abstract class DefaultNodes { static NodeModel get ethereum => NodeModel( host: "https://eth.stackwallet.com", port: 443, - name: defaultName, - id: _nodeId(Coin.ethereum), + name: DefaultNodes.defaultName, + id: DefaultNodes.buildId(Coin.ethereum), useSSL: true, enabled: true, coinName: Coin.ethereum.name, @@ -166,8 +167,8 @@ abstract class DefaultNodes { static NodeModel get namecoin => NodeModel( host: "namecoin.stackwallet.com", port: 57002, - name: defaultName, - id: _nodeId(Coin.namecoin), + name: DefaultNodes.defaultName, + id: DefaultNodes.buildId(Coin.namecoin), useSSL: true, enabled: true, coinName: Coin.namecoin.name, @@ -176,66 +177,71 @@ abstract class DefaultNodes { ); static NodeModel get particl => NodeModel( - host: "particl.stackwallet.com", - port: 58002, - name: defaultName, - id: _nodeId(Coin.particl), - useSSL: true, - enabled: true, - coinName: Coin.particl.name, - isFailover: true, - isDown: false); + host: "particl.stackwallet.com", + port: 58002, + name: DefaultNodes.defaultName, + id: DefaultNodes.buildId(Coin.particl), + useSSL: true, + enabled: true, + coinName: Coin.particl.name, + isFailover: true, + isDown: false, + ); static NodeModel get stellar => NodeModel( - host: "https://horizon.stellar.org", - port: 443, - name: defaultName, - id: _nodeId(Coin.stellar), - useSSL: false, - enabled: true, - coinName: Coin.stellar.name, - isFailover: true, - isDown: false); + host: "https://horizon.stellar.org", + port: 443, + name: DefaultNodes.defaultName, + id: DefaultNodes.buildId(Coin.stellar), + useSSL: false, + enabled: true, + coinName: Coin.stellar.name, + isFailover: true, + isDown: false, + ); static NodeModel get tezos => NodeModel( - // TODO: Change this to stack wallet one - host: "https://mainnet.api.tez.ie", - port: 443, - name: defaultName, - id: _nodeId(Coin.tezos), - useSSL: true, - enabled: true, - coinName: Coin.tezos.name, - isFailover: true, - isDown: false); + // TODO: Change this to stack wallet one + host: "https://mainnet.api.tez.ie", + port: 443, + name: DefaultNodes.defaultName, + id: DefaultNodes.buildId(Coin.tezos), + useSSL: true, + enabled: true, + coinName: Coin.tezos.name, + isFailover: true, + isDown: false, + ); static NodeModel get nano => NodeModel( - host: "https://rainstorm.city/api", - port: 443, - name: defaultName, - id: _nodeId(Coin.nano), - useSSL: true, - enabled: true, - coinName: Coin.nano.name, - isFailover: true, - isDown: false); + host: "https://rainstorm.city/api", + port: 443, + name: DefaultNodes.defaultName, + id: DefaultNodes.buildId(Coin.nano), + useSSL: true, + enabled: true, + coinName: Coin.nano.name, + isFailover: true, + isDown: false, + ); static NodeModel get banano => NodeModel( - host: "https://kaliumapi.appditto.com/api", - port: 443, - name: defaultName, - id: _nodeId(Coin.banano), - useSSL: true, - enabled: true, - coinName: Coin.banano.name, - isFailover: true, - isDown: false); + host: "https://kaliumapi.appditto.com/api", + port: 443, + name: DefaultNodes.defaultName, + id: DefaultNodes.buildId(Coin.banano), + useSSL: true, + enabled: true, + coinName: Coin.banano.name, + isFailover: true, + isDown: false, + ); static NodeModel get bitcoinTestnet => NodeModel( host: "bitcoin-testnet.stackwallet.com", port: 51002, - name: defaultName, - id: _nodeId(Coin.bitcoinTestNet), + name: DefaultNodes.defaultName, + id: DefaultNodes.buildId(Coin.bitcoinTestNet), useSSL: true, enabled: true, coinName: Coin.bitcoinTestNet.name, @@ -246,7 +252,7 @@ abstract class DefaultNodes { // static NodeModel get firoTestnet => NodeModel( // host: "firo-testnet.stackwallet.com", // port: 50002, - // name: defaultName, + // name: DefaultNodes.defaultName, // id: _nodeId(Coin.firoTestNet), // useSSL: true, // enabled: true, @@ -259,8 +265,8 @@ abstract class DefaultNodes { static NodeModel get firoTestnet => NodeModel( host: "95.179.164.13", port: 51002, - name: defaultName, - id: _nodeId(Coin.firoTestNet), + name: DefaultNodes.defaultName, + id: DefaultNodes.buildId(Coin.firoTestNet), useSSL: true, enabled: true, coinName: Coin.firoTestNet.name, @@ -271,8 +277,8 @@ abstract class DefaultNodes { static NodeModel get dogecoinTestnet => NodeModel( host: "dogecoin-testnet.stackwallet.com", port: 50022, - name: defaultName, - id: _nodeId(Coin.dogecoinTestNet), + name: DefaultNodes.defaultName, + id: DefaultNodes.buildId(Coin.dogecoinTestNet), useSSL: true, enabled: true, coinName: Coin.dogecoinTestNet.name, @@ -283,8 +289,8 @@ abstract class DefaultNodes { static NodeModel get bitcoincashTestnet => NodeModel( host: "bitcoincash-testnet.stackwallet.com", port: 60002, - name: defaultName, - id: _nodeId(Coin.bitcoincashTestnet), + name: DefaultNodes.defaultName, + id: DefaultNodes.buildId(Coin.bitcoincashTestnet), useSSL: true, enabled: true, coinName: Coin.bitcoincashTestnet.name, @@ -295,8 +301,8 @@ abstract class DefaultNodes { static NodeModel get eCash => NodeModel( host: "electrum.bitcoinabc.org", port: 50002, - name: defaultName, - id: _nodeId(Coin.eCash), + name: DefaultNodes.defaultName, + id: DefaultNodes.buildId(Coin.eCash), useSSL: true, enabled: true, coinName: Coin.eCash.name, @@ -307,8 +313,8 @@ abstract class DefaultNodes { static NodeModel get stellarTestnet => NodeModel( host: "https://horizon-testnet.stellar.org/", port: 50022, - name: defaultName, - id: _nodeId(Coin.stellarTestnet), + name: DefaultNodes.defaultName, + id: DefaultNodes.buildId(Coin.stellarTestnet), useSSL: true, enabled: true, coinName: Coin.stellarTestnet.name, diff --git a/lib/wallets/crypto_currency/coins/banano.dart b/lib/wallets/crypto_currency/coins/banano.dart index 9b6060980..8f980e947 100644 --- a/lib/wallets/crypto_currency/coins/banano.dart +++ b/lib/wallets/crypto_currency/coins/banano.dart @@ -1,4 +1,6 @@ import 'package:nanodart/nanodart.dart'; +import 'package:stackwallet/models/node_model.dart'; +import 'package:stackwallet/utilities/default_nodes.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; import 'package:stackwallet/wallets/crypto_currency/intermediate/nano_currency.dart'; @@ -22,4 +24,25 @@ class Banano extends NanoCurrency { @override int get nanoAccountType => NanoAccountType.BANANO; + + @override + NodeModel get defaultNode { + switch (network) { + case CryptoCurrencyNetwork.main: + return NodeModel( + host: "https://kaliumapi.appditto.com/api", + port: 443, + name: DefaultNodes.defaultName, + id: DefaultNodes.buildId(Coin.banano), + useSSL: true, + enabled: true, + coinName: Coin.banano.name, + isFailover: true, + isDown: false, + ); + + default: + throw UnimplementedError(); + } + } } diff --git a/lib/wallets/crypto_currency/coins/bitcoin.dart b/lib/wallets/crypto_currency/coins/bitcoin.dart index d51aec647..9511bfbd0 100644 --- a/lib/wallets/crypto_currency/coins/bitcoin.dart +++ b/lib/wallets/crypto_currency/coins/bitcoin.dart @@ -1,6 +1,8 @@ import 'package:coinlib_flutter/coinlib_flutter.dart' as coinlib; import 'package:stackwallet/models/isar/models/blockchain_data/address.dart'; +import 'package:stackwallet/models/node_model.dart'; import 'package:stackwallet/utilities/amount/amount.dart'; +import 'package:stackwallet/utilities/default_nodes.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/enums/derive_path_type_enum.dart'; import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; @@ -175,4 +177,38 @@ class Bitcoin extends Bip39HDCurrency { return false; } } + + @override + NodeModel get defaultNode { + switch (network) { + case CryptoCurrencyNetwork.main: + return NodeModel( + host: "bitcoin.stackwallet.com", + port: 50002, + name: DefaultNodes.defaultName, + id: DefaultNodes.buildId(Coin.bitcoin), + useSSL: true, + enabled: true, + coinName: Coin.bitcoin.name, + isFailover: true, + isDown: false, + ); + + case CryptoCurrencyNetwork.test: + return NodeModel( + host: "bitcoin-testnet.stackwallet.com", + port: 51002, + name: DefaultNodes.defaultName, + id: DefaultNodes.buildId(Coin.bitcoinTestNet), + useSSL: true, + enabled: true, + coinName: Coin.bitcoinTestNet.name, + isFailover: true, + isDown: false, + ); + + default: + throw UnimplementedError(); + } + } } diff --git a/lib/wallets/crypto_currency/coins/bitcoincash.dart b/lib/wallets/crypto_currency/coins/bitcoincash.dart index 60019a106..a1f709b45 100644 --- a/lib/wallets/crypto_currency/coins/bitcoincash.dart +++ b/lib/wallets/crypto_currency/coins/bitcoincash.dart @@ -5,7 +5,9 @@ import 'package:bitbox/bitbox.dart' as bitbox; import 'package:bs58check/bs58check.dart' as bs58check; import 'package:coinlib_flutter/coinlib_flutter.dart' as coinlib; import 'package:stackwallet/models/isar/models/blockchain_data/address.dart'; +import 'package:stackwallet/models/node_model.dart'; import 'package:stackwallet/utilities/amount/amount.dart'; +import 'package:stackwallet/utilities/default_nodes.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/enums/derive_path_type_enum.dart'; import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; @@ -245,4 +247,38 @@ class Bitcoincash extends Bip39HDCurrency { } throw ArgumentError('$address has no matching Script'); } + + @override + NodeModel get defaultNode { + switch (network) { + case CryptoCurrencyNetwork.main: + return NodeModel( + host: "bitcoincash.stackwallet.com", + port: 50002, + name: DefaultNodes.defaultName, + id: DefaultNodes.buildId(Coin.bitcoincash), + useSSL: true, + enabled: true, + coinName: Coin.bitcoincash.name, + isFailover: true, + isDown: false, + ); + + case CryptoCurrencyNetwork.test: + return NodeModel( + host: "bitcoincash-testnet.stackwallet.com", + port: 60002, + name: DefaultNodes.defaultName, + id: DefaultNodes.buildId(Coin.bitcoincashTestnet), + useSSL: true, + enabled: true, + coinName: Coin.bitcoincashTestnet.name, + isFailover: true, + isDown: false, + ); + + default: + throw UnimplementedError(); + } + } } diff --git a/lib/wallets/crypto_currency/coins/dogecoin.dart b/lib/wallets/crypto_currency/coins/dogecoin.dart index 296d110ff..2051839e4 100644 --- a/lib/wallets/crypto_currency/coins/dogecoin.dart +++ b/lib/wallets/crypto_currency/coins/dogecoin.dart @@ -1,6 +1,8 @@ import 'package:coinlib_flutter/coinlib_flutter.dart' as coinlib; import 'package:stackwallet/models/isar/models/blockchain_data/address.dart'; +import 'package:stackwallet/models/node_model.dart'; import 'package:stackwallet/utilities/amount/amount.dart'; +import 'package:stackwallet/utilities/default_nodes.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/enums/derive_path_type_enum.dart'; import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; @@ -136,4 +138,38 @@ class Dogecoin extends Bip39HDCurrency { return false; } } + + @override + NodeModel get defaultNode { + switch (network) { + case CryptoCurrencyNetwork.main: + return NodeModel( + host: "dogecoin.stackwallet.com", + port: 50022, + name: DefaultNodes.defaultName, + id: DefaultNodes.buildId(Coin.dogecoin), + useSSL: true, + enabled: true, + coinName: Coin.dogecoin.name, + isFailover: true, + isDown: false, + ); + + case CryptoCurrencyNetwork.test: + return NodeModel( + host: "dogecoin-testnet.stackwallet.com", + port: 50022, + name: DefaultNodes.defaultName, + id: DefaultNodes.buildId(Coin.dogecoinTestNet), + useSSL: true, + enabled: true, + coinName: Coin.dogecoinTestNet.name, + isFailover: true, + isDown: false, + ); + + default: + throw UnimplementedError(); + } + } } diff --git a/lib/wallets/crypto_currency/coins/ecash.dart b/lib/wallets/crypto_currency/coins/ecash.dart index 2d428babb..0f2297b35 100644 --- a/lib/wallets/crypto_currency/coins/ecash.dart +++ b/lib/wallets/crypto_currency/coins/ecash.dart @@ -5,7 +5,9 @@ import 'package:bitbox/bitbox.dart' as bitbox; import 'package:bs58check/bs58check.dart' as bs58check; import 'package:coinlib_flutter/coinlib_flutter.dart' as coinlib; import 'package:stackwallet/models/isar/models/blockchain_data/address.dart'; +import 'package:stackwallet/models/node_model.dart'; import 'package:stackwallet/utilities/amount/amount.dart'; +import 'package:stackwallet/utilities/default_nodes.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/enums/derive_path_type_enum.dart'; import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; @@ -238,4 +240,25 @@ class Ecash extends Bip39HDCurrency { } throw ArgumentError('$address has no matching Script'); } + + @override + NodeModel get defaultNode { + switch (network) { + case CryptoCurrencyNetwork.main: + return NodeModel( + host: "electrum.bitcoinabc.org", + port: 50002, + name: DefaultNodes.defaultName, + id: DefaultNodes.buildId(Coin.eCash), + useSSL: true, + enabled: true, + coinName: Coin.eCash.name, + isFailover: true, + isDown: false, + ); + + default: + throw UnimplementedError(); + } + } } diff --git a/lib/wallets/crypto_currency/coins/epiccash.dart b/lib/wallets/crypto_currency/coins/epiccash.dart index 88dd391b6..0f4e77af2 100644 --- a/lib/wallets/crypto_currency/coins/epiccash.dart +++ b/lib/wallets/crypto_currency/coins/epiccash.dart @@ -1,4 +1,6 @@ import 'package:flutter_libepiccash/lib.dart' as epic; +import 'package:stackwallet/models/node_model.dart'; +import 'package:stackwallet/utilities/default_nodes.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; import 'package:stackwallet/wallets/crypto_currency/intermediate/bip39_currency.dart'; @@ -37,4 +39,26 @@ class Epiccash extends Bip39Currency { return epic.LibEpiccash.validateSendAddress(address: address); } + + @override + NodeModel get defaultNode { + switch (network) { + case CryptoCurrencyNetwork.main: + return NodeModel( + host: "https://wownero.stackwallet.com", + port: 34568, + name: DefaultNodes.defaultName, + id: DefaultNodes.buildId(Coin.wownero), + useSSL: true, + enabled: true, + coinName: Coin.wownero.name, + isFailover: true, + isDown: false, + trusted: true, + ); + + default: + throw UnimplementedError(); + } + } } diff --git a/lib/wallets/crypto_currency/coins/firo.dart b/lib/wallets/crypto_currency/coins/firo.dart index 09fe1ddda..bccdc950c 100644 --- a/lib/wallets/crypto_currency/coins/firo.dart +++ b/lib/wallets/crypto_currency/coins/firo.dart @@ -1,6 +1,8 @@ import 'package:coinlib_flutter/coinlib_flutter.dart' as coinlib; import 'package:stackwallet/models/isar/models/blockchain_data/address.dart'; +import 'package:stackwallet/models/node_model.dart'; import 'package:stackwallet/utilities/amount/amount.dart'; +import 'package:stackwallet/utilities/default_nodes.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/enums/derive_path_type_enum.dart'; import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; @@ -134,4 +136,51 @@ class Firo extends Bip39HDCurrency { } // TODO: implement validateAddress for spark addresses? } + + @override + NodeModel get defaultNode { + switch (network) { + case CryptoCurrencyNetwork.main: + return NodeModel( + host: "firo.stackwallet.com", + port: 50002, + name: DefaultNodes.defaultName, + id: DefaultNodes.buildId(Coin.firo), + useSSL: true, + enabled: true, + coinName: Coin.firo.name, + isFailover: true, + isDown: false, + ); + + case CryptoCurrencyNetwork.test: + // NodeModel( + // host: "firo-testnet.stackwallet.com", + // port: 50002, + // name: DefaultNodes.defaultName, + // id: _nodeId(Coin.firoTestNet), + // useSSL: true, + // enabled: true, + // coinName: Coin.firoTestNet.name, + // isFailover: true, + // isDown: false, + // ); + + // TODO revert to above eventually + return NodeModel( + host: "95.179.164.13", + port: 51002, + name: DefaultNodes.defaultName, + id: DefaultNodes.buildId(Coin.firoTestNet), + useSSL: true, + enabled: true, + coinName: Coin.firoTestNet.name, + isFailover: true, + isDown: false, + ); + + default: + throw UnimplementedError(); + } + } } diff --git a/lib/wallets/crypto_currency/coins/nano.dart b/lib/wallets/crypto_currency/coins/nano.dart index 448f17188..016a3b796 100644 --- a/lib/wallets/crypto_currency/coins/nano.dart +++ b/lib/wallets/crypto_currency/coins/nano.dart @@ -1,4 +1,6 @@ import 'package:nanodart/nanodart.dart'; +import 'package:stackwallet/models/node_model.dart'; +import 'package:stackwallet/utilities/default_nodes.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; import 'package:stackwallet/wallets/crypto_currency/intermediate/nano_currency.dart'; @@ -22,4 +24,25 @@ class Nano extends NanoCurrency { @override int get nanoAccountType => NanoAccountType.NANO; + + @override + NodeModel get defaultNode { + switch (network) { + case CryptoCurrencyNetwork.main: + return NodeModel( + host: "https://rainstorm.city/api", + port: 443, + name: DefaultNodes.defaultName, + id: DefaultNodes.buildId(Coin.nano), + useSSL: true, + enabled: true, + coinName: Coin.nano.name, + isFailover: true, + isDown: false, + ); + + default: + throw UnimplementedError(); + } + } } diff --git a/lib/wallets/crypto_currency/coins/wownero.dart b/lib/wallets/crypto_currency/coins/wownero.dart index 4eb76419b..e96660c00 100644 --- a/lib/wallets/crypto_currency/coins/wownero.dart +++ b/lib/wallets/crypto_currency/coins/wownero.dart @@ -1,8 +1,19 @@ import 'package:cw_wownero/api/wallet.dart' as wownero_wallet; +import 'package:stackwallet/models/node_model.dart'; +import 'package:stackwallet/utilities/default_nodes.dart'; +import 'package:stackwallet/utilities/enums/coin_enum.dart'; +import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; import 'package:stackwallet/wallets/crypto_currency/intermediate/cryptonote_currency.dart'; class Wownero extends CryptonoteCurrency { - Wownero(super.network); + Wownero(super.network) { + switch (network) { + case CryptoCurrencyNetwork.main: + coin = Coin.wownero; + default: + throw Exception("Unsupported network: $network"); + } + } @override int get minConfirms => 15; @@ -11,4 +22,26 @@ class Wownero extends CryptonoteCurrency { bool validateAddress(String address) { return wownero_wallet.validateAddress(address); } + + @override + NodeModel get defaultNode { + switch (network) { + case CryptoCurrencyNetwork.main: + return NodeModel( + host: "https://wownero.stackwallet.com", + port: 34568, + name: DefaultNodes.defaultName, + id: DefaultNodes.buildId(Coin.wownero), + useSSL: true, + enabled: true, + coinName: Coin.wownero.name, + isFailover: true, + isDown: false, + trusted: true, + ); + + default: + throw UnimplementedError(); + } + } } diff --git a/lib/wallets/crypto_currency/crypto_currency.dart b/lib/wallets/crypto_currency/crypto_currency.dart index 5e43ee51d..088e83317 100644 --- a/lib/wallets/crypto_currency/crypto_currency.dart +++ b/lib/wallets/crypto_currency/crypto_currency.dart @@ -1,3 +1,4 @@ +import 'package:stackwallet/models/node_model.dart'; import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; @@ -29,4 +30,6 @@ abstract class CryptoCurrency { String get genesisHash; bool validateAddress(String address); + + NodeModel get defaultNode; }