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;
|
2022-12-13 17:39:19 +00:00
|
|
|
import 'package:stackwallet/services/coins/ethereum/ethereum_wallet.dart'
|
|
|
|
as eth;
|
2022-08-26 08:11:35 +00:00
|
|
|
import 'package:stackwallet/services/coins/firo/firo_wallet.dart' as firo;
|
2022-10-29 15:14:59 +00:00
|
|
|
import 'package:stackwallet/services/coins/litecoin/litecoin_wallet.dart'
|
|
|
|
as ltc;
|
2022-08-26 08:11:35 +00:00
|
|
|
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-11-22 21:37:47 +00:00
|
|
|
import 'package:stackwallet/utilities/util.dart';
|
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,
|
2022-12-13 17:39:19 +00:00
|
|
|
ethereum,
|
2022-08-26 08:11:35 +00:00
|
|
|
firo,
|
2022-10-29 15:14:59 +00:00
|
|
|
litecoin,
|
2022-08-26 08:11:35 +00:00
|
|
|
monero,
|
2022-09-23 21:02:53 +00:00
|
|
|
namecoin,
|
2022-10-29 15:14:59 +00:00
|
|
|
wownero,
|
2022-08-26 08:11:35 +00:00
|
|
|
|
|
|
|
///
|
2022-10-28 18:03:52 +00:00
|
|
|
|
2022-08-26 08:11:35 +00:00
|
|
|
///
|
|
|
|
///
|
|
|
|
|
|
|
|
bitcoinTestNet,
|
2022-10-28 18:03:52 +00:00
|
|
|
litecoinTestNet,
|
2022-09-26 20:32:53 +00:00
|
|
|
bitcoincashTestnet,
|
2022-08-26 08:11:35 +00:00
|
|
|
dogecoinTestNet,
|
|
|
|
firoTestNet,
|
|
|
|
}
|
|
|
|
|
2022-11-22 21:37:47 +00:00
|
|
|
final int kTestNetCoinCount = Util.isDesktop ? 5 : 4;
|
2022-08-26 08:11:35 +00:00
|
|
|
|
|
|
|
extension CoinExt on Coin {
|
|
|
|
String get prettyName {
|
|
|
|
switch (this) {
|
|
|
|
case Coin.bitcoin:
|
|
|
|
return "Bitcoin";
|
2022-10-28 18:03:52 +00:00
|
|
|
case Coin.litecoin:
|
|
|
|
return "Litecoin";
|
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";
|
2022-12-13 17:39:19 +00:00
|
|
|
case Coin.ethereum:
|
|
|
|
return "Ethereum";
|
2022-08-26 08:11:35 +00:00
|
|
|
case Coin.firo:
|
|
|
|
return "Firo";
|
|
|
|
case Coin.monero:
|
|
|
|
return "Monero";
|
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-10-28 18:03:52 +00:00
|
|
|
case Coin.litecoinTestNet:
|
|
|
|
return "tLitecoin";
|
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-10-28 18:03:52 +00:00
|
|
|
case Coin.litecoin:
|
|
|
|
return "LTC";
|
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";
|
2022-12-13 17:39:19 +00:00
|
|
|
case Coin.ethereum:
|
|
|
|
return "ETH";
|
2022-08-26 08:11:35 +00:00
|
|
|
case Coin.firo:
|
|
|
|
return "FIRO";
|
|
|
|
case Coin.monero:
|
|
|
|
return "XMR";
|
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-10-28 18:03:52 +00:00
|
|
|
case Coin.litecoinTestNet:
|
|
|
|
return "tLTC";
|
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-10-28 18:03:52 +00:00
|
|
|
case Coin.litecoin:
|
|
|
|
return "litecoin";
|
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";
|
2022-12-13 17:39:19 +00:00
|
|
|
case Coin.ethereum:
|
|
|
|
return "ethereum";
|
2022-08-26 08:11:35 +00:00
|
|
|
case Coin.firo:
|
|
|
|
return "firo";
|
|
|
|
case Coin.monero:
|
|
|
|
return "monero";
|
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-10-28 18:03:52 +00:00
|
|
|
case Coin.litecoinTestNet:
|
|
|
|
return "litecoin";
|
2022-09-26 20:32:53 +00:00
|
|
|
case Coin.bitcoincashTestnet:
|
2022-11-10 15:54:58 +00:00
|
|
|
return "bchtest";
|
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-10-28 18:03:52 +00:00
|
|
|
case Coin.litecoin:
|
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-08-26 08:11:35 +00:00
|
|
|
case Coin.bitcoinTestNet:
|
2022-10-28 18:03:52 +00:00
|
|
|
case Coin.litecoinTestNet:
|
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:
|
2022-12-13 17:39:19 +00:00
|
|
|
case Coin.ethereum:
|
2022-08-26 08:11:35 +00:00
|
|
|
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-10-28 18:03:52 +00:00
|
|
|
case Coin.litecoin:
|
|
|
|
case Coin.litecoinTestNet:
|
|
|
|
return ltc.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;
|
|
|
|
|
2022-12-13 17:39:19 +00:00
|
|
|
case Coin.ethereum:
|
|
|
|
return eth.MINIMUM_CONFIRMATIONS;
|
|
|
|
|
2022-08-26 08:11:35 +00:00
|
|
|
case Coin.monero:
|
|
|
|
return xmr.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-10-28 18:03:52 +00:00
|
|
|
case "Litecoin":
|
|
|
|
case "litecoin":
|
|
|
|
return Coin.litecoin;
|
|
|
|
|
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-12-13 17:39:19 +00:00
|
|
|
case "Ethereum":
|
|
|
|
case "ethereum":
|
|
|
|
return Coin.ethereum;
|
|
|
|
|
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-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-10-28 18:03:52 +00:00
|
|
|
case "Litecoin Testnet":
|
|
|
|
case "tlitecoin":
|
|
|
|
case "litecoinTestNet":
|
|
|
|
case "tLitecoin":
|
|
|
|
return Coin.litecoinTestNet;
|
|
|
|
|
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(
|
2022-10-29 15:14:59 +00:00
|
|
|
name,
|
|
|
|
"name",
|
|
|
|
"No Coin enum value with that prettyName",
|
|
|
|
);
|
2022-08-26 08:11:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Coin coinFromTickerCaseInsensitive(String ticker) {
|
|
|
|
switch (ticker.toLowerCase()) {
|
|
|
|
case "btc":
|
|
|
|
return Coin.bitcoin;
|
2022-10-28 18:03:52 +00:00
|
|
|
case "ltc":
|
|
|
|
return Coin.litecoin;
|
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;
|
2022-12-13 17:39:19 +00:00
|
|
|
case "eth":
|
|
|
|
return Coin.ethereum;
|
2022-08-26 08:11:35 +00:00
|
|
|
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-29 15:14:59 +00:00
|
|
|
case "tltc":
|
|
|
|
return Coin.litecoinTestNet;
|
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");
|
|
|
|
}
|
|
|
|
}
|