Fix edge case of sending amount that will leave near dust amount as a change (#2044)

This commit is contained in:
Omar Hatem
2025-03-04 19:12:19 +02:00
committed by GitHub
parent dcd978eb38
commit f28af937ec
+5 -2
View File
@@ -915,6 +915,10 @@ abstract class ElectrumWalletBase
}
}
// if the amount left for change is less than dust, but not less than 0
// then add it to the fees
fee += amountLeftForChange;
return EstimatedTxResult(
utxos: utxoDetails.utxos,
inputPrivKeyInfos: utxoDetails.inputPrivKeyInfos,
@@ -1366,7 +1370,7 @@ abstract class ElectrumWalletBase
List<BitcoinUnspent> updatedUnspentCoins = [];
final previousUnspentCoins = List<BitcoinUnspent>.from(unspentCoins.where((utxo) =>
utxo.bitcoinAddressRecord.type != SegwitAddresType.mweb &&
utxo.bitcoinAddressRecord.type != SegwitAddresType.mweb &&
utxo.bitcoinAddressRecord is! BitcoinSilentPaymentAddressRecord));
if (hasSilentPaymentsScanning) {
@@ -1424,7 +1428,6 @@ abstract class ElectrumWalletBase
required List<BitcoinUnspent> updatedUnspentCoins,
required List<List<BitcoinUnspent>?> results,
}) {
if (failedCount == results.length) {
printV("All UTXOs failed to fetch, falling back to previous UTXOs");
return previousUnspentCoins;