don't show change in amount total

This commit is contained in:
julian 2024-01-05 13:45:42 -06:00
parent 8ff9227e48
commit 7bbc235b92
17 changed files with 192 additions and 61 deletions

View file

@ -421,7 +421,7 @@ class _ConfirmChangeNowSendViewState
builder: (context) { builder: (context) {
final coin = ref.read(pWalletCoin(walletId)); final coin = ref.read(pWalletCoin(walletId));
final fee = widget.txData.fee!; final fee = widget.txData.fee!;
final amount = widget.txData.amount!; final amount = widget.txData.amountWithoutChange!;
final total = amount + fee; final total = amount + fee;
return Text( return Text(
@ -580,9 +580,11 @@ class _ConfirmChangeNowSendViewState
final price = ref.watch( final price = ref.watch(
priceAnd24hChangeNotifierProvider priceAnd24hChangeNotifierProvider
.select((value) => value.getPrice(coin))); .select((value) => value.getPrice(coin)));
final amount = widget.txData.amount!; final amountWithoutChange =
final value = (price.item1 * amount.decimal) widget.txData.amountWithoutChange!;
.toAmount(fractionDigits: 2); final value =
(price.item1 * amountWithoutChange.decimal)
.toAmount(fractionDigits: 2);
final currency = ref.watch(prefsChangeNotifierProvider final currency = ref.watch(prefsChangeNotifierProvider
.select((value) => value.currency)); .select((value) => value.currency));
final locale = ref.watch( final locale = ref.watch(
@ -608,7 +610,7 @@ class _ConfirmChangeNowSendViewState
ref ref
.watch(pAmountFormatter( .watch(pAmountFormatter(
ref.watch(pWalletCoin(walletId)))) ref.watch(pWalletCoin(walletId))))
.format((widget.txData.amount!)), .format((widget.txData.amountWithoutChange!)),
style: STextStyles.itemSubtitle12(context), style: STextStyles.itemSubtitle12(context),
textAlign: TextAlign.right, textAlign: TextAlign.right,
), ),
@ -722,7 +724,7 @@ class _ConfirmChangeNowSendViewState
builder: (context) { builder: (context) {
final coin = ref.watch(pWalletCoin(walletId)); final coin = ref.watch(pWalletCoin(walletId));
final fee = widget.txData.fee!; final fee = widget.txData.fee!;
final amount = widget.txData.amount!; final amount = widget.txData.amountWithoutChange!;
final total = amount + fee; final total = amount + fee;
return Text( return Text(

View file

@ -241,10 +241,18 @@ class _Step4ViewState extends ConsumerState<Step4View> {
Future<TxData> txDataFuture; Future<TxData> txDataFuture;
// TODO: [prio=high] Firo spark
if (wallet is FiroWallet && !firoPublicSend) { if (wallet is FiroWallet && !firoPublicSend) {
txDataFuture = wallet.prepareSendLelantus( txDataFuture = wallet.prepareSendLelantus(
txData: TxData( txData: TxData(
recipients: [(address: address, amount: amount)], recipients: [
(
address: address,
amount: amount,
isChange: false,
)
],
note: "${model.trade!.payInCurrency.toUpperCase()}/" note: "${model.trade!.payInCurrency.toUpperCase()}/"
"${model.trade!.payOutCurrency.toUpperCase()} exchange", "${model.trade!.payOutCurrency.toUpperCase()} exchange",
), ),
@ -259,7 +267,11 @@ class _Step4ViewState extends ConsumerState<Step4View> {
txDataFuture = wallet.prepareSend( txDataFuture = wallet.prepareSend(
txData: TxData( txData: TxData(
recipients: [ recipients: [
(address: address, amount: amount), (
address: address,
amount: amount,
isChange: false,
),
], ],
memo: memo, memo: memo,
feeRateType: FeeRateType.average, feeRateType: FeeRateType.average,

View file

@ -287,7 +287,7 @@ class _SendFromCardState extends ConsumerState<SendFromCard> {
recipients: [ recipients: [
( (
address: address, address: address,
amount: amount, amount: amount, isChange: false,
), ),
], ],
memo: memo, memo: memo,
@ -303,7 +303,7 @@ class _SendFromCardState extends ConsumerState<SendFromCard> {
recipients: [ recipients: [
( (
address: address, address: address,
amount: amount, amount: amount, isChange: false,
), ),
], ],
feeRateType: FeeRateType.average, feeRateType: FeeRateType.average,
@ -315,7 +315,7 @@ class _SendFromCardState extends ConsumerState<SendFromCard> {
recipients: [ recipients: [
( (
address: address, address: address,
amount: amount, amount: amount, isChange: false,
), ),
], ],
// feeRateType: FeeRateType.average, // feeRateType: FeeRateType.average,

View file

@ -351,7 +351,7 @@ class _ConfirmTransactionViewState
} }
final Amount? fee; final Amount? fee;
final Amount amount; final Amount amountWithoutChange;
final wallet = ref.watch(pWallets).getWallet(walletId); final wallet = ref.watch(pWallets).getWallet(walletId);
@ -362,33 +362,33 @@ class _ConfirmTransactionViewState
fee = widget.txData.sparkMints! fee = widget.txData.sparkMints!
.map((e) => e.fee!) .map((e) => e.fee!)
.reduce((value, element) => value += element); .reduce((value, element) => value += element);
amount = widget.txData.sparkMints! amountWithoutChange = widget.txData.sparkMints!
.map((e) => e.amountSpark!) .map((e) => e.amountSpark!)
.reduce((value, element) => value += element); .reduce((value, element) => value += element);
} else { } else {
fee = widget.txData.fee; fee = widget.txData.fee;
amount = widget.txData.amount!; amountWithoutChange = widget.txData.amountWithoutChange!;
} }
break; break;
case FiroType.lelantus: case FiroType.lelantus:
fee = widget.txData.fee; fee = widget.txData.fee;
amount = widget.txData.amount!; amountWithoutChange = widget.txData.amountWithoutChange!;
break; break;
case FiroType.spark: case FiroType.spark:
fee = widget.txData.fee; fee = widget.txData.fee;
amount = (widget.txData.amount ?? amountWithoutChange = (widget.txData.amountWithoutChange ??
Amount.zeroWith( Amount.zeroWith(
fractionDigits: wallet.cryptoCurrency.fractionDigits)) + fractionDigits: wallet.cryptoCurrency.fractionDigits)) +
(widget.txData.amountSpark ?? (widget.txData.amountSparkWithoutChange ??
Amount.zeroWith( Amount.zeroWith(
fractionDigits: wallet.cryptoCurrency.fractionDigits)); fractionDigits: wallet.cryptoCurrency.fractionDigits));
break; break;
} }
} else { } else {
fee = widget.txData.fee; fee = widget.txData.fee;
amount = widget.txData.amount!; amountWithoutChange = widget.txData.amountWithoutChange!;
} }
return ConditionalParent( return ConditionalParent(
@ -516,7 +516,7 @@ class _ConfirmTransactionViewState
), ),
SelectableText( SelectableText(
ref.watch(pAmountFormatter(coin)).format( ref.watch(pAmountFormatter(coin)).format(
amount, amountWithoutChange,
ethContract: ref ethContract: ref
.watch(tokenServiceProvider) .watch(tokenServiceProvider)
?.tokenContract, ?.tokenContract,
@ -719,14 +719,15 @@ class _ConfirmTransactionViewState
.getPrice(coin) .getPrice(coin)
.item1; .item1;
if (price > Decimal.zero) { if (price > Decimal.zero) {
fiatAmount = (amount.decimal * price) fiatAmount =
.toAmount(fractionDigits: 2) (amountWithoutChange.decimal * price)
.fiatString( .toAmount(fractionDigits: 2)
locale: ref .fiatString(
.read( locale: ref
localeServiceChangeNotifierProvider) .read(
.locale, localeServiceChangeNotifierProvider)
); .locale,
);
} }
} }
@ -734,7 +735,7 @@ class _ConfirmTransactionViewState
children: [ children: [
SelectableText( SelectableText(
ref.watch(pAmountFormatter(coin)).format( ref.watch(pAmountFormatter(coin)).format(
amount, amountWithoutChange,
ethContract: ref ethContract: ref
.read(tokenServiceProvider) .read(tokenServiceProvider)
?.tokenContract), ?.tokenContract),
@ -1128,7 +1129,9 @@ class _ConfirmTransactionViewState
), ),
), ),
SelectableText( SelectableText(
ref.watch(pAmountFormatter(coin)).format(amount + fee!), ref
.watch(pAmountFormatter(coin))
.format(amountWithoutChange + fee!),
style: isDesktop style: isDesktop
? STextStyles.desktopTextExtraExtraSmall(context) ? STextStyles.desktopTextExtraExtraSmall(context)
.copyWith( .copyWith(

View file

@ -644,6 +644,7 @@ class _SendViewState extends ConsumerState<SendView> {
( (
address: widget.accountLite!.code, address: widget.accountLite!.code,
amount: amount, amount: amount,
isChange: false,
) )
], ],
satsPerVByte: isCustomFee ? customFeeRate : null, satsPerVByte: isCustomFee ? customFeeRate : null,
@ -666,6 +667,7 @@ class _SendViewState extends ConsumerState<SendView> {
address: _address!, address: _address!,
amount: amount, amount: amount,
memo: memoController.text, memo: memoController.text,
isChange: false,
) )
], ],
feeRateType: ref.read(feeRateTypeStateProvider), feeRateType: ref.read(feeRateTypeStateProvider),
@ -680,7 +682,13 @@ class _SendViewState extends ConsumerState<SendView> {
} else { } else {
txDataFuture = wallet.prepareSend( txDataFuture = wallet.prepareSend(
txData: TxData( txData: TxData(
recipients: [(address: _address!, amount: amount)], recipients: [
(
address: _address!,
amount: amount,
isChange: false,
)
],
feeRateType: ref.read(feeRateTypeStateProvider), feeRateType: ref.read(feeRateTypeStateProvider),
satsPerVByte: isCustomFee ? customFeeRate : null, satsPerVByte: isCustomFee ? customFeeRate : null,
utxos: (wallet is CoinControlInterface && utxos: (wallet is CoinControlInterface &&
@ -696,7 +704,13 @@ class _SendViewState extends ConsumerState<SendView> {
case FiroType.lelantus: case FiroType.lelantus:
txDataFuture = wallet.prepareSendLelantus( txDataFuture = wallet.prepareSendLelantus(
txData: TxData( txData: TxData(
recipients: [(address: _address!, amount: amount)], recipients: [
(
address: _address!,
amount: amount,
isChange: false,
)
],
), ),
); );
break; break;
@ -706,13 +720,20 @@ class _SendViewState extends ConsumerState<SendView> {
txData: TxData( txData: TxData(
recipients: ref.read(pValidSparkSendToAddress) recipients: ref.read(pValidSparkSendToAddress)
? null ? null
: [(address: _address!, amount: amount)], : [
(
address: _address!,
amount: amount,
isChange: false,
)
],
sparkRecipients: ref.read(pValidSparkSendToAddress) sparkRecipients: ref.read(pValidSparkSendToAddress)
? [ ? [
( (
address: _address!, address: _address!,
amount: amount, amount: amount,
memo: memoController.text, memo: memoController.text,
isChange: false,
) )
] ]
: null, : null,
@ -726,7 +747,13 @@ class _SendViewState extends ConsumerState<SendView> {
: null; : null;
txDataFuture = wallet.prepareSend( txDataFuture = wallet.prepareSend(
txData: TxData( txData: TxData(
recipients: [(address: _address!, amount: amount)], recipients: [
(
address: _address!,
amount: amount,
isChange: false,
)
],
memo: memo, memo: memo,
feeRateType: ref.read(feeRateTypeStateProvider), feeRateType: ref.read(feeRateTypeStateProvider),
satsPerVByte: isCustomFee ? customFeeRate : null, satsPerVByte: isCustomFee ? customFeeRate : null,

View file

@ -482,6 +482,7 @@ class _TokenSendViewState extends ConsumerState<TokenSendView> {
( (
address: _address!, address: _address!,
amount: amount, amount: amount,
isChange: false,
) )
], ],
feeRateType: ref.read(feeRateTypeStateProvider), feeRateType: ref.read(feeRateTypeStateProvider),

View file

@ -304,6 +304,7 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
( (
address: widget.accountLite!.code, address: widget.accountLite!.code,
amount: amount, amount: amount,
isChange: false,
) )
], ],
satsPerVByte: isCustomFee ? customFeeRate : null, satsPerVByte: isCustomFee ? customFeeRate : null,
@ -326,6 +327,7 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
address: _address!, address: _address!,
amount: amount, amount: amount,
memo: memoController.text, memo: memoController.text,
isChange: false,
) )
], ],
feeRateType: ref.read(feeRateTypeStateProvider), feeRateType: ref.read(feeRateTypeStateProvider),
@ -340,7 +342,13 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
} else { } else {
txDataFuture = wallet.prepareSend( txDataFuture = wallet.prepareSend(
txData: TxData( txData: TxData(
recipients: [(address: _address!, amount: amount)], recipients: [
(
address: _address!,
amount: amount,
isChange: false,
)
],
feeRateType: ref.read(feeRateTypeStateProvider), feeRateType: ref.read(feeRateTypeStateProvider),
satsPerVByte: isCustomFee ? customFeeRate : null, satsPerVByte: isCustomFee ? customFeeRate : null,
utxos: (wallet is CoinControlInterface && utxos: (wallet is CoinControlInterface &&
@ -356,7 +364,13 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
case FiroType.lelantus: case FiroType.lelantus:
txDataFuture = wallet.prepareSendLelantus( txDataFuture = wallet.prepareSendLelantus(
txData: TxData( txData: TxData(
recipients: [(address: _address!, amount: amount)], recipients: [
(
address: _address!,
amount: amount,
isChange: false,
)
],
), ),
); );
break; break;
@ -366,13 +380,20 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
txData: TxData( txData: TxData(
recipients: ref.read(pValidSparkSendToAddress) recipients: ref.read(pValidSparkSendToAddress)
? null ? null
: [(address: _address!, amount: amount)], : [
(
address: _address!,
amount: amount,
isChange: false,
)
],
sparkRecipients: ref.read(pValidSparkSendToAddress) sparkRecipients: ref.read(pValidSparkSendToAddress)
? [ ? [
( (
address: _address!, address: _address!,
amount: amount, amount: amount,
memo: memoController.text, memo: memoController.text,
isChange: false,
) )
] ]
: null, : null,
@ -384,7 +405,13 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
final memo = isStellar ? memoController.text : null; final memo = isStellar ? memoController.text : null;
txDataFuture = wallet.prepareSend( txDataFuture = wallet.prepareSend(
txData: TxData( txData: TxData(
recipients: [(address: _address!, amount: amount)], recipients: [
(
address: _address!,
amount: amount,
isChange: false,
)
],
memo: memo, memo: memo,
feeRateType: ref.read(feeRateTypeStateProvider), feeRateType: ref.read(feeRateTypeStateProvider),
satsPerVByte: isCustomFee ? customFeeRate : null, satsPerVByte: isCustomFee ? customFeeRate : null,

View file

@ -243,6 +243,7 @@ class _DesktopTokenSendState extends ConsumerState<DesktopTokenSend> {
( (
address: _address!, address: _address!,
amount: amount, amount: amount,
isChange: false,
) )
], ],
feeRateType: ref.read(feeRateTypeStateProvider), feeRateType: ref.read(feeRateTypeStateProvider),

View file

@ -17,4 +17,4 @@ enum FiroType {
} }
final publicPrivateBalanceStateProvider = final publicPrivateBalanceStateProvider =
StateProvider<FiroType>((_) => FiroType.lelantus); StateProvider<FiroType>((_) => FiroType.spark);

View file

@ -300,6 +300,7 @@ abstract final class LelantusFfiWrapper {
}) arg) async { }) arg) async {
final spendAmount = arg.txData.recipients!.first.amount.raw.toInt(); final spendAmount = arg.txData.recipients!.first.amount.raw.toInt();
final address = arg.txData.recipients!.first.address; final address = arg.txData.recipients!.first.address;
final isChange = arg.txData.recipients!.first.isChange;
final estimateJoinSplitFee = await _estimateJoinSplitFee( final estimateJoinSplitFee = await _estimateJoinSplitFee(
( (
@ -465,7 +466,9 @@ abstract final class LelantusFfiWrapper {
return arg.txData.copyWith( return arg.txData.copyWith(
txid: txId, txid: txId,
raw: txHex, raw: txHex,
recipients: [(address: address, amount: amountAmount)], recipients: [
(address: address, amount: amountAmount, isChange: isChange)
],
fee: Amount( fee: Amount(
rawValue: BigInt.from(fee), rawValue: BigInt.from(fee),
fractionDigits: arg.cryptoCurrency.fractionDigits, fractionDigits: arg.cryptoCurrency.fractionDigits,

View file

@ -25,7 +25,7 @@ class TxData {
final String? memo; final String? memo;
final List<({String address, Amount amount})>? recipients; final List<({String address, Amount amount, bool isChange})>? recipients;
final Set<UTXO>? utxos; final Set<UTXO>? utxos;
final List<UTXO>? usedUTXOs; final List<UTXO>? usedUTXOs;
@ -62,6 +62,7 @@ class TxData {
String address, String address,
Amount amount, Amount amount,
String memo, String memo,
bool isChange,
})>? sparkRecipients; })>? sparkRecipients;
final List<TxData>? sparkMints; final List<TxData>? sparkMints;
@ -115,6 +116,22 @@ class TxData {
.reduce((total, amount) => total += amount) .reduce((total, amount) => total += amount)
: null; : 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 int? get estimatedSatsPerVByte => fee != null && vSize != null
? (fee!.raw ~/ BigInt.from(vSize!)).toInt() ? (fee!.raw ~/ BigInt.from(vSize!)).toInt()
: null; : null;
@ -133,7 +150,13 @@ class TxData {
String? memo, String? memo,
Set<UTXO>? utxos, Set<UTXO>? utxos,
List<UTXO>? usedUTXOs, List<UTXO>? usedUTXOs,
List<({String address, Amount amount})>? recipients, List<
({
String address,
Amount amount,
bool isChange,
})>?
recipients,
String? frostMSConfig, String? frostMSConfig,
String? changeAddress, String? changeAddress,
PaynymAccountLite? paynymAccountLite, PaynymAccountLite? paynymAccountLite,
@ -154,6 +177,7 @@ class TxData {
String address, String address,
Amount amount, Amount amount,
String memo, String memo,
bool isChange,
})>? })>?
sparkRecipients, sparkRecipients,
List<TxData>? sparkMints, List<TxData>? sparkMints,

View file

@ -237,6 +237,7 @@ class TezosWallet extends Bip39Wallet<Tezos> {
( (
amount: sendAmount, amount: sendAmount,
address: txData.recipients!.first.address, address: txData.recipients!.first.address,
isChange: txData.recipients!.first.isChange,
) )
], ],
// fee: fee, // fee: fee,

View file

@ -111,6 +111,7 @@ class WowneroWallet extends CryptonoteWallet with MultiAddressInterface {
address: address:
"WW3iVcnoAY6K9zNdU4qmdvZELefx6xZz4PMpTwUifRkvMQckyadhSPYMVPJhBdYE8P9c27fg9RPmVaWNFx1cDaj61HnetqBiy", "WW3iVcnoAY6K9zNdU4qmdvZELefx6xZz4PMpTwUifRkvMQckyadhSPYMVPJhBdYE8P9c27fg9RPmVaWNFx1cDaj61HnetqBiy",
amount: amount, amount: amount,
isChange: false,
), ),
], ],
feeRateType: feeRateType, feeRateType: feeRateType,

View file

@ -35,18 +35,30 @@ mixin ElectrumXInterface on Bip39HDWallet {
(_serverVersion != null && _serverVersion! >= 1.6) || (_serverVersion != null && _serverVersion! >= 1.6) ||
cryptoCurrency is Firo; cryptoCurrency is Firo;
List<({String address, Amount amount})> _helperRecipientsConvert( Future<List<({String address, Amount amount, bool isChange})>>
List<String> addrs, List<int> satValues) { _helperRecipientsConvert(List<String> addrs, List<int> satValues) async {
final List<({String address, Amount amount})> results = []; final List<({String address, Amount amount, bool isChange})> results = [];
for (int i = 0; i < addrs.length; i++) { for (int i = 0; i < addrs.length; i++) {
results.add(( results.add(
address: addrs[i], (
amount: Amount( address: addrs[i],
rawValue: BigInt.from(satValues[i]), amount: Amount(
fractionDigits: cryptoCurrency.fractionDigits, 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; return results;
@ -178,7 +190,7 @@ mixin ElectrumXInterface on Bip39HDWallet {
final int vSizeForOneOutput = (await buildTransaction( final int vSizeForOneOutput = (await buildTransaction(
utxoSigningData: utxoSigningData, utxoSigningData: utxoSigningData,
txData: txData.copyWith( txData: txData.copyWith(
recipients: _helperRecipientsConvert( recipients: await _helperRecipientsConvert(
[recipientAddress], [recipientAddress],
[satoshisBeingUsed - 1], [satoshisBeingUsed - 1],
), ),
@ -206,7 +218,7 @@ mixin ElectrumXInterface on Bip39HDWallet {
final int amount = satoshiAmountToSend - feeForOneOutput; final int amount = satoshiAmountToSend - feeForOneOutput;
final data = await buildTransaction( final data = await buildTransaction(
txData: txData.copyWith( txData: txData.copyWith(
recipients: _helperRecipientsConvert( recipients: await _helperRecipientsConvert(
[recipientAddress], [recipientAddress],
[amount], [amount],
), ),
@ -228,7 +240,7 @@ mixin ElectrumXInterface on Bip39HDWallet {
vSizeForOneOutput = (await buildTransaction( vSizeForOneOutput = (await buildTransaction(
utxoSigningData: utxoSigningData, utxoSigningData: utxoSigningData,
txData: txData.copyWith( txData: txData.copyWith(
recipients: _helperRecipientsConvert( recipients: await _helperRecipientsConvert(
[recipientAddress], [recipientAddress],
[satoshisBeingUsed - 1], [satoshisBeingUsed - 1],
), ),
@ -245,7 +257,7 @@ mixin ElectrumXInterface on Bip39HDWallet {
vSizeForTwoOutPuts = (await buildTransaction( vSizeForTwoOutPuts = (await buildTransaction(
utxoSigningData: utxoSigningData, utxoSigningData: utxoSigningData,
txData: txData.copyWith( txData: txData.copyWith(
recipients: _helperRecipientsConvert( recipients: await _helperRecipientsConvert(
[recipientAddress, (await getCurrentChangeAddress())!.value], [recipientAddress, (await getCurrentChangeAddress())!.value],
[ [
satoshiAmountToSend, satoshiAmountToSend,
@ -321,7 +333,7 @@ mixin ElectrumXInterface on Bip39HDWallet {
var txn = await buildTransaction( var txn = await buildTransaction(
utxoSigningData: utxoSigningData, utxoSigningData: utxoSigningData,
txData: txData.copyWith( txData: txData.copyWith(
recipients: _helperRecipientsConvert( recipients: await _helperRecipientsConvert(
recipientsArray, recipientsArray,
recipientsAmtArray, recipientsAmtArray,
), ),
@ -352,7 +364,7 @@ mixin ElectrumXInterface on Bip39HDWallet {
txn = await buildTransaction( txn = await buildTransaction(
utxoSigningData: utxoSigningData, utxoSigningData: utxoSigningData,
txData: txData.copyWith( txData: txData.copyWith(
recipients: _helperRecipientsConvert( recipients: await _helperRecipientsConvert(
recipientsArray, recipientsArray,
recipientsAmtArray, recipientsAmtArray,
), ),
@ -383,7 +395,7 @@ mixin ElectrumXInterface on Bip39HDWallet {
final txn = await buildTransaction( final txn = await buildTransaction(
utxoSigningData: utxoSigningData, utxoSigningData: utxoSigningData,
txData: txData.copyWith( txData: txData.copyWith(
recipients: _helperRecipientsConvert( recipients: await _helperRecipientsConvert(
recipientsArray, recipientsArray,
recipientsAmtArray, recipientsAmtArray,
), ),
@ -415,7 +427,7 @@ mixin ElectrumXInterface on Bip39HDWallet {
final txn = await buildTransaction( final txn = await buildTransaction(
utxoSigningData: utxoSigningData, utxoSigningData: utxoSigningData,
txData: txData.copyWith( txData: txData.copyWith(
recipients: _helperRecipientsConvert( recipients: await _helperRecipientsConvert(
recipientsArray, recipientsArray,
recipientsAmtArray, recipientsAmtArray,
), ),
@ -447,7 +459,7 @@ mixin ElectrumXInterface on Bip39HDWallet {
final txn = await buildTransaction( final txn = await buildTransaction(
utxoSigningData: utxoSigningData, utxoSigningData: utxoSigningData,
txData: txData.copyWith( txData: txData.copyWith(
recipients: _helperRecipientsConvert( recipients: await _helperRecipientsConvert(
recipientsArray, recipientsArray,
recipientsAmtArray, recipientsAmtArray,
), ),

View file

@ -800,6 +800,7 @@ mixin LelantusInterface on Bip39HDWallet, ElectrumXInterface {
fractionDigits: cryptoCurrency.fractionDigits, fractionDigits: cryptoCurrency.fractionDigits,
), ),
address: "no address for lelantus mints", address: "no address for lelantus mints",
isChange: false,
) )
], ],
vSize: builtHex.virtualSize(), vSize: builtHex.virtualSize(),

View file

@ -370,6 +370,7 @@ mixin PaynymInterface on Bip39HDWallet, ElectrumXInterface {
( (
address: sendToAddress.value, address: sendToAddress.value,
amount: txData.recipients!.first.amount, amount: txData.recipients!.first.amount,
isChange: false,
), ),
], ],
), ),
@ -582,7 +583,11 @@ mixin PaynymInterface on Bip39HDWallet, ElectrumXInterface {
final txData = TxData( final txData = TxData(
raw: txn.item1, raw: txn.item1,
recipients: [ recipients: [
(address: targetPaymentCodeString, amount: amountToSend) (
address: targetPaymentCodeString,
amount: amountToSend,
isChange: false,
),
], ],
fee: Amount( fee: Amount(
rawValue: feeBeingPaid, rawValue: feeBeingPaid,
@ -610,6 +615,7 @@ mixin PaynymInterface on Bip39HDWallet, ElectrumXInterface {
( (
address: targetPaymentCodeString, address: targetPaymentCodeString,
amount: amountToSend, amount: amountToSend,
isChange: false,
) )
], ],
fee: Amount( fee: Amount(
@ -639,6 +645,7 @@ mixin PaynymInterface on Bip39HDWallet, ElectrumXInterface {
( (
address: targetPaymentCodeString, address: targetPaymentCodeString,
amount: amountToSend, amount: amountToSend,
isChange: false,
) )
], ],
fee: Amount( fee: Amount(

View file

@ -283,12 +283,18 @@ mixin SparkInterface on Bip39HDWallet, ElectrumXInterface {
txb.setLockTime(await chainHeight); txb.setLockTime(await chainHeight);
txb.setVersion(3 | (9 << 16)); txb.setVersion(3 | (9 << 16));
List<({String address, Amount amount})>? recipientsWithFeeSubtracted; List<
({
String address,
Amount amount,
bool isChange,
})>? recipientsWithFeeSubtracted;
List< List<
({ ({
String address, String address,
Amount amount, Amount amount,
String memo, String memo,
bool isChange,
})>? sparkRecipientsWithFeeSubtracted; })>? sparkRecipientsWithFeeSubtracted;
final recipientCount = (txData.recipients final recipientCount = (txData.recipients
?.where( ?.where(
@ -330,6 +336,7 @@ mixin SparkInterface on Bip39HDWallet, ElectrumXInterface {
fractionDigits: cryptoCurrency.fractionDigits, fractionDigits: cryptoCurrency.fractionDigits,
), ),
memo: txData.sparkRecipients![i].memo, memo: txData.sparkRecipients![i].memo,
isChange: sparkChangeAddress == txData.sparkRecipients![i].address,
), ),
); );
} }
@ -350,6 +357,7 @@ mixin SparkInterface on Bip39HDWallet, ElectrumXInterface {
(estimatedFee ~/ BigInt.from(totalRecipientCount)), (estimatedFee ~/ BigInt.from(totalRecipientCount)),
fractionDigits: cryptoCurrency.fractionDigits, fractionDigits: cryptoCurrency.fractionDigits,
), ),
isChange: txData.recipients![i].isChange,
), ),
); );
@ -1157,6 +1165,7 @@ mixin SparkInterface on Bip39HDWallet, ElectrumXInterface {
rawValue: BigInt.from(e.$2), rawValue: BigInt.from(e.$2),
fractionDigits: cryptoCurrency.fractionDigits, fractionDigits: cryptoCurrency.fractionDigits,
), ),
isChange: false, // ok?
), ),
) )
.toList(), .toList(),