mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-12-25 13:16:44 +00:00
add null safe tests for standard account types
This commit is contained in:
parent
1d560d6aa6
commit
b3516063b2
9 changed files with 12 additions and 12 deletions
2
drongo
2
drongo
|
@ -1 +1 @@
|
||||||
Subproject commit 28551247c699c79561180dfe1c2b02db2b742a27
|
Subproject commit 94aafbc11e974e44ba53fe505940767ff77ef940
|
|
@ -55,7 +55,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()) && !WHIRLPOOL_ACCOUNTS.contains(standardAccount)) {
|
if(!existingIndexes.contains(standardAccount.getAccountNumber()) && !StandardAccount.isWhirlpoolAccount(standardAccount)) {
|
||||||
availableAccounts.add(standardAccount);
|
availableAccounts.add(standardAccount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1697,7 +1697,7 @@ public class ElectrumServer {
|
||||||
Map<WalletNode, Set<BlockTransactionHash>> childTransactionMap = new TreeMap<>();
|
Map<WalletNode, Set<BlockTransactionHash>> childTransactionMap = new TreeMap<>();
|
||||||
electrumServer.getReferences(childWallet, childWallet.getNode(KeyPurpose.RECEIVE).getChildren(), childTransactionMap, 0);
|
electrumServer.getReferences(childWallet, childWallet.getNode(KeyPurpose.RECEIVE).getChildren(), childTransactionMap, 0);
|
||||||
if(childTransactionMap.values().stream().anyMatch(blockTransactionHashes -> !blockTransactionHashes.isEmpty())) {
|
if(childTransactionMap.values().stream().anyMatch(blockTransactionHashes -> !blockTransactionHashes.isEmpty())) {
|
||||||
if(StandardAccount.WHIRLPOOL_ACCOUNTS.contains(standardAccount)) {
|
if(StandardAccount.isWhirlpoolAccount(standardAccount)) {
|
||||||
foundAccounts.addAll(StandardAccount.WHIRLPOOL_ACCOUNTS);
|
foundAccounts.addAll(StandardAccount.WHIRLPOOL_ACCOUNTS);
|
||||||
} else {
|
} else {
|
||||||
foundAccounts.add(standardAccount);
|
foundAccounts.add(standardAccount);
|
||||||
|
@ -1726,7 +1726,7 @@ public class ElectrumServer {
|
||||||
|
|
||||||
List<StandardAccount> accounts = new ArrayList<>();
|
List<StandardAccount> accounts = new ArrayList<>();
|
||||||
for(StandardAccount account : StandardAccount.values()) {
|
for(StandardAccount account : StandardAccount.values()) {
|
||||||
if(account != StandardAccount.ACCOUNT_0 && (!StandardAccount.WHIRLPOOL_ACCOUNTS.contains(account) || wallet.getScriptType() == ScriptType.P2WPKH)) {
|
if(account != StandardAccount.ACCOUNT_0 && (!StandardAccount.isWhirlpoolAccount(account) || wallet.getScriptType() == ScriptType.P2WPKH)) {
|
||||||
accounts.add(account);
|
accounts.add(account);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,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.WHIRLPOOL_ACCOUNTS.contains(standardAccount)) {
|
if(!existingIndexes.contains(standardAccount.getAccountNumber()) && !StandardAccount.isWhirlpoolAccount(standardAccount)) {
|
||||||
availableAccounts.add(standardAccount);
|
availableAccounts.add(standardAccount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,7 @@ final class AddAccountDialog extends DialogWindow {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
if(StandardAccount.WHIRLPOOL_ACCOUNTS.contains(account)) {
|
if(StandardAccount.isWhirlpoolAccount(account)) {
|
||||||
return "Whirlpool Accounts";
|
return "Whirlpool Accounts";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -114,7 +114,7 @@ public class SettingsDialog extends WalletDialog {
|
||||||
if(standardAccount != null) {
|
if(standardAccount != null) {
|
||||||
addAccount(masterWallet, standardAccount, () -> {
|
addAccount(masterWallet, standardAccount, () -> {
|
||||||
SparrowTerminal.get().getGuiThread().invokeLater(() -> {
|
SparrowTerminal.get().getGuiThread().invokeLater(() -> {
|
||||||
if(StandardAccount.WHIRLPOOL_ACCOUNTS.contains(standardAccount)) {
|
if(StandardAccount.isWhirlpoolAccount(standardAccount)) {
|
||||||
showSuccessDialog("Added Accounts", "Whirlpool Accounts have been successfully added.");
|
showSuccessDialog("Added Accounts", "Whirlpool Accounts have been successfully added.");
|
||||||
} else {
|
} else {
|
||||||
showSuccessDialog("Added Account", standardAccount.getName() + " has been successfully added.");
|
showSuccessDialog("Added Account", standardAccount.getName() + " has been successfully added.");
|
||||||
|
|
|
@ -124,7 +124,7 @@ public class WalletDialog extends DialogWindow {
|
||||||
|
|
||||||
private void addAndSaveAccount(Wallet masterWallet, StandardAccount standardAccount, Key key) {
|
private void addAndSaveAccount(Wallet masterWallet, StandardAccount standardAccount, Key key) {
|
||||||
List<Wallet> childWallets;
|
List<Wallet> childWallets;
|
||||||
if(StandardAccount.WHIRLPOOL_ACCOUNTS.contains(standardAccount)) {
|
if(StandardAccount.isWhirlpoolAccount(standardAccount)) {
|
||||||
childWallets = WhirlpoolServices.prepareWhirlpoolWallet(masterWallet, getWalletForm().getWalletId(), getWalletForm().getStorage());
|
childWallets = WhirlpoolServices.prepareWhirlpoolWallet(masterWallet, getWalletForm().getWalletId(), getWalletForm().getStorage());
|
||||||
} else {
|
} else {
|
||||||
Wallet childWallet = masterWallet.addChildWallet(standardAccount);
|
Wallet childWallet = masterWallet.addChildWallet(standardAccount);
|
||||||
|
|
|
@ -411,7 +411,7 @@ public class SendController extends WalletFormController implements Initializabl
|
||||||
});
|
});
|
||||||
|
|
||||||
efficiencyToggle.setOnAction(event -> {
|
efficiencyToggle.setOnAction(event -> {
|
||||||
if(StandardAccount.WHIRLPOOL_MIX_ACCOUNTS.contains(getWalletForm().getWallet().getStandardAccountType()) && !overrideOptimizationStrategy) {
|
if(StandardAccount.isWhirlpoolMixAccount(getWalletForm().getWallet().getStandardAccountType()) && !overrideOptimizationStrategy) {
|
||||||
AppServices.showWarningDialog("Privacy may be lost!", "It is recommended to optimize for privacy when sending coinjoined outputs.");
|
AppServices.showWarningDialog("Privacy may be lost!", "It is recommended to optimize for privacy when sending coinjoined outputs.");
|
||||||
overrideOptimizationStrategy = true;
|
overrideOptimizationStrategy = true;
|
||||||
}
|
}
|
||||||
|
@ -1014,7 +1014,7 @@ public class SendController extends WalletFormController implements Initializabl
|
||||||
|
|
||||||
private OptimizationStrategy getPreferredOptimizationStrategy() {
|
private OptimizationStrategy getPreferredOptimizationStrategy() {
|
||||||
OptimizationStrategy optimizationStrategy = Config.get().getSendOptimizationStrategy();
|
OptimizationStrategy optimizationStrategy = Config.get().getSendOptimizationStrategy();
|
||||||
if(StandardAccount.WHIRLPOOL_MIX_ACCOUNTS.contains(getWalletForm().getWallet().getStandardAccountType()) && !overrideOptimizationStrategy) {
|
if(StandardAccount.isWhirlpoolMixAccount(getWalletForm().getWallet().getStandardAccountType()) && !overrideOptimizationStrategy) {
|
||||||
optimizationStrategy = OptimizationStrategy.PRIVACY;
|
optimizationStrategy = OptimizationStrategy.PRIVACY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -390,7 +390,7 @@ public class Whirlpool {
|
||||||
|
|
||||||
public static Wallet getStandardAccountWallet(WhirlpoolAccount whirlpoolAccount, Wallet wallet) {
|
public static Wallet getStandardAccountWallet(WhirlpoolAccount whirlpoolAccount, Wallet wallet) {
|
||||||
StandardAccount standardAccount = getStandardAccount(whirlpoolAccount);
|
StandardAccount standardAccount = getStandardAccount(whirlpoolAccount);
|
||||||
if(StandardAccount.WHIRLPOOL_ACCOUNTS.contains(standardAccount) || wallet.getStandardAccountType() != standardAccount) {
|
if(StandardAccount.isWhirlpoolAccount(standardAccount) || wallet.getStandardAccountType() != standardAccount) {
|
||||||
Wallet standardWallet = wallet.getChildWallet(standardAccount);
|
Wallet standardWallet = wallet.getChildWallet(standardAccount);
|
||||||
if(standardWallet == null) {
|
if(standardWallet == null) {
|
||||||
throw new IllegalStateException("Cannot find " + standardAccount + " wallet");
|
throw new IllegalStateException("Cannot find " + standardAccount + " wallet");
|
||||||
|
|
|
@ -173,7 +173,7 @@ public class WhirlpoolServices {
|
||||||
&& wallet.getKeystores().get(0).hasSeed()
|
&& wallet.getKeystores().get(0).hasSeed()
|
||||||
&& wallet.getKeystores().get(0).getSeed().getType() == DeterministicSeed.Type.BIP39
|
&& wallet.getKeystores().get(0).getSeed().getType() == DeterministicSeed.Type.BIP39
|
||||||
&& wallet.getStandardAccountType() != null
|
&& wallet.getStandardAccountType() != null
|
||||||
&& StandardAccount.MIXABLE_ACCOUNTS.contains(wallet.getStandardAccountType());
|
&& StandardAccount.isMixableAccount(wallet.getStandardAccountType());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean canWatchPostmix(Wallet wallet) {
|
public static boolean canWatchPostmix(Wallet wallet) {
|
||||||
|
|
Loading…
Reference in a new issue