diff --git a/common/src/main/java/bisq/common/config/Config.java b/common/src/main/java/bisq/common/config/Config.java index 75adba0a71..51fd534db2 100644 --- a/common/src/main/java/bisq/common/config/Config.java +++ b/common/src/main/java/bisq/common/config/Config.java @@ -66,6 +66,7 @@ public class Config { public static final String NUM_CONNECTIONS_FOR_BTC = "numConnectionsForBtc"; public static final String RPC_USER = "rpcUser"; public static final String RPC_PASSWORD = "rpcPassword"; + public static final String RPC_HOST = "rpcHost"; private static final Logger log = LoggerFactory.getLogger(Config.class); @@ -129,6 +130,7 @@ public class Config { private final int numConnectionsForBtc; private final String rpcUser; private final String rpcPassword; + private final String rpcHost; // properties derived from cli options, but not exposed as cli options themselves private boolean localBitcoinNodeIsRunning = false; // FIXME: eliminate mutable state @@ -453,6 +455,11 @@ public class Config { .withRequiredArg() .defaultsTo(""); + ArgumentAcceptingOptionSpec rpcHostOpt = + parser.accepts(RPC_HOST, "Bitcoind rpc host") + .withRequiredArg() + .defaultsTo(""); + try { OptionSet cliOpts = parser.parse(args); @@ -542,6 +549,7 @@ public class Config { this.numConnectionsForBtc = options.valueOf(numConnectionsForBtcOpt); this.rpcUser = options.valueOf(rpcUserOpt); this.rpcPassword = options.valueOf(rpcPasswordOpt); + this.rpcHost = options.valueOf(rpcHostOpt); } catch (OptionException ex) { throw new ConfigException(format("problem parsing option '%s': %s", ex.options().get(0), @@ -813,4 +821,8 @@ public class Config { public String getRpcPassword() { return rpcPassword; } + + public String getRpcHost() { + return rpcHost; + } } diff --git a/core/src/main/java/bisq/core/app/BisqEnvironment.java b/core/src/main/java/bisq/core/app/BisqEnvironment.java index 8a951e4685..b4039a1219 100644 --- a/core/src/main/java/bisq/core/app/BisqEnvironment.java +++ b/core/src/main/java/bisq/core/app/BisqEnvironment.java @@ -57,7 +57,7 @@ public class BisqEnvironment extends StandardEnvironment { protected boolean isBitcoinLocalhostNodeRunning; protected final String - rpcHost, rpcPort, rpcBlockNotificationPort, rpcBlockNotificationHost, dumpBlockchainData, fullDaoNode, + rpcPort, rpcBlockNotificationPort, rpcBlockNotificationHost, dumpBlockchainData, fullDaoNode, genesisTxId, genesisBlockHeight, genesisTotalSupply, daoActivated; @@ -69,7 +69,6 @@ public class BisqEnvironment extends StandardEnvironment { @SuppressWarnings("ConstantConditions") public BisqEnvironment(PropertySource commandLineProperties) { //DaoOptionKeys - rpcHost = getProperty(commandLineProperties, DaoOptionKeys.RPC_HOST, ""); rpcPort = getProperty(commandLineProperties, DaoOptionKeys.RPC_PORT, ""); rpcBlockNotificationPort = getProperty(commandLineProperties, DaoOptionKeys.RPC_BLOCK_NOTIFICATION_PORT, ""); rpcBlockNotificationHost = getProperty(commandLineProperties, DaoOptionKeys.RPC_BLOCK_NOTIFICATION_HOST, ""); @@ -96,7 +95,6 @@ public class BisqEnvironment extends StandardEnvironment { private PropertySource defaultProperties() { return new PropertiesPropertySource(BISQ_DEFAULT_PROPERTY_SOURCE_NAME, new Properties() { { - setProperty(DaoOptionKeys.RPC_HOST, rpcHost); setProperty(DaoOptionKeys.RPC_PORT, rpcPort); setProperty(DaoOptionKeys.RPC_BLOCK_NOTIFICATION_PORT, rpcBlockNotificationPort); setProperty(DaoOptionKeys.RPC_BLOCK_NOTIFICATION_HOST, rpcBlockNotificationHost); diff --git a/core/src/main/java/bisq/core/app/BisqExecutable.java b/core/src/main/java/bisq/core/app/BisqExecutable.java index 91b4d27f23..8489eb127d 100644 --- a/core/src/main/java/bisq/core/app/BisqExecutable.java +++ b/core/src/main/java/bisq/core/app/BisqExecutable.java @@ -285,10 +285,6 @@ public abstract class BisqExecutable implements GracefulShutDownHandler, BisqSet .ofType(boolean.class); //RpcOptionKeys - parser.accepts(DaoOptionKeys.RPC_HOST, - "Bitcoind rpc host") - .withRequiredArg(); - parser.accepts(DaoOptionKeys.RPC_PORT, "Bitcoind rpc port") .withRequiredArg(); diff --git a/core/src/main/java/bisq/core/dao/DaoModule.java b/core/src/main/java/bisq/core/dao/DaoModule.java index b5a334ce27..ceb5cd73d7 100644 --- a/core/src/main/java/bisq/core/dao/DaoModule.java +++ b/core/src/main/java/bisq/core/dao/DaoModule.java @@ -225,7 +225,7 @@ public class DaoModule extends AppModule { // Options bindConstant().annotatedWith(named(Config.RPC_USER)).to(config.getRpcUser()); bindConstant().annotatedWith(named(Config.RPC_PASSWORD)).to(config.getRpcPassword()); - bindConstant().annotatedWith(named(DaoOptionKeys.RPC_HOST)).to(environment.getRequiredProperty(DaoOptionKeys.RPC_HOST)); + bindConstant().annotatedWith(named(Config.RPC_HOST)).to(config.getRpcHost()); bindConstant().annotatedWith(named(DaoOptionKeys.RPC_PORT)).to(environment.getRequiredProperty(DaoOptionKeys.RPC_PORT)); bindConstant().annotatedWith(named(DaoOptionKeys.RPC_BLOCK_NOTIFICATION_PORT)) .to(environment.getRequiredProperty(DaoOptionKeys.RPC_BLOCK_NOTIFICATION_PORT)); diff --git a/core/src/main/java/bisq/core/dao/DaoOptionKeys.java b/core/src/main/java/bisq/core/dao/DaoOptionKeys.java index c5f6f9b3f5..b05aea6934 100644 --- a/core/src/main/java/bisq/core/dao/DaoOptionKeys.java +++ b/core/src/main/java/bisq/core/dao/DaoOptionKeys.java @@ -24,7 +24,6 @@ public class DaoOptionKeys { public static final String RPC_PORT = "rpcPort"; public static final String RPC_BLOCK_NOTIFICATION_PORT = "rpcBlockNotificationPort"; public static final String RPC_BLOCK_NOTIFICATION_HOST = "rpcBlockNotificationHost"; - public static final String RPC_HOST = "rpcHost"; public static final String DUMP_BLOCKCHAIN_DATA = "dumpBlockchainData"; public static final String FULL_DAO_NODE = "fullDaoNode"; diff --git a/core/src/main/java/bisq/core/dao/node/full/RpcService.java b/core/src/main/java/bisq/core/dao/node/full/RpcService.java index 522890bb32..14666e7429 100644 --- a/core/src/main/java/bisq/core/dao/node/full/RpcService.java +++ b/core/src/main/java/bisq/core/dao/node/full/RpcService.java @@ -24,6 +24,7 @@ import bisq.core.user.Preferences; import bisq.common.UserThread; import bisq.common.config.BaseCurrencyNetwork; +import bisq.common.config.Config; import bisq.common.handlers.ResultHandler; import bisq.common.util.Utilities; @@ -92,7 +93,7 @@ public class RpcService { @SuppressWarnings("WeakerAccess") @Inject public RpcService(Preferences preferences, - @Named(DaoOptionKeys.RPC_HOST) String rpcHost, + @Named(Config.RPC_HOST) String rpcHost, @Named(DaoOptionKeys.RPC_PORT) String rpcPort, @Named(DaoOptionKeys.RPC_BLOCK_NOTIFICATION_PORT) String rpcBlockPort, @Named(DaoOptionKeys.RPC_BLOCK_NOTIFICATION_HOST) String rpcBlockHost) { @@ -100,7 +101,7 @@ public class RpcService { this.rpcPassword = preferences.getRpcPw(); // mainnet is 8332, testnet 18332, regtest 18443 - boolean isHostSet = rpcHost != null && !rpcHost.isEmpty(); + boolean isHostSet = !rpcHost.isEmpty(); boolean isPortSet = rpcPort != null && !rpcPort.isEmpty(); boolean isMainnet = BaseCurrencyNetwork.CURRENT_NETWORK.isMainnet(); boolean isTestnet = BaseCurrencyNetwork.CURRENT_NETWORK.isTestnet();