From 21d91d3d10de1c6699e1c31cda095911921385bb Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Tue, 23 Apr 2024 08:32:58 +0200 Subject: [PATCH] add additional check against existing child wallet names when suggesting new accounts to add --- .../sparrowwallet/sparrow/control/AddAccountDialog.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/sparrowwallet/sparrow/control/AddAccountDialog.java b/src/main/java/com/sparrowwallet/sparrow/control/AddAccountDialog.java index 94b622eb..a7ccf229 100644 --- a/src/main/java/com/sparrowwallet/sparrow/control/AddAccountDialog.java +++ b/src/main/java/com/sparrowwallet/sparrow/control/AddAccountDialog.java @@ -14,8 +14,7 @@ import javafx.util.StringConverter; import org.controlsfx.glyphfont.Glyph; -import java.util.ArrayList; -import java.util.List; +import java.util.*; import static com.sparrowwallet.drongo.wallet.StandardAccount.*; @@ -46,12 +45,14 @@ public AddAccountDialog(Wallet wallet) { standardAccountCombo = new ComboBox<>(); standardAccountCombo.setMaxWidth(Double.MAX_VALUE); - List existingIndexes = new ArrayList<>(); + Set existingIndexes = new LinkedHashSet<>(); Wallet masterWallet = wallet.isMasterWallet() ? wallet : wallet.getMasterWallet(); existingIndexes.add(masterWallet.getAccountIndex()); for(Wallet childWallet : masterWallet.getChildWallets()) { if(!childWallet.isNested()) { existingIndexes.add(childWallet.getAccountIndex()); + Optional optStdAcc = Arrays.stream(StandardAccount.values()).filter(stdacc -> stdacc.getName().equals(childWallet.getName())).findFirst(); + optStdAcc.ifPresent(standardAccount -> existingIndexes.add(standardAccount.getAccountNumber())); } }