diff --git a/src/main/java/com/sparrowwallet/sparrow/AppController.java b/src/main/java/com/sparrowwallet/sparrow/AppController.java index c32992a7..5b6b1e1e 100644 --- a/src/main/java/com/sparrowwallet/sparrow/AppController.java +++ b/src/main/java/com/sparrowwallet/sparrow/AppController.java @@ -19,7 +19,6 @@ import com.sparrowwallet.drongo.psbt.PSBTSignatureException; import com.sparrowwallet.drongo.wallet.*; import com.sparrowwallet.hummingbird.UR; import com.sparrowwallet.hummingbird.registry.CryptoPSBT; -import com.sparrowwallet.hummingbird.registry.RegistryType; import com.sparrowwallet.sparrow.control.*; import com.sparrowwallet.sparrow.event.*; import com.sparrowwallet.sparrow.glyphfont.FontAwesome5; @@ -1930,7 +1929,7 @@ public class AppController implements Initializable { } List blockTransactions = new ArrayList<>(event.getBlockTransactions()); - List whirlpoolTransactions = event.getWhirlpoolMixTransactions(); + List whirlpoolTransactions = event.getUnspentWhirlpoolMixTransactions(); blockTransactions.removeAll(whirlpoolTransactions); if(!whirlpoolTransactions.isEmpty()) { diff --git a/src/main/java/com/sparrowwallet/sparrow/event/NewWalletTransactionsEvent.java b/src/main/java/com/sparrowwallet/sparrow/event/NewWalletTransactionsEvent.java index 5ca23e73..6df59372 100644 --- a/src/main/java/com/sparrowwallet/sparrow/event/NewWalletTransactionsEvent.java +++ b/src/main/java/com/sparrowwallet/sparrow/event/NewWalletTransactionsEvent.java @@ -7,7 +7,9 @@ import com.sparrowwallet.drongo.wallet.Wallet; import com.sparrowwallet.sparrow.control.CoinLabel; import com.sparrowwallet.sparrow.io.Config; import com.sparrowwallet.sparrow.wallet.Entry; +import com.sparrowwallet.sparrow.wallet.HashIndexEntry; import com.sparrowwallet.sparrow.wallet.TransactionEntry; +import com.sparrowwallet.sparrow.wallet.TransactionHashIndexEntry; import java.util.ArrayList; import java.util.List; @@ -60,12 +62,21 @@ public class NewWalletTransactionsEvent { return String.format(Locale.ENGLISH, "%,d", value) + " sats"; } - public List getWhirlpoolMixTransactions() { + public List getUnspentWhirlpoolMixTransactions() { List mixTransactions = new ArrayList<>(); if(wallet.isWhirlpoolMixWallet()) { - return transactionEntries.stream().filter(txEntry -> txEntry.getValue() == 0).map(TransactionEntry::getBlockTransaction).collect(Collectors.toList()); + return transactionEntries.stream() + .filter(txEntry -> txEntry.getValue() == 0 && !allOutputsSpent(txEntry)) + .map(TransactionEntry::getBlockTransaction).collect(Collectors.toList()); } return mixTransactions; } + + private boolean allOutputsSpent(TransactionEntry txEntry) { + return txEntry.getChildren().stream() + .map(refEntry -> ((TransactionHashIndexEntry)refEntry)) + .filter(txRefEntry -> txRefEntry.getType() == HashIndexEntry.Type.OUTPUT) + .allMatch(txRefEntry -> txRefEntry.getHashIndex().isSpent()); + } }