diff --git a/src/main/java/com/sparrowwallet/sparrow/AppController.java b/src/main/java/com/sparrowwallet/sparrow/AppController.java
index d2674f1c..991d7ed3 100644
--- a/src/main/java/com/sparrowwallet/sparrow/AppController.java
+++ b/src/main/java/com/sparrowwallet/sparrow/AppController.java
@@ -386,7 +386,7 @@ public class AppController implements Initializable {
configureSwitchServer();
setServerType(Config.get().getServerType());
serverToggle.setSelected(isConnected());
- serverToggle.setDisable(Config.get().getServerType() == null);
+ serverToggle.setDisable(!Config.get().hasServer());
onlineProperty().bindBidirectional(serverToggle.selectedProperty());
onlineProperty().addListener(new WeakChangeListener<>(serverToggleOnlineListener));
serverToggle.addEventHandler(MouseEvent.MOUSE_CLICKED, event -> {
@@ -1248,6 +1248,7 @@ public class AppController implements Initializable {
PreferencesDialog preferencesDialog = new PreferencesDialog(preferenceGroup);
preferencesDialog.showAndWait();
configureSwitchServer();
+ serverToggle.setDisable(!Config.get().hasServer());
}
public void signVerifyMessage(ActionEvent event) {
@@ -2091,7 +2092,7 @@ public class AppController implements Initializable {
serverToggle.getStyleClass().remove("core-server");
}
- serverToggle.setDisable(false);
+ serverToggle.setDisable(!Config.get().hasServer());
}
public void setTheme(ActionEvent event) {
diff --git a/src/main/java/com/sparrowwallet/sparrow/preferences/ServerPreferencesController.java b/src/main/java/com/sparrowwallet/sparrow/preferences/ServerPreferencesController.java
index 6a7786cf..956ba817 100644
--- a/src/main/java/com/sparrowwallet/sparrow/preferences/ServerPreferencesController.java
+++ b/src/main/java/com/sparrowwallet/sparrow/preferences/ServerPreferencesController.java
@@ -748,11 +748,13 @@ public class ServerPreferencesController extends PreferencesDetailController {
String hostAsString = getHost(coreHost.getText());
Integer portAsInteger = getPort(corePort.getText());
- if(hostAsString != null && portAsInteger != null && isValidPort(portAsInteger)) {
+ if(hostAsString != null && !hostAsString.isEmpty() && portAsInteger != null && isValidPort(portAsInteger)) {
Protocol protocol = portAsInteger == Protocol.HTTPS.getDefaultPort() ? Protocol.HTTPS : Protocol.HTTP;
config.setCoreServer(new Server(protocol.toUrlString(hostAsString, portAsInteger)));
- } else if(hostAsString != null) {
+ } else if(hostAsString != null && !hostAsString.isEmpty()) {
config.setCoreServer(new Server(Protocol.HTTP.toUrlString(hostAsString)));
+ } else {
+ config.setCoreServer(null);
}
}
@@ -781,10 +783,12 @@ public class ServerPreferencesController extends PreferencesDetailController {
String hostAsString = getHost(electrumHost.getText());
Integer portAsInteger = getPort(electrumPort.getText());
- if(hostAsString != null && portAsInteger != null && isValidPort(portAsInteger)) {
+ if(hostAsString != null && !hostAsString.isEmpty() && portAsInteger != null && isValidPort(portAsInteger)) {
config.setElectrumServer(new Server(getProtocol().toUrlString(hostAsString, portAsInteger)));
- } else if(hostAsString != null) {
+ } else if(hostAsString != null && !hostAsString.isEmpty()) {
config.setElectrumServer(new Server(getProtocol().toUrlString(hostAsString)));
+ } else {
+ config.setElectrumServer(null);
}
}
diff --git a/src/main/resources/com/sparrowwallet/sparrow/preferences/server.fxml b/src/main/resources/com/sparrowwallet/sparrow/preferences/server.fxml
index 43691886..fb504815 100644
--- a/src/main/resources/com/sparrowwallet/sparrow/preferences/server.fxml
+++ b/src/main/resources/com/sparrowwallet/sparrow/preferences/server.fxml
@@ -154,7 +154,7 @@
-
+