diff --git a/common/src/main/java/bisq/common/config/Config.java b/common/src/main/java/bisq/common/config/Config.java index 4efa582d3b..96e95b72fe 100644 --- a/common/src/main/java/bisq/common/config/Config.java +++ b/common/src/main/java/bisq/common/config/Config.java @@ -59,6 +59,7 @@ public class Config { public static final String TOR_CONTROL_USE_SAFE_COOKIE_AUTH = "torControlUseSafeCookieAuth"; public static final String TOR_STREAM_ISOLATION = "torStreamIsolation"; public static final String IGNORE_LOCAL_BTC_NODE = "ignoreLocalBtcNode"; + public static final String BTC_NODES = "btcNodes"; private static final Logger log = LoggerFactory.getLogger(Config.class); @@ -112,6 +113,7 @@ public class Config { private final int msgThrottlePer10Sec; private final int sendMsgThrottleTrigger; private final int sendMsgThrottleSleep; + private final String btcNodes; // properties derived from cli options, but not exposed as cli options themselves private boolean localBitcoinNodeIsRunning = false; // FIXME: eliminate mutable state @@ -387,6 +389,12 @@ public class Config { .withRequiredArg() .ofType(int.class) .defaultsTo(50); // Pause in ms to sleep if we get too many messages to send + + ArgumentAcceptingOptionSpec btcNodesOpt = + parser.accepts(BTC_NODES, "Custom nodes used for BitcoinJ as comma separated IP addresses.") + .withRequiredArg() + .describedAs("ip[,...]") + .defaultsTo(""); try { OptionSet cliOpts = parser.parse(args); @@ -467,6 +475,7 @@ public class Config { " msgThrottlePerSec={},\n msgThrottlePer10Sec={},\n" + " sendMsgThrottleTrigger={},\n sendMsgThrottleSleep={}\n}", msgThrottlePerSec, msgThrottlePer10Sec, sendMsgThrottleTrigger, sendMsgThrottleSleep); + this.btcNodes = options.valueOf(btcNodesOpt); } catch (OptionException ex) { throw new ConfigException(format("problem parsing option '%s': %s", ex.options().get(0), @@ -702,4 +711,8 @@ public class Config { public int getSendMsgThrottleSleep() { return sendMsgThrottleSleep; } + + public String getBtcNodes() { + return btcNodes; + } } diff --git a/core/src/main/java/bisq/core/app/BisqEnvironment.java b/core/src/main/java/bisq/core/app/BisqEnvironment.java index 12767ac988..5990525f98 100644 --- a/core/src/main/java/bisq/core/app/BisqEnvironment.java +++ b/core/src/main/java/bisq/core/app/BisqEnvironment.java @@ -59,7 +59,7 @@ public class BisqEnvironment extends StandardEnvironment { @Setter protected boolean isBitcoinLocalhostNodeRunning; - protected final String btcNodes, useTorForBtc, rpcUser, rpcPassword, + protected final String useTorForBtc, rpcUser, rpcPassword, rpcHost, rpcPort, rpcBlockNotificationPort, rpcBlockNotificationHost, dumpBlockchainData, fullDaoNode, useAllProvidedNodes, numConnectionForBtc, genesisTxId, genesisBlockHeight, genesisTotalSupply, daoActivated; @@ -86,7 +86,6 @@ public class BisqEnvironment extends StandardEnvironment { daoActivated = getProperty(commandLineProperties, DaoOptionKeys.DAO_ACTIVATED, "true"); //BtcOptionKeys - btcNodes = getProperty(commandLineProperties, BtcOptionKeys.BTC_NODES, ""); useTorForBtc = getProperty(commandLineProperties, BtcOptionKeys.USE_TOR_FOR_BTC, ""); userAgent = getProperty(commandLineProperties, BtcOptionKeys.USER_AGENT, "Bisq"); useAllProvidedNodes = getProperty(commandLineProperties, BtcOptionKeys.USE_ALL_PROVIDED_NODES, "false"); @@ -121,7 +120,6 @@ public class BisqEnvironment extends StandardEnvironment { setProperty(DaoOptionKeys.GENESIS_TOTAL_SUPPLY, genesisTotalSupply); setProperty(DaoOptionKeys.DAO_ACTIVATED, daoActivated); - setProperty(BtcOptionKeys.BTC_NODES, btcNodes); setProperty(BtcOptionKeys.USE_TOR_FOR_BTC, useTorForBtc); setProperty(BtcOptionKeys.USER_AGENT, userAgent); setProperty(BtcOptionKeys.USE_ALL_PROVIDED_NODES, useAllProvidedNodes); diff --git a/core/src/main/java/bisq/core/app/BisqExecutable.java b/core/src/main/java/bisq/core/app/BisqExecutable.java index 9a081142c7..94410475e9 100644 --- a/core/src/main/java/bisq/core/app/BisqExecutable.java +++ b/core/src/main/java/bisq/core/app/BisqExecutable.java @@ -286,11 +286,6 @@ public abstract class BisqExecutable implements GracefulShutDownHandler, BisqSet .ofType(boolean.class); //BtcOptionKeys - parser.accepts(BtcOptionKeys.BTC_NODES, - "Custom nodes used for BitcoinJ as comma separated IP addresses.") - .withRequiredArg() - .describedAs("ip[,...]"); - parser.accepts(BtcOptionKeys.USE_TOR_FOR_BTC, "If set to true BitcoinJ is routed over tor (socks 5 proxy).") .withRequiredArg(); diff --git a/core/src/main/java/bisq/core/btc/BitcoinModule.java b/core/src/main/java/bisq/core/btc/BitcoinModule.java index 085c909b11..bc717b1da3 100644 --- a/core/src/main/java/bisq/core/btc/BitcoinModule.java +++ b/core/src/main/java/bisq/core/btc/BitcoinModule.java @@ -80,7 +80,7 @@ public class BitcoinModule extends AppModule { bind(File.class).annotatedWith(named(WALLET_DIR)).toInstance(config.getWalletDir()); - bindConstant().annotatedWith(named(BtcOptionKeys.BTC_NODES)).to(environment.getRequiredProperty(BtcOptionKeys.BTC_NODES)); + bindConstant().annotatedWith(named(Config.BTC_NODES)).to(config.getBtcNodes()); bindConstant().annotatedWith(named(BtcOptionKeys.USER_AGENT)).to(environment.getRequiredProperty(BtcOptionKeys.USER_AGENT)); bindConstant().annotatedWith(named(BtcOptionKeys.NUM_CONNECTIONS_FOR_BTC)).to(environment.getRequiredProperty(BtcOptionKeys.NUM_CONNECTIONS_FOR_BTC)); bindConstant().annotatedWith(named(BtcOptionKeys.USE_ALL_PROVIDED_NODES)).to(environment.getRequiredProperty(BtcOptionKeys.USE_ALL_PROVIDED_NODES)); diff --git a/core/src/main/java/bisq/core/btc/BtcOptionKeys.java b/core/src/main/java/bisq/core/btc/BtcOptionKeys.java index e56c933645..3e042fdff4 100644 --- a/core/src/main/java/bisq/core/btc/BtcOptionKeys.java +++ b/core/src/main/java/bisq/core/btc/BtcOptionKeys.java @@ -18,7 +18,6 @@ package bisq.core.btc; public class BtcOptionKeys { - public static final String BTC_NODES = "btcNodes"; public static final String USE_TOR_FOR_BTC = "useTorForBtc"; public static final String SOCKS5_DISCOVER_MODE = "socks5DiscoverMode"; public static final String USER_AGENT = "userAgent"; diff --git a/core/src/main/java/bisq/core/user/Preferences.java b/core/src/main/java/bisq/core/user/Preferences.java index ba7cd911c0..7d92c1249f 100644 --- a/core/src/main/java/bisq/core/user/Preferences.java +++ b/core/src/main/java/bisq/core/user/Preferences.java @@ -150,7 +150,7 @@ public final class Preferences implements PersistedDataHost, BridgeAddressProvid @Inject public Preferences(Storage storage, Config config, - @Named(BtcOptionKeys.BTC_NODES) String btcNodesFromOptions, + @Named(Config.BTC_NODES) String btcNodesFromOptions, @Named(BtcOptionKeys.USE_TOR_FOR_BTC) String useTorFlagFromOptions, @Named(Config.REFERRAL_ID) String referralId, @Named(DaoOptionKeys.FULL_DAO_NODE) String fullDaoNode,