btc testnet4

This commit is contained in:
julian 2024-06-19 09:15:49 -06:00
parent b7b28115b2
commit 1495eaa6d2
24 changed files with 115 additions and 66 deletions

View file

@ -63,7 +63,7 @@ class _AddWalletViewState extends ConsumerState<AddWalletView> {
String _searchTerm = ""; String _searchTerm = "";
final _coinsTestnet = [ final _coinsTestnet = [
...AppConfig.coins.where((e) => e.network == CryptoCurrencyNetwork.test), ...AppConfig.coins.where((e) => e.network.isTestNet),
]; ];
final _coins = [ final _coins = [
...AppConfig.coins.where((e) => e.network == CryptoCurrencyNetwork.main), ...AppConfig.coins.where((e) => e.network == CryptoCurrencyNetwork.main),

View file

@ -11,11 +11,10 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_svg/svg.dart'; import 'package:flutter_svg/svg.dart';
import '../../app_config.dart'; import '../../app_config.dart';
import '../../models/isar/models/blockchain_data/address.dart'; import '../../models/isar/models/blockchain_data/address.dart';
import '../../models/isar/models/contact_entry.dart'; import '../../models/isar/models/contact_entry.dart';
import 'subviews/add_address_book_entry_view.dart';
import 'subviews/address_book_filter_view.dart';
import '../../providers/db/main_db_provider.dart'; import '../../providers/db/main_db_provider.dart';
import '../../providers/global/address_book_service_provider.dart'; import '../../providers/global/address_book_service_provider.dart';
import '../../providers/providers.dart'; import '../../providers/providers.dart';
@ -35,6 +34,8 @@ import '../../widgets/icon_widgets/x_icon.dart';
import '../../widgets/rounded_white_container.dart'; import '../../widgets/rounded_white_container.dart';
import '../../widgets/stack_text_field.dart'; import '../../widgets/stack_text_field.dart';
import '../../widgets/textfield_icon_button.dart'; import '../../widgets/textfield_icon_button.dart';
import 'subviews/add_address_book_entry_view.dart';
import 'subviews/address_book_filter_view.dart';
class AddressBookView extends ConsumerStatefulWidget { class AddressBookView extends ConsumerStatefulWidget {
const AddressBookView({ const AddressBookView({
@ -67,7 +68,7 @@ class _AddressBookViewState extends ConsumerState<AddressBookView> {
if (widget.coin == null) { if (widget.coin == null) {
final coins = [...AppConfig.coins]; final coins = [...AppConfig.coins];
coins.removeWhere( coins.removeWhere(
(e) => e is Firo && e.network == CryptoCurrencyNetwork.test, (e) => e is Firo && e.network.isTestNet,
); );
final bool showTestNet = final bool showTestNet =

View file

@ -43,7 +43,7 @@ class _AddressBookFilterViewState extends ConsumerState<AddressBookFilterView> {
void initState() { void initState() {
final coins = [...AppConfig.coins]; final coins = [...AppConfig.coins];
coins.removeWhere( coins.removeWhere(
(e) => e is Firo && e.network == CryptoCurrencyNetwork.test, (e) => e is Firo && e.network.isTestNet,
); );
final showTestNet = ref.read(prefsChangeNotifierProvider).showTestNetCoins; final showTestNet = ref.read(prefsChangeNotifierProvider).showTestNetCoins;

View file

@ -13,8 +13,9 @@ import 'dart:io';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_svg/svg.dart'; import 'package:flutter_svg/svg.dart';
import '../../../providers/global/prefs_provider.dart';
import '../../../app_config.dart'; import '../../../app_config.dart';
import '../../../providers/global/prefs_provider.dart';
import '../../../themes/coin_image_provider.dart'; import '../../../themes/coin_image_provider.dart';
import '../../../themes/stack_colors.dart'; import '../../../themes/stack_colors.dart';
import '../../../utilities/constants.dart'; import '../../../utilities/constants.dart';
@ -29,7 +30,7 @@ class CoinSelectSheet extends StatelessWidget {
final maxHeight = MediaQuery.of(context).size.height * 0.60; final maxHeight = MediaQuery.of(context).size.height * 0.60;
final coins_ = [...AppConfig.coins]; final coins_ = [...AppConfig.coins];
coins_.removeWhere( coins_.removeWhere(
(e) => e is Firo && e.network == CryptoCurrencyNetwork.test, (e) => e is Firo && e.network.isTestNet,
); );
return Container( return Container(
decoration: BoxDecoration( decoration: BoxDecoration(

View file

@ -15,11 +15,11 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_svg/svg.dart'; import 'package:flutter_svg/svg.dart';
import 'coin_select_sheet.dart';
import '../../../app_config.dart';
import '../../../providers/providers.dart'; import '../../../providers/providers.dart';
// import 'package:stackwallet/providers/global/should_show_lockscreen_on_resume_state_provider.dart'; // import 'package:stackwallet/providers/global/should_show_lockscreen_on_resume_state_provider.dart';
import '../../../providers/ui/address_book_providers/address_entry_data_provider.dart'; import '../../../providers/ui/address_book_providers/address_entry_data_provider.dart';
import '../../../app_config.dart';
import '../../../themes/coin_icon_provider.dart'; import '../../../themes/coin_icon_provider.dart';
import '../../../themes/stack_colors.dart'; import '../../../themes/stack_colors.dart';
import '../../../utilities/address_utils.dart'; import '../../../utilities/address_utils.dart';
@ -36,6 +36,7 @@ import '../../../widgets/icon_widgets/qrcode_icon.dart';
import '../../../widgets/icon_widgets/x_icon.dart'; import '../../../widgets/icon_widgets/x_icon.dart';
import '../../../widgets/stack_text_field.dart'; import '../../../widgets/stack_text_field.dart';
import '../../../widgets/textfield_icon_button.dart'; import '../../../widgets/textfield_icon_button.dart';
import 'coin_select_sheet.dart';
class NewContactAddressEntryForm extends ConsumerStatefulWidget { class NewContactAddressEntryForm extends ConsumerStatefulWidget {
const NewContactAddressEntryForm({ const NewContactAddressEntryForm({
@ -92,7 +93,7 @@ class _NewContactAddressEntryFormState
if (isDesktop) { if (isDesktop) {
coins = [...AppConfig.coins]; coins = [...AppConfig.coins];
coins.removeWhere( coins.removeWhere(
(e) => e is Firo && e.network == CryptoCurrencyNetwork.test, (e) => e is Firo && e.network.isTestNet,
); );
final showTestNet = final showTestNet =

View file

@ -392,8 +392,7 @@ class _SendViewState extends ConsumerState<SendView> {
ref.read(pValidSparkSendToAddress.notifier).state = ref.read(pValidSparkSendToAddress.notifier).state =
SparkInterface.validateSparkAddress( SparkInterface.validateSparkAddress(
address: address ?? "", address: address ?? "",
isTestNet: isTestNet: wallet.cryptoCurrency.network.isTestNet,
wallet.cryptoCurrency.network == CryptoCurrencyNetwork.test,
); );
} }

View file

@ -44,7 +44,7 @@ class _ManageNodesViewState extends ConsumerState<ManageNodesView> {
void initState() { void initState() {
_coins = _coins.toList(); _coins = _coins.toList();
_coins.removeWhere( _coins.removeWhere(
(e) => e is Firo && e.network == CryptoCurrencyNetwork.test, (e) => e is Firo && e.network.isTestNet,
); );
super.initState(); super.initState();
} }

View file

@ -377,7 +377,7 @@ class _WalletViewState extends ConsumerState<WalletView> {
Future<void> _onExchangePressed(BuildContext context) async { Future<void> _onExchangePressed(BuildContext context) async {
final CryptoCurrency coin = ref.read(pWalletCoin(walletId)); final CryptoCurrency coin = ref.read(pWalletCoin(walletId));
if (coin.network == CryptoCurrencyNetwork.test) { if (coin.network.isTestNet) {
await showDialog<void>( await showDialog<void>(
context: context, context: context,
builder: (_) => const StackOkDialog( builder: (_) => const StackOkDialog(
@ -423,7 +423,7 @@ class _WalletViewState extends ConsumerState<WalletView> {
Future<void> _onBuyPressed(BuildContext context) async { Future<void> _onBuyPressed(BuildContext context) async {
final CryptoCurrency coin = ref.read(pWalletCoin(walletId)); final CryptoCurrency coin = ref.read(pWalletCoin(walletId));
if (coin.network == CryptoCurrencyNetwork.test) { if (coin.network.isTestNet) {
await showDialog<void>( await showDialog<void>(
context: context, context: context,
builder: (_) => const StackOkDialog( builder: (_) => const StackOkDialog(

View file

@ -11,13 +11,12 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_svg/svg.dart'; import 'package:flutter_svg/svg.dart';
import '../../app_config.dart'; import '../../app_config.dart';
import '../../models/isar/models/blockchain_data/address.dart'; import '../../models/isar/models/blockchain_data/address.dart';
import '../../models/isar/models/contact_entry.dart'; import '../../models/isar/models/contact_entry.dart';
import '../../pages/address_book_views/subviews/add_address_book_entry_view.dart'; import '../../pages/address_book_views/subviews/add_address_book_entry_view.dart';
import '../../pages/address_book_views/subviews/address_book_filter_view.dart'; import '../../pages/address_book_views/subviews/address_book_filter_view.dart';
import 'subwidgets/desktop_address_book_scaffold.dart';
import 'subwidgets/desktop_contact_details.dart';
import '../../providers/db/main_db_provider.dart'; import '../../providers/db/main_db_provider.dart';
import '../../providers/global/address_book_service_provider.dart'; import '../../providers/global/address_book_service_provider.dart';
import '../../providers/providers.dart'; import '../../providers/providers.dart';
@ -40,6 +39,8 @@ import '../../widgets/rounded_container.dart';
import '../../widgets/rounded_white_container.dart'; import '../../widgets/rounded_white_container.dart';
import '../../widgets/stack_text_field.dart'; import '../../widgets/stack_text_field.dart';
import '../../widgets/textfield_icon_button.dart'; import '../../widgets/textfield_icon_button.dart';
import 'subwidgets/desktop_address_book_scaffold.dart';
import 'subwidgets/desktop_contact_details.dart';
class DesktopAddressBook extends ConsumerStatefulWidget { class DesktopAddressBook extends ConsumerStatefulWidget {
const DesktopAddressBook({super.key}); const DesktopAddressBook({super.key});
@ -99,7 +100,7 @@ class _DesktopAddressBook extends ConsumerState<DesktopAddressBook> {
// if (widget.coin == null) { // if (widget.coin == null) {
final coins = AppConfig.coins.toList(); final coins = AppConfig.coins.toList();
coins.removeWhere( coins.removeWhere(
(e) => e is Firo && e.network == CryptoCurrencyNetwork.test, (e) => e is Firo && e.network.isTestNet,
); );
final bool showTestNet = final bool showTestNet =

View file

@ -704,8 +704,7 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
ref.read(pValidSparkSendToAddress.notifier).state = ref.read(pValidSparkSendToAddress.notifier).state =
SparkInterface.validateSparkAddress( SparkInterface.validateSparkAddress(
address: address ?? "", address: address ?? "",
isTestNet: isTestNet: wallet.cryptoCurrency.network.isTestNet,
wallet.cryptoCurrency.network == CryptoCurrencyNetwork.test,
); );
} }
@ -1468,7 +1467,7 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
if (_data != null && _data!.contactLabel == _address) { if (_data != null && _data!.contactLabel == _address) {
error = SparkInterface.validateSparkAddress( error = SparkInterface.validateSparkAddress(
address: _data!.address, address: _data!.address,
isTestNet: coin.network == CryptoCurrencyNetwork.test, isTestNet: coin.network.isTestNet,
) )
? "Lelantus to Spark not supported" ? "Lelantus to Spark not supported"
: null; : null;

View file

@ -69,7 +69,7 @@ class _NodesSettings extends ConsumerState<NodesSettings> {
void initState() { void initState() {
_coins = _coins.toList(); _coins = _coins.toList();
_coins.removeWhere( _coins.removeWhere(
(e) => e is Firo && e.network == CryptoCurrencyNetwork.test, (e) => e is Firo && e.network.isTestNet,
); );
searchNodeController = TextEditingController(); searchNodeController = TextEditingController();

View file

@ -6,6 +6,7 @@ import 'package:frostdart/frostdart.dart';
import 'package:frostdart/frostdart_bindings_generated.dart'; import 'package:frostdart/frostdart_bindings_generated.dart';
import 'package:frostdart/output.dart'; import 'package:frostdart/output.dart';
import 'package:frostdart/util.dart'; import 'package:frostdart/util.dart';
import '../models/isar/models/blockchain_data/utxo.dart'; import '../models/isar/models/blockchain_data/utxo.dart';
import '../utilities/amount/amount.dart'; import '../utilities/amount/amount.dart';
import '../utilities/extensions/extensions.dart'; import '../utilities/extensions/extensions.dart';
@ -83,9 +84,8 @@ abstract class Frost {
required CryptoCurrency coin, required CryptoCurrency coin,
}) { }) {
try { try {
final network = coin.network == CryptoCurrencyNetwork.test final network =
? Network.Testnet coin.network.isTestNet ? Network.Testnet : Network.Mainnet;
: Network.Mainnet;
final signConfigPointer = decodedSignConfig( final signConfigPointer = decodedSignConfig(
encodedConfig: signConfig, encodedConfig: signConfig,
network: network, network: network,

View file

@ -11,7 +11,6 @@ import '../../utilities/extensions/impl/string.dart';
import '../../utilities/extensions/impl/uint8_list.dart'; import '../../utilities/extensions/impl/uint8_list.dart';
import '../../utilities/format.dart'; import '../../utilities/format.dart';
import '../../utilities/logger.dart'; import '../../utilities/logger.dart';
import '../crypto_currency/crypto_currency.dart';
import '../crypto_currency/intermediate/bip39_hd_currency.dart'; import '../crypto_currency/intermediate/bip39_hd_currency.dart';
import '../models/tx_data.dart'; import '../models/tx_data.dart';
@ -92,7 +91,7 @@ abstract final class LelantusFfiWrapper {
mintKeyPair.privateKey!.toHex, mintKeyPair.privateKey!.toHex,
currentIndex, currentIndex,
mintKeyPair.identifier.toHex, mintKeyPair.identifier.toHex,
isTestnet: args.cryptoCurrency.network == CryptoCurrencyNetwork.test, isTestnet: args.cryptoCurrency.network.isTestNet,
); );
for (int setId = 1; setId <= args.latestSetId; setId++) { for (int setId = 1; setId <= args.latestSetId; setId++) {
@ -117,8 +116,7 @@ abstract final class LelantusFfiWrapper {
amount, amount,
mintKeyPair.privateKey!.toHex, mintKeyPair.privateKey!.toHex,
currentIndex, currentIndex,
isTestnet: isTestnet: args.cryptoCurrency.network.isTestNet,
args.cryptoCurrency.network == CryptoCurrencyNetwork.test,
); );
final bool isUsed = args.usedSerialNumbers.contains(serialNumber); final bool isUsed = args.usedSerialNumbers.contains(serialNumber);
@ -162,8 +160,7 @@ abstract final class LelantusFfiWrapper {
amount, amount,
aesPrivateKey, aesPrivateKey,
currentIndex, currentIndex,
isTestnet: isTestnet: args.cryptoCurrency.network.isTestNet,
args.cryptoCurrency.network == CryptoCurrencyNetwork.test,
); );
final bool isUsed = args.usedSerialNumbers.contains(serialNumber); final bool isUsed = args.usedSerialNumbers.contains(serialNumber);
@ -314,7 +311,7 @@ abstract final class LelantusFfiWrapper {
spendAmount: spendAmount, spendAmount: spendAmount,
subtractFeeFromAmount: arg.subtractFeeFromAmount, subtractFeeFromAmount: arg.subtractFeeFromAmount,
lelantusEntries: arg.lelantusEntries, lelantusEntries: arg.lelantusEntries,
isTestNet: arg.cryptoCurrency.network == CryptoCurrencyNetwork.test, isTestNet: arg.cryptoCurrency.network.isTestNet,
), ),
); );
final changeToMint = estimateJoinSplitFee.changeToMint; final changeToMint = estimateJoinSplitFee.changeToMint;
@ -364,7 +361,7 @@ abstract final class LelantusFfiWrapper {
changeToMint, changeToMint,
jmintprivatekey, jmintprivatekey,
arg.index, arg.index,
isTestnet: arg.cryptoCurrency.network == CryptoCurrencyNetwork.test, isTestnet: arg.cryptoCurrency.network.isTestNet,
); );
final _derivePath = "${arg.partialDerivationPath}$JMINT_INDEX/$keyPath"; final _derivePath = "${arg.partialDerivationPath}$JMINT_INDEX/$keyPath";
@ -378,7 +375,7 @@ abstract final class LelantusFfiWrapper {
arg.index, arg.index,
Format.uint8listToString(jmintKeyPair.identifier), Format.uint8listToString(jmintKeyPair.identifier),
aesPrivateKey, aesPrivateKey,
isTestnet: arg.cryptoCurrency.network == CryptoCurrencyNetwork.test, isTestnet: arg.cryptoCurrency.network.isTestNet,
); );
tx.addOutput( tx.addOutput(
@ -434,7 +431,7 @@ abstract final class LelantusFfiWrapper {
anonymitySets, anonymitySets,
anonymitySetHashes, anonymitySetHashes,
groupBlockHashes, groupBlockHashes,
isTestnet: arg.cryptoCurrency.network == CryptoCurrencyNetwork.test, isTestnet: arg.cryptoCurrency.network.isTestNet,
); );
final finalTx = bitcoindart.TransactionBuilder(network: _network); final finalTx = bitcoindart.TransactionBuilder(network: _network);

View file

@ -24,6 +24,10 @@ class Bitcoin extends Bip39HDCurrency
_id = "bitcoinTestNet"; _id = "bitcoinTestNet";
_name = "tBitcoin"; _name = "tBitcoin";
_ticker = "tBTC"; _ticker = "tBTC";
case CryptoCurrencyNetwork.test4:
_id = "bitcoinTestNet4";
_name = "t4Bitcoin";
_ticker = "t4BTC";
default: default:
throw Exception("Unsupported network: $network"); throw Exception("Unsupported network: $network");
} }
@ -71,6 +75,8 @@ class Bitcoin extends Bip39HDCurrency
return "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"; return "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f";
case CryptoCurrencyNetwork.test: case CryptoCurrencyNetwork.test:
return "000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943"; return "000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943";
case CryptoCurrencyNetwork.test4:
return "00000000da84f2bafbbc53dee25a72ae507ff4914b867c565be350b0da8bf043";
default: default:
throw Exception("Unsupported network: $network"); throw Exception("Unsupported network: $network");
} }
@ -99,6 +105,7 @@ class Bitcoin extends Bip39HDCurrency
feePerKb: BigInt.from(1), // Not used in stack wallet currently feePerKb: BigInt.from(1), // Not used in stack wallet currently
); );
case CryptoCurrencyNetwork.test: case CryptoCurrencyNetwork.test:
case CryptoCurrencyNetwork.test4:
return coinlib.Network( return coinlib.Network(
wifPrefix: 0xef, wifPrefix: 0xef,
p2pkhPrefix: 0x6f, p2pkhPrefix: 0x6f,
@ -247,6 +254,19 @@ class Bitcoin extends Bip39HDCurrency
isDown: false, isDown: false,
); );
case CryptoCurrencyNetwork.test4:
return NodeModel(
host: "bitcoin-testnet4.stackwallet.com",
port: 50002,
name: DefaultNodes.defaultName,
id: DefaultNodes.buildId(this),
useSSL: true,
enabled: true,
coinName: identifier,
isFailover: true,
isDown: false,
);
default: default:
throw UnimplementedError(); throw UnimplementedError();
} }
@ -286,6 +306,8 @@ class Bitcoin extends Bip39HDCurrency
return Uri.parse("https://mempool.space/tx/$txid"); return Uri.parse("https://mempool.space/tx/$txid");
case CryptoCurrencyNetwork.test: case CryptoCurrencyNetwork.test:
return Uri.parse("https://mempool.space/testnet/tx/$txid"); return Uri.parse("https://mempool.space/testnet/tx/$txid");
case CryptoCurrencyNetwork.test4:
return Uri.parse("https://mempool.space/testnet4/tx/$txid");
default: default:
throw Exception( throw Exception(
"Unsupported network for defaultBlockExplorer(): $network", "Unsupported network for defaultBlockExplorer(): $network",

View file

@ -24,6 +24,10 @@ class BitcoinFrost extends FrostCurrency {
_id = "bitcoinFrostTestNet"; _id = "bitcoinFrostTestNet";
_name = "tBitcoin Frost"; _name = "tBitcoin Frost";
_ticker = "tBTC"; _ticker = "tBTC";
case CryptoCurrencyNetwork.test4:
_id = "bitcoinFrostTestNet4";
_name = "t4Bitcoin Frost";
_ticker = "t4BTC";
default: default:
throw Exception("Unsupported network: $network"); throw Exception("Unsupported network: $network");
} }
@ -84,6 +88,19 @@ class BitcoinFrost extends FrostCurrency {
isDown: false, isDown: false,
); );
case CryptoCurrencyNetwork.test4:
return NodeModel(
host: "bitcoin-testnet4.stackwallet.com",
port: 50002,
name: DefaultNodes.defaultName,
id: DefaultNodes.buildId(this),
useSSL: true,
enabled: true,
coinName: identifier,
isFailover: true,
isDown: false,
);
default: default:
throw UnimplementedError(); throw UnimplementedError();
} }
@ -96,6 +113,8 @@ class BitcoinFrost extends FrostCurrency {
return "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"; return "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f";
case CryptoCurrencyNetwork.test: case CryptoCurrencyNetwork.test:
return "000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943"; return "000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943";
case CryptoCurrencyNetwork.test4:
return "00000000da84f2bafbbc53dee25a72ae507ff4914b867c565be350b0da8bf043";
default: default:
throw Exception("Unsupported network: $network"); throw Exception("Unsupported network: $network");
} }
@ -132,6 +151,7 @@ class BitcoinFrost extends FrostCurrency {
feePerKb: BigInt.from(1), // Not used in stack wallet currently feePerKb: BigInt.from(1), // Not used in stack wallet currently
); );
case CryptoCurrencyNetwork.test: case CryptoCurrencyNetwork.test:
case CryptoCurrencyNetwork.test4:
return coinlib.Network( return coinlib.Network(
wifPrefix: 0xef, wifPrefix: 0xef,
p2pkhPrefix: 0x6f, p2pkhPrefix: 0x6f,
@ -195,6 +215,8 @@ class BitcoinFrost extends FrostCurrency {
return Uri.parse("https://mempool.space/tx/$txid"); return Uri.parse("https://mempool.space/tx/$txid");
case CryptoCurrencyNetwork.test: case CryptoCurrencyNetwork.test:
return Uri.parse("https://mempool.space/testnet/tx/$txid"); return Uri.parse("https://mempool.space/testnet/tx/$txid");
case CryptoCurrencyNetwork.test4:
return Uri.parse("https://mempool.space/testnet4/tx/$txid");
default: default:
throw Exception( throw Exception(
"Unsupported network for defaultBlockExplorer(): $network", "Unsupported network for defaultBlockExplorer(): $network",

View file

@ -211,7 +211,7 @@ class Bitcoincash extends Bip39HDCurrency with ElectrumXCurrencyInterface {
// 0 for bitcoincash: address scheme, 1 for legacy address // 0 for bitcoincash: address scheme, 1 for legacy address
final format = bitbox.Address.detectFormat(address); final format = bitbox.Address.detectFormat(address);
if (network == CryptoCurrencyNetwork.test) { if (network.isTestNet) {
return true; return true;
} }

View file

@ -176,7 +176,7 @@ class Firo extends Bip39HDCurrency with ElectrumXCurrencyInterface {
bool validateSparkAddress(String address) { bool validateSparkAddress(String address) {
return SparkInterface.validateSparkAddress( return SparkInterface.validateSparkAddress(
address: address, address: address,
isTestNet: network == CryptoCurrencyNetwork.test, isTestNet: network.isTestNet,
); );
} }

View file

@ -25,7 +25,11 @@ export 'coins/wownero.dart';
enum CryptoCurrencyNetwork { enum CryptoCurrencyNetwork {
main, main,
test, test,
stage; stage,
test4;
bool get isTestNet =>
this == CryptoCurrencyNetwork.test || this == CryptoCurrencyNetwork.test4;
} }
abstract class CryptoCurrency { abstract class CryptoCurrency {

View file

@ -8,7 +8,6 @@ import '../../../models/isar/models/blockchain_data/v2/transaction_v2.dart';
import '../../../models/isar/models/isar_models.dart'; import '../../../models/isar/models/isar_models.dart';
import '../../../models/signing_data.dart'; import '../../../models/signing_data.dart';
import '../../../utilities/logger.dart'; import '../../../utilities/logger.dart';
import '../../crypto_currency/crypto_currency.dart';
import '../../crypto_currency/interfaces/electrumx_currency_interface.dart'; import '../../crypto_currency/interfaces/electrumx_currency_interface.dart';
import '../../models/tx_data.dart'; import '../../models/tx_data.dart';
import '../intermediate/bip39_hd_wallet.dart'; import '../intermediate/bip39_hd_wallet.dart';
@ -27,7 +26,7 @@ mixin BCashInterface<T extends ElectrumXCurrencyInterface>
// TODO: use coinlib // TODO: use coinlib
final builder = bitbox.Bitbox.transactionBuilder( final builder = bitbox.Bitbox.transactionBuilder(
testnet: cryptoCurrency.network == CryptoCurrencyNetwork.test, testnet: cryptoCurrency.network.isTestNet,
); );
builder.setVersion(cryptoCurrency.transactionVersion); builder.setVersion(cryptoCurrency.transactionVersion);
@ -100,7 +99,7 @@ mixin BCashInterface<T extends ElectrumXCurrencyInterface>
network: bitbox_utils.Network( network: bitbox_utils.Network(
cryptoCurrency.networkParams.privHDPrefix, cryptoCurrency.networkParams.privHDPrefix,
cryptoCurrency.networkParams.pubHDPrefix, cryptoCurrency.networkParams.pubHDPrefix,
cryptoCurrency.network == CryptoCurrencyNetwork.test, cryptoCurrency.network.isTestNet,
cryptoCurrency.networkParams.p2pkhPrefix, cryptoCurrency.networkParams.p2pkhPrefix,
cryptoCurrency.networkParams.wifPrefix, cryptoCurrency.networkParams.wifPrefix,
cryptoCurrency.networkParams.p2pkhPrefix, cryptoCurrency.networkParams.p2pkhPrefix,

View file

@ -6,6 +6,8 @@ import 'package:bitcoindart/bitcoindart.dart' as bitcoindart;
import 'package:decimal/decimal.dart'; import 'package:decimal/decimal.dart';
import 'package:isar/isar.dart'; import 'package:isar/isar.dart';
import 'package:lelantus/lelantus.dart' as lelantus; import 'package:lelantus/lelantus.dart' as lelantus;
import 'package:tuple/tuple.dart';
import '../../../models/balance.dart'; import '../../../models/balance.dart';
import '../../../models/isar/models/isar_models.dart'; import '../../../models/isar/models/isar_models.dart';
import '../../../models/lelantus_fee_data.dart'; import '../../../models/lelantus_fee_data.dart';
@ -15,12 +17,10 @@ import '../../../utilities/extensions/impl/uint8_list.dart';
import '../../../utilities/format.dart'; import '../../../utilities/format.dart';
import '../../../utilities/logger.dart'; import '../../../utilities/logger.dart';
import '../../api/lelantus_ffi_wrapper.dart'; import '../../api/lelantus_ffi_wrapper.dart';
import '../../crypto_currency/crypto_currency.dart';
import '../../crypto_currency/interfaces/electrumx_currency_interface.dart'; import '../../crypto_currency/interfaces/electrumx_currency_interface.dart';
import '../../models/tx_data.dart'; import '../../models/tx_data.dart';
import '../intermediate/bip39_hd_wallet.dart'; import '../intermediate/bip39_hd_wallet.dart';
import 'electrumx_interface.dart'; import 'electrumx_interface.dart';
import 'package:tuple/tuple.dart';
mixin LelantusInterface<T extends ElectrumXCurrencyInterface> mixin LelantusInterface<T extends ElectrumXCurrencyInterface>
on Bip39HDWallet<T>, ElectrumXInterface<T> { on Bip39HDWallet<T>, ElectrumXInterface<T> {
@ -38,7 +38,7 @@ mixin LelantusInterface<T extends ElectrumXCurrencyInterface>
spendAmount: amount, spendAmount: amount,
subtractFeeFromAmount: true, subtractFeeFromAmount: true,
lelantusEntries: lelantusEntries, lelantusEntries: lelantusEntries,
isTestNet: cryptoCurrency.network == CryptoCurrencyNetwork.test, isTestNet: cryptoCurrency.network.isTestNet,
); );
return Amount( return Amount(
@ -526,7 +526,7 @@ mixin LelantusInterface<T extends ElectrumXCurrencyInterface>
int.parse(coin.value), int.parse(coin.value),
mintKeyPair.privateKey.data.toHex, mintKeyPair.privateKey.data.toHex,
coin.mintIndex, coin.mintIndex,
isTestnet: cryptoCurrency.network == CryptoCurrencyNetwork.test, isTestnet: cryptoCurrency.network.isTestNet,
); );
final bool isUsed = usedSerialNumbersSet.contains(serialNumber); final bool isUsed = usedSerialNumbersSet.contains(serialNumber);
@ -1033,7 +1033,7 @@ mixin LelantusInterface<T extends ElectrumXCurrencyInterface>
await mainDB.getHighestUsedMintIndex(walletId: walletId); await mainDB.getHighestUsedMintIndex(walletId: walletId);
final nextFreeMintIndex = (lastUsedIndex ?? 0) + 1; final nextFreeMintIndex = (lastUsedIndex ?? 0) + 1;
final isTestnet = cryptoCurrency.network == CryptoCurrencyNetwork.test; final isTestnet = cryptoCurrency.network.isTestNet;
final root = await getRootHDNode(); final root = await getRootHDNode();

View file

@ -68,7 +68,7 @@ mixin PaynymInterface<T extends PaynymCurrencyInterface>
final root = await _getRootNode(); final root = await _getRootNode();
final node = root.derivePath( final node = root.derivePath(
_basePaynymDerivePath( _basePaynymDerivePath(
testnet: info.coin.network == CryptoCurrencyNetwork.test, testnet: info.coin.network.isTestNet,
), ),
); );
return node; return node;
@ -159,7 +159,7 @@ mixin PaynymInterface<T extends PaynymCurrencyInterface>
final root = await _getRootNode(); final root = await _getRootNode();
final node = root.derivePath( final node = root.derivePath(
_basePaynymDerivePath( _basePaynymDerivePath(
testnet: info.coin.network == CryptoCurrencyNetwork.test, testnet: info.coin.network.isTestNet,
), ),
); );
@ -182,7 +182,7 @@ mixin PaynymInterface<T extends PaynymCurrencyInterface>
derivationPath: DerivationPath() derivationPath: DerivationPath()
..value = _receivingPaynymAddressDerivationPath( ..value = _receivingPaynymAddressDerivationPath(
index, index,
testnet: info.coin.network == CryptoCurrencyNetwork.test, testnet: info.coin.network.isTestNet,
), ),
type: generateSegwitAddress ? AddressType.p2wpkh : AddressType.p2pkh, type: generateSegwitAddress ? AddressType.p2wpkh : AddressType.p2pkh,
subType: AddressSubType.paynymReceive, subType: AddressSubType.paynymReceive,
@ -219,7 +219,7 @@ mixin PaynymInterface<T extends PaynymCurrencyInterface>
derivationPath: DerivationPath() derivationPath: DerivationPath()
..value = _sendPaynymAddressDerivationPath( ..value = _sendPaynymAddressDerivationPath(
index, index,
testnet: info.coin.network == CryptoCurrencyNetwork.test, testnet: info.coin.network.isTestNet,
), ),
type: AddressType.nonWallet, type: AddressType.nonWallet,
subType: AddressSubType.paynymSend, subType: AddressSubType.paynymSend,
@ -314,7 +314,7 @@ mixin PaynymInterface<T extends PaynymCurrencyInterface>
final node = root final node = root
.derivePath( .derivePath(
_basePaynymDerivePath( _basePaynymDerivePath(
testnet: info.coin.network == CryptoCurrencyNetwork.test, testnet: info.coin.network.isTestNet,
), ),
) )
.derive(0); .derive(0);
@ -330,7 +330,7 @@ mixin PaynymInterface<T extends PaynymCurrencyInterface>
final paymentCode = PaymentCode.fromBip32Node( final paymentCode = PaymentCode.fromBip32Node(
node.derivePath( node.derivePath(
_basePaynymDerivePath( _basePaynymDerivePath(
testnet: info.coin.network == CryptoCurrencyNetwork.test, testnet: info.coin.network.isTestNet,
), ),
), ),
networkType: networkType, networkType: networkType,
@ -1469,7 +1469,7 @@ mixin PaynymInterface<T extends PaynymCurrencyInterface>
final root = await _getRootNode(); final root = await _getRootNode();
final node = root.derivePath( final node = root.derivePath(
_basePaynymDerivePath( _basePaynymDerivePath(
testnet: info.coin.network == CryptoCurrencyNetwork.test, testnet: info.coin.network.isTestNet,
), ),
); );
final paymentCode = PaymentCode.fromBip32Node( final paymentCode = PaymentCode.fromBip32Node(
@ -1497,7 +1497,7 @@ mixin PaynymInterface<T extends PaynymCurrencyInterface>
derivationIndex: 0, derivationIndex: 0,
derivationPath: DerivationPath() derivationPath: DerivationPath()
..value = _notificationDerivationPath( ..value = _notificationDerivationPath(
testnet: info.coin.network == CryptoCurrencyNetwork.test, testnet: info.coin.network.isTestNet,
), ),
type: AddressType.p2pkh, type: AddressType.p2pkh,
subType: AddressSubType.paynymNotification, subType: AddressSubType.paynymNotification,

View file

@ -18,7 +18,6 @@ import '../../../utilities/amount/amount.dart';
import '../../../utilities/enums/derive_path_type_enum.dart'; import '../../../utilities/enums/derive_path_type_enum.dart';
import '../../../utilities/extensions/extensions.dart'; import '../../../utilities/extensions/extensions.dart';
import '../../../utilities/logger.dart'; import '../../../utilities/logger.dart';
import '../../crypto_currency/crypto_currency.dart';
import '../../crypto_currency/interfaces/electrumx_currency_interface.dart'; import '../../crypto_currency/interfaces/electrumx_currency_interface.dart';
import '../../isar/models/spark_coin.dart'; import '../../isar/models/spark_coin.dart';
import '../../isar/models/wallet_info.dart'; import '../../isar/models/wallet_info.dart';
@ -86,7 +85,7 @@ mixin SparkInterface<T extends ElectrumXCurrencyInterface>
if (_sparkChangeAddressCached == null) { if (_sparkChangeAddressCached == null) {
final root = await getRootHDNode(); final root = await getRootHDNode();
final String derivationPath; final String derivationPath;
if (cryptoCurrency.network == CryptoCurrencyNetwork.test) { if (cryptoCurrency.network.isTestNet) {
derivationPath = derivationPath =
"$kSparkBaseDerivationPathTestnet$kDefaultSparkIndex"; "$kSparkBaseDerivationPathTestnet$kDefaultSparkIndex";
} else { } else {
@ -98,7 +97,7 @@ mixin SparkInterface<T extends ElectrumXCurrencyInterface>
privateKey: keys.privateKey.data, privateKey: keys.privateKey.data,
index: kDefaultSparkIndex, index: kDefaultSparkIndex,
diversifier: kSparkChange, diversifier: kSparkChange,
isTestNet: cryptoCurrency.network == CryptoCurrencyNetwork.test, isTestNet: cryptoCurrency.network.isTestNet,
); );
} }
} catch (e, s) { } catch (e, s) {
@ -158,7 +157,7 @@ mixin SparkInterface<T extends ElectrumXCurrencyInterface>
final root = await getRootHDNode(); final root = await getRootHDNode();
final String derivationPath; final String derivationPath;
if (cryptoCurrency.network == CryptoCurrencyNetwork.test) { if (cryptoCurrency.network.isTestNet) {
derivationPath = "$kSparkBaseDerivationPathTestnet$kDefaultSparkIndex"; derivationPath = "$kSparkBaseDerivationPathTestnet$kDefaultSparkIndex";
} else { } else {
derivationPath = "$kSparkBaseDerivationPath$kDefaultSparkIndex"; derivationPath = "$kSparkBaseDerivationPath$kDefaultSparkIndex";
@ -169,7 +168,7 @@ mixin SparkInterface<T extends ElectrumXCurrencyInterface>
privateKey: keys.privateKey.data, privateKey: keys.privateKey.data,
index: kDefaultSparkIndex, index: kDefaultSparkIndex,
diversifier: diversifier, diversifier: diversifier,
isTestNet: cryptoCurrency.network == CryptoCurrencyNetwork.test, isTestNet: cryptoCurrency.network.isTestNet,
); );
return Address( return Address(
@ -335,7 +334,7 @@ mixin SparkInterface<T extends ElectrumXCurrencyInterface>
final root = await getRootHDNode(); final root = await getRootHDNode();
final String derivationPath; final String derivationPath;
if (cryptoCurrency.network == CryptoCurrencyNetwork.test) { if (cryptoCurrency.network.isTestNet) {
derivationPath = "$kSparkBaseDerivationPathTestnet$kDefaultSparkIndex"; derivationPath = "$kSparkBaseDerivationPathTestnet$kDefaultSparkIndex";
} else { } else {
derivationPath = "$kSparkBaseDerivationPath$kDefaultSparkIndex"; derivationPath = "$kSparkBaseDerivationPath$kDefaultSparkIndex";
@ -704,7 +703,7 @@ mixin SparkInterface<T extends ElectrumXCurrencyInterface>
groupId: groupId, groupId: groupId,
privateKeyHexSet: privateKeyHexSet, privateKeyHexSet: privateKeyHexSet,
walletId: walletId, walletId: walletId,
isTestNet: cryptoCurrency.network == CryptoCurrencyNetwork.test, isTestNet: cryptoCurrency.network.isTestNet,
), ),
); );
@ -836,7 +835,7 @@ mixin SparkInterface<T extends ElectrumXCurrencyInterface>
groupId: groupId, groupId: groupId,
privateKeyHexSet: privateKeyHexSet, privateKeyHexSet: privateKeyHexSet,
walletId: walletId, walletId: walletId,
isTestNet: cryptoCurrency.network == CryptoCurrencyNetwork.test, isTestNet: cryptoCurrency.network.isTestNet,
), ),
); );
newlyIdCoins.addAll(myCoins); newlyIdCoins.addAll(myCoins);

View file

@ -56,7 +56,9 @@ final List<CryptoCurrency> _supportedCoins = List.unmodifiable([
Monero(CryptoCurrencyNetwork.main), Monero(CryptoCurrencyNetwork.main),
BitcoinFrost(CryptoCurrencyNetwork.main), BitcoinFrost(CryptoCurrencyNetwork.main),
Bitcoin(CryptoCurrencyNetwork.test), Bitcoin(CryptoCurrencyNetwork.test),
Bitcoin(CryptoCurrencyNetwork.test4),
BitcoinFrost(CryptoCurrencyNetwork.test), BitcoinFrost(CryptoCurrencyNetwork.test),
BitcoinFrost(CryptoCurrencyNetwork.test4),
]); ]);
EOF EOF

View file

@ -69,13 +69,15 @@ final List<CryptoCurrency> _supportedCoins = List.unmodifiable([
Tezos(CryptoCurrencyNetwork.main), Tezos(CryptoCurrencyNetwork.main),
Wownero(CryptoCurrencyNetwork.main), Wownero(CryptoCurrencyNetwork.main),
Bitcoin(CryptoCurrencyNetwork.test), Bitcoin(CryptoCurrencyNetwork.test),
BitcoinFrost(CryptoCurrencyNetwork.test), Bitcoin(CryptoCurrencyNetwork.test4),
Litecoin(CryptoCurrencyNetwork.test),
Bitcoincash(CryptoCurrencyNetwork.test), Bitcoincash(CryptoCurrencyNetwork.test),
Firo(CryptoCurrencyNetwork.test), BitcoinFrost(CryptoCurrencyNetwork.test),
BitcoinFrost(CryptoCurrencyNetwork.test4),
Dogecoin(CryptoCurrencyNetwork.test), Dogecoin(CryptoCurrencyNetwork.test),
Stellar(CryptoCurrencyNetwork.test), Firo(CryptoCurrencyNetwork.test),
Litecoin(CryptoCurrencyNetwork.test),
Peercoin(CryptoCurrencyNetwork.test), Peercoin(CryptoCurrencyNetwork.test),
Stellar(CryptoCurrencyNetwork.test),
]); ]);
EOF EOF