Skip to content

Commit

Permalink
add additional check against existing child wallet names when suggest…
Browse files Browse the repository at this point in the history
…ing new accounts to add
  • Loading branch information
craigraw committed Apr 23, 2024
1 parent f1cddc2 commit 21d91d3
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;

Expand Down Expand Up @@ -46,12 +45,14 @@ public AddAccountDialog(Wallet wallet) {
standardAccountCombo = new ComboBox<>();
standardAccountCombo.setMaxWidth(Double.MAX_VALUE);

List<Integer> existingIndexes = new ArrayList<>();
Set<Integer> 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<StandardAccount> optStdAcc = Arrays.stream(StandardAccount.values()).filter(stdacc -> stdacc.getName().equals(childWallet.getName())).findFirst();
optStdAcc.ifPresent(standardAccount -> existingIndexes.add(standardAccount.getAccountNumber()));
}
}

Expand Down

0 comments on commit 21d91d3

Please sign in to comment.