From 5c29bf51b7c04fe2caa7496d0da1a5a78a95d587 Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Tue, 11 Feb 2025 14:03:43 +0200 Subject: [PATCH] handle scanning and pasting server urls in the electrum format --- src/main/java/com/sparrowwallet/sparrow/net/Protocol.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/sparrowwallet/sparrow/net/Protocol.java b/src/main/java/com/sparrowwallet/sparrow/net/Protocol.java index 66bc58a3..7b63fc6c 100644 --- a/src/main/java/com/sparrowwallet/sparrow/net/Protocol.java +++ b/src/main/java/com/sparrowwallet/sparrow/net/Protocol.java @@ -129,7 +129,7 @@ public enum Protocol { public abstract CloseableTransport getTransport(HostAndPort server, File serverCert, HostAndPort proxy) throws IOException, CertificateException, NoSuchAlgorithmException, KeyStoreException, KeyManagementException; public HostAndPort getServerHostAndPort(String url) { - String lessProtocol = url.substring(this.toUrlString().length()); + String lessProtocol = url.endsWith(":t") || url.endsWith(":s") ? url.substring(0, url.length() - 2) : url.substring(this.toUrlString().length()); int pathStart = lessProtocol.indexOf('/'); return HostAndPort.fromString(pathStart < 0 ? lessProtocol : lessProtocol.substring(0, pathStart)); } @@ -178,10 +178,10 @@ public enum Protocol { } public static Protocol getProtocol(String url) { - if(url.startsWith("tcp://")) { + if(url.startsWith("tcp://") || url.endsWith(":t")) { return TCP; } - if(url.startsWith("ssl://")) { + if(url.startsWith("ssl://") || url.endsWith(":s")) { return SSL; } if(url.startsWith("http://")) {