handle scanning and pasting server urls in the electrum format

This commit is contained in:
Craig Raw 2025-02-11 14:03:43 +02:00
parent d426703dcc
commit 5c29bf51b7

View file

@ -129,7 +129,7 @@ public enum Protocol {
public abstract CloseableTransport getTransport(HostAndPort server, File serverCert, HostAndPort proxy) throws IOException, CertificateException, NoSuchAlgorithmException, KeyStoreException, KeyManagementException; public abstract CloseableTransport getTransport(HostAndPort server, File serverCert, HostAndPort proxy) throws IOException, CertificateException, NoSuchAlgorithmException, KeyStoreException, KeyManagementException;
public HostAndPort getServerHostAndPort(String url) { 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('/'); int pathStart = lessProtocol.indexOf('/');
return HostAndPort.fromString(pathStart < 0 ? lessProtocol : lessProtocol.substring(0, pathStart)); return HostAndPort.fromString(pathStart < 0 ? lessProtocol : lessProtocol.substring(0, pathStart));
} }
@ -178,10 +178,10 @@ public enum Protocol {
} }
public static Protocol getProtocol(String url) { public static Protocol getProtocol(String url) {
if(url.startsWith("tcp://")) { if(url.startsWith("tcp://") || url.endsWith(":t")) {
return TCP; return TCP;
} }
if(url.startsWith("ssl://")) { if(url.startsWith("ssl://") || url.endsWith(":s")) {
return SSL; return SSL;
} }
if(url.startsWith("http://")) { if(url.startsWith("http://")) {