WIP: Add bitcoincash

This commit is contained in:
Likho 2022-09-06 16:17:45 +02:00
parent 8ce09d7f47
commit d5b82f26f7
10 changed files with 3077 additions and 0 deletions

View file

@ -115,6 +115,7 @@ class _AddEditNodeViewState extends ConsumerState<AddEditNodeView> {
case Coin.bitcoin:
case Coin.dogecoin:
case Coin.firo:
case Coin.bitcoincash:
case Coin.bitcoinTestNet:
case Coin.firoTestNet:
case Coin.dogecoinTestNet:
@ -527,6 +528,7 @@ class _NodeFormState extends ConsumerState<NodeForm> {
case Coin.bitcoin:
case Coin.dogecoin:
case Coin.firo:
case Coin.bitcoincash:
case Coin.bitcoinTestNet:
case Coin.firoTestNet:
case Coin.dogecoinTestNet:

File diff suppressed because it is too large Load diff

View file

@ -8,6 +8,7 @@ import 'package:stackwallet/services/coins/dogecoin/dogecoin_wallet.dart';
import 'package:stackwallet/services/coins/epiccash/epiccash_wallet.dart';
import 'package:stackwallet/services/coins/firo/firo_wallet.dart';
import 'package:stackwallet/services/coins/monero/monero_wallet.dart';
import 'package:stackwallet/services/coins/bitcoincash/bitcoincash_wallet.dart';
import 'package:stackwallet/services/transaction_notification_tracker.dart';
import 'package:stackwallet/utilities/enums/coin_enum.dart';
import 'package:stackwallet/utilities/prefs.dart';
@ -132,6 +133,16 @@ abstract class CoinServiceAPI {
cachedClient: cachedClient,
tracker: tracker,
);
case Coin.bitcoincash:
return BitcoinCashWallet(
walletId: walletId,
walletName: walletName,
coin: coin,
client: client,
cachedClient: cachedClient,
tracker: tracker,
);
}
}

View file

@ -5,6 +5,7 @@ import 'package:crypto/crypto.dart';
import 'package:flutter_libepiccash/epic_cash.dart';
import 'package:stackwallet/services/coins/dogecoin/dogecoin_wallet.dart';
import 'package:stackwallet/services/coins/firo/firo_wallet.dart';
import 'package:stackwallet/services/coins/bitcoincash/bitcoincash_wallet.dart';
import 'package:stackwallet/utilities/enums/coin_enum.dart';
import 'package:stackwallet/utilities/logger.dart';
@ -49,6 +50,8 @@ class AddressUtils {
case Coin.monero:
return RegExp("[a-zA-Z0-9]{95}").hasMatch(address) ||
RegExp("[a-zA-Z0-9]{106}").hasMatch(address);
case Coin.bitcoincash:
return Address.validateAddress(address, bitcoincash);
case Coin.bitcoinTestNet:
return Address.validateAddress(address, testnet);
case Coin.firoTestNet:

View file

@ -110,6 +110,7 @@ class _SVG {
String get bitcoinTestnet => "assets/svg/coin_icons/Bitcoin.svg";
String get firoTestnet => "assets/svg/coin_icons/Firo.svg";
String get dogecoinTestnet => "assets/svg/coin_icons/Dogecoin.svg";
String get bitcoincash => "assets/svg/coin_icons/Bitcoin.svg";
String iconFor({required Coin coin}) {
switch (coin) {
@ -123,6 +124,8 @@ class _SVG {
return firo;
case Coin.monero:
return monero;
case Coin.bitcoincash:
return bitcoincash;
case Coin.bitcoinTestNet:
return bitcoinTestnet;
case Coin.firoTestNet:
@ -144,6 +147,7 @@ class _PNG {
String get dogecoin => "assets/images/doge.png";
String get bitcoin => "assets/images/bitcoin.png";
String get epicCash => "assets/images/epic-cash.png";
String get bitcoincash => "assets/images/bitcoin.png";
String imageFor({required Coin coin}) {
switch (coin) {
@ -156,6 +160,8 @@ class _PNG {
case Coin.epicCash:
return epicCash;
case Coin.firo:
case Coin.bitcoincash:
return bitcoincash;
case Coin.firoTestNet:
return firo;
case Coin.monero:

View file

@ -22,5 +22,7 @@ Uri getBlockExplorerTransactionUrlFor({
return Uri.parse("https://explorer.firo.org/tx/$txid");
case Coin.firoTestNet:
return Uri.parse("https://testexplorer.firo.org/tx/$txid");
case Coin.bitcoincash:
return Uri.parse("https://www.blockchain.com/bch/tx/$txid");
}
}

View file

@ -10,6 +10,7 @@ class _CoinThemeColor {
Color get dogecoin => const Color(0xFFFFE079);
Color get epicCash => const Color(0xFFC1C1FF);
Color get monero => const Color(0xFFB1C5FF);
Color get bitcoincash => const Color(0xFFFCC17B);
Color forCoin(Coin coin) {
switch (coin) {
@ -26,6 +27,8 @@ class _CoinThemeColor {
return firo;
case Coin.monero:
return monero;
case Coin.bitcoincash:
return bitcoincash;
}
}
}

View file

@ -45,6 +45,7 @@ abstract class Constants {
case Coin.dogecoinTestNet:
case Coin.firoTestNet:
case Coin.epicCash:
case Coin.bitcoincash:
values.addAll([24, 21, 18, 15, 12]);
break;
@ -75,6 +76,8 @@ abstract class Constants {
case Coin.monero:
return 120;
case Coin.bitcoincash:
return 600;
}
}

View file

@ -13,6 +13,7 @@ abstract class DefaultNodes {
firo,
monero,
epicCash,
bitcoincash,
bitcoinTestnet,
dogecoinTestnet,
firoTestnet,
@ -80,6 +81,18 @@ abstract class DefaultNodes {
isDown: false,
);
static NodeModel get bitcoincash => NodeModel(
host: "https://electrum1.cipig.net:20055",
port: 20055,
name: defaultName,
id: _nodeId(Coin.bitcoincash),
useSSL: true,
enabled: true,
coinName: Coin.bitcoincash.name,
isFailover: true,
isDown: false,
);
static NodeModel get bitcoinTestnet => NodeModel(
host: "electrumx-testnet.cypherstack.com",
port: 51002,
@ -133,6 +146,9 @@ abstract class DefaultNodes {
case Coin.monero:
return monero;
case Coin.bitcoincash:
return bitcoincash;
case Coin.bitcoinTestNet:
return bitcoinTestnet;

View file

@ -5,6 +5,8 @@ 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;
import 'package:stackwallet/services/coins/bitcoincash/bitcoincash_wallet.dart'
as bch;
enum Coin {
bitcoin,
@ -12,6 +14,7 @@ enum Coin {
epicCash,
firo,
monero,
bitcoincash,
///
///
@ -38,6 +41,8 @@ extension CoinExt on Coin {
return "Firo";
case Coin.monero:
return "Monero";
case Coin.bitcoincash:
return "Bitcoincash";
case Coin.bitcoinTestNet:
return "tBitcoin";
case Coin.firoTestNet:
@ -59,6 +64,8 @@ extension CoinExt on Coin {
return "FIRO";
case Coin.monero:
return "XMR";
case Coin.bitcoincash:
return "BCH";
case Coin.bitcoinTestNet:
return "tBTC";
case Coin.firoTestNet:
@ -81,6 +88,8 @@ extension CoinExt on Coin {
return "firo";
case Coin.monero:
return "monero";
case Coin.bitcoincash:
return "bitcoincash";
case Coin.bitcoinTestNet:
return "bitcoin";
case Coin.firoTestNet:
@ -95,6 +104,7 @@ extension CoinExt on Coin {
case Coin.bitcoin:
case Coin.dogecoin:
case Coin.firo:
case Coin.bitcoincash:
case Coin.bitcoinTestNet:
case Coin.firoTestNet:
case Coin.dogecoinTestNet:
@ -125,6 +135,9 @@ extension CoinExt on Coin {
case Coin.monero:
return xmr.MINIMUM_CONFIRMATIONS;
case Coin.bitcoincash:
return bch.MINIMUM_CONFIRMATIONS;
}
}
}
@ -146,6 +159,9 @@ Coin coinFromPrettyName(String name) {
case "Monero":
case "monero":
return Coin.monero;
case "Bitcoincash":
case "bitcoincash":
return Coin.bitcoincash;
case "Bitcoin Testnet":
case "tBitcoin":
case "bitcoinTestNet":
@ -176,6 +192,8 @@ Coin coinFromTickerCaseInsensitive(String ticker) {
return Coin.firo;
case "xmr":
return Coin.monero;
case "bch":
return Coin.bitcoincash;
case "tbtc":
return Coin.bitcoinTestNet;
case "tfiro":