From 18269020662b147d232209fd5c12eb44097f37f8 Mon Sep 17 00:00:00 2001 From: jmacxx <47253594+jmacxx@users.noreply.github.com> Date: Thu, 28 Jan 2021 11:38:39 -0600 Subject: [PATCH] Replace deprecated bisq explorer settings If user preferences were set to a bisq explorer that has been retired, switch it to another explorer from the provided list. Users can still choose their own explorer, or enter a custom explorer address (such as their local node). --- core/src/main/java/bisq/core/user/Preferences.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/bisq/core/user/Preferences.java b/core/src/main/java/bisq/core/user/Preferences.java index ee276d0ef0..f85a449bd9 100644 --- a/core/src/main/java/bisq/core/user/Preferences.java +++ b/core/src/main/java/bisq/core/user/Preferences.java @@ -309,15 +309,25 @@ public final class Preferences implements PersistedDataHost, BridgeAddressProvid useStandbyModeProperty.set(prefPayload.isUseStandbyMode()); cssThemeProperty.set(prefPayload.getCssTheme()); + // a list of previously-used federated explorers + // if user preference references any deprecated explorers we need to select a new valid explorer + String deprecatedExplorers = "(bsq.bisq.cc|bsq.vante.me|bsq.emzy.de|bsq.sqrrm.net|bsq.bisq.services|bsq.ninja).*"; + // if no valid Bitcoin block explorer is set, select the 1st valid Bitcoin block explorer ArrayList btcExplorers = getBlockChainExplorers(); - if (getBlockChainExplorer() == null || getBlockChainExplorer().name.length() == 0) + if (getBlockChainExplorer() == null || + getBlockChainExplorer().name.length() == 0 || + getBlockChainExplorer().name.matches(deprecatedExplorers)) { setBlockChainExplorer(btcExplorers.get(0)); + } // if no valid BSQ block explorer is set, randomly select a valid BSQ block explorer ArrayList bsqExplorers = getBsqBlockChainExplorers(); - if (getBsqBlockChainExplorer() == null || getBsqBlockChainExplorer().name.length() == 0) + if (getBsqBlockChainExplorer() == null || + getBsqBlockChainExplorer().name.length() == 0 || + getBsqBlockChainExplorer().name.matches(deprecatedExplorers)) { setBsqBlockChainExplorer(bsqExplorers.get((new Random()).nextInt(bsqExplorers.size()))); + } tradeCurrenciesAsObservable.addAll(prefPayload.getFiatCurrencies()); tradeCurrenciesAsObservable.addAll(prefPayload.getCryptoCurrencies());