From 686c008e97abfee467534cc2e62a22332f87ccd5 Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Mon, 3 Feb 2025 18:02:18 +0200 Subject: [PATCH] allow server urls to be pasted into the server settings host fields --- .../settings/ServerSettingsController.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/main/java/com/sparrowwallet/sparrow/settings/ServerSettingsController.java b/src/main/java/com/sparrowwallet/sparrow/settings/ServerSettingsController.java index ed9c9594..06a932d0 100644 --- a/src/main/java/com/sparrowwallet/sparrow/settings/ServerSettingsController.java +++ b/src/main/java/com/sparrowwallet/sparrow/settings/ServerSettingsController.java @@ -770,6 +770,20 @@ public class ServerSettingsController extends SettingsDetailController { existingServer = null; } coreHost.setLeft(existingServer == null ? null : getGlyph(FontAwesome5.Glyph.TAG, null)); + + Protocol protocol = Protocol.getProtocol(newValue); + if(existingServer == null && protocol != null) { + if(Protocol.getProtocol(oldValue) == null) { + HostAndPort hostAndPort = protocol.getServerHostAndPort(newValue); + if(!hostAndPort.getHost().isEmpty()) { + coreHost.setText(hostAndPort.getHost()); + corePort.setText(hostAndPort.hasPort() ? String.valueOf(hostAndPort.getPort()) : ""); + } + } else { + return; + } + } + setCoreServerInConfig(config); }; } @@ -809,6 +823,21 @@ public class ServerSettingsController extends SettingsDetailController { existingServer = null; } electrumHost.setLeft(existingServer == null ? null : getGlyph(FontAwesome5.Glyph.TAG, null)); + + Protocol protocol = Protocol.getProtocol(newValue); + if(existingServer == null && protocol != null) { + if(Protocol.getProtocol(oldValue) == null) { + HostAndPort hostAndPort = protocol.getServerHostAndPort(newValue); + if(!hostAndPort.getHost().isEmpty()) { + electrumHost.setText(hostAndPort.getHost()); + electrumPort.setText(hostAndPort.hasPort() ? String.valueOf(hostAndPort.getPort()) : ""); + electrumUseSsl.setSelected(protocol == Protocol.SSL); + } + } else { + return; + } + } + setElectrumServerInConfig(config); }; }