From 525d57ec73085eed6ae670e9c19ca73065b0d277 Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Thu, 4 Feb 2021 12:14:42 +0200 Subject: [PATCH] handle rbf fee increase for consolidation outputs --- .../com/sparrowwallet/sparrow/control/EntryCell.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/java/com/sparrowwallet/sparrow/control/EntryCell.java b/src/main/java/com/sparrowwallet/sparrow/control/EntryCell.java index fe87c34f..91f99711 100644 --- a/src/main/java/com/sparrowwallet/sparrow/control/EntryCell.java +++ b/src/main/java/com/sparrowwallet/sparrow/control/EntryCell.java @@ -1,5 +1,6 @@ package com.sparrowwallet.sparrow.control; +import com.sparrowwallet.drongo.KeyPurpose; import com.sparrowwallet.drongo.Utils; import com.sparrowwallet.drongo.address.Address; import com.sparrowwallet.drongo.protocol.Transaction; @@ -173,6 +174,13 @@ class EntryCell extends TreeTableCell { .map(e -> e.getBlockTransaction().getTransaction().getOutputs().get((int)e.getHashIndex().getIndex())) .collect(Collectors.toList()); + List consolidationOutputs = transactionEntry.getChildren().stream() + .filter(e -> e instanceof HashIndexEntry) + .map(e -> (HashIndexEntry)e) + .filter(e -> e.getType().equals(HashIndexEntry.Type.OUTPUT) && e.getKeyPurpose() == KeyPurpose.RECEIVE) + .map(e -> e.getBlockTransaction().getTransaction().getOutputs().get((int)e.getHashIndex().getIndex())) + .collect(Collectors.toList()); + long changeTotal = ourOutputs.stream().mapToLong(TransactionOutput::getValue).sum(); Transaction tx = blockTransaction.getTransaction(); int vSize = tx.getVirtualSize(); @@ -189,6 +197,7 @@ class EntryCell extends TreeTableCell { List externalOutputs = new ArrayList<>(blockTransaction.getTransaction().getOutputs()); externalOutputs.removeAll(ourOutputs); + externalOutputs.addAll(consolidationOutputs); List payments = externalOutputs.stream().map(txOutput -> { try { return new Payment(txOutput.getScript().getToAddresses()[0], transactionEntry.getLabel(), txOutput.getValue(), false);