fix cormorant server.version rpc issue

This commit is contained in:
Craig Raw 2025-06-04 17:18:31 +02:00
parent 890f0476b1
commit c265fd1969
2 changed files with 5 additions and 4 deletions

View file

@ -39,7 +39,7 @@ public class SimpleElectrumServerRpc implements ElectrumServerRpc {
@Override @Override
public List<String> getServerVersion(Transport transport, String clientName, String[] supportedVersions) { public List<String> getServerVersion(Transport transport, String clientName, String[] supportedVersions) {
if(Config.get().isLegacyServer()) { if(Config.get().getServerType() == ServerType.ELECTRUM_SERVER && Config.get().isLegacyServer()) {
return getLegacyServerVersion(transport, clientName); return getLegacyServerVersion(transport, clientName);
} }

View file

@ -35,10 +35,11 @@ public class ElectrumServerService {
} }
@JsonRpcMethod("server.version") @JsonRpcMethod("server.version")
public List<String> getServerVersion(@JsonRpcParam("client_name") String clientName, @JsonRpcParam("protocol_version") String protocolVersion) throws UnsupportedVersionException { public List<String> getServerVersion(@JsonRpcParam("client_name") String clientName, @JsonRpcParam("protocol_version") String[] protocolVersion) throws UnsupportedVersionException {
Version clientVersion = new Version(protocolVersion); String version = protocolVersion.length > 1 ? protocolVersion[1] : protocolVersion[0];
Version clientVersion = new Version(version);
if(clientVersion.compareTo(VERSION) < 0) { if(clientVersion.compareTo(VERSION) < 0) {
throw new UnsupportedVersionException(protocolVersion); throw new UnsupportedVersionException(version);
} }
return List.of(Cormorant.SERVER_NAME + " " + SparrowWallet.APP_VERSION, VERSION.get()); return List.of(Cormorant.SERVER_NAME + " " + SparrowWallet.APP_VERSION, VERSION.get());