From 7bbc235b9268eb2887f6aa6d833904a2beddf82b Mon Sep 17 00:00:00 2001 From: julian Date: Fri, 5 Jan 2024 13:45:42 -0600 Subject: [PATCH] don't show change in amount total --- .../confirm_change_now_send.dart | 14 +++--- .../exchange_step_views/step_4_view.dart | 16 ++++++- lib/pages/exchange_view/send_from_view.dart | 6 +-- .../send_view/confirm_transaction_view.dart | 39 ++++++++------- lib/pages/send_view/send_view.dart | 35 ++++++++++++-- lib/pages/send_view/token_send_view.dart | 1 + .../wallet_view/sub_widgets/desktop_send.dart | 35 ++++++++++++-- .../sub_widgets/desktop_token_send.dart | 1 + ...public_private_balance_state_provider.dart | 2 +- lib/wallets/api/lelantus_ffi_wrapper.dart | 5 +- lib/wallets/models/tx_data.dart | 28 ++++++++++- lib/wallets/wallet/impl/tezos_wallet.dart | 1 + lib/wallets/wallet/impl/wownero_wallet.dart | 1 + .../electrumx_interface.dart | 48 ++++++++++++------- .../lelantus_interface.dart | 1 + .../paynym_interface.dart | 9 +++- .../spark_interface.dart | 11 ++++- 17 files changed, 192 insertions(+), 61 deletions(-) diff --git a/lib/pages/exchange_view/confirm_change_now_send.dart b/lib/pages/exchange_view/confirm_change_now_send.dart index a9cc410ab..60d543719 100644 --- a/lib/pages/exchange_view/confirm_change_now_send.dart +++ b/lib/pages/exchange_view/confirm_change_now_send.dart @@ -421,7 +421,7 @@ class _ConfirmChangeNowSendViewState builder: (context) { final coin = ref.read(pWalletCoin(walletId)); final fee = widget.txData.fee!; - final amount = widget.txData.amount!; + final amount = widget.txData.amountWithoutChange!; final total = amount + fee; return Text( @@ -580,9 +580,11 @@ class _ConfirmChangeNowSendViewState final price = ref.watch( priceAnd24hChangeNotifierProvider .select((value) => value.getPrice(coin))); - final amount = widget.txData.amount!; - final value = (price.item1 * amount.decimal) - .toAmount(fractionDigits: 2); + final amountWithoutChange = + widget.txData.amountWithoutChange!; + final value = + (price.item1 * amountWithoutChange.decimal) + .toAmount(fractionDigits: 2); final currency = ref.watch(prefsChangeNotifierProvider .select((value) => value.currency)); final locale = ref.watch( @@ -608,7 +610,7 @@ class _ConfirmChangeNowSendViewState ref .watch(pAmountFormatter( ref.watch(pWalletCoin(walletId)))) - .format((widget.txData.amount!)), + .format((widget.txData.amountWithoutChange!)), style: STextStyles.itemSubtitle12(context), textAlign: TextAlign.right, ), @@ -722,7 +724,7 @@ class _ConfirmChangeNowSendViewState builder: (context) { final coin = ref.watch(pWalletCoin(walletId)); final fee = widget.txData.fee!; - final amount = widget.txData.amount!; + final amount = widget.txData.amountWithoutChange!; final total = amount + fee; return Text( diff --git a/lib/pages/exchange_view/exchange_step_views/step_4_view.dart b/lib/pages/exchange_view/exchange_step_views/step_4_view.dart index 146e85673..874f57385 100644 --- a/lib/pages/exchange_view/exchange_step_views/step_4_view.dart +++ b/lib/pages/exchange_view/exchange_step_views/step_4_view.dart @@ -241,10 +241,18 @@ class _Step4ViewState extends ConsumerState { Future txDataFuture; + // TODO: [prio=high] Firo spark + if (wallet is FiroWallet && !firoPublicSend) { txDataFuture = wallet.prepareSendLelantus( txData: TxData( - recipients: [(address: address, amount: amount)], + recipients: [ + ( + address: address, + amount: amount, + isChange: false, + ) + ], note: "${model.trade!.payInCurrency.toUpperCase()}/" "${model.trade!.payOutCurrency.toUpperCase()} exchange", ), @@ -259,7 +267,11 @@ class _Step4ViewState extends ConsumerState { txDataFuture = wallet.prepareSend( txData: TxData( recipients: [ - (address: address, amount: amount), + ( + address: address, + amount: amount, + isChange: false, + ), ], memo: memo, feeRateType: FeeRateType.average, diff --git a/lib/pages/exchange_view/send_from_view.dart b/lib/pages/exchange_view/send_from_view.dart index 9c8ce9c48..1fbed82eb 100644 --- a/lib/pages/exchange_view/send_from_view.dart +++ b/lib/pages/exchange_view/send_from_view.dart @@ -287,7 +287,7 @@ class _SendFromCardState extends ConsumerState { recipients: [ ( address: address, - amount: amount, + amount: amount, isChange: false, ), ], memo: memo, @@ -303,7 +303,7 @@ class _SendFromCardState extends ConsumerState { recipients: [ ( address: address, - amount: amount, + amount: amount, isChange: false, ), ], feeRateType: FeeRateType.average, @@ -315,7 +315,7 @@ class _SendFromCardState extends ConsumerState { recipients: [ ( address: address, - amount: amount, + amount: amount, isChange: false, ), ], // feeRateType: FeeRateType.average, diff --git a/lib/pages/send_view/confirm_transaction_view.dart b/lib/pages/send_view/confirm_transaction_view.dart index c23a9dc14..4292443de 100644 --- a/lib/pages/send_view/confirm_transaction_view.dart +++ b/lib/pages/send_view/confirm_transaction_view.dart @@ -351,7 +351,7 @@ class _ConfirmTransactionViewState } final Amount? fee; - final Amount amount; + final Amount amountWithoutChange; final wallet = ref.watch(pWallets).getWallet(walletId); @@ -362,33 +362,33 @@ class _ConfirmTransactionViewState fee = widget.txData.sparkMints! .map((e) => e.fee!) .reduce((value, element) => value += element); - amount = widget.txData.sparkMints! + amountWithoutChange = widget.txData.sparkMints! .map((e) => e.amountSpark!) .reduce((value, element) => value += element); } else { fee = widget.txData.fee; - amount = widget.txData.amount!; + amountWithoutChange = widget.txData.amountWithoutChange!; } break; case FiroType.lelantus: fee = widget.txData.fee; - amount = widget.txData.amount!; + amountWithoutChange = widget.txData.amountWithoutChange!; break; case FiroType.spark: fee = widget.txData.fee; - amount = (widget.txData.amount ?? + amountWithoutChange = (widget.txData.amountWithoutChange ?? Amount.zeroWith( fractionDigits: wallet.cryptoCurrency.fractionDigits)) + - (widget.txData.amountSpark ?? + (widget.txData.amountSparkWithoutChange ?? Amount.zeroWith( fractionDigits: wallet.cryptoCurrency.fractionDigits)); break; } } else { fee = widget.txData.fee; - amount = widget.txData.amount!; + amountWithoutChange = widget.txData.amountWithoutChange!; } return ConditionalParent( @@ -516,7 +516,7 @@ class _ConfirmTransactionViewState ), SelectableText( ref.watch(pAmountFormatter(coin)).format( - amount, + amountWithoutChange, ethContract: ref .watch(tokenServiceProvider) ?.tokenContract, @@ -719,14 +719,15 @@ class _ConfirmTransactionViewState .getPrice(coin) .item1; if (price > Decimal.zero) { - fiatAmount = (amount.decimal * price) - .toAmount(fractionDigits: 2) - .fiatString( - locale: ref - .read( - localeServiceChangeNotifierProvider) - .locale, - ); + fiatAmount = + (amountWithoutChange.decimal * price) + .toAmount(fractionDigits: 2) + .fiatString( + locale: ref + .read( + localeServiceChangeNotifierProvider) + .locale, + ); } } @@ -734,7 +735,7 @@ class _ConfirmTransactionViewState children: [ SelectableText( ref.watch(pAmountFormatter(coin)).format( - amount, + amountWithoutChange, ethContract: ref .read(tokenServiceProvider) ?.tokenContract), @@ -1128,7 +1129,9 @@ class _ConfirmTransactionViewState ), ), SelectableText( - ref.watch(pAmountFormatter(coin)).format(amount + fee!), + ref + .watch(pAmountFormatter(coin)) + .format(amountWithoutChange + fee!), style: isDesktop ? STextStyles.desktopTextExtraExtraSmall(context) .copyWith( diff --git a/lib/pages/send_view/send_view.dart b/lib/pages/send_view/send_view.dart index f752ce4b4..3cc213dd9 100644 --- a/lib/pages/send_view/send_view.dart +++ b/lib/pages/send_view/send_view.dart @@ -644,6 +644,7 @@ class _SendViewState extends ConsumerState { ( address: widget.accountLite!.code, amount: amount, + isChange: false, ) ], satsPerVByte: isCustomFee ? customFeeRate : null, @@ -666,6 +667,7 @@ class _SendViewState extends ConsumerState { address: _address!, amount: amount, memo: memoController.text, + isChange: false, ) ], feeRateType: ref.read(feeRateTypeStateProvider), @@ -680,7 +682,13 @@ class _SendViewState extends ConsumerState { } else { txDataFuture = wallet.prepareSend( txData: TxData( - recipients: [(address: _address!, amount: amount)], + recipients: [ + ( + address: _address!, + amount: amount, + isChange: false, + ) + ], feeRateType: ref.read(feeRateTypeStateProvider), satsPerVByte: isCustomFee ? customFeeRate : null, utxos: (wallet is CoinControlInterface && @@ -696,7 +704,13 @@ class _SendViewState extends ConsumerState { case FiroType.lelantus: txDataFuture = wallet.prepareSendLelantus( txData: TxData( - recipients: [(address: _address!, amount: amount)], + recipients: [ + ( + address: _address!, + amount: amount, + isChange: false, + ) + ], ), ); break; @@ -706,13 +720,20 @@ class _SendViewState extends ConsumerState { txData: TxData( recipients: ref.read(pValidSparkSendToAddress) ? null - : [(address: _address!, amount: amount)], + : [ + ( + address: _address!, + amount: amount, + isChange: false, + ) + ], sparkRecipients: ref.read(pValidSparkSendToAddress) ? [ ( address: _address!, amount: amount, memo: memoController.text, + isChange: false, ) ] : null, @@ -726,7 +747,13 @@ class _SendViewState extends ConsumerState { : null; txDataFuture = wallet.prepareSend( txData: TxData( - recipients: [(address: _address!, amount: amount)], + recipients: [ + ( + address: _address!, + amount: amount, + isChange: false, + ) + ], memo: memo, feeRateType: ref.read(feeRateTypeStateProvider), satsPerVByte: isCustomFee ? customFeeRate : null, diff --git a/lib/pages/send_view/token_send_view.dart b/lib/pages/send_view/token_send_view.dart index 4ba5ff920..8fd1312c0 100644 --- a/lib/pages/send_view/token_send_view.dart +++ b/lib/pages/send_view/token_send_view.dart @@ -482,6 +482,7 @@ class _TokenSendViewState extends ConsumerState { ( address: _address!, amount: amount, + isChange: false, ) ], feeRateType: ref.read(feeRateTypeStateProvider), 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 2884c9d1a..3df9da05d 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 @@ -304,6 +304,7 @@ class _DesktopSendState extends ConsumerState { ( address: widget.accountLite!.code, amount: amount, + isChange: false, ) ], satsPerVByte: isCustomFee ? customFeeRate : null, @@ -326,6 +327,7 @@ class _DesktopSendState extends ConsumerState { address: _address!, amount: amount, memo: memoController.text, + isChange: false, ) ], feeRateType: ref.read(feeRateTypeStateProvider), @@ -340,7 +342,13 @@ class _DesktopSendState extends ConsumerState { } else { txDataFuture = wallet.prepareSend( txData: TxData( - recipients: [(address: _address!, amount: amount)], + recipients: [ + ( + address: _address!, + amount: amount, + isChange: false, + ) + ], feeRateType: ref.read(feeRateTypeStateProvider), satsPerVByte: isCustomFee ? customFeeRate : null, utxos: (wallet is CoinControlInterface && @@ -356,7 +364,13 @@ class _DesktopSendState extends ConsumerState { case FiroType.lelantus: txDataFuture = wallet.prepareSendLelantus( txData: TxData( - recipients: [(address: _address!, amount: amount)], + recipients: [ + ( + address: _address!, + amount: amount, + isChange: false, + ) + ], ), ); break; @@ -366,13 +380,20 @@ class _DesktopSendState extends ConsumerState { txData: TxData( recipients: ref.read(pValidSparkSendToAddress) ? null - : [(address: _address!, amount: amount)], + : [ + ( + address: _address!, + amount: amount, + isChange: false, + ) + ], sparkRecipients: ref.read(pValidSparkSendToAddress) ? [ ( address: _address!, amount: amount, memo: memoController.text, + isChange: false, ) ] : null, @@ -384,7 +405,13 @@ class _DesktopSendState extends ConsumerState { final memo = isStellar ? memoController.text : null; txDataFuture = wallet.prepareSend( txData: TxData( - recipients: [(address: _address!, amount: amount)], + recipients: [ + ( + address: _address!, + amount: amount, + isChange: false, + ) + ], memo: memo, feeRateType: ref.read(feeRateTypeStateProvider), satsPerVByte: isCustomFee ? customFeeRate : null, diff --git a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_token_send.dart b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_token_send.dart index 06229a757..d0b0bf475 100644 --- a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_token_send.dart +++ b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_token_send.dart @@ -243,6 +243,7 @@ class _DesktopTokenSendState extends ConsumerState { ( address: _address!, amount: amount, + isChange: false, ) ], feeRateType: ref.read(feeRateTypeStateProvider), diff --git a/lib/providers/wallet/public_private_balance_state_provider.dart b/lib/providers/wallet/public_private_balance_state_provider.dart index 503aa40f2..8fa012edb 100644 --- a/lib/providers/wallet/public_private_balance_state_provider.dart +++ b/lib/providers/wallet/public_private_balance_state_provider.dart @@ -17,4 +17,4 @@ enum FiroType { } final publicPrivateBalanceStateProvider = - StateProvider((_) => FiroType.lelantus); + StateProvider((_) => FiroType.spark); diff --git a/lib/wallets/api/lelantus_ffi_wrapper.dart b/lib/wallets/api/lelantus_ffi_wrapper.dart index 7271fd308..ef70b801f 100644 --- a/lib/wallets/api/lelantus_ffi_wrapper.dart +++ b/lib/wallets/api/lelantus_ffi_wrapper.dart @@ -300,6 +300,7 @@ abstract final class LelantusFfiWrapper { }) arg) async { final spendAmount = arg.txData.recipients!.first.amount.raw.toInt(); final address = arg.txData.recipients!.first.address; + final isChange = arg.txData.recipients!.first.isChange; final estimateJoinSplitFee = await _estimateJoinSplitFee( ( @@ -465,7 +466,9 @@ abstract final class LelantusFfiWrapper { return arg.txData.copyWith( txid: txId, raw: txHex, - recipients: [(address: address, amount: amountAmount)], + recipients: [ + (address: address, amount: amountAmount, isChange: isChange) + ], fee: Amount( rawValue: BigInt.from(fee), fractionDigits: arg.cryptoCurrency.fractionDigits, diff --git a/lib/wallets/models/tx_data.dart b/lib/wallets/models/tx_data.dart index 1469196cf..c8621d623 100644 --- a/lib/wallets/models/tx_data.dart +++ b/lib/wallets/models/tx_data.dart @@ -25,7 +25,7 @@ class TxData { final String? memo; - final List<({String address, Amount amount})>? recipients; + final List<({String address, Amount amount, bool isChange})>? recipients; final Set? utxos; final List? usedUTXOs; @@ -62,6 +62,7 @@ class TxData { String address, Amount amount, String memo, + bool isChange, })>? sparkRecipients; final List? sparkMints; @@ -115,6 +116,22 @@ class TxData { .reduce((total, amount) => total += amount) : null; + Amount? get amountWithoutChange => + recipients != null && recipients!.isNotEmpty + ? recipients! + .where((e) => !e.isChange) + .map((e) => e.amount) + .reduce((total, amount) => total += amount) + : null; + + Amount? get amountSparkWithoutChange => + sparkRecipients != null && sparkRecipients!.isNotEmpty + ? sparkRecipients! + .where((e) => !e.isChange) + .map((e) => e.amount) + .reduce((total, amount) => total += amount) + : null; + int? get estimatedSatsPerVByte => fee != null && vSize != null ? (fee!.raw ~/ BigInt.from(vSize!)).toInt() : null; @@ -133,7 +150,13 @@ class TxData { String? memo, Set? utxos, List? usedUTXOs, - List<({String address, Amount amount})>? recipients, + List< + ({ + String address, + Amount amount, + bool isChange, + })>? + recipients, String? frostMSConfig, String? changeAddress, PaynymAccountLite? paynymAccountLite, @@ -154,6 +177,7 @@ class TxData { String address, Amount amount, String memo, + bool isChange, })>? sparkRecipients, List? sparkMints, diff --git a/lib/wallets/wallet/impl/tezos_wallet.dart b/lib/wallets/wallet/impl/tezos_wallet.dart index 794c40006..72cd498fe 100644 --- a/lib/wallets/wallet/impl/tezos_wallet.dart +++ b/lib/wallets/wallet/impl/tezos_wallet.dart @@ -237,6 +237,7 @@ class TezosWallet extends Bip39Wallet { ( amount: sendAmount, address: txData.recipients!.first.address, + isChange: txData.recipients!.first.isChange, ) ], // fee: fee, diff --git a/lib/wallets/wallet/impl/wownero_wallet.dart b/lib/wallets/wallet/impl/wownero_wallet.dart index c7df2eebc..8f5747d68 100644 --- a/lib/wallets/wallet/impl/wownero_wallet.dart +++ b/lib/wallets/wallet/impl/wownero_wallet.dart @@ -111,6 +111,7 @@ class WowneroWallet extends CryptonoteWallet with MultiAddressInterface { address: "WW3iVcnoAY6K9zNdU4qmdvZELefx6xZz4PMpTwUifRkvMQckyadhSPYMVPJhBdYE8P9c27fg9RPmVaWNFx1cDaj61HnetqBiy", amount: amount, + isChange: false, ), ], feeRateType: feeRateType, diff --git a/lib/wallets/wallet/wallet_mixin_interfaces/electrumx_interface.dart b/lib/wallets/wallet/wallet_mixin_interfaces/electrumx_interface.dart index de95b7e38..00754cd5a 100644 --- a/lib/wallets/wallet/wallet_mixin_interfaces/electrumx_interface.dart +++ b/lib/wallets/wallet/wallet_mixin_interfaces/electrumx_interface.dart @@ -35,18 +35,30 @@ mixin ElectrumXInterface on Bip39HDWallet { (_serverVersion != null && _serverVersion! >= 1.6) || cryptoCurrency is Firo; - List<({String address, Amount amount})> _helperRecipientsConvert( - List addrs, List satValues) { - final List<({String address, Amount amount})> results = []; + Future> + _helperRecipientsConvert(List addrs, List satValues) async { + final List<({String address, Amount amount, bool isChange})> results = []; for (int i = 0; i < addrs.length; i++) { - results.add(( - address: addrs[i], - amount: Amount( - rawValue: BigInt.from(satValues[i]), - fractionDigits: cryptoCurrency.fractionDigits, + results.add( + ( + address: addrs[i], + amount: Amount( + rawValue: BigInt.from(satValues[i]), + fractionDigits: cryptoCurrency.fractionDigits, + ), + isChange: (await mainDB.isar.addresses + .where() + .walletIdEqualTo(walletId) + .filter() + .subTypeEqualTo(AddressSubType.change) + .and() + .valueEqualTo(addrs[i]) + .valueProperty() + .findFirst()) != + null ), - )); + ); } return results; @@ -178,7 +190,7 @@ mixin ElectrumXInterface on Bip39HDWallet { final int vSizeForOneOutput = (await buildTransaction( utxoSigningData: utxoSigningData, txData: txData.copyWith( - recipients: _helperRecipientsConvert( + recipients: await _helperRecipientsConvert( [recipientAddress], [satoshisBeingUsed - 1], ), @@ -206,7 +218,7 @@ mixin ElectrumXInterface on Bip39HDWallet { final int amount = satoshiAmountToSend - feeForOneOutput; final data = await buildTransaction( txData: txData.copyWith( - recipients: _helperRecipientsConvert( + recipients: await _helperRecipientsConvert( [recipientAddress], [amount], ), @@ -228,7 +240,7 @@ mixin ElectrumXInterface on Bip39HDWallet { vSizeForOneOutput = (await buildTransaction( utxoSigningData: utxoSigningData, txData: txData.copyWith( - recipients: _helperRecipientsConvert( + recipients: await _helperRecipientsConvert( [recipientAddress], [satoshisBeingUsed - 1], ), @@ -245,7 +257,7 @@ mixin ElectrumXInterface on Bip39HDWallet { vSizeForTwoOutPuts = (await buildTransaction( utxoSigningData: utxoSigningData, txData: txData.copyWith( - recipients: _helperRecipientsConvert( + recipients: await _helperRecipientsConvert( [recipientAddress, (await getCurrentChangeAddress())!.value], [ satoshiAmountToSend, @@ -321,7 +333,7 @@ mixin ElectrumXInterface on Bip39HDWallet { var txn = await buildTransaction( utxoSigningData: utxoSigningData, txData: txData.copyWith( - recipients: _helperRecipientsConvert( + recipients: await _helperRecipientsConvert( recipientsArray, recipientsAmtArray, ), @@ -352,7 +364,7 @@ mixin ElectrumXInterface on Bip39HDWallet { txn = await buildTransaction( utxoSigningData: utxoSigningData, txData: txData.copyWith( - recipients: _helperRecipientsConvert( + recipients: await _helperRecipientsConvert( recipientsArray, recipientsAmtArray, ), @@ -383,7 +395,7 @@ mixin ElectrumXInterface on Bip39HDWallet { final txn = await buildTransaction( utxoSigningData: utxoSigningData, txData: txData.copyWith( - recipients: _helperRecipientsConvert( + recipients: await _helperRecipientsConvert( recipientsArray, recipientsAmtArray, ), @@ -415,7 +427,7 @@ mixin ElectrumXInterface on Bip39HDWallet { final txn = await buildTransaction( utxoSigningData: utxoSigningData, txData: txData.copyWith( - recipients: _helperRecipientsConvert( + recipients: await _helperRecipientsConvert( recipientsArray, recipientsAmtArray, ), @@ -447,7 +459,7 @@ mixin ElectrumXInterface on Bip39HDWallet { final txn = await buildTransaction( utxoSigningData: utxoSigningData, txData: txData.copyWith( - recipients: _helperRecipientsConvert( + recipients: await _helperRecipientsConvert( recipientsArray, recipientsAmtArray, ), diff --git a/lib/wallets/wallet/wallet_mixin_interfaces/lelantus_interface.dart b/lib/wallets/wallet/wallet_mixin_interfaces/lelantus_interface.dart index a4dec9157..a3d505c48 100644 --- a/lib/wallets/wallet/wallet_mixin_interfaces/lelantus_interface.dart +++ b/lib/wallets/wallet/wallet_mixin_interfaces/lelantus_interface.dart @@ -800,6 +800,7 @@ mixin LelantusInterface on Bip39HDWallet, ElectrumXInterface { fractionDigits: cryptoCurrency.fractionDigits, ), address: "no address for lelantus mints", + isChange: false, ) ], vSize: builtHex.virtualSize(), diff --git a/lib/wallets/wallet/wallet_mixin_interfaces/paynym_interface.dart b/lib/wallets/wallet/wallet_mixin_interfaces/paynym_interface.dart index 54bf6661e..81c8661e4 100644 --- a/lib/wallets/wallet/wallet_mixin_interfaces/paynym_interface.dart +++ b/lib/wallets/wallet/wallet_mixin_interfaces/paynym_interface.dart @@ -370,6 +370,7 @@ mixin PaynymInterface on Bip39HDWallet, ElectrumXInterface { ( address: sendToAddress.value, amount: txData.recipients!.first.amount, + isChange: false, ), ], ), @@ -582,7 +583,11 @@ mixin PaynymInterface on Bip39HDWallet, ElectrumXInterface { final txData = TxData( raw: txn.item1, recipients: [ - (address: targetPaymentCodeString, amount: amountToSend) + ( + address: targetPaymentCodeString, + amount: amountToSend, + isChange: false, + ), ], fee: Amount( rawValue: feeBeingPaid, @@ -610,6 +615,7 @@ mixin PaynymInterface on Bip39HDWallet, ElectrumXInterface { ( address: targetPaymentCodeString, amount: amountToSend, + isChange: false, ) ], fee: Amount( @@ -639,6 +645,7 @@ mixin PaynymInterface on Bip39HDWallet, ElectrumXInterface { ( address: targetPaymentCodeString, amount: amountToSend, + isChange: false, ) ], fee: Amount( diff --git a/lib/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart b/lib/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart index c2d8e8ba3..b31a86a9b 100644 --- a/lib/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart +++ b/lib/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart @@ -283,12 +283,18 @@ mixin SparkInterface on Bip39HDWallet, ElectrumXInterface { txb.setLockTime(await chainHeight); txb.setVersion(3 | (9 << 16)); - List<({String address, Amount amount})>? recipientsWithFeeSubtracted; + List< + ({ + String address, + Amount amount, + bool isChange, + })>? recipientsWithFeeSubtracted; List< ({ String address, Amount amount, String memo, + bool isChange, })>? sparkRecipientsWithFeeSubtracted; final recipientCount = (txData.recipients ?.where( @@ -330,6 +336,7 @@ mixin SparkInterface on Bip39HDWallet, ElectrumXInterface { fractionDigits: cryptoCurrency.fractionDigits, ), memo: txData.sparkRecipients![i].memo, + isChange: sparkChangeAddress == txData.sparkRecipients![i].address, ), ); } @@ -350,6 +357,7 @@ mixin SparkInterface on Bip39HDWallet, ElectrumXInterface { (estimatedFee ~/ BigInt.from(totalRecipientCount)), fractionDigits: cryptoCurrency.fractionDigits, ), + isChange: txData.recipients![i].isChange, ), ); @@ -1157,6 +1165,7 @@ mixin SparkInterface on Bip39HDWallet, ElectrumXInterface { rawValue: BigInt.from(e.$2), fractionDigits: cryptoCurrency.fractionDigits, ), + isChange: false, // ok? ), ) .toList(),