diff --git a/core/src/main/java/haveno/core/api/CoreApi.java b/core/src/main/java/haveno/core/api/CoreApi.java index 9afc4ee2b9..14ec0f6d08 100644 --- a/core/src/main/java/haveno/core/api/CoreApi.java +++ b/core/src/main/java/haveno/core/api/CoreApi.java @@ -247,6 +247,10 @@ public class CoreApi { xmrConnectionService.setAutoSwitch(autoSwitch); } + public boolean getXmrConnectionAutoSwitch() { + return xmrConnectionService.getAutoSwitch(); + } + /////////////////////////////////////////////////////////////////////////////////////////// // Monero node /////////////////////////////////////////////////////////////////////////////////////////// diff --git a/core/src/main/java/haveno/core/api/XmrConnectionService.java b/core/src/main/java/haveno/core/api/XmrConnectionService.java index ffeacbfd38..b49de52b62 100644 --- a/core/src/main/java/haveno/core/api/XmrConnectionService.java +++ b/core/src/main/java/haveno/core/api/XmrConnectionService.java @@ -349,6 +349,11 @@ public final class XmrConnectionService { connectionList.setAutoSwitch(autoSwitch); } + public boolean getAutoSwitch() { + accountService.checkAccountOpen(); + return connectionList.getAutoSwitch(); + } + public boolean isConnectionLocalHost() { return isConnectionLocalHost(getConnection()); } diff --git a/daemon/src/main/java/haveno/daemon/grpc/GrpcXmrConnectionService.java b/daemon/src/main/java/haveno/daemon/grpc/GrpcXmrConnectionService.java index eb1b8f6fd0..a03dc5a73e 100644 --- a/daemon/src/main/java/haveno/daemon/grpc/GrpcXmrConnectionService.java +++ b/daemon/src/main/java/haveno/daemon/grpc/GrpcXmrConnectionService.java @@ -45,6 +45,8 @@ import haveno.proto.grpc.CheckConnectionReply; import haveno.proto.grpc.CheckConnectionRequest; import haveno.proto.grpc.CheckConnectionsReply; import haveno.proto.grpc.CheckConnectionsRequest; +import haveno.proto.grpc.GetAutoSwitchReply; +import haveno.proto.grpc.GetAutoSwitchRequest; import haveno.proto.grpc.GetBestAvailableConnectionReply; import haveno.proto.grpc.GetBestAvailableConnectionRequest; import haveno.proto.grpc.GetConnectionReply; @@ -221,6 +223,16 @@ class GrpcXmrConnectionService extends XmrConnectionsImplBase { }); } + @Override + public void getAutoSwitch(GetAutoSwitchRequest request, + StreamObserver responseObserver) { + handleRequest(responseObserver, () -> { + GetAutoSwitchReply.Builder builder = GetAutoSwitchReply.newBuilder(); + builder.setAutoSwitch(coreApi.getXmrConnectionAutoSwitch()); + return builder.build(); + }); + } + private <_Reply> void handleRequest(StreamObserver<_Reply> responseObserver, RpcRequestHandler<_Reply> handler) { try { diff --git a/proto/src/main/proto/grpc.proto b/proto/src/main/proto/grpc.proto index 1bb4c9f5ec..cb6ba81860 100644 --- a/proto/src/main/proto/grpc.proto +++ b/proto/src/main/proto/grpc.proto @@ -323,6 +323,8 @@ service XmrConnections { } rpc SetAutoSwitch(SetAutoSwitchRequest) returns (SetAutoSwitchReply) { } + rpc GetAutoSwitch(GetAutoSwitchRequest) returns (GetAutoSwitchReply) { + } } message UrlConnection { @@ -410,6 +412,12 @@ message SetAutoSwitchRequest { message SetAutoSwitchReply {} +message GetAutoSwitchRequest {} + +message GetAutoSwitchReply { + bool auto_switch = 1; +} + /////////////////////////////////////////////////////////////////////////////////////////// // XmrNode ///////////////////////////////////////////////////////////////////////////////////////////