Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow host as bitcoinRegtestHost parameter #2312

Merged
merged 2 commits into from
Jan 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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