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 tor to be used with regtest #2346

Merged
merged 3 commits into from
Feb 4, 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
5 changes: 3 additions & 2 deletions core/src/main/java/bisq/core/btc/setup/WalletConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -446,8 +446,9 @@ protected void startUp() throws Exception {
// before we're actually connected the broadcast waits for an appropriate number of connections.
if (peerAddresses != null) {
for (PeerAddress addr : peerAddresses) vPeerGroup.addAddress(addr);
log.info("We try to connect to {} btc nodes", numConnectionForBtc);
vPeerGroup.setMaxConnections(Math.min(numConnectionForBtc, peerAddresses.length));
int maxConnections = Math.min(numConnectionForBtc, peerAddresses.length);
log.info("We try to connect to {} btc nodes", maxConnections);
vPeerGroup.setMaxConnections(maxConnections);
peerAddresses = null;
} else if (!params.equals(RegTestParams.get())) {
vPeerGroup.addPeerDiscovery(discovery != null ? discovery : new DnsDiscovery(params));
Expand Down
7 changes: 5 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 @@ -236,7 +236,6 @@ protected void onSetupCompleted() {
if (regTestHost == RegTestHost.LOCALHOST) {
walletConfig.setPeerNodesForLocalHost();
} else if (regTestHost == RegTestHost.REMOTE_HOST) {
walletConfig.setMinBroadcastConnections(1);
ManfredKarrer marked this conversation as resolved.
Show resolved Hide resolved
configPeerNodesForRegTestServer();
} else {
configPeerNodes(socks5Proxy);
Expand Down Expand Up @@ -315,7 +314,11 @@ private int evaluateMode(String socks5DiscoverModeString) {

private void configPeerNodesForRegTestServer() {
try {
walletConfig.setPeerNodes(new PeerAddress(InetAddress.getByName(RegTestHost.HOST), params.getPort()));
if (RegTestHost.HOST.endsWith(".onion")) {
walletConfig.setPeerNodes(new PeerAddress(RegTestHost.HOST, params.getPort()));
} else {
walletConfig.setPeerNodes(new PeerAddress(InetAddress.getByName(RegTestHost.HOST), params.getPort()));
}
} catch (UnknownHostException e) {
log.error(e.toString());
e.printStackTrace();
Expand Down
8 changes: 5 additions & 3 deletions core/src/main/java/bisq/core/user/Preferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -692,10 +692,12 @@ public boolean showAgain(String key) {
}

public boolean getUseTorForBitcoinJ() {
// We override the useTorForBitcoinJ and set it to false if we detected a localhost node or if we are not on mainnet.
// At testnet there are very few Bitcoin tor nodes and we don't provide tor nodes.
if (!BisqEnvironment.getBaseCurrencyNetwork().isMainnet()
// We override the useTorForBitcoinJ and set it to false if we detected a localhost node or if we are not on mainnet,
// unless the useTorForBtc parameter is explicitly provided.
// On testnet there are very few Bitcoin tor nodes and we don't provide tor nodes.
if ((!BisqEnvironment.getBaseCurrencyNetwork().isMainnet()
|| bisqEnvironment.isBitcoinLocalhostNodeRunning())
&& (useTorFlagFromOptions == null || useTorFlagFromOptions.isEmpty()))
return false;
else
return prefPayload.isUseTorForBitcoinJ();
Expand Down