mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-24 15:10:44 +01:00
ensure useTor==false case works, and also that wallet init is deferred only for useTor==true case
This commit is contained in:
parent
6198307d76
commit
c392915c4a
3 changed files with 32 additions and 12 deletions
|
@ -43,7 +43,14 @@ public class WalletAppKitBitSquare extends WalletAppKit {
|
|||
}
|
||||
|
||||
protected PeerGroup createPeerGroup() throws TimeoutException {
|
||||
int CONNECT_TIMEOUT_MSEC = 60 * 1000;
|
||||
|
||||
// no proxy case.
|
||||
if(proxy == null) {
|
||||
return super.createPeerGroup();
|
||||
}
|
||||
|
||||
// proxy case.
|
||||
int CONNECT_TIMEOUT_MSEC = 60 * 1000; // same value used in bitcoinj.
|
||||
ProxySocketFactory proxySocketFactory = new ProxySocketFactory(proxy);
|
||||
BlockingClientManager mgr = new BlockingClientManager(proxySocketFactory);
|
||||
PeerGroup result = new PeerGroup(params, vChain, mgr);
|
||||
|
@ -51,7 +58,6 @@ public class WalletAppKitBitSquare extends WalletAppKit {
|
|||
mgr.setConnectTimeoutMillis(CONNECT_TIMEOUT_MSEC);
|
||||
result.setConnectTimeoutMillis(CONNECT_TIMEOUT_MSEC);
|
||||
|
||||
// result.addPeerDiscovery(new OnionSeedPeers(params));
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -272,10 +272,11 @@ public class WalletService {
|
|||
//TODO Check how to pass seed nodes to the wallet kit. Probably via walletAppKit.setPeerNodes
|
||||
}
|
||||
|
||||
if (useTor && params.getId().equals(NetworkParameters.ID_MAINNET))
|
||||
walletAppKit.useTor();
|
||||
|
||||
|
||||
// We do not call walletAppKit.useTor() anymore because that would turn
|
||||
// on orchid Tor, which we do not want. Instead, we create a Tor proxy
|
||||
// later.
|
||||
// if (useTor && params.getId().equals(NetworkParameters.ID_MAINNET))
|
||||
// walletAppKit.useTor();
|
||||
|
||||
// Now configure and start the appkit. This will take a second or two - we could show a temporary splash screen
|
||||
// or progress widget to keep the user engaged whilst we initialise, but we don't.
|
||||
|
|
|
@ -352,7 +352,9 @@ public class MainViewModel implements ViewModel {
|
|||
public void onTorNodeReady() {
|
||||
bootstrapState.set("Tor node created");
|
||||
p2PNetworkIconId.set("image-connection-tor");
|
||||
initWalletService();
|
||||
if( preferences.getUseTorForBitcoinJ() ) {
|
||||
initWalletService();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -428,6 +430,13 @@ public class MainViewModel implements ViewModel {
|
|||
|
||||
private BooleanProperty initBitcoinWallet() {
|
||||
final BooleanProperty walletInitialized = new SimpleBooleanProperty();
|
||||
|
||||
// We only init wallet service here if not using Tor for bitcoinj.
|
||||
// When using Tor, wallet init must be deferred until Tor is ready.
|
||||
if( !preferences.getUseTorForBitcoinJ() ) {
|
||||
initWalletService();
|
||||
}
|
||||
|
||||
return walletInitialized;
|
||||
}
|
||||
|
||||
|
@ -472,11 +481,15 @@ public class MainViewModel implements ViewModel {
|
|||
btcInfo.set(newValue);
|
||||
});
|
||||
|
||||
// Use p2p service
|
||||
Socks5Proxy socks5Proxy = p2PService.getNetworkNode().getSocksProxy();
|
||||
Proxy proxy = proxy = new Proxy ( Proxy.Type.SOCKS,
|
||||
new InetSocketAddress(socks5Proxy.getInetAddress().getHostName(),
|
||||
socks5Proxy.getPort() ) );
|
||||
Proxy proxy = null;
|
||||
|
||||
if( preferences.getUseTorForBitcoinJ() ) {
|
||||
// Use p2p service
|
||||
Socks5Proxy socks5Proxy = p2PService.getNetworkNode().getSocksProxy();
|
||||
proxy = new Proxy ( Proxy.Type.SOCKS,
|
||||
new InetSocketAddress(socks5Proxy.getInetAddress().getHostName(),
|
||||
socks5Proxy.getPort() ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Uncomment this to wire up user specified proxy via program args or config file.
|
||||
|
|
Loading…
Add table
Reference in a new issue