mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-12-25 13:16:44 +00:00
allow adding additional accounts (up to account 30) if accounts 0-9 have already been added
This commit is contained in:
parent
6a496894e1
commit
0f05502af6
3 changed files with 9 additions and 5 deletions
|
@ -20,6 +20,8 @@ import java.util.List;
|
||||||
import static com.sparrowwallet.drongo.wallet.StandardAccount.*;
|
import static com.sparrowwallet.drongo.wallet.StandardAccount.*;
|
||||||
|
|
||||||
public class AddAccountDialog extends Dialog<List<StandardAccount>> {
|
public class AddAccountDialog extends Dialog<List<StandardAccount>> {
|
||||||
|
private static final int MAX_SHOWN_ACCOUNTS = 8;
|
||||||
|
|
||||||
private final ComboBox<StandardAccount> standardAccountCombo;
|
private final ComboBox<StandardAccount> standardAccountCombo;
|
||||||
private boolean discoverAccounts = false;
|
private boolean discoverAccounts = false;
|
||||||
|
|
||||||
|
@ -55,7 +57,7 @@ public class AddAccountDialog extends Dialog<List<StandardAccount>> {
|
||||||
|
|
||||||
List<StandardAccount> availableAccounts = new ArrayList<>();
|
List<StandardAccount> availableAccounts = new ArrayList<>();
|
||||||
for(StandardAccount standardAccount : StandardAccount.values()) {
|
for(StandardAccount standardAccount : StandardAccount.values()) {
|
||||||
if(!existingIndexes.contains(standardAccount.getAccountNumber()) && !StandardAccount.isWhirlpoolAccount(standardAccount)) {
|
if(!existingIndexes.contains(standardAccount.getAccountNumber()) && !StandardAccount.isWhirlpoolAccount(standardAccount) && availableAccounts.size() <= MAX_SHOWN_ACCOUNTS) {
|
||||||
availableAccounts.add(standardAccount);
|
availableAccounts.add(standardAccount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1702,7 +1702,7 @@ public class ElectrumServer {
|
||||||
|
|
||||||
for(int i = 0; i < wallets.size(); i++) {
|
for(int i = 0; i < wallets.size(); i++) {
|
||||||
Wallet wallet = wallets.get(i);
|
Wallet wallet = wallets.get(i);
|
||||||
updateProgress(i, wallets.size() + StandardAccount.values().length);
|
updateProgress(i, wallets.size() + StandardAccount.DISCOVERY_ACCOUNTS.size());
|
||||||
Map<WalletNode, Set<BlockTransactionHash>> nodeTransactionMap = new TreeMap<>();
|
Map<WalletNode, Set<BlockTransactionHash>> nodeTransactionMap = new TreeMap<>();
|
||||||
electrumServer.getReferences(wallet, wallet.getNode(KeyPurpose.RECEIVE).getChildren(), nodeTransactionMap, 0);
|
electrumServer.getReferences(wallet, wallet.getNode(KeyPurpose.RECEIVE).getChildren(), nodeTransactionMap, 0);
|
||||||
if(nodeTransactionMap.values().stream().anyMatch(blockTransactionHashes -> !blockTransactionHashes.isEmpty())) {
|
if(nodeTransactionMap.values().stream().anyMatch(blockTransactionHashes -> !blockTransactionHashes.isEmpty())) {
|
||||||
|
@ -1721,7 +1721,7 @@ public class ElectrumServer {
|
||||||
foundAccounts.add(standardAccount);
|
foundAccounts.add(standardAccount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
updateProgress(i + j, wallets.size() + StandardAccount.values().length);
|
updateProgress(i + j, wallets.size() + StandardAccount.DISCOVERY_ACCOUNTS.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
for(StandardAccount standardAccount : foundAccounts) {
|
for(StandardAccount standardAccount : foundAccounts) {
|
||||||
|
@ -1743,7 +1743,7 @@ public class ElectrumServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
List<StandardAccount> accounts = new ArrayList<>();
|
List<StandardAccount> accounts = new ArrayList<>();
|
||||||
for(StandardAccount account : StandardAccount.values()) {
|
for(StandardAccount account : StandardAccount.DISCOVERY_ACCOUNTS) {
|
||||||
if(account != StandardAccount.ACCOUNT_0 && (!StandardAccount.isWhirlpoolAccount(account) || wallet.getScriptType() == ScriptType.P2WPKH)) {
|
if(account != StandardAccount.ACCOUNT_0 && (!StandardAccount.isWhirlpoolAccount(account) || wallet.getScriptType() == ScriptType.P2WPKH)) {
|
||||||
accounts.add(account);
|
accounts.add(account);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,8 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
final class AddAccountDialog extends DialogWindow {
|
final class AddAccountDialog extends DialogWindow {
|
||||||
|
private static final int MAX_SHOWN_ACCOUNTS = 8;
|
||||||
|
|
||||||
private ComboBox<DisplayStandardAccount> standardAccounts;
|
private ComboBox<DisplayStandardAccount> standardAccounts;
|
||||||
private StandardAccount standardAccount;
|
private StandardAccount standardAccount;
|
||||||
|
|
||||||
|
@ -40,7 +42,7 @@ final class AddAccountDialog extends DialogWindow {
|
||||||
|
|
||||||
List<StandardAccount> availableAccounts = new ArrayList<>();
|
List<StandardAccount> availableAccounts = new ArrayList<>();
|
||||||
for(StandardAccount standardAccount : StandardAccount.values()) {
|
for(StandardAccount standardAccount : StandardAccount.values()) {
|
||||||
if(!existingIndexes.contains(standardAccount.getAccountNumber()) && !StandardAccount.isWhirlpoolAccount(standardAccount)) {
|
if(!existingIndexes.contains(standardAccount.getAccountNumber()) && !StandardAccount.isWhirlpoolAccount(standardAccount) && availableAccounts.size() <= MAX_SHOWN_ACCOUNTS) {
|
||||||
availableAccounts.add(standardAccount);
|
availableAccounts.add(standardAccount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue