From 4ad9cdedb6b0b5331294293d144877609468c5d7 Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Thu, 19 Jan 2023 14:12:35 +0200 Subject: [PATCH] add merge function for wallet transaction entry edge case --- .../sparrowwallet/sparrow/wallet/WalletTransactionsEntry.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/sparrowwallet/sparrow/wallet/WalletTransactionsEntry.java b/src/main/java/com/sparrowwallet/sparrow/wallet/WalletTransactionsEntry.java index 2a9b994e..2d3e0fbb 100644 --- a/src/main/java/com/sparrowwallet/sparrow/wallet/WalletTransactionsEntry.java +++ b/src/main/java/com/sparrowwallet/sparrow/wallet/WalletTransactionsEntry.java @@ -15,6 +15,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.*; +import java.util.function.BinaryOperator; import java.util.stream.Collectors; public class WalletTransactionsEntry extends Entry { @@ -68,7 +69,8 @@ public class WalletTransactionsEntry extends Entry { public void updateTransactions() { Map walletTxos = getWallet().getWalletTxos().entrySet().stream() - .collect(Collectors.toUnmodifiableMap(entry -> new HashIndex(entry.getKey().getHash(), entry.getKey().getIndex()), Map.Entry::getKey)); + .collect(Collectors.toUnmodifiableMap(entry -> new HashIndex(entry.getKey().getHash(), entry.getKey().getIndex()), Map.Entry::getKey, + BinaryOperator.maxBy(BlockTransactionHashIndex::compareTo))); List current = getWalletTransactions(getWallet()).stream().map(WalletTransaction::getTransactionEntry).collect(Collectors.toList()); List previous = new ArrayList<>(getChildren());