From 2c1f7e181cb45c3e3a62eb50e4fa3424e628cb4f Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Mon, 23 May 2022 13:11:08 +0200 Subject: [PATCH] when hiding empty used addresses, add previously used updated address nodes in sequence --- .../sparrow/control/AddressTreeTable.java | 14 +++++++++++++- 1 file changed, 13 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 d55c93af..cf922c79 100644 --- a/src/main/java/com/sparrowwallet/sparrow/control/AddressTreeTable.java +++ b/src/main/java/com/sparrowwallet/sparrow/control/AddressTreeTable.java @@ -121,7 +121,19 @@ public class AddressTreeTable extends CoinTreeTable { } } else { NodeEntry nodeEntry = new NodeEntry(rootEntry.getWallet(), updatedNode); - rootEntry.getChildren().add(nodeEntry); + + if(Config.get().isHideEmptyUsedAddresses()) { + int index = 0; + for( ; index < rootEntry.getChildren().size(); index++) { + NodeEntry existingEntry = (NodeEntry)rootEntry.getChildren().get(index); + if(nodeEntry.compareTo(existingEntry) < 0) { + break; + } + } + rootEntry.getChildren().add(index, nodeEntry); + } else { + rootEntry.getChildren().add(nodeEntry); + } } }