mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 09:52:23 +01:00
Prevent connection to localhost bitcoin node if dao testnet is used
This commit is contained in:
parent
64fd8d9bc8
commit
518fe724d9
@ -417,30 +417,35 @@ public class BisqSetup {
|
||||
}
|
||||
|
||||
private void checkIfLocalHostNodeIsRunning() {
|
||||
Thread checkIfLocalHostNodeIsRunningThread = new Thread(() -> {
|
||||
Thread.currentThread().setName("checkIfLocalHostNodeIsRunningThread");
|
||||
Socket socket = null;
|
||||
try {
|
||||
socket = new Socket();
|
||||
socket.connect(new InetSocketAddress(InetAddresses.forString("127.0.0.1"),
|
||||
BisqEnvironment.getBaseCurrencyNetwork().getParameters().getPort()), 5000);
|
||||
log.info("Localhost Bitcoin node detected.");
|
||||
UserThread.execute(() -> {
|
||||
bisqEnvironment.setBitcoinLocalhostNodeRunning(true);
|
||||
step3();
|
||||
});
|
||||
} catch (Throwable e) {
|
||||
UserThread.execute(BisqSetup.this::step3);
|
||||
} finally {
|
||||
if (socket != null) {
|
||||
try {
|
||||
socket.close();
|
||||
} catch (IOException ignore) {
|
||||
// For DAO testnet we ignore local btc node
|
||||
if (BisqEnvironment.getBaseCurrencyNetwork().isDaoTestNet()) {
|
||||
step3();
|
||||
} else {
|
||||
Thread checkIfLocalHostNodeIsRunningThread = new Thread(() -> {
|
||||
Thread.currentThread().setName("checkIfLocalHostNodeIsRunningThread");
|
||||
Socket socket = null;
|
||||
try {
|
||||
socket = new Socket();
|
||||
socket.connect(new InetSocketAddress(InetAddresses.forString("127.0.0.1"),
|
||||
BisqEnvironment.getBaseCurrencyNetwork().getParameters().getPort()), 5000);
|
||||
log.info("Localhost Bitcoin node detected.");
|
||||
UserThread.execute(() -> {
|
||||
bisqEnvironment.setBitcoinLocalhostNodeRunning(true);
|
||||
step3();
|
||||
});
|
||||
} catch (Throwable e) {
|
||||
UserThread.execute(BisqSetup.this::step3);
|
||||
} finally {
|
||||
if (socket != null) {
|
||||
try {
|
||||
socket.close();
|
||||
} catch (IOException ignore) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
checkIfLocalHostNodeIsRunningThread.start();
|
||||
});
|
||||
checkIfLocalHostNodeIsRunningThread.start();
|
||||
}
|
||||
}
|
||||
|
||||
private void readMapsFromResources() {
|
||||
|
@ -22,7 +22,6 @@ import bisq.core.btc.nodes.ProxySocketFactory;
|
||||
import bisq.core.btc.wallet.BisqRiskAnalysis;
|
||||
|
||||
import bisq.common.app.Version;
|
||||
import bisq.common.util.Utilities;
|
||||
|
||||
import org.bitcoinj.core.BlockChain;
|
||||
import org.bitcoinj.core.CheckpointManager;
|
||||
@ -220,7 +219,7 @@ public class WalletConfig extends AbstractIdleService {
|
||||
socks5Proxy.getPort()));
|
||||
|
||||
ProxySocketFactory proxySocketFactory = new ProxySocketFactory(proxy);
|
||||
// we dont use tor mode if we have a local node running
|
||||
// We don't use tor mode if we have a local node running
|
||||
BlockingClientManager blockingClientManager = bisqEnvironment.isBitcoinLocalhostNodeRunning() ?
|
||||
new BlockingClientManager() :
|
||||
new BlockingClientManager(proxySocketFactory);
|
||||
@ -230,6 +229,11 @@ public class WalletConfig extends AbstractIdleService {
|
||||
blockingClientManager.setConnectTimeoutMillis(TIMEOUT);
|
||||
peerGroup.setConnectTimeoutMillis(TIMEOUT);
|
||||
|
||||
// For dao testnet (server side regtest) we prevent to connect to a localhost node to avoid confusion
|
||||
// if local btc node is not synced with our dao testnet master node.
|
||||
if (BisqEnvironment.getBaseCurrencyNetwork().isDaoTestNet())
|
||||
peerGroup.setUseLocalhostPeerWhenPossible(false);
|
||||
|
||||
return peerGroup;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user