diff --git a/lib/pages/send_view/send_view.dart b/lib/pages/send_view/send_view.dart index d610c0aa1..cfaa41f64 100644 --- a/lib/pages/send_view/send_view.dart +++ b/lib/pages/send_view/send_view.dart @@ -1087,7 +1087,10 @@ class _SendViewState extends ConsumerState { ref.refresh(pIsExchangeAddress); }); isCustomFee.addListener(() { - if (!isCustomFee.value) ethFee = null; + if (!isCustomFee.value) { + customFeeRate = 1; + ethFee = null; + } }); hasFees = coin is! Epiccash && coin is! NanoCurrency && coin is! Tezos; _currentFee = 0.toAmountAsRaw(fractionDigits: coin.fractionDigits); 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 b4e259f6c..b4c183c43 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 @@ -1666,6 +1666,7 @@ class _DesktopSendState extends ConsumerState { onCustomFeeSliderChanged: (value) => customFeeRate = value, onCustomFeeOptionChanged: (value) { isCustomFee = value; + customFeeRate = 1; ethFee = null; }, onCustomEip1559FeeOptionChanged: (value) => ethFee = value, diff --git a/lib/wallets/crypto_currency/coins/bitcoincash.dart b/lib/wallets/crypto_currency/coins/bitcoincash.dart index 6ea2a8c3e..d236b21a4 100644 --- a/lib/wallets/crypto_currency/coins/bitcoincash.dart +++ b/lib/wallets/crypto_currency/coins/bitcoincash.dart @@ -1,9 +1,8 @@ -import 'dart:typed_data'; - import 'package:bech32/bech32.dart'; import 'package:bitbox/bitbox.dart' as bitbox; import 'package:bs58check/bs58check.dart' as bs58check; import 'package:coinlib_flutter/coinlib_flutter.dart' as coinlib; +import 'package:flutter/foundation.dart'; import '../../../models/isar/models/blockchain_data/address.dart'; import '../../../models/node_model.dart'; @@ -231,6 +230,17 @@ class Bitcoincash extends Bip39HDCurrency with ElectrumXCurrencyInterface { // Do not validate "p" (P2SH) addresses. } + @override + AddressType? getAddressType(String address) { + final format = bitbox.Address.detectFormat(address); + + return super.getAddressType( + format == bitbox.Address.formatCashAddr + ? bitbox.Address.toLegacyAddress(address) + : address, + ); + } + @override DerivePathType addressType({required String address}) { Uint8List? decodeBase58; diff --git a/lib/wallets/crypto_currency/coins/ecash.dart b/lib/wallets/crypto_currency/coins/ecash.dart index a41a47394..c7d99b2d5 100644 --- a/lib/wallets/crypto_currency/coins/ecash.dart +++ b/lib/wallets/crypto_currency/coins/ecash.dart @@ -222,6 +222,17 @@ class Ecash extends Bip39HDCurrency with ElectrumXCurrencyInterface { // Do not validate "p" (P2SH) addresses. } + @override + AddressType? getAddressType(String address) { + final format = bitbox.Address.detectFormat(address); + + return super.getAddressType( + format == bitbox.Address.formatCashAddr + ? bitbox.Address.toLegacyAddress(address) + : address, + ); + } + @override DerivePathType addressType({required String address}) { Uint8List? decodeBase58; diff --git a/lib/wallets/crypto_currency/interfaces/electrumx_currency_interface.dart b/lib/wallets/crypto_currency/interfaces/electrumx_currency_interface.dart index 9cc01cf64..70929af41 100644 --- a/lib/wallets/crypto_currency/interfaces/electrumx_currency_interface.dart +++ b/lib/wallets/crypto_currency/interfaces/electrumx_currency_interface.dart @@ -1,6 +1,8 @@ import 'package:coinlib_flutter/coinlib_flutter.dart' as cl; +import 'package:flutter/foundation.dart'; import '../../../models/isar/models/blockchain_data/address.dart'; +import '../../../utilities/logger.dart'; import '../intermediate/bip39_hd_currency.dart'; mixin ElectrumXCurrencyInterface on Bip39HDCurrency { @@ -14,15 +16,29 @@ mixin ElectrumXCurrencyInterface on Bip39HDCurrency { try { final clAddress = cl.Address.fromString(address, networkParams); + Logging.instance.t( + "getAddressType($address) type is ${clAddress.runtimeType}", + ); + return switch (clAddress) { cl.P2PKHAddress() => AddressType.p2pkh, - cl.P2WSHAddress() => AddressType.p2sh, + cl.P2SHAddress() => AddressType.p2sh, cl.P2WPKHAddress() => AddressType.p2wpkh, cl.P2TRAddress() => AddressType.p2tr, cl.MwebAddress() => AddressType.mweb, _ => null, }; - } catch (_) { + } catch (e, s) { + if (kDebugMode) { + Logging.instance.e( + "getAddressType($address) failed", + error: e, + stackTrace: s, + ); + } else { + Logging.instance.t("getAddressType($address) failed"); + } + return null; } } diff --git a/lib/wallets/wallet/impl/particl_wallet.dart b/lib/wallets/wallet/impl/particl_wallet.dart index 08e27cc18..4725110af 100644 --- a/lib/wallets/wallet/impl/particl_wallet.dart +++ b/lib/wallets/wallet/impl/particl_wallet.dart @@ -352,8 +352,10 @@ class ParticlWallet @override Future buildTransaction({ required TxData txData, - required covariant List inputsWithKeys, + required List inputsWithKeys, }) async { + final insAndKeys = inputsWithKeys.cast(); + Logging.instance.d("Starting Particl buildTransaction ----------"); // TODO: use coinlib (For this we need coinlib to support particl) @@ -371,8 +373,8 @@ class ParticlWallet ); final List<({Uint8List? output, Uint8List? redeem})> extraData = []; - for (int i = 0; i < inputsWithKeys.length; i++) { - final sd = inputsWithKeys[i]; + for (int i = 0; i < insAndKeys.length; i++) { + final sd = insAndKeys[i]; final pubKey = sd.key!.publicKey.data; final bitcoindart.PaymentData? data; @@ -448,11 +450,11 @@ class ParticlWallet final List tempOutputs = []; // Add inputs. - for (var i = 0; i < inputsWithKeys.length; i++) { - final txid = inputsWithKeys[i].utxo.txid; + for (var i = 0; i < insAndKeys.length; i++) { + final txid = insAndKeys[i].utxo.txid; txb.addInput( txid, - inputsWithKeys[i].utxo.vout, + insAndKeys[i].utxo.vout, null, extraData[i].output!, cryptoCurrency.networkParams.bech32Hrp, @@ -464,14 +466,14 @@ class ParticlWallet scriptSigAsm: null, sequence: 0xffffffff - 1, outpoint: OutpointV2.isarCantDoRequiredInDefaultConstructor( - txid: inputsWithKeys[i].utxo.txid, - vout: inputsWithKeys[i].utxo.vout, + txid: insAndKeys[i].utxo.txid, + vout: insAndKeys[i].utxo.vout, ), addresses: - inputsWithKeys[i].utxo.address == null + insAndKeys[i].utxo.address == null ? [] - : [inputsWithKeys[i].utxo.address!], - valueStringSats: inputsWithKeys[i].utxo.value.toString(), + : [insAndKeys[i].utxo.address!], + valueStringSats: insAndKeys[i].utxo.value.toString(), witness: null, innerRedeemScriptAsm: null, coinbase: null, @@ -508,15 +510,15 @@ class ParticlWallet // Sign. try { - for (var i = 0; i < inputsWithKeys.length; i++) { + for (var i = 0; i < insAndKeys.length; i++) { txb.sign( vin: i, keyPair: bitcoindart.ECPair.fromPrivateKey( - inputsWithKeys[i].key!.privateKey!.data, + insAndKeys[i].key!.privateKey!.data, network: convertedNetwork, - compressed: inputsWithKeys[i].key!.privateKey!.compressed, + compressed: insAndKeys[i].key!.privateKey!.compressed, ), - witnessValue: inputsWithKeys[i].utxo.value, + witnessValue: insAndKeys[i].utxo.value, redeemScript: extraData[i].redeem, overridePrefix: cryptoCurrency.networkParams.bech32Hrp, ); diff --git a/lib/wallets/wallet/wallet_mixin_interfaces/bcash_interface.dart b/lib/wallets/wallet/wallet_mixin_interfaces/bcash_interface.dart index 410f11d2e..0f428ec89 100644 --- a/lib/wallets/wallet/wallet_mixin_interfaces/bcash_interface.dart +++ b/lib/wallets/wallet/wallet_mixin_interfaces/bcash_interface.dart @@ -18,8 +18,10 @@ mixin BCashInterface @override Future buildTransaction({ required TxData txData, - required covariant List inputsWithKeys, + required List inputsWithKeys, }) async { + final insAndKeys = inputsWithKeys.cast(); + Logging.instance.d("Starting buildTransaction ----------"); // TODO: use coinlib @@ -35,11 +37,8 @@ mixin BCashInterface final List tempOutputs = []; // Add transaction inputs - for (int i = 0; i < inputsWithKeys.length; i++) { - builder.addInput( - inputsWithKeys[i].utxo.txid, - inputsWithKeys[i].utxo.vout, - ); + for (int i = 0; i < insAndKeys.length; i++) { + builder.addInput(insAndKeys[i].utxo.txid, insAndKeys[i].utxo.vout); tempInputs.add( InputV2.isarCantDoRequiredInDefaultConstructor( @@ -47,14 +46,14 @@ mixin BCashInterface scriptSigAsm: null, sequence: 0xffffffff - 1, outpoint: OutpointV2.isarCantDoRequiredInDefaultConstructor( - txid: inputsWithKeys[i].utxo.txid, - vout: inputsWithKeys[i].utxo.vout, + txid: insAndKeys[i].utxo.txid, + vout: insAndKeys[i].utxo.vout, ), addresses: - inputsWithKeys[i].utxo.address == null + insAndKeys[i].utxo.address == null ? [] - : [inputsWithKeys[i].utxo.address!], - valueStringSats: inputsWithKeys[i].utxo.value.toString(), + : [insAndKeys[i].utxo.address!], + valueStringSats: insAndKeys[i].utxo.value.toString(), witness: null, innerRedeemScriptAsm: null, coinbase: null, @@ -92,9 +91,9 @@ mixin BCashInterface try { // Sign the transaction accordingly - for (int i = 0; i < inputsWithKeys.length; i++) { + for (int i = 0; i < insAndKeys.length; i++) { final bitboxEC = bitbox.ECPair.fromPrivateKey( - inputsWithKeys[i].key!.privateKey!.data, + insAndKeys[i].key!.privateKey!.data, network: bitbox_utils.Network( cryptoCurrency.networkParams.privHDPrefix, cryptoCurrency.networkParams.pubHDPrefix, @@ -103,10 +102,10 @@ mixin BCashInterface cryptoCurrency.networkParams.wifPrefix, cryptoCurrency.networkParams.p2pkhPrefix, ), - compressed: inputsWithKeys[i].key!.privateKey!.compressed, + compressed: insAndKeys[i].key!.privateKey!.compressed, ); - builder.sign(i, bitboxEC, inputsWithKeys[i].utxo.value); + builder.sign(i, bitboxEC, insAndKeys[i].utxo.value); } } catch (e, s) { Logging.instance.e( diff --git a/pubspec.lock b/pubspec.lock index 39d500ae1..ab6a39710 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -985,10 +985,10 @@ packages: dependency: "direct main" description: name: flutter_mwebd - sha256: f6daecf6a4e10dde0a2fbfe026d801cd41864c6464923d9a26a92c613c893173 + sha256: "73b35b6eaccb6e1be7eb37e04bcc94f091244fa31b8aedc17e4119c580a7a747" url: "https://pub.dev" source: hosted - version: "0.0.1-pre.6" + version: "0.0.1-pre.7" flutter_native_splash: dependency: "direct main" description: diff --git a/scripts/app_config/templates/pubspec.template b/scripts/app_config/templates/pubspec.template index ae6032744..ef0f72984 100644 --- a/scripts/app_config/templates/pubspec.template +++ b/scripts/app_config/templates/pubspec.template @@ -224,7 +224,7 @@ dependencies: path: ^1.9.1 cs_salvium: ^1.2.1 cs_salvium_flutter_libs: ^1.0.4 - flutter_mwebd: ^0.0.1-pre.6 + flutter_mwebd: ^0.0.1-pre.7 mweb_client: ^0.2.0 fixnum: ^1.1.1