From bd1c6c076e2b3f5186a7131535ce08dc5a01885e Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Mon, 7 Aug 2023 12:54:29 +0200 Subject: [PATCH] avoid adding inputs when constructing a consolidation transaction replacement, allowing output to decrease --- src/main/java/com/sparrowwallet/sparrow/control/EntryCell.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/sparrowwallet/sparrow/control/EntryCell.java b/src/main/java/com/sparrowwallet/sparrow/control/EntryCell.java index 88b9bc42..9aec1c64 100644 --- a/src/main/java/com/sparrowwallet/sparrow/control/EntryCell.java +++ b/src/main/java/com/sparrowwallet/sparrow/control/EntryCell.java @@ -240,6 +240,7 @@ public class EntryCell extends TreeTableCell implements Confirmati .map(e -> e.getBlockTransaction().getTransaction().getOutputs().get((int)e.getHashIndex().getIndex())) .collect(Collectors.toList()); + boolean consolidationTransaction = consolidationOutputs.size() == blockTransaction.getTransaction().getOutputs().size() && consolidationOutputs.size() == 1; long changeTotal = ourOutputs.stream().mapToLong(TransactionOutput::getValue).sum() - consolidationOutputs.stream().mapToLong(TransactionOutput::getValue).sum(); Transaction tx = blockTransaction.getTransaction(); double vSize = tx.getVirtualSize(); @@ -254,7 +255,7 @@ public class EntryCell extends TreeTableCell implements Confirmati List outputGroups = transactionEntry.getWallet().getGroupedUtxos(txoFilters, feeRate, AppServices.getMinimumRelayFeeRate(), Config.get().isGroupByAddress()) .stream().filter(outputGroup -> outputGroup.getEffectiveValue() >= 0).collect(Collectors.toList()); Collections.shuffle(outputGroups); - while((double)changeTotal / vSize < getMaxFeeRate() && !outputGroups.isEmpty() && !cancelTransaction) { + while((double)changeTotal / vSize < getMaxFeeRate() && !outputGroups.isEmpty() && !cancelTransaction && !consolidationTransaction) { //If there is insufficient change output, include another random output group so the fee can be increased OutputGroup outputGroup = outputGroups.remove(0); for(BlockTransactionHashIndex utxo : outputGroup.getUtxos()) {