replace a server alias with its host when the ssl switch differs from the aliased server, and keep the alias when opening server settings
What changed, and why it matters
This commit fixes a UI bug in Sparrow Wallet's server settings. When a user had saved a server under a friendly nickname (alias) and then changed the SSL/TLS switch or port, the wallet could end up trying to connect to the wrong server because the alias still pointed to the original protocol or port. The change makes the alias resolve to the actual server host when the connection protocol or port no longer matches the saved alias, preventing accidental misconnections.
Treat as a low-severity correctness fix. Users relying on server aliases should upgrade to ensure aliases resolve to the intended host when protocol or port settings are changed. No immediate incident response is indicated unless further evidence shows active exploitation.
Security signals we found
Connection target confusion due to stale alias after protocol/port change
UI state desynchronization between host alias, port, and SSL toggle
Potential unintended Electrum server connection
Evidence from the diff
ServerSettingsController.java is updated so that an Electrum server alias is replaced with its real host when the SSL protocol selection or port differs from the aliased server’s stored protocol/port. Previously, the alias text could remain in the host field while the port or SSL setting changed, causing the resolved connection target to drift from the server the alias represented. The patch also reorders port and host assignment when opening settings so the alias is only preserved while the port field still holds the aliased server’s port.
Changed components
src/main/java/com/sparrowwallet/sparrow/settings/ServerSettingsController.javaElectrum server configuration UIServer alias resolution logicInspect captured patch +11 / −4
### src/main/java/com/sparrowwallet/sparrow/settings/ServerSettingsController.java
@@ -381,7 +381,13 @@ public void initializeView(Config config) {
});
electrumUseSsl.selectedProperty().addListener((observable, oldValue, newValue) -> {
- setElectrumServerInConfig(config);
+ //An alias names a server at one protocol as it does at one port, so changing either leaves the host it names to be connected to as entered
+ Server aliasServer = config.getRecentElectrumServers().stream().filter(server -> electrumHost.getText().equals(server.getAlias())).findFirst().orElse(null);
+ if(aliasServer != null && aliasServer.getProtocol() != getProtocol()) {
+ electrumHost.setText(aliasServer.getHost());
+ } else {
+ setElectrumServerInConfig(config);
+ }
electrumCertificate.setDisable(!newValue);
electrumCertificateSelect.setDisable(!newValue);
electrumPort.setPromptText(newValue ? "e.g. 50002" : "e.g. 50001");
@@ -468,10 +474,11 @@ public void initializeView(Config config) {
if(server != null) {
coreHost.setLeft(getGlyph(FontAwesome5.Glyph.TAG, null));
}
- coreHost.setText(server == null || server.getAlias() == null ? hostAndPort.getHost() : server.getAlias());
+ //The port is set first, as an alias in the host field is only kept while the port field holds the port of the server it names
if(hostAndPort.hasPort()) {
corePort.setText(Integer.toString(hostAndPort.getPort()));
}
+ coreHost.setText(server == null || server.getAlias() == null ? hostAndPort.getHost() : server.getAlias());
} else {
coreHost.setText("127.0.0.1");
corePort.setText(String.valueOf(Network.get().getDefaultPort()));
@@ -502,10 +509,10 @@ public void initializeView(Config config) {
if(server != null) {
electrumHost.setLeft(getGlyph(FontAwesome5.Glyph.TAG, null));
}
- electrumHost.setText(server == null || server.getAlias() == null ? hostAndPort.getHost() : server.getAlias());
if(hostAndPort.hasPort()) {
electrumPort.setText(Integer.toString(hostAndPort.getPort()));
}
+ electrumHost.setText(server == null || server.getAlias() == null ? hostAndPort.getHost() : server.getAlias());
}
File certificateFile = config.getElectrumServerCert();
@@ -892,7 +899,7 @@ private ChangeListener<String> getBitcoinAuthListener(Config config) {
private ChangeListener<String> getElectrumServerListener(Config config) {
return (observable, oldValue, newValue) -> {
Server existingServer = config.getRecentElectrumServers().stream().filter(server -> electrumHost.getText().equals(server.getAlias())).findFirst().orElse(null);
- if(existingServer != null && !existingServer.portEquals(electrumPort.getText())) {
+ if(existingServer != null && (!existingServer.portEquals(electrumPort.getText()) || existingServer.getProtocol() != getProtocol())) {
electrumHost.setText(existingServer.getHost());
existingServer = null;
}Why this scored 35/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.