2022-08-26 08:11:35 +00:00
|
|
|
import 'package:stackwallet/services/coins/bitcoin/bitcoin_wallet.dart' as btc;
|
2022-09-26 20:32:53 +00:00
|
|
|
import 'package:stackwallet/services/coins/bitcoincash/bitcoincash_wallet.dart'
|
|
|
|
as bch;
|
2022-08-26 08:11:35 +00:00
|
|
|
import 'package:stackwallet/services/coins/dogecoin/dogecoin_wallet.dart'
|
|
|
|
as doge;
|
|
|
|
import 'package:stackwallet/services/coins/epiccash/epiccash_wallet.dart'
|
|
|
|
as epic;
|
|
|
|
import 'package:stackwallet/services/coins/firo/firo_wallet.dart' as firo;
|
|
|
|
import 'package:stackwallet/services/coins/monero/monero_wallet.dart' as xmr;
|
2022-09-23 21:02:53 +00:00
|
|
|
import 'package:stackwallet/services/coins/namecoin/namecoin_wallet.dart'
|
|
|
|
as nmc;
|
2022-09-27 16:27:51 +00:00
|
|
|
import 'package:stackwallet/services/coins/wownero/wownero_wallet.dart' as wow;
|
2022-10-25 15:06:37 +00:00
|
|
|
import 'package:stackwallet/services/coins/particl/particl_wallet.dart'
|
|
|
|
as particl;
|
2022-08-26 08:11:35 +00:00
|
|
|
|
|
|
|
enum Coin {
|
|
|
|
bitcoin,
|
2022-09-26 20:32:53 +00:00
|
|
|
bitcoincash,
|
2022-08-26 08:11:35 +00:00
|
|
|
dogecoin,
|
|
|
|
epicCash,
|
|
|
|
firo,
|
|
|
|
monero,
|
2022-10-25 15:06:37 +00:00
|
|
|
particl,
|
2022-09-27 08:09:31 +00:00
|
|
|
wownero,
|
2022-09-23 21:02:53 +00:00
|
|
|
namecoin,
|
2022-08-26 08:11:35 +00:00
|
|
|
|
|
|
|
///
|
|
|
|
///
|
|
|
|
///
|
|
|
|
|
|
|
|
bitcoinTestNet,
|
2022-09-26 20:32:53 +00:00
|
|
|
bitcoincashTestnet,
|
2022-08-26 08:11:35 +00:00
|
|
|
dogecoinTestNet,
|
|
|
|
firoTestNet,
|
|
|
|
}
|
|
|
|
|
2022-08-29 13:50:02 +00:00
|
|
|
// remove firotestnet for now
|
2022-09-26 20:44:07 +00:00
|
|
|
const int kTestNetCoinCount = 3;
|
2022-08-26 08:11:35 +00:00
|
|
|
|
|
|
|
extension CoinExt on Coin {
|
|
|
|
String get prettyName {
|
|
|
|
switch (this) {
|
|
|
|
case Coin.bitcoin:
|
|
|
|
return "Bitcoin";
|
2022-09-26 20:32:53 +00:00
|
|
|
case Coin.bitcoincash:
|
|
|
|
return "Bitcoin Cash";
|
2022-08-26 08:11:35 +00:00
|
|
|
case Coin.dogecoin:
|
|
|
|
return "Dogecoin";
|
|
|
|
case Coin.epicCash:
|
|
|
|
return "Epic Cash";
|
|
|
|
case Coin.firo:
|
|
|
|
return "Firo";
|
|
|
|
case Coin.monero:
|
|
|
|
return "Monero";
|
2022-10-25 15:06:37 +00:00
|
|
|
case Coin.particl:
|
|
|
|
return "Particl";
|
2022-09-27 08:09:31 +00:00
|
|
|
case Coin.wownero:
|
|
|
|
return "Wownero";
|
2022-09-23 21:02:53 +00:00
|
|
|
case Coin.namecoin:
|
|
|
|
return "Namecoin";
|
2022-08-26 08:11:35 +00:00
|
|
|
case Coin.bitcoinTestNet:
|
|
|
|
return "tBitcoin";
|
2022-09-26 20:32:53 +00:00
|
|
|
case Coin.bitcoincashTestnet:
|
|
|
|
return "tBitcoin Cash";
|
2022-08-26 08:11:35 +00:00
|
|
|
case Coin.firoTestNet:
|
|
|
|
return "tFiro";
|
|
|
|
case Coin.dogecoinTestNet:
|
|
|
|
return "tDogecoin";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
String get ticker {
|
|
|
|
switch (this) {
|
|
|
|
case Coin.bitcoin:
|
|
|
|
return "BTC";
|
2022-09-26 20:32:53 +00:00
|
|
|
case Coin.bitcoincash:
|
|
|
|
return "BCH";
|
2022-08-26 08:11:35 +00:00
|
|
|
case Coin.dogecoin:
|
|
|
|
return "DOGE";
|
|
|
|
case Coin.epicCash:
|
|
|
|
return "EPIC";
|
|
|
|
case Coin.firo:
|
|
|
|
return "FIRO";
|
|
|
|
case Coin.monero:
|
|
|
|
return "XMR";
|
2022-10-25 15:06:37 +00:00
|
|
|
case Coin.particl:
|
|
|
|
return "PART";
|
2022-09-27 08:09:31 +00:00
|
|
|
case Coin.wownero:
|
|
|
|
return "WOW";
|
2022-09-23 21:02:53 +00:00
|
|
|
case Coin.namecoin:
|
|
|
|
return "NMC";
|
2022-08-26 08:11:35 +00:00
|
|
|
case Coin.bitcoinTestNet:
|
|
|
|
return "tBTC";
|
2022-09-26 20:32:53 +00:00
|
|
|
case Coin.bitcoincashTestnet:
|
|
|
|
return "tBCH";
|
2022-08-26 08:11:35 +00:00
|
|
|
case Coin.firoTestNet:
|
|
|
|
return "tFIRO";
|
|
|
|
case Coin.dogecoinTestNet:
|
|
|
|
return "tDOGE";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
String get uriScheme {
|
|
|
|
switch (this) {
|
|
|
|
case Coin.bitcoin:
|
|
|
|
return "bitcoin";
|
2022-09-26 20:32:53 +00:00
|
|
|
case Coin.bitcoincash:
|
|
|
|
return "bitcoincash";
|
2022-08-26 08:11:35 +00:00
|
|
|
case Coin.dogecoin:
|
|
|
|
return "dogecoin";
|
|
|
|
case Coin.epicCash:
|
|
|
|
// TODO: is this actually the right one?
|
|
|
|
return "epic";
|
|
|
|
case Coin.firo:
|
|
|
|
return "firo";
|
|
|
|
case Coin.monero:
|
|
|
|
return "monero";
|
2022-10-25 15:06:37 +00:00
|
|
|
case Coin.particl:
|
|
|
|
return "particl";
|
2022-09-27 08:09:31 +00:00
|
|
|
case Coin.wownero:
|
|
|
|
return "wownero";
|
2022-09-23 21:02:53 +00:00
|
|
|
case Coin.namecoin:
|
|
|
|
return "namecoin";
|
2022-08-26 08:11:35 +00:00
|
|
|
case Coin.bitcoinTestNet:
|
|
|
|
return "bitcoin";
|
2022-09-26 20:32:53 +00:00
|
|
|
case Coin.bitcoincashTestnet:
|
|
|
|
return "bitcoincash";
|
2022-08-26 08:11:35 +00:00
|
|
|
case Coin.firoTestNet:
|
|
|
|
return "firo";
|
|
|
|
case Coin.dogecoinTestNet:
|
|
|
|
return "dogecoin";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool get isElectrumXCoin {
|
|
|
|
switch (this) {
|
|
|
|
case Coin.bitcoin:
|
2022-09-26 20:32:53 +00:00
|
|
|
case Coin.bitcoincash:
|
2022-08-26 08:11:35 +00:00
|
|
|
case Coin.dogecoin:
|
|
|
|
case Coin.firo:
|
2022-09-23 21:02:53 +00:00
|
|
|
case Coin.namecoin:
|
2022-10-25 15:06:37 +00:00
|
|
|
case Coin.particl:
|
2022-08-26 08:11:35 +00:00
|
|
|
case Coin.bitcoinTestNet:
|
2022-09-26 20:32:53 +00:00
|
|
|
case Coin.bitcoincashTestnet:
|
2022-08-26 08:11:35 +00:00
|
|
|
case Coin.firoTestNet:
|
|
|
|
case Coin.dogecoinTestNet:
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case Coin.epicCash:
|
|
|
|
case Coin.monero:
|
2022-09-27 08:09:31 +00:00
|
|
|
case Coin.wownero:
|
2022-08-26 08:11:35 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int get requiredConfirmations {
|
|
|
|
switch (this) {
|
|
|
|
case Coin.bitcoin:
|
|
|
|
case Coin.bitcoinTestNet:
|
|
|
|
return btc.MINIMUM_CONFIRMATIONS;
|
|
|
|
|
2022-09-26 20:32:53 +00:00
|
|
|
case Coin.bitcoincash:
|
|
|
|
case Coin.bitcoincashTestnet:
|
|
|
|
return bch.MINIMUM_CONFIRMATIONS;
|
2022-09-09 10:59:40 +00:00
|
|
|
|
2022-08-26 08:11:35 +00:00
|
|
|
case Coin.firo:
|
|
|
|
case Coin.firoTestNet:
|
|
|
|
return firo.MINIMUM_CONFIRMATIONS;
|
|
|
|
|
|
|
|
case Coin.dogecoin:
|
|
|
|
case Coin.dogecoinTestNet:
|
|
|
|
return doge.MINIMUM_CONFIRMATIONS;
|
|
|
|
|
|
|
|
case Coin.epicCash:
|
|
|
|
return epic.MINIMUM_CONFIRMATIONS;
|
|
|
|
|
|
|
|
case Coin.monero:
|
|
|
|
return xmr.MINIMUM_CONFIRMATIONS;
|
2022-09-27 08:09:31 +00:00
|
|
|
|
2022-10-25 15:06:37 +00:00
|
|
|
case Coin.particl:
|
|
|
|
return particl.MINIMUM_CONFIRMATIONS;
|
|
|
|
|
2022-09-27 08:09:31 +00:00
|
|
|
case Coin.wownero:
|
|
|
|
return wow.MINIMUM_CONFIRMATIONS;
|
2022-09-27 08:16:20 +00:00
|
|
|
|
2022-09-23 21:02:53 +00:00
|
|
|
case Coin.namecoin:
|
|
|
|
return nmc.MINIMUM_CONFIRMATIONS;
|
2022-08-26 08:11:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Coin coinFromPrettyName(String name) {
|
|
|
|
switch (name) {
|
|
|
|
case "Bitcoin":
|
|
|
|
case "bitcoin":
|
|
|
|
return Coin.bitcoin;
|
2022-10-20 17:01:25 +00:00
|
|
|
|
2022-09-26 20:32:53 +00:00
|
|
|
case "Bitcoincash":
|
|
|
|
case "bitcoincash":
|
|
|
|
case "Bitcoin Cash":
|
|
|
|
return Coin.bitcoincash;
|
2022-10-20 17:01:25 +00:00
|
|
|
|
2022-08-26 08:11:35 +00:00
|
|
|
case "Dogecoin":
|
|
|
|
case "dogecoin":
|
|
|
|
return Coin.dogecoin;
|
2022-10-20 17:01:25 +00:00
|
|
|
|
2022-08-26 08:11:35 +00:00
|
|
|
case "Epic Cash":
|
|
|
|
case "epicCash":
|
|
|
|
return Coin.epicCash;
|
2022-10-20 17:01:25 +00:00
|
|
|
|
2022-08-26 08:11:35 +00:00
|
|
|
case "Firo":
|
|
|
|
case "firo":
|
|
|
|
return Coin.firo;
|
2022-10-20 17:01:25 +00:00
|
|
|
|
2022-08-26 08:11:35 +00:00
|
|
|
case "Monero":
|
|
|
|
case "monero":
|
|
|
|
return Coin.monero;
|
2022-10-20 17:01:25 +00:00
|
|
|
|
2022-10-25 15:06:37 +00:00
|
|
|
case "Particl":
|
|
|
|
case "particl":
|
|
|
|
return Coin.particl;
|
|
|
|
|
2022-09-23 21:02:53 +00:00
|
|
|
case "Namecoin":
|
|
|
|
case "namecoin":
|
|
|
|
return Coin.namecoin;
|
2022-10-20 17:01:25 +00:00
|
|
|
|
2022-08-26 08:11:35 +00:00
|
|
|
case "Bitcoin Testnet":
|
|
|
|
case "tBitcoin":
|
|
|
|
case "bitcoinTestNet":
|
|
|
|
return Coin.bitcoinTestNet;
|
2022-09-16 11:13:30 +00:00
|
|
|
|
2022-09-26 20:32:53 +00:00
|
|
|
case "Bitcoincash Testnet":
|
|
|
|
case "tBitcoin Cash":
|
|
|
|
case "Bitcoin Cash Testnet":
|
2022-10-20 17:01:25 +00:00
|
|
|
case "bitcoincashTestnet":
|
2022-09-26 20:32:53 +00:00
|
|
|
return Coin.bitcoincashTestnet;
|
2022-10-20 17:01:25 +00:00
|
|
|
|
2022-08-26 08:11:35 +00:00
|
|
|
case "Firo Testnet":
|
|
|
|
case "tFiro":
|
|
|
|
case "firoTestNet":
|
|
|
|
return Coin.firoTestNet;
|
2022-10-20 17:01:25 +00:00
|
|
|
|
2022-08-26 08:11:35 +00:00
|
|
|
case "Dogecoin Testnet":
|
|
|
|
case "tDogecoin":
|
|
|
|
case "dogecoinTestNet":
|
|
|
|
return Coin.dogecoinTestNet;
|
2022-10-20 17:01:25 +00:00
|
|
|
|
2022-09-27 16:27:51 +00:00
|
|
|
case "Wownero":
|
|
|
|
case "tWownero":
|
|
|
|
case "wownero":
|
|
|
|
return Coin.wownero;
|
2022-10-20 17:01:25 +00:00
|
|
|
|
2022-08-26 08:11:35 +00:00
|
|
|
default:
|
|
|
|
throw ArgumentError.value(
|
|
|
|
name, "name", "No Coin enum value with that prettyName");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Coin coinFromTickerCaseInsensitive(String ticker) {
|
|
|
|
switch (ticker.toLowerCase()) {
|
|
|
|
case "btc":
|
|
|
|
return Coin.bitcoin;
|
2022-09-26 20:32:53 +00:00
|
|
|
case "bch":
|
|
|
|
return Coin.bitcoincash;
|
2022-08-26 08:11:35 +00:00
|
|
|
case "doge":
|
|
|
|
return Coin.dogecoin;
|
|
|
|
case "epic":
|
|
|
|
return Coin.epicCash;
|
|
|
|
case "firo":
|
|
|
|
return Coin.firo;
|
|
|
|
case "xmr":
|
|
|
|
return Coin.monero;
|
2022-09-23 21:02:53 +00:00
|
|
|
case "nmc":
|
|
|
|
return Coin.namecoin;
|
2022-10-25 15:06:37 +00:00
|
|
|
case "part":
|
|
|
|
return Coin.particl;
|
2022-08-26 08:11:35 +00:00
|
|
|
case "tbtc":
|
|
|
|
return Coin.bitcoinTestNet;
|
2022-09-26 20:32:53 +00:00
|
|
|
case "tbch":
|
|
|
|
return Coin.bitcoincashTestnet;
|
2022-08-26 08:11:35 +00:00
|
|
|
case "tfiro":
|
|
|
|
return Coin.firoTestNet;
|
|
|
|
case "tdoge":
|
|
|
|
return Coin.dogecoinTestNet;
|
2022-09-27 16:27:51 +00:00
|
|
|
case "wow":
|
|
|
|
return Coin.wownero;
|
2022-08-26 08:11:35 +00:00
|
|
|
default:
|
|
|
|
throw ArgumentError.value(
|
|
|
|
ticker, "name", "No Coin enum value with that ticker");
|
|
|
|
}
|
|
|
|
}
|