mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-12-25 13:16:44 +00:00
add additional check against existing child wallet names when suggesting new accounts to add
This commit is contained in:
parent
f1cddc28e7
commit
21d91d3d10
1 changed files with 4 additions and 3 deletions
|
@ -14,8 +14,7 @@ import javafx.scene.layout.VBox;
|
||||||
import javafx.util.StringConverter;
|
import javafx.util.StringConverter;
|
||||||
import org.controlsfx.glyphfont.Glyph;
|
import org.controlsfx.glyphfont.Glyph;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import static com.sparrowwallet.drongo.wallet.StandardAccount.*;
|
import static com.sparrowwallet.drongo.wallet.StandardAccount.*;
|
||||||
|
|
||||||
|
@ -46,12 +45,14 @@ public class AddAccountDialog extends Dialog<List<StandardAccount>> {
|
||||||
standardAccountCombo = new ComboBox<>();
|
standardAccountCombo = new ComboBox<>();
|
||||||
standardAccountCombo.setMaxWidth(Double.MAX_VALUE);
|
standardAccountCombo.setMaxWidth(Double.MAX_VALUE);
|
||||||
|
|
||||||
List<Integer> existingIndexes = new ArrayList<>();
|
Set<Integer> existingIndexes = new LinkedHashSet<>();
|
||||||
Wallet masterWallet = wallet.isMasterWallet() ? wallet : wallet.getMasterWallet();
|
Wallet masterWallet = wallet.isMasterWallet() ? wallet : wallet.getMasterWallet();
|
||||||
existingIndexes.add(masterWallet.getAccountIndex());
|
existingIndexes.add(masterWallet.getAccountIndex());
|
||||||
for(Wallet childWallet : masterWallet.getChildWallets()) {
|
for(Wallet childWallet : masterWallet.getChildWallets()) {
|
||||||
if(!childWallet.isNested()) {
|
if(!childWallet.isNested()) {
|
||||||
existingIndexes.add(childWallet.getAccountIndex());
|
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()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue