add null safe tests for standard account types

This commit is contained in:
Craig Raw 2023-11-15 10:52:05 +02:00
parent 1d560d6aa6
commit b3516063b2
9 changed files with 12 additions and 12 deletions

2
drongo

@ -1 +1 @@
Subproject commit 28551247c699c79561180dfe1c2b02db2b742a27
Subproject commit 94aafbc11e974e44ba53fe505940767ff77ef940

View file

@ -55,7 +55,7 @@ public class AddAccountDialog extends Dialog<List<StandardAccount>> {
List<StandardAccount> availableAccounts = new ArrayList<>();
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);
}
}

View file

@ -1697,7 +1697,7 @@ public class ElectrumServer {
Map<WalletNode, Set<BlockTransactionHash>> childTransactionMap = new TreeMap<>();
electrumServer.getReferences(childWallet, childWallet.getNode(KeyPurpose.RECEIVE).getChildren(), childTransactionMap, 0);
if(childTransactionMap.values().stream().anyMatch(blockTransactionHashes -> !blockTransactionHashes.isEmpty())) {
if(StandardAccount.WHIRLPOOL_ACCOUNTS.contains(standardAccount)) {
if(StandardAccount.isWhirlpoolAccount(standardAccount)) {
foundAccounts.addAll(StandardAccount.WHIRLPOOL_ACCOUNTS);
} else {
foundAccounts.add(standardAccount);
@ -1726,7 +1726,7 @@ public class ElectrumServer {
List<StandardAccount> accounts = new ArrayList<>();
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);
}
}

View file

@ -40,7 +40,7 @@ final class AddAccountDialog extends DialogWindow {
List<StandardAccount> availableAccounts = new ArrayList<>();
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);
}
}
@ -87,7 +87,7 @@ final class AddAccountDialog extends DialogWindow {
@Override
public String toString() {
if(StandardAccount.WHIRLPOOL_ACCOUNTS.contains(account)) {
if(StandardAccount.isWhirlpoolAccount(account)) {
return "Whirlpool Accounts";
}

View file

@ -114,7 +114,7 @@ public class SettingsDialog extends WalletDialog {
if(standardAccount != null) {
addAccount(masterWallet, standardAccount, () -> {
SparrowTerminal.get().getGuiThread().invokeLater(() -> {
if(StandardAccount.WHIRLPOOL_ACCOUNTS.contains(standardAccount)) {
if(StandardAccount.isWhirlpoolAccount(standardAccount)) {
showSuccessDialog("Added Accounts", "Whirlpool Accounts have been successfully added.");
} else {
showSuccessDialog("Added Account", standardAccount.getName() + " has been successfully added.");

View file

@ -124,7 +124,7 @@ public class WalletDialog extends DialogWindow {
private void addAndSaveAccount(Wallet masterWallet, StandardAccount standardAccount, Key key) {
List<Wallet> childWallets;
if(StandardAccount.WHIRLPOOL_ACCOUNTS.contains(standardAccount)) {
if(StandardAccount.isWhirlpoolAccount(standardAccount)) {
childWallets = WhirlpoolServices.prepareWhirlpoolWallet(masterWallet, getWalletForm().getWalletId(), getWalletForm().getStorage());
} else {
Wallet childWallet = masterWallet.addChildWallet(standardAccount);

View file

@ -411,7 +411,7 @@ public class SendController extends WalletFormController implements Initializabl
});
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.");
overrideOptimizationStrategy = true;
}
@ -1014,7 +1014,7 @@ public class SendController extends WalletFormController implements Initializabl
private OptimizationStrategy getPreferredOptimizationStrategy() {
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;
}

View file

@ -390,7 +390,7 @@ public class Whirlpool {
public static Wallet getStandardAccountWallet(WhirlpoolAccount whirlpoolAccount, Wallet wallet) {
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);
if(standardWallet == null) {
throw new IllegalStateException("Cannot find " + standardAccount + " wallet");

View file

@ -173,7 +173,7 @@ public class WhirlpoolServices {
&& wallet.getKeystores().get(0).hasSeed()
&& wallet.getKeystores().get(0).getSeed().getType() == DeterministicSeed.Type.BIP39
&& wallet.getStandardAccountType() != null
&& StandardAccount.MIXABLE_ACCOUNTS.contains(wallet.getStandardAccountType());
&& StandardAccount.isMixableAccount(wallet.getStandardAccountType());
}
public static boolean canWatchPostmix(Wallet wallet) {