From c06c3935cae3f815a0074435f48e0d836f194b91 Mon Sep 17 00:00:00 2001 From: julian Date: Tue, 31 Jan 2023 10:37:03 -0600 Subject: [PATCH] handle fee rounding error --- lib/services/mixins/paynym_wallet_interface.dart | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/services/mixins/paynym_wallet_interface.dart b/lib/services/mixins/paynym_wallet_interface.dart index e1fe7cbee..c979e80da 100644 --- a/lib/services/mixins/paynym_wallet_interface.dart +++ b/lib/services/mixins/paynym_wallet_interface.dart @@ -455,7 +455,7 @@ mixin PaynymWalletInterface { // check estimates are correct and build notification tx if (changeAmount >= _dustLimitP2PKH && satoshisBeingUsed - amountToSend - changeAmount == feeForWithChange) { - final txn = await _createNotificationTx( + var txn = await _createNotificationTx( targetPaymentCodeString: targetPaymentCodeString, utxosToUse: utxoObjectsToUse, utxoSigningData: utxoSigningData, @@ -464,6 +464,18 @@ mixin PaynymWalletInterface { int feeBeingPaid = satoshisBeingUsed - amountToSend - changeAmount; + // make sure minimum fee is accurate if that is being used + if (txn.item2 - feeBeingPaid == 1) { + changeAmount -= 1; + feeBeingPaid += 1; + txn = await _createNotificationTx( + targetPaymentCodeString: targetPaymentCodeString, + utxosToUse: utxoObjectsToUse, + utxoSigningData: utxoSigningData, + change: changeAmount, + ); + } + Map transactionObject = { "hex": txn.item1, "recipientPaynym": targetPaymentCodeString,