Skip to content

Commit

Permalink
Merge pull request #2312 from devinbileck/regtest-host-parameter
Browse files Browse the repository at this point in the history
Allow host as bitcoinRegtestHost parameter
  • Loading branch information
ManfredKarrer authored Jan 24, 2019
2 parents 852a1df + 145e3ea commit 92d15c2
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
4 changes: 2 additions & 2 deletions core/src/main/java/bisq/core/app/BisqExecutable.java
Original file line number Diff line number Diff line change
Expand Up @@ -482,9 +482,9 @@ protected void customizeOptionParsing(OptionParser parser) {
.describedAs(format("%s|%s|%s", BTC_MAINNET, BTC_TESTNET, BTC_REGTEST));

parser.accepts(BtcOptionKeys.REG_TEST_HOST,
format("(default: %s)", RegTestHost.DEFAULT))
format("Bitcoin regtest host when using BTC_REGTEST network (default: %s)", RegTestHost.DEFAULT_HOST))
.withRequiredArg()
.ofType(RegTestHost.class);
.describedAs("host");

parser.accepts(BtcOptionKeys.BTC_NODES,
"Custom nodes used for BitcoinJ as comma separated IP addresses.")
Expand Down
10 changes: 9 additions & 1 deletion core/src/main/java/bisq/core/btc/BitcoinModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@

import java.io.File;

import java.util.Arrays;

import static com.google.inject.name.Names.named;

public class BitcoinModule extends AppModule {
Expand All @@ -51,7 +53,13 @@ public BitcoinModule(Environment environment) {

@Override
protected void configure() {
bind(RegTestHost.class).toInstance(environment.getProperty(BtcOptionKeys.REG_TEST_HOST, RegTestHost.class, RegTestHost.DEFAULT));
String regTestHost = environment.getProperty(BtcOptionKeys.REG_TEST_HOST, String.class, RegTestHost.DEFAULT_HOST);
if (Arrays.asList("localhost", "127.0.0.1").contains(regTestHost)) {
bind(RegTestHost.class).toInstance(RegTestHost.LOCALHOST);
} else {
bind(RegTestHost.class).toInstance(RegTestHost.REMOTE_HOST);
}
RegTestHost.HOST = regTestHost;

bindConstant().annotatedWith(named(UserAgent.NAME_KEY)).to(environment.getRequiredProperty(UserAgent.NAME_KEY));
bindConstant().annotatedWith(named(UserAgent.VERSION_KEY)).to(environment.getRequiredProperty(UserAgent.VERSION_KEY));
Expand Down
6 changes: 3 additions & 3 deletions core/src/main/java/bisq/core/btc/setup/RegTestHost.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ public enum RegTestHost {

NONE,
LOCALHOST,
REG_TEST_SERVER; // 188.226.179.109
REMOTE_HOST;

public static final RegTestHost DEFAULT = LOCALHOST;
public static final String SERVER_IP = "188.226.179.109";
public static final String DEFAULT_HOST = "localhost";
public static String HOST = DEFAULT_HOST;

}
4 changes: 2 additions & 2 deletions core/src/main/java/bisq/core/btc/setup/WalletsSetup.java
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ protected void onSetupCompleted() {
walletConfig.setMinBroadcastConnections(1);
if (regTestHost == RegTestHost.LOCALHOST) {
walletConfig.setPeerNodesForLocalHost();
} else if (regTestHost == RegTestHost.REG_TEST_SERVER) {
} else if (regTestHost == RegTestHost.REMOTE_HOST) {
walletConfig.setMinBroadcastConnections(1);
configPeerNodesForRegTestServer();
} else {
Expand Down Expand Up @@ -315,7 +315,7 @@ private int evaluateMode(String socks5DiscoverModeString) {

private void configPeerNodesForRegTestServer() {
try {
walletConfig.setPeerNodes(new PeerAddress(InetAddress.getByName(RegTestHost.SERVER_IP), params.getPort()));
walletConfig.setPeerNodes(new PeerAddress(InetAddress.getByName(RegTestHost.HOST), params.getPort()));
} catch (UnknownHostException e) {
log.error(e.toString());
e.printStackTrace();
Expand Down

0 comments on commit 92d15c2

Please sign in to comment.