From d7ce58d81029f5df32c8a22392b3572188554556 Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Mon, 23 May 2022 09:40:35 +0200 Subject: [PATCH] when hiding empty used addresses, remove updated address nodes where address balance is zero --- .../sparrowwallet/sparrow/control/AddressTreeTable.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/sparrowwallet/sparrow/control/AddressTreeTable.java b/src/main/java/com/sparrowwallet/sparrow/control/AddressTreeTable.java index 2f82e80e..d55c93af 100644 --- a/src/main/java/com/sparrowwallet/sparrow/control/AddressTreeTable.java +++ b/src/main/java/com/sparrowwallet/sparrow/control/AddressTreeTable.java @@ -5,6 +5,7 @@ import com.sparrowwallet.sparrow.AppServices; import com.sparrowwallet.sparrow.EventManager; import com.sparrowwallet.sparrow.event.ReceiveActionEvent; import com.sparrowwallet.sparrow.event.ReceiveToEvent; +import com.sparrowwallet.sparrow.io.Config; import com.sparrowwallet.sparrow.wallet.Entry; import com.sparrowwallet.sparrow.wallet.NodeEntry; import javafx.application.Platform; @@ -106,7 +107,7 @@ public class AddressTreeTable extends CoinTreeTable { } public void updateHistory(List updatedNodes) { - //We only ever add child nodes - never remove in order to keep a full sequence + //We only ever add child nodes - never remove in order to keep a full sequence (unless hide empty used addresses is set) NodeEntry rootEntry = (NodeEntry)getRoot().getValue(); for(WalletNode updatedNode : updatedNodes) { @@ -114,6 +115,10 @@ public class AddressTreeTable extends CoinTreeTable { if(optEntry.isPresent()) { NodeEntry existingEntry = (NodeEntry)optEntry.get(); existingEntry.refreshChildren(); + + if(Config.get().isHideEmptyUsedAddresses() && existingEntry.getValue() == 0L) { + rootEntry.getChildren().remove(existingEntry); + } } else { NodeEntry nodeEntry = new NodeEntry(rootEntry.getWallet(), updatedNode); rootEntry.getChildren().add(nodeEntry);