Allow tor to be used on regtest

This allows for a tor .onion address to be specified as the
bitcoinRegtestHost parameter and, as long as the --useTorForBtc=true
parameter is included, it will use tor when on regtest.
This commit is contained in:
Devin Bileck 2019-01-30 15:14:58 -08:00
parent bf94810126
commit 53cf14791f
No known key found for this signature in database
GPG Key ID: 38750B26EA8B8C93
2 changed files with 10 additions and 5 deletions

View File

@ -236,7 +236,6 @@ public class WalletsSetup {
if (regTestHost == RegTestHost.LOCALHOST) {
walletConfig.setPeerNodesForLocalHost();
} else if (regTestHost == RegTestHost.REMOTE_HOST) {
walletConfig.setMinBroadcastConnections(1);
configPeerNodesForRegTestServer();
} else {
configPeerNodes(socks5Proxy);
@ -315,7 +314,11 @@ public class WalletsSetup {
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();

View File

@ -692,10 +692,12 @@ public final class Preferences implements PersistedDataHost, BridgeAddressProvid
}
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())
&& bisqEnvironment.getProperty(BtcOptionKeys.USE_TOR_FOR_BTC).isEmpty())
return false;
else
return prefPayload.isUseTorForBitcoinJ();