keep an entered https or ssl when the host entered is also the alias of a saved server at another protocol
What changed, and why it matters
This commit fixes a UI/server-selection bug in Sparrow Wallet's settings screen. Previously, if a user typed a server host that was also a saved nickname ('alias') for a different server using a different protocol (for example, HTTP vs HTTPS), the wallet could silently switch back to the saved alias's protocol and server details instead of keeping what the user actually entered. The change makes the wallet only treat the saved alias as active when the port and protocol the user entered exactly match that saved alias. In practical terms, it prevents the wallet from accidentally connecting to the wrong server when a host name overlaps with a saved alias.
Treat as a low-to-moderate correctness fix with possible security implications. Review whether the alias-matching logic is used anywhere else in the codebase and ensure similar protocol/port validation is applied consistently. No immediate emergency response is indicated, but users relying on aliases should verify server connections after upgrading. Consider adding a regression test for the alias/protocol overlap scenario.
Security signals we found
Incorrect server selection could cause wallet to connect to attacker-controlled or unintended Electrum/Bitcoin Core server
Alias resolution did not previously require matching protocol and port, allowing saved server to override user-entered values
UI state/config sync inconsistency: SSL toggle path skipped config update when alias was detected
Fix adds explicit protocol+port validation before treating a host string as a saved alias
Evidence from the diff
ServerSettingsController.java is updated so that alias matching for both Electrum and Bitcoin Core servers now checks whether the entered port and protocol still correspond to the saved alias. New helper methods isElectrumAliasEntered() and isCoreAliasEntered() replace looser checks (port-only or protocol-only). The Electrum SSL toggle listener now always writes the current UI state to config rather than skipping setElectrumServerInConfig() when an alias was found, and it adds a tag glyph when the host field is an active alias. For Bitcoin Core, the HTTPS host is tracked so an HTTPS-entered host that is also an HTTP alias is not misidentified as that alias. This closes a logic gap where a host string could match an alias at a different protocol/port and cause the saved server to override user input.
Changed components
src/main/java/com/sparrowwallet/sparrow/settings/ServerSettingsController.javaElectrum server settings UIBitcoin Core server settings UIServer alias resolution logicConfig persistence for recent/selected serversInspect captured patch +21 / −8
### src/main/java/com/sparrowwallet/sparrow/settings/ServerSettingsController.java
@@ -381,13 +381,14 @@ public void initializeView(Config config) {
});
electrumUseSsl.selectedProperty().addListener((observable, oldValue, newValue) -> {
- //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
+ //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.
+ //The config is set whether or not the host field changed, since an alias that is also its server's host is replaced by the same text
Server aliasServer = config.getRecentElectrumServers().stream().filter(server -> electrumHost.getText().equals(server.getAlias())).findFirst().orElse(null);
- if(aliasServer != null && aliasServer.getProtocol() != getProtocol()) {
+ if(aliasServer != null && !isElectrumAliasEntered(aliasServer)) {
electrumHost.setText(aliasServer.getHost());
- } else {
- setElectrumServerInConfig(config);
}
+ electrumHost.setLeft(aliasServer != null && isElectrumAliasEntered(aliasServer) ? getGlyph(FontAwesome5.Glyph.TAG, null) : null);
+ setElectrumServerInConfig(config);
electrumCertificate.setDisable(!newValue);
electrumCertificateSelect.setDisable(!newValue);
electrumPort.setPromptText(newValue ? "e.g. 50002" : "e.g. 50001");
@@ -792,7 +793,7 @@ private ChangeListener<PublicElectrumServer> getPublicElectrumServerListener(Con
private ChangeListener<String> getBitcoinCoreListener(Config config) {
return (observable, oldValue, newValue) -> {
Server existingServer = config.getRecentCoreServers().stream().filter(server -> coreHost.getText().equals(server.getAlias())).findFirst().orElse(null);
- if(existingServer != null && !existingServer.portEquals(corePort.getText())) {
+ if(existingServer != null && !isCoreAliasEntered(existingServer)) {
coreHost.setText(existingServer.getHost());
existingServer = null;
}
@@ -818,7 +819,7 @@ private ChangeListener<String> getBitcoinCoreListener(Config config) {
private void setCoreServerInConfig(Config config) {
Server existingServer = config.getRecentCoreServers().stream().filter(server -> coreHost.getText().equals(server.getAlias())).findFirst().orElse(null);
- if(existingServer != null) {
+ if(existingServer != null && isCoreAliasEntered(existingServer)) {
config.setCoreServer(existingServer);
return;
}
@@ -841,6 +842,13 @@ private void setCoreProtocol(Protocol protocol, String host) {
coreHttpsHost = protocol == Protocol.HTTPS ? host : null;
}
+ //Whether an alias in the host field still names its server: an alias names a server at one port and one protocol, and an https entered for a
+ //host that is also the alias of an http server is not that server. Only such an alias can be the host an entered https leaves in the field
+ private boolean isCoreAliasEntered(Server aliasServer) {
+ return aliasServer.portEquals(corePort.getText()) && !(aliasServer.getProtocol() == Protocol.HTTP && aliasServer.getHost().equalsIgnoreCase(coreHttpsHost)
+ && aliasServer.getHost().equalsIgnoreCase(aliasServer.getAlias()));
+ }
+
private void showRemoteCoreServerWarning(Config config) {
Server coreServer = config.getCoreServer();
if(!coreServerWarningShown && config.getServerType() == ServerType.BITCOIN_CORE && isRemoteNode(coreServer)) {
@@ -899,7 +907,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()) || existingServer.getProtocol() != getProtocol())) {
+ if(existingServer != null && !isElectrumAliasEntered(existingServer)) {
electrumHost.setText(existingServer.getHost());
existingServer = null;
}
@@ -923,9 +931,14 @@ private ChangeListener<String> getElectrumServerListener(Config config) {
};
}
+ //Whether an alias in the host field still names its server at the port and protocol entered
+ private boolean isElectrumAliasEntered(Server aliasServer) {
+ return aliasServer.portEquals(electrumPort.getText()) && aliasServer.getProtocol() == getProtocol();
+ }
+
private void setElectrumServerInConfig(Config config) {
Server existingServer = config.getRecentElectrumServers().stream().filter(server -> electrumHost.getText().equals(server.getAlias())).findFirst().orElse(null);
- if(existingServer != null) {
+ if(existingServer != null && isElectrumAliasEntered(existingServer)) {
config.setElectrumServer(existingServer);
return;
}Why this scored 33/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.