diff --git a/core/src/main/java/bisq/core/user/Preferences.java b/core/src/main/java/bisq/core/user/Preferences.java index fee30828819..e38c57cc55a 100644 --- a/core/src/main/java/bisq/core/user/Preferences.java +++ b/core/src/main/java/bisq/core/user/Preferences.java @@ -254,14 +254,12 @@ public void readPersisted() { // if no valid Bitcoin block explorer is set, select the 1st valid Bitcoin block explorer ArrayList btcExplorers = getBlockChainExplorers(); - BlockChainExplorer btcExplorer = getBlockChainExplorer(); - if (btcExplorer == null || btcExplorers.contains(btcExplorer) == false) + if (!blockExplorerExists(btcExplorers, getBlockChainExplorer())) setBlockChainExplorer(btcExplorers.get(0)); // if no valid BSQ block explorer is set, randomly select a valid BSQ block explorer ArrayList bsqExplorers = getBsqBlockChainExplorers(); - BlockChainExplorer bsqExplorer = getBsqBlockChainExplorer(); - if (bsqExplorer == null || bsqExplorers.contains(bsqExplorer) == false) + if (!blockExplorerExists(bsqExplorers, getBsqBlockChainExplorer())) setBsqBlockChainExplorer(bsqExplorers.get((new Random()).nextInt(bsqExplorers.size()))); tradeCurrenciesAsObservable.addAll(prefPayload.getFiatCurrencies()); @@ -826,6 +824,16 @@ else if (change.wasRemoved() && change.getRemovedSize() == 1 && initialReadDone) tradeCurrenciesAsObservable.remove(change.getRemoved().get(0)); } + private boolean blockExplorerExists(ArrayList explorers, + BlockChainExplorer explorer) + { + if (explorer != null && explorers != null && explorers.size() > 0) + for (int i = 0; i < explorers.size(); i++) + if (explorers.get(i).name.equals(explorer.name)) + return true; + return false; + } + private interface ExcludesDelegateMethods { void setTacAccepted(boolean tacAccepted);