From 1495eaa6d283c884800b787fe1606ce7e980619d Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 19 Jun 2024 09:15:49 -0600 Subject: [PATCH] btc testnet4 --- .../add_wallet_view/add_wallet_view.dart | 2 +- .../address_book_views/address_book_view.dart | 7 +++--- .../subviews/address_book_filter_view.dart | 2 +- .../subviews/coin_select_sheet.dart | 5 +++-- .../new_contact_address_entry_form.dart | 7 +++--- lib/pages/send_view/send_view.dart | 3 +-- .../manage_nodes_views/manage_nodes_view.dart | 2 +- lib/pages/wallet_view/wallet_view.dart | 4 ++-- .../desktop_address_book.dart | 7 +++--- .../wallet_view/sub_widgets/desktop_send.dart | 5 ++--- .../settings_menu/nodes_settings.dart | 2 +- lib/services/frost.dart | 6 ++--- lib/wallets/api/lelantus_ffi_wrapper.dart | 17 ++++++-------- .../crypto_currency/coins/bitcoin.dart | 22 +++++++++++++++++++ .../crypto_currency/coins/bitcoin_frost.dart | 22 +++++++++++++++++++ .../crypto_currency/coins/bitcoincash.dart | 2 +- lib/wallets/crypto_currency/coins/firo.dart | 2 +- .../crypto_currency/crypto_currency.dart | 6 ++++- .../bcash_interface.dart | 5 ++--- .../lelantus_interface.dart | 10 ++++----- .../paynym_interface.dart | 16 +++++++------- .../spark_interface.dart | 15 ++++++------- scripts/app_config/configure_stack_duo.sh | 2 ++ scripts/app_config/configure_stack_wallet.sh | 10 +++++---- 24 files changed, 115 insertions(+), 66 deletions(-) diff --git a/lib/pages/add_wallet_views/add_wallet_view/add_wallet_view.dart b/lib/pages/add_wallet_views/add_wallet_view/add_wallet_view.dart index 57f707700..deb38a648 100644 --- a/lib/pages/add_wallet_views/add_wallet_view/add_wallet_view.dart +++ b/lib/pages/add_wallet_views/add_wallet_view/add_wallet_view.dart @@ -63,7 +63,7 @@ class _AddWalletViewState extends ConsumerState { String _searchTerm = ""; final _coinsTestnet = [ - ...AppConfig.coins.where((e) => e.network == CryptoCurrencyNetwork.test), + ...AppConfig.coins.where((e) => e.network.isTestNet), ]; final _coins = [ ...AppConfig.coins.where((e) => e.network == CryptoCurrencyNetwork.main), diff --git a/lib/pages/address_book_views/address_book_view.dart b/lib/pages/address_book_views/address_book_view.dart index dc5cc6f99..852803f6f 100644 --- a/lib/pages/address_book_views/address_book_view.dart +++ b/lib/pages/address_book_views/address_book_view.dart @@ -11,11 +11,10 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; + import '../../app_config.dart'; import '../../models/isar/models/blockchain_data/address.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/global/address_book_service_provider.dart'; import '../../providers/providers.dart'; @@ -35,6 +34,8 @@ import '../../widgets/icon_widgets/x_icon.dart'; import '../../widgets/rounded_white_container.dart'; import '../../widgets/stack_text_field.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 { const AddressBookView({ @@ -67,7 +68,7 @@ class _AddressBookViewState extends ConsumerState { if (widget.coin == null) { final coins = [...AppConfig.coins]; coins.removeWhere( - (e) => e is Firo && e.network == CryptoCurrencyNetwork.test, + (e) => e is Firo && e.network.isTestNet, ); final bool showTestNet = diff --git a/lib/pages/address_book_views/subviews/address_book_filter_view.dart b/lib/pages/address_book_views/subviews/address_book_filter_view.dart index 124cf142f..9feaa0a37 100644 --- a/lib/pages/address_book_views/subviews/address_book_filter_view.dart +++ b/lib/pages/address_book_views/subviews/address_book_filter_view.dart @@ -43,7 +43,7 @@ class _AddressBookFilterViewState extends ConsumerState { void initState() { final coins = [...AppConfig.coins]; coins.removeWhere( - (e) => e is Firo && e.network == CryptoCurrencyNetwork.test, + (e) => e is Firo && e.network.isTestNet, ); final showTestNet = ref.read(prefsChangeNotifierProvider).showTestNetCoins; diff --git a/lib/pages/address_book_views/subviews/coin_select_sheet.dart b/lib/pages/address_book_views/subviews/coin_select_sheet.dart index 7e2cd0710..64cc5124d 100644 --- a/lib/pages/address_book_views/subviews/coin_select_sheet.dart +++ b/lib/pages/address_book_views/subviews/coin_select_sheet.dart @@ -13,8 +13,9 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import '../../../providers/global/prefs_provider.dart'; + import '../../../app_config.dart'; +import '../../../providers/global/prefs_provider.dart'; import '../../../themes/coin_image_provider.dart'; import '../../../themes/stack_colors.dart'; import '../../../utilities/constants.dart'; @@ -29,7 +30,7 @@ class CoinSelectSheet extends StatelessWidget { final maxHeight = MediaQuery.of(context).size.height * 0.60; final coins_ = [...AppConfig.coins]; coins_.removeWhere( - (e) => e is Firo && e.network == CryptoCurrencyNetwork.test, + (e) => e is Firo && e.network.isTestNet, ); return Container( decoration: BoxDecoration( diff --git a/lib/pages/address_book_views/subviews/new_contact_address_entry_form.dart b/lib/pages/address_book_views/subviews/new_contact_address_entry_form.dart index fc4c8f900..2bad87bc6 100644 --- a/lib/pages/address_book_views/subviews/new_contact_address_entry_form.dart +++ b/lib/pages/address_book_views/subviews/new_contact_address_entry_form.dart @@ -15,11 +15,11 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'coin_select_sheet.dart'; + +import '../../../app_config.dart'; import '../../../providers/providers.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 '../../../app_config.dart'; import '../../../themes/coin_icon_provider.dart'; import '../../../themes/stack_colors.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/stack_text_field.dart'; import '../../../widgets/textfield_icon_button.dart'; +import 'coin_select_sheet.dart'; class NewContactAddressEntryForm extends ConsumerStatefulWidget { const NewContactAddressEntryForm({ @@ -92,7 +93,7 @@ class _NewContactAddressEntryFormState if (isDesktop) { coins = [...AppConfig.coins]; coins.removeWhere( - (e) => e is Firo && e.network == CryptoCurrencyNetwork.test, + (e) => e is Firo && e.network.isTestNet, ); final showTestNet = diff --git a/lib/pages/send_view/send_view.dart b/lib/pages/send_view/send_view.dart index 8d1f12c5d..c64ce53f3 100644 --- a/lib/pages/send_view/send_view.dart +++ b/lib/pages/send_view/send_view.dart @@ -392,8 +392,7 @@ class _SendViewState extends ConsumerState { ref.read(pValidSparkSendToAddress.notifier).state = SparkInterface.validateSparkAddress( address: address ?? "", - isTestNet: - wallet.cryptoCurrency.network == CryptoCurrencyNetwork.test, + isTestNet: wallet.cryptoCurrency.network.isTestNet, ); } diff --git a/lib/pages/settings_views/global_settings_view/manage_nodes_views/manage_nodes_view.dart b/lib/pages/settings_views/global_settings_view/manage_nodes_views/manage_nodes_view.dart index 34b37b621..e44d352f4 100644 --- a/lib/pages/settings_views/global_settings_view/manage_nodes_views/manage_nodes_view.dart +++ b/lib/pages/settings_views/global_settings_view/manage_nodes_views/manage_nodes_view.dart @@ -44,7 +44,7 @@ class _ManageNodesViewState extends ConsumerState { void initState() { _coins = _coins.toList(); _coins.removeWhere( - (e) => e is Firo && e.network == CryptoCurrencyNetwork.test, + (e) => e is Firo && e.network.isTestNet, ); super.initState(); } diff --git a/lib/pages/wallet_view/wallet_view.dart b/lib/pages/wallet_view/wallet_view.dart index e4bc2a755..bfe2cb8c5 100644 --- a/lib/pages/wallet_view/wallet_view.dart +++ b/lib/pages/wallet_view/wallet_view.dart @@ -377,7 +377,7 @@ class _WalletViewState extends ConsumerState { Future _onExchangePressed(BuildContext context) async { final CryptoCurrency coin = ref.read(pWalletCoin(walletId)); - if (coin.network == CryptoCurrencyNetwork.test) { + if (coin.network.isTestNet) { await showDialog( context: context, builder: (_) => const StackOkDialog( @@ -423,7 +423,7 @@ class _WalletViewState extends ConsumerState { Future _onBuyPressed(BuildContext context) async { final CryptoCurrency coin = ref.read(pWalletCoin(walletId)); - if (coin.network == CryptoCurrencyNetwork.test) { + if (coin.network.isTestNet) { await showDialog( context: context, builder: (_) => const StackOkDialog( diff --git a/lib/pages_desktop_specific/address_book_view/desktop_address_book.dart b/lib/pages_desktop_specific/address_book_view/desktop_address_book.dart index c68b9c058..f27147cb3 100644 --- a/lib/pages_desktop_specific/address_book_view/desktop_address_book.dart +++ b/lib/pages_desktop_specific/address_book_view/desktop_address_book.dart @@ -11,13 +11,12 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; + import '../../app_config.dart'; import '../../models/isar/models/blockchain_data/address.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/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/global/address_book_service_provider.dart'; import '../../providers/providers.dart'; @@ -40,6 +39,8 @@ import '../../widgets/rounded_container.dart'; import '../../widgets/rounded_white_container.dart'; import '../../widgets/stack_text_field.dart'; import '../../widgets/textfield_icon_button.dart'; +import 'subwidgets/desktop_address_book_scaffold.dart'; +import 'subwidgets/desktop_contact_details.dart'; class DesktopAddressBook extends ConsumerStatefulWidget { const DesktopAddressBook({super.key}); @@ -99,7 +100,7 @@ class _DesktopAddressBook extends ConsumerState { // if (widget.coin == null) { final coins = AppConfig.coins.toList(); coins.removeWhere( - (e) => e is Firo && e.network == CryptoCurrencyNetwork.test, + (e) => e is Firo && e.network.isTestNet, ); final bool showTestNet = diff --git a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_send.dart b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_send.dart index 6c7c28296..aa325a653 100644 --- a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_send.dart +++ b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_send.dart @@ -704,8 +704,7 @@ class _DesktopSendState extends ConsumerState { ref.read(pValidSparkSendToAddress.notifier).state = SparkInterface.validateSparkAddress( address: address ?? "", - isTestNet: - wallet.cryptoCurrency.network == CryptoCurrencyNetwork.test, + isTestNet: wallet.cryptoCurrency.network.isTestNet, ); } @@ -1468,7 +1467,7 @@ class _DesktopSendState extends ConsumerState { if (_data != null && _data!.contactLabel == _address) { error = SparkInterface.validateSparkAddress( address: _data!.address, - isTestNet: coin.network == CryptoCurrencyNetwork.test, + isTestNet: coin.network.isTestNet, ) ? "Lelantus to Spark not supported" : null; diff --git a/lib/pages_desktop_specific/settings/settings_menu/nodes_settings.dart b/lib/pages_desktop_specific/settings/settings_menu/nodes_settings.dart index 517073f4c..bf6914869 100644 --- a/lib/pages_desktop_specific/settings/settings_menu/nodes_settings.dart +++ b/lib/pages_desktop_specific/settings/settings_menu/nodes_settings.dart @@ -69,7 +69,7 @@ class _NodesSettings extends ConsumerState { void initState() { _coins = _coins.toList(); _coins.removeWhere( - (e) => e is Firo && e.network == CryptoCurrencyNetwork.test, + (e) => e is Firo && e.network.isTestNet, ); searchNodeController = TextEditingController(); diff --git a/lib/services/frost.dart b/lib/services/frost.dart index 932ee61ed..632299e37 100644 --- a/lib/services/frost.dart +++ b/lib/services/frost.dart @@ -6,6 +6,7 @@ import 'package:frostdart/frostdart.dart'; import 'package:frostdart/frostdart_bindings_generated.dart'; import 'package:frostdart/output.dart'; import 'package:frostdart/util.dart'; + import '../models/isar/models/blockchain_data/utxo.dart'; import '../utilities/amount/amount.dart'; import '../utilities/extensions/extensions.dart'; @@ -83,9 +84,8 @@ abstract class Frost { required CryptoCurrency coin, }) { try { - final network = coin.network == CryptoCurrencyNetwork.test - ? Network.Testnet - : Network.Mainnet; + final network = + coin.network.isTestNet ? Network.Testnet : Network.Mainnet; final signConfigPointer = decodedSignConfig( encodedConfig: signConfig, network: network, diff --git a/lib/wallets/api/lelantus_ffi_wrapper.dart b/lib/wallets/api/lelantus_ffi_wrapper.dart index d43f504c4..44e446507 100644 --- a/lib/wallets/api/lelantus_ffi_wrapper.dart +++ b/lib/wallets/api/lelantus_ffi_wrapper.dart @@ -11,7 +11,6 @@ import '../../utilities/extensions/impl/string.dart'; import '../../utilities/extensions/impl/uint8_list.dart'; import '../../utilities/format.dart'; import '../../utilities/logger.dart'; -import '../crypto_currency/crypto_currency.dart'; import '../crypto_currency/intermediate/bip39_hd_currency.dart'; import '../models/tx_data.dart'; @@ -92,7 +91,7 @@ abstract final class LelantusFfiWrapper { mintKeyPair.privateKey!.toHex, currentIndex, mintKeyPair.identifier.toHex, - isTestnet: args.cryptoCurrency.network == CryptoCurrencyNetwork.test, + isTestnet: args.cryptoCurrency.network.isTestNet, ); for (int setId = 1; setId <= args.latestSetId; setId++) { @@ -117,8 +116,7 @@ abstract final class LelantusFfiWrapper { amount, mintKeyPair.privateKey!.toHex, currentIndex, - isTestnet: - args.cryptoCurrency.network == CryptoCurrencyNetwork.test, + isTestnet: args.cryptoCurrency.network.isTestNet, ); final bool isUsed = args.usedSerialNumbers.contains(serialNumber); @@ -162,8 +160,7 @@ abstract final class LelantusFfiWrapper { amount, aesPrivateKey, currentIndex, - isTestnet: - args.cryptoCurrency.network == CryptoCurrencyNetwork.test, + isTestnet: args.cryptoCurrency.network.isTestNet, ); final bool isUsed = args.usedSerialNumbers.contains(serialNumber); @@ -314,7 +311,7 @@ abstract final class LelantusFfiWrapper { spendAmount: spendAmount, subtractFeeFromAmount: arg.subtractFeeFromAmount, lelantusEntries: arg.lelantusEntries, - isTestNet: arg.cryptoCurrency.network == CryptoCurrencyNetwork.test, + isTestNet: arg.cryptoCurrency.network.isTestNet, ), ); final changeToMint = estimateJoinSplitFee.changeToMint; @@ -364,7 +361,7 @@ abstract final class LelantusFfiWrapper { changeToMint, jmintprivatekey, arg.index, - isTestnet: arg.cryptoCurrency.network == CryptoCurrencyNetwork.test, + isTestnet: arg.cryptoCurrency.network.isTestNet, ); final _derivePath = "${arg.partialDerivationPath}$JMINT_INDEX/$keyPath"; @@ -378,7 +375,7 @@ abstract final class LelantusFfiWrapper { arg.index, Format.uint8listToString(jmintKeyPair.identifier), aesPrivateKey, - isTestnet: arg.cryptoCurrency.network == CryptoCurrencyNetwork.test, + isTestnet: arg.cryptoCurrency.network.isTestNet, ); tx.addOutput( @@ -434,7 +431,7 @@ abstract final class LelantusFfiWrapper { anonymitySets, anonymitySetHashes, groupBlockHashes, - isTestnet: arg.cryptoCurrency.network == CryptoCurrencyNetwork.test, + isTestnet: arg.cryptoCurrency.network.isTestNet, ); final finalTx = bitcoindart.TransactionBuilder(network: _network); diff --git a/lib/wallets/crypto_currency/coins/bitcoin.dart b/lib/wallets/crypto_currency/coins/bitcoin.dart index dd103c794..c303124c3 100644 --- a/lib/wallets/crypto_currency/coins/bitcoin.dart +++ b/lib/wallets/crypto_currency/coins/bitcoin.dart @@ -24,6 +24,10 @@ class Bitcoin extends Bip39HDCurrency _id = "bitcoinTestNet"; _name = "tBitcoin"; _ticker = "tBTC"; + case CryptoCurrencyNetwork.test4: + _id = "bitcoinTestNet4"; + _name = "t4Bitcoin"; + _ticker = "t4BTC"; default: throw Exception("Unsupported network: $network"); } @@ -71,6 +75,8 @@ class Bitcoin extends Bip39HDCurrency return "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"; case CryptoCurrencyNetwork.test: return "000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943"; + case CryptoCurrencyNetwork.test4: + return "00000000da84f2bafbbc53dee25a72ae507ff4914b867c565be350b0da8bf043"; default: throw Exception("Unsupported network: $network"); } @@ -99,6 +105,7 @@ class Bitcoin extends Bip39HDCurrency feePerKb: BigInt.from(1), // Not used in stack wallet currently ); case CryptoCurrencyNetwork.test: + case CryptoCurrencyNetwork.test4: return coinlib.Network( wifPrefix: 0xef, p2pkhPrefix: 0x6f, @@ -247,6 +254,19 @@ class Bitcoin extends Bip39HDCurrency 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: throw UnimplementedError(); } @@ -286,6 +306,8 @@ class Bitcoin extends Bip39HDCurrency return Uri.parse("https://mempool.space/tx/$txid"); case CryptoCurrencyNetwork.test: return Uri.parse("https://mempool.space/testnet/tx/$txid"); + case CryptoCurrencyNetwork.test4: + return Uri.parse("https://mempool.space/testnet4/tx/$txid"); default: throw Exception( "Unsupported network for defaultBlockExplorer(): $network", diff --git a/lib/wallets/crypto_currency/coins/bitcoin_frost.dart b/lib/wallets/crypto_currency/coins/bitcoin_frost.dart index a5f02ac08..c5e0049b7 100644 --- a/lib/wallets/crypto_currency/coins/bitcoin_frost.dart +++ b/lib/wallets/crypto_currency/coins/bitcoin_frost.dart @@ -24,6 +24,10 @@ class BitcoinFrost extends FrostCurrency { _id = "bitcoinFrostTestNet"; _name = "tBitcoin Frost"; _ticker = "tBTC"; + case CryptoCurrencyNetwork.test4: + _id = "bitcoinFrostTestNet4"; + _name = "t4Bitcoin Frost"; + _ticker = "t4BTC"; default: throw Exception("Unsupported network: $network"); } @@ -84,6 +88,19 @@ class BitcoinFrost extends FrostCurrency { 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: throw UnimplementedError(); } @@ -96,6 +113,8 @@ class BitcoinFrost extends FrostCurrency { return "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"; case CryptoCurrencyNetwork.test: return "000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943"; + case CryptoCurrencyNetwork.test4: + return "00000000da84f2bafbbc53dee25a72ae507ff4914b867c565be350b0da8bf043"; default: throw Exception("Unsupported network: $network"); } @@ -132,6 +151,7 @@ class BitcoinFrost extends FrostCurrency { feePerKb: BigInt.from(1), // Not used in stack wallet currently ); case CryptoCurrencyNetwork.test: + case CryptoCurrencyNetwork.test4: return coinlib.Network( wifPrefix: 0xef, p2pkhPrefix: 0x6f, @@ -195,6 +215,8 @@ class BitcoinFrost extends FrostCurrency { return Uri.parse("https://mempool.space/tx/$txid"); case CryptoCurrencyNetwork.test: return Uri.parse("https://mempool.space/testnet/tx/$txid"); + case CryptoCurrencyNetwork.test4: + return Uri.parse("https://mempool.space/testnet4/tx/$txid"); default: throw Exception( "Unsupported network for defaultBlockExplorer(): $network", diff --git a/lib/wallets/crypto_currency/coins/bitcoincash.dart b/lib/wallets/crypto_currency/coins/bitcoincash.dart index e06578ac6..c0014039d 100644 --- a/lib/wallets/crypto_currency/coins/bitcoincash.dart +++ b/lib/wallets/crypto_currency/coins/bitcoincash.dart @@ -211,7 +211,7 @@ class Bitcoincash extends Bip39HDCurrency with ElectrumXCurrencyInterface { // 0 for bitcoincash: address scheme, 1 for legacy address final format = bitbox.Address.detectFormat(address); - if (network == CryptoCurrencyNetwork.test) { + if (network.isTestNet) { return true; } diff --git a/lib/wallets/crypto_currency/coins/firo.dart b/lib/wallets/crypto_currency/coins/firo.dart index 47ee606c4..ae73f13b7 100644 --- a/lib/wallets/crypto_currency/coins/firo.dart +++ b/lib/wallets/crypto_currency/coins/firo.dart @@ -176,7 +176,7 @@ class Firo extends Bip39HDCurrency with ElectrumXCurrencyInterface { bool validateSparkAddress(String address) { return SparkInterface.validateSparkAddress( address: address, - isTestNet: network == CryptoCurrencyNetwork.test, + isTestNet: network.isTestNet, ); } diff --git a/lib/wallets/crypto_currency/crypto_currency.dart b/lib/wallets/crypto_currency/crypto_currency.dart index eb6e88daa..5ea51e557 100644 --- a/lib/wallets/crypto_currency/crypto_currency.dart +++ b/lib/wallets/crypto_currency/crypto_currency.dart @@ -25,7 +25,11 @@ export 'coins/wownero.dart'; enum CryptoCurrencyNetwork { main, test, - stage; + stage, + test4; + + bool get isTestNet => + this == CryptoCurrencyNetwork.test || this == CryptoCurrencyNetwork.test4; } abstract class CryptoCurrency { diff --git a/lib/wallets/wallet/wallet_mixin_interfaces/bcash_interface.dart b/lib/wallets/wallet/wallet_mixin_interfaces/bcash_interface.dart index be0727bfc..0fd65ba0d 100644 --- a/lib/wallets/wallet/wallet_mixin_interfaces/bcash_interface.dart +++ b/lib/wallets/wallet/wallet_mixin_interfaces/bcash_interface.dart @@ -8,7 +8,6 @@ import '../../../models/isar/models/blockchain_data/v2/transaction_v2.dart'; import '../../../models/isar/models/isar_models.dart'; import '../../../models/signing_data.dart'; import '../../../utilities/logger.dart'; -import '../../crypto_currency/crypto_currency.dart'; import '../../crypto_currency/interfaces/electrumx_currency_interface.dart'; import '../../models/tx_data.dart'; import '../intermediate/bip39_hd_wallet.dart'; @@ -27,7 +26,7 @@ mixin BCashInterface // TODO: use coinlib final builder = bitbox.Bitbox.transactionBuilder( - testnet: cryptoCurrency.network == CryptoCurrencyNetwork.test, + testnet: cryptoCurrency.network.isTestNet, ); builder.setVersion(cryptoCurrency.transactionVersion); @@ -100,7 +99,7 @@ mixin BCashInterface network: bitbox_utils.Network( cryptoCurrency.networkParams.privHDPrefix, cryptoCurrency.networkParams.pubHDPrefix, - cryptoCurrency.network == CryptoCurrencyNetwork.test, + cryptoCurrency.network.isTestNet, cryptoCurrency.networkParams.p2pkhPrefix, cryptoCurrency.networkParams.wifPrefix, cryptoCurrency.networkParams.p2pkhPrefix, diff --git a/lib/wallets/wallet/wallet_mixin_interfaces/lelantus_interface.dart b/lib/wallets/wallet/wallet_mixin_interfaces/lelantus_interface.dart index 9d536197a..7116f6c7d 100644 --- a/lib/wallets/wallet/wallet_mixin_interfaces/lelantus_interface.dart +++ b/lib/wallets/wallet/wallet_mixin_interfaces/lelantus_interface.dart @@ -6,6 +6,8 @@ import 'package:bitcoindart/bitcoindart.dart' as bitcoindart; import 'package:decimal/decimal.dart'; import 'package:isar/isar.dart'; import 'package:lelantus/lelantus.dart' as lelantus; +import 'package:tuple/tuple.dart'; + import '../../../models/balance.dart'; import '../../../models/isar/models/isar_models.dart'; import '../../../models/lelantus_fee_data.dart'; @@ -15,12 +17,10 @@ import '../../../utilities/extensions/impl/uint8_list.dart'; import '../../../utilities/format.dart'; import '../../../utilities/logger.dart'; import '../../api/lelantus_ffi_wrapper.dart'; -import '../../crypto_currency/crypto_currency.dart'; import '../../crypto_currency/interfaces/electrumx_currency_interface.dart'; import '../../models/tx_data.dart'; import '../intermediate/bip39_hd_wallet.dart'; import 'electrumx_interface.dart'; -import 'package:tuple/tuple.dart'; mixin LelantusInterface on Bip39HDWallet, ElectrumXInterface { @@ -38,7 +38,7 @@ mixin LelantusInterface spendAmount: amount, subtractFeeFromAmount: true, lelantusEntries: lelantusEntries, - isTestNet: cryptoCurrency.network == CryptoCurrencyNetwork.test, + isTestNet: cryptoCurrency.network.isTestNet, ); return Amount( @@ -526,7 +526,7 @@ mixin LelantusInterface int.parse(coin.value), mintKeyPair.privateKey.data.toHex, coin.mintIndex, - isTestnet: cryptoCurrency.network == CryptoCurrencyNetwork.test, + isTestnet: cryptoCurrency.network.isTestNet, ); final bool isUsed = usedSerialNumbersSet.contains(serialNumber); @@ -1033,7 +1033,7 @@ mixin LelantusInterface await mainDB.getHighestUsedMintIndex(walletId: walletId); final nextFreeMintIndex = (lastUsedIndex ?? 0) + 1; - final isTestnet = cryptoCurrency.network == CryptoCurrencyNetwork.test; + final isTestnet = cryptoCurrency.network.isTestNet; final root = await getRootHDNode(); diff --git a/lib/wallets/wallet/wallet_mixin_interfaces/paynym_interface.dart b/lib/wallets/wallet/wallet_mixin_interfaces/paynym_interface.dart index 0d9ebf75b..f86e76d0d 100644 --- a/lib/wallets/wallet/wallet_mixin_interfaces/paynym_interface.dart +++ b/lib/wallets/wallet/wallet_mixin_interfaces/paynym_interface.dart @@ -68,7 +68,7 @@ mixin PaynymInterface final root = await _getRootNode(); final node = root.derivePath( _basePaynymDerivePath( - testnet: info.coin.network == CryptoCurrencyNetwork.test, + testnet: info.coin.network.isTestNet, ), ); return node; @@ -159,7 +159,7 @@ mixin PaynymInterface final root = await _getRootNode(); final node = root.derivePath( _basePaynymDerivePath( - testnet: info.coin.network == CryptoCurrencyNetwork.test, + testnet: info.coin.network.isTestNet, ), ); @@ -182,7 +182,7 @@ mixin PaynymInterface derivationPath: DerivationPath() ..value = _receivingPaynymAddressDerivationPath( index, - testnet: info.coin.network == CryptoCurrencyNetwork.test, + testnet: info.coin.network.isTestNet, ), type: generateSegwitAddress ? AddressType.p2wpkh : AddressType.p2pkh, subType: AddressSubType.paynymReceive, @@ -219,7 +219,7 @@ mixin PaynymInterface derivationPath: DerivationPath() ..value = _sendPaynymAddressDerivationPath( index, - testnet: info.coin.network == CryptoCurrencyNetwork.test, + testnet: info.coin.network.isTestNet, ), type: AddressType.nonWallet, subType: AddressSubType.paynymSend, @@ -314,7 +314,7 @@ mixin PaynymInterface final node = root .derivePath( _basePaynymDerivePath( - testnet: info.coin.network == CryptoCurrencyNetwork.test, + testnet: info.coin.network.isTestNet, ), ) .derive(0); @@ -330,7 +330,7 @@ mixin PaynymInterface final paymentCode = PaymentCode.fromBip32Node( node.derivePath( _basePaynymDerivePath( - testnet: info.coin.network == CryptoCurrencyNetwork.test, + testnet: info.coin.network.isTestNet, ), ), networkType: networkType, @@ -1469,7 +1469,7 @@ mixin PaynymInterface final root = await _getRootNode(); final node = root.derivePath( _basePaynymDerivePath( - testnet: info.coin.network == CryptoCurrencyNetwork.test, + testnet: info.coin.network.isTestNet, ), ); final paymentCode = PaymentCode.fromBip32Node( @@ -1497,7 +1497,7 @@ mixin PaynymInterface derivationIndex: 0, derivationPath: DerivationPath() ..value = _notificationDerivationPath( - testnet: info.coin.network == CryptoCurrencyNetwork.test, + testnet: info.coin.network.isTestNet, ), type: AddressType.p2pkh, subType: AddressSubType.paynymNotification, diff --git a/lib/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart b/lib/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart index 496147da1..90f7cfe31 100644 --- a/lib/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart +++ b/lib/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart @@ -18,7 +18,6 @@ import '../../../utilities/amount/amount.dart'; import '../../../utilities/enums/derive_path_type_enum.dart'; import '../../../utilities/extensions/extensions.dart'; import '../../../utilities/logger.dart'; -import '../../crypto_currency/crypto_currency.dart'; import '../../crypto_currency/interfaces/electrumx_currency_interface.dart'; import '../../isar/models/spark_coin.dart'; import '../../isar/models/wallet_info.dart'; @@ -86,7 +85,7 @@ mixin SparkInterface if (_sparkChangeAddressCached == null) { final root = await getRootHDNode(); final String derivationPath; - if (cryptoCurrency.network == CryptoCurrencyNetwork.test) { + if (cryptoCurrency.network.isTestNet) { derivationPath = "$kSparkBaseDerivationPathTestnet$kDefaultSparkIndex"; } else { @@ -98,7 +97,7 @@ mixin SparkInterface privateKey: keys.privateKey.data, index: kDefaultSparkIndex, diversifier: kSparkChange, - isTestNet: cryptoCurrency.network == CryptoCurrencyNetwork.test, + isTestNet: cryptoCurrency.network.isTestNet, ); } } catch (e, s) { @@ -158,7 +157,7 @@ mixin SparkInterface final root = await getRootHDNode(); final String derivationPath; - if (cryptoCurrency.network == CryptoCurrencyNetwork.test) { + if (cryptoCurrency.network.isTestNet) { derivationPath = "$kSparkBaseDerivationPathTestnet$kDefaultSparkIndex"; } else { derivationPath = "$kSparkBaseDerivationPath$kDefaultSparkIndex"; @@ -169,7 +168,7 @@ mixin SparkInterface privateKey: keys.privateKey.data, index: kDefaultSparkIndex, diversifier: diversifier, - isTestNet: cryptoCurrency.network == CryptoCurrencyNetwork.test, + isTestNet: cryptoCurrency.network.isTestNet, ); return Address( @@ -335,7 +334,7 @@ mixin SparkInterface final root = await getRootHDNode(); final String derivationPath; - if (cryptoCurrency.network == CryptoCurrencyNetwork.test) { + if (cryptoCurrency.network.isTestNet) { derivationPath = "$kSparkBaseDerivationPathTestnet$kDefaultSparkIndex"; } else { derivationPath = "$kSparkBaseDerivationPath$kDefaultSparkIndex"; @@ -704,7 +703,7 @@ mixin SparkInterface groupId: groupId, privateKeyHexSet: privateKeyHexSet, walletId: walletId, - isTestNet: cryptoCurrency.network == CryptoCurrencyNetwork.test, + isTestNet: cryptoCurrency.network.isTestNet, ), ); @@ -836,7 +835,7 @@ mixin SparkInterface groupId: groupId, privateKeyHexSet: privateKeyHexSet, walletId: walletId, - isTestNet: cryptoCurrency.network == CryptoCurrencyNetwork.test, + isTestNet: cryptoCurrency.network.isTestNet, ), ); newlyIdCoins.addAll(myCoins); diff --git a/scripts/app_config/configure_stack_duo.sh b/scripts/app_config/configure_stack_duo.sh index 56c12bd37..7c1b2ff36 100755 --- a/scripts/app_config/configure_stack_duo.sh +++ b/scripts/app_config/configure_stack_duo.sh @@ -56,7 +56,9 @@ final List _supportedCoins = List.unmodifiable([ Monero(CryptoCurrencyNetwork.main), BitcoinFrost(CryptoCurrencyNetwork.main), Bitcoin(CryptoCurrencyNetwork.test), + Bitcoin(CryptoCurrencyNetwork.test4), BitcoinFrost(CryptoCurrencyNetwork.test), + BitcoinFrost(CryptoCurrencyNetwork.test4), ]); EOF \ No newline at end of file diff --git a/scripts/app_config/configure_stack_wallet.sh b/scripts/app_config/configure_stack_wallet.sh index 7c0dc2a67..fb2438182 100755 --- a/scripts/app_config/configure_stack_wallet.sh +++ b/scripts/app_config/configure_stack_wallet.sh @@ -69,13 +69,15 @@ final List _supportedCoins = List.unmodifiable([ Tezos(CryptoCurrencyNetwork.main), Wownero(CryptoCurrencyNetwork.main), Bitcoin(CryptoCurrencyNetwork.test), - BitcoinFrost(CryptoCurrencyNetwork.test), - Litecoin(CryptoCurrencyNetwork.test), + Bitcoin(CryptoCurrencyNetwork.test4), Bitcoincash(CryptoCurrencyNetwork.test), - Firo(CryptoCurrencyNetwork.test), + BitcoinFrost(CryptoCurrencyNetwork.test), + BitcoinFrost(CryptoCurrencyNetwork.test4), Dogecoin(CryptoCurrencyNetwork.test), - Stellar(CryptoCurrencyNetwork.test), + Firo(CryptoCurrencyNetwork.test), + Litecoin(CryptoCurrencyNetwork.test), Peercoin(CryptoCurrencyNetwork.test), + Stellar(CryptoCurrencyNetwork.test), ]); EOF \ No newline at end of file