diff --git a/network/tor/tor/src/main/java/bisq/tor/controller/TorController.java b/network/tor/tor/src/main/java/bisq/tor/controller/TorController.java index c7e4ff9af3..dc53bfca0c 100644 --- a/network/tor/tor/src/main/java/bisq/tor/controller/TorController.java +++ b/network/tor/tor/src/main/java/bisq/tor/controller/TorController.java @@ -32,12 +32,12 @@ public TorController(int bootstrapTimeout) { this.bootstrapTimeout = bootstrapTimeout; } - public void initialize(int controlPort, PasswordDigest hashedControlPassword) throws IOException { - var torControlProtocol = new TorControlProtocol(controlPort); - this.torControlProtocol = Optional.of(torControlProtocol); + public void initialize(int controlPort) throws IOException { + initialize(controlPort, Optional.empty()); + } - torControlProtocol.initialize(); - torControlProtocol.authenticate(hashedControlPassword); + public void initialize(int controlPort, PasswordDigest hashedControlPassword) throws IOException { + initialize(controlPort, Optional.of(hashedControlPassword)); } public void shutdown() { @@ -90,6 +90,16 @@ public void onBootstrapStatusEvent(BootstrapEvent bootstrapEvent) { } } + private void initialize(int controlPort, Optional hashedControlPassword) throws IOException { + var torControlProtocol = new TorControlProtocol(controlPort); + this.torControlProtocol = Optional.of(torControlProtocol); + + torControlProtocol.initialize(); + if (hashedControlPassword.isPresent()) { + torControlProtocol.authenticate(hashedControlPassword.get()); + } + } + private void bindToBisq() throws IOException { TorControlProtocol torControlProtocol = getTorControlProtocol(); torControlProtocol.takeOwnership();