diff --git a/lib/pages/send_view/send_view.dart b/lib/pages/send_view/send_view.dart index 9ac52806f..76aebaf33 100644 --- a/lib/pages/send_view/send_view.dart +++ b/lib/pages/send_view/send_view.dart @@ -1222,7 +1222,7 @@ class _SendViewState extends ConsumerState { ), ) && ref.watch(pWallets).getWallet(walletId) is CoinControlInterface && - balType == BalanceType.public; + (showPrivateBalance ? balType == BalanceType.public : true); final isExchangeAddress = ref.watch(pIsExchangeAddress); 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 567f3a94a..dd3a70f9d 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 @@ -1052,7 +1052,7 @@ class _DesktopSendState extends ConsumerState { ), ) && ref.watch(pWallets).getWallet(walletId) is CoinControlInterface && - balType == BalanceType.public; + (showPrivateBalance ? balType == BalanceType.public : true); return Column( crossAxisAlignment: CrossAxisAlignment.start, diff --git a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_send_fee_form.dart b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_send_fee_form.dart index 6b08923ab..69757ac7c 100644 --- a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_send_fee_form.dart +++ b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_send_fee_form.dart @@ -55,7 +55,15 @@ class _DesktopSendFeeFormState extends ConsumerState { bool get isEth => cryptoCurrency is Ethereum; - bool isCustomFee = false; + bool _isCustomFeeValue = false; + bool get _isCustomFee => _isCustomFeeValue; + set _isCustomFee(bool newValue) { + if (_isCustomFeeValue != newValue) { + _isCustomFeeValue = newValue; + widget.onCustomFeeOptionChanged.call(_isCustomFeeValue); + } + } + (FeeRateType, String?, String?)? feeSelectionResult; @override @@ -97,12 +105,12 @@ class _DesktopSendFeeFormState extends ConsumerState { ); if (feeSelectionResult != null) { - if (isCustomFee && + if (_isCustomFee && feeSelectionResult!.$1 != FeeRateType.custom) { - isCustomFee = false; - } else if (!isCustomFee && + _isCustomFee = false; + } else if (!_isCustomFee && feeSelectionResult!.$1 == FeeRateType.custom) { - isCustomFee = true; + _isCustomFee = true; } } @@ -113,7 +121,7 @@ class _DesktopSendFeeFormState extends ConsumerState { ), child: Text( "Transaction fee" - "${isCustomFee ? "" : " (${isEth ? "max" : "estimated"})"}", + "${_isCustomFee ? "" : " (${isEth ? "max" : "estimated"})"}", style: STextStyles.desktopTextExtraSmall(context).copyWith( color: Theme.of( @@ -124,7 +132,7 @@ class _DesktopSendFeeFormState extends ConsumerState { ), ), const SizedBox(height: 10), - if (!isCustomFee) + if (!_isCustomFee) Padding( padding: const EdgeInsets.all(10), child: @@ -275,7 +283,7 @@ class _DesktopSendFeeFormState extends ConsumerState { ], ), ), - if (isCustomFee && isEth) + if (_isCustomFee && isEth) EthFeeForm( minGasLimit: widget.isToken @@ -284,7 +292,7 @@ class _DesktopSendFeeFormState extends ConsumerState { stateChanged: (value) => widget.onCustomEip1559FeeOptionChanged?.call(value), ), - if (isCustomFee && !isEth) + if (_isCustomFee && !isEth) Padding( padding: const EdgeInsets.only(bottom: 12, top: 16), child: FeeSlider( diff --git a/lib/wallets/crypto_currency/coins/bitcoin_frost.dart b/lib/wallets/crypto_currency/coins/bitcoin_frost.dart index 3edaea351..b24316b52 100644 --- a/lib/wallets/crypto_currency/coins/bitcoin_frost.dart +++ b/lib/wallets/crypto_currency/coins/bitcoin_frost.dart @@ -255,6 +255,7 @@ class BitcoinFrost extends FrostCurrency { final clAddress = cl.Address.fromString(address, networkParams); return switch (clAddress) { + cl.P2TRAddress() => AddressType.p2tr, cl.P2PKHAddress() => AddressType.p2pkh, cl.P2WSHAddress() => AddressType.p2sh, cl.P2WPKHAddress() => AddressType.p2wpkh, diff --git a/lib/wallets/crypto_currency/interfaces/electrumx_currency_interface.dart b/lib/wallets/crypto_currency/interfaces/electrumx_currency_interface.dart index c9d0da2b9..9cc01cf64 100644 --- a/lib/wallets/crypto_currency/interfaces/electrumx_currency_interface.dart +++ b/lib/wallets/crypto_currency/interfaces/electrumx_currency_interface.dart @@ -18,6 +18,7 @@ mixin ElectrumXCurrencyInterface on Bip39HDCurrency { cl.P2PKHAddress() => AddressType.p2pkh, cl.P2WSHAddress() => AddressType.p2sh, cl.P2WPKHAddress() => AddressType.p2wpkh, + cl.P2TRAddress() => AddressType.p2tr, cl.MwebAddress() => AddressType.mweb, _ => null, }; diff --git a/lib/wallets/wallet/wallet_mixin_interfaces/mweb_interface.dart b/lib/wallets/wallet/wallet_mixin_interfaces/mweb_interface.dart index a870aaa1e..4480ef81b 100644 --- a/lib/wallets/wallet/wallet_mixin_interfaces/mweb_interface.dart +++ b/lib/wallets/wallet/wallet_mixin_interfaces/mweb_interface.dart @@ -216,17 +216,28 @@ mixin MwebInterface (e) => e.outputId.equals(utxo.outputId), )).getSingleOrNull(); - final newUtxo = MwebUtxosCompanion( - outputId: Value(prev?.outputId ?? utxo.outputId), - address: Value(prev?.address ?? utxo.address), - value: Value(utxo.value.toInt()), - height: Value(utxo.height), - blockTime: Value(utxo.blockTime), - blocked: Value(prev?.blocked ?? false), - used: Value(prev?.used ?? false), - ); + if (prev == null) { + final newUtxo = MwebUtxosCompanion( + outputId: Value(utxo.outputId), + address: Value(utxo.address), + value: Value(utxo.value.toInt()), + height: Value(utxo.height), + blockTime: Value(utxo.blockTime), + blocked: const Value(false), + used: const Value(false), + ); - await db.into(db.mwebUtxos).insertOnConflictUpdate(newUtxo); + await db.into(db.mwebUtxos).insert(newUtxo); + } else { + await db + .update(db.mwebUtxos) + .replace( + prev.copyWith( + blockTime: utxo.blockTime, + height: utxo.height, + ), + ); + } }); Address? addr = await mainDB.getAddress(walletId, utxo.address); @@ -469,7 +480,19 @@ mixin MwebInterface ); // Update used mweb utxos as used in database - await _checkSpentMwebUtxos(); + final usedMwebUtxos = + txData.usedUTXOs!.whereType().map((e) => e.utxo).toList(); + + Logging.instance.i("Used mweb inputs: $usedMwebUtxos"); + + if (usedMwebUtxos.isNotEmpty) { + final db = Drift.get(walletId); + await db.transaction(() async { + for (final used in usedMwebUtxos) { + await db.update(db.mwebUtxos).replace(used); + } + }); + } return await updateSentCachedTxData(txData: txData); } catch (e, s) { @@ -583,35 +606,6 @@ mixin MwebInterface } } - Future _checkSpentMwebUtxos() async { - try { - final db = Drift.get(walletId); - final mwebUtxos = await db.select(db.mwebUtxos).get(); - - final client = await _client; - - final spent = await client.spent( - SpentRequest(outputId: mwebUtxos.map((e) => e.outputId)), - ); - - await db.transaction(() async { - for (final utxo in mwebUtxos) { - await db - .into(db.mwebUtxos) - .insertOnConflictUpdate( - utxo - .toCompanion(false) - .copyWith( - used: Value(spent.outputId.contains(utxo.outputId)), - ), - ); - } - }); - } catch (e, s) { - Logging.instance.e("_checkSpentMwebUtxos()", error: e, stackTrace: s); - } - } - Future _checkAddresses() async { // check change first as it is index 0 Address? changeAddress = await getMwebChangeAddress(); @@ -667,8 +661,6 @@ mixin MwebInterface if (info.isMwebEnabled) { final start = DateTime.now(); try { - await _checkSpentMwebUtxos(); - final currentHeight = await chainHeight; final db = Drift.get(walletId); final mwebUtxos = diff --git a/pubspec.lock b/pubspec.lock index 66cfe0e85..39d500ae1 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -532,18 +532,18 @@ packages: dependency: "direct main" description: name: cs_salvium - sha256: "5711a9b547e9e5ba1d91e1c6b37ba94803b0b7c6ef56baf245b270e2a637b839" + sha256: "838a2f21b0ad567f68a5294360c4c96727b722037ae7bfdc26651c99d6c26bd3" url: "https://pub.dev" source: hosted - version: "1.2.0" + version: "1.2.1" cs_salvium_flutter_libs: dependency: "direct main" description: name: cs_salvium_flutter_libs - sha256: cb2759e3d0829251cb13daa9e012f7821d9717ec1f1dedc9329c4012f99f386c + sha256: d1e49ed67632f77d863ad3eafc78db8867f155cf9decf156345ec75c92e0d026 url: "https://pub.dev" source: hosted - version: "1.0.2" + version: "1.0.4" cs_salvium_flutter_libs_android: dependency: transitive description: @@ -580,10 +580,10 @@ packages: dependency: transitive description: name: cs_salvium_flutter_libs_ios - sha256: "4c11cc7499ca7d3a8c0f2b29fcb4eaf4cd1475c5752f34856a3d4c0b721a6319" + sha256: "54d18fbac60c8a602e4d0f967ea7d02fab71bff3e032f9576e159229ce372534" url: "https://pub.dev" source: hosted - version: "1.0.1" + version: "1.1.1" cs_salvium_flutter_libs_linux: dependency: transitive description: diff --git a/scripts/app_config/templates/pubspec.template b/scripts/app_config/templates/pubspec.template index 4e60e7857..ae6032744 100644 --- a/scripts/app_config/templates/pubspec.template +++ b/scripts/app_config/templates/pubspec.template @@ -222,8 +222,8 @@ dependencies: drift: ^2.22.1 drift_flutter: ^0.2.3 path: ^1.9.1 - cs_salvium: ^1.2.0 - cs_salvium_flutter_libs: ^1.0.2 + cs_salvium: ^1.2.1 + cs_salvium_flutter_libs: ^1.0.4 flutter_mwebd: ^0.0.1-pre.6 mweb_client: ^0.2.0 fixnum: ^1.1.1