From ffccf83ac5040cd6b6efbc8849fcf6b86ec73fc2 Mon Sep 17 00:00:00 2001 From: woodser Date: Sun, 15 May 2022 13:46:01 -0400 Subject: [PATCH] support getXmrPrimaryAddress(), getXmrNewSubaddress() --- core/src/main/java/bisq/core/api/CoreApi.java | 10 +++++-- .../bisq/core/api/CoreWalletsService.java | 8 ++++-- .../bisq/daemon/grpc/GrpcWalletsService.java | 28 +++++++++++++++---- proto/src/main/proto/grpc.proto | 15 ++++++++-- 4 files changed, 47 insertions(+), 14 deletions(-) diff --git a/core/src/main/java/bisq/core/api/CoreApi.java b/core/src/main/java/bisq/core/api/CoreApi.java index d16cff0488..785fb341f7 100644 --- a/core/src/main/java/bisq/core/api/CoreApi.java +++ b/core/src/main/java/bisq/core/api/CoreApi.java @@ -268,13 +268,17 @@ public class CoreApi { public BalancesInfo getBalances(String currencyCode) { return walletsService.getBalances(currencyCode); } - + public String getXmrSeed() { return walletsService.getXmrSeed(); } - public String getNewDepositAddress() { - return walletsService.getNewDepositAddress(); + public String getXmrPrimaryAddress() { + return walletsService.getXmrPrimaryAddress(); + } + + public String getXmrNewSubaddress() { + return walletsService.getXmrNewSubaddress(); } public List getXmrTxs() { diff --git a/core/src/main/java/bisq/core/api/CoreWalletsService.java b/core/src/main/java/bisq/core/api/CoreWalletsService.java index dd34a1800c..9a29bab410 100644 --- a/core/src/main/java/bisq/core/api/CoreWalletsService.java +++ b/core/src/main/java/bisq/core/api/CoreWalletsService.java @@ -160,12 +160,16 @@ class CoreWalletsService { return new BalancesInfo(getBtcBalances(), getXmrBalances()); } } - + String getXmrSeed() { return xmrWalletService.getWallet().getMnemonic(); } - String getNewDepositAddress() { + String getXmrPrimaryAddress() { + return xmrWalletService.getWallet().getPrimaryAddress(); + } + + String getXmrNewSubaddress() { accountService.checkAccountOpen(); return xmrWalletService.getWallet().createSubaddress(0).getAddress(); } diff --git a/daemon/src/main/java/bisq/daemon/grpc/GrpcWalletsService.java b/daemon/src/main/java/bisq/daemon/grpc/GrpcWalletsService.java index 7102c8220f..045ba6a3e4 100644 --- a/daemon/src/main/java/bisq/daemon/grpc/GrpcWalletsService.java +++ b/daemon/src/main/java/bisq/daemon/grpc/GrpcWalletsService.java @@ -28,8 +28,10 @@ import bisq.proto.grpc.GetBalancesReply; import bisq.proto.grpc.GetBalancesRequest; import bisq.proto.grpc.GetFundingAddressesReply; import bisq.proto.grpc.GetFundingAddressesRequest; -import bisq.proto.grpc.GetNewDepositAddressRequest; -import bisq.proto.grpc.GetNewDepositAddressReply; +import bisq.proto.grpc.GetXmrNewSubaddressRequest; +import bisq.proto.grpc.GetXmrPrimaryAddressReply; +import bisq.proto.grpc.GetXmrPrimaryAddressRequest; +import bisq.proto.grpc.GetXmrNewSubaddressReply; import bisq.proto.grpc.GetXmrTxsRequest; import bisq.proto.grpc.GetXmrTxsReply; import bisq.proto.grpc.CreateXmrTxRequest; @@ -132,13 +134,27 @@ class GrpcWalletsService extends WalletsImplBase { exceptionHandler.handleException(log, cause, responseObserver); } } + + @Override + public void getXmrPrimaryAddress(GetXmrPrimaryAddressRequest req, + StreamObserver responseObserver) { + try { + var reply = GetXmrPrimaryAddressReply.newBuilder() + .setPrimaryAddress(coreApi.getXmrPrimaryAddress()) + .build(); + responseObserver.onNext(reply); + responseObserver.onCompleted(); + } catch (Throwable cause) { + exceptionHandler.handleException(log, cause, responseObserver); + } + } @Override - public void getNewDepositAddress(GetNewDepositAddressRequest req, - StreamObserver responseObserver) { + public void getXmrNewSubaddress(GetXmrNewSubaddressRequest req, + StreamObserver responseObserver) { try { - String subaddress = coreApi.getNewDepositAddress(); - var reply = GetNewDepositAddressReply.newBuilder() + String subaddress = coreApi.getXmrNewSubaddress(); + var reply = GetXmrNewSubaddressReply.newBuilder() .setSubaddress(subaddress) .build(); responseObserver.onNext(reply); diff --git a/proto/src/main/proto/grpc.proto b/proto/src/main/proto/grpc.proto index a544573317..4eb0767c37 100644 --- a/proto/src/main/proto/grpc.proto +++ b/proto/src/main/proto/grpc.proto @@ -858,7 +858,9 @@ service Wallets { } rpc GetXmrSeed (GetXmrSeedRequest) returns (GetXmrSeedReply) { } - rpc GetNewDepositAddress (GetNewDepositAddressRequest) returns (GetNewDepositAddressReply) { + rpc GetXmrPrimaryAddress (GetXmrPrimaryAddressRequest) returns (GetXmrPrimaryAddressReply) { + } + rpc GetXmrNewSubaddress (GetXmrNewSubaddressRequest) returns (GetXmrNewSubaddressReply) { } rpc GetXmrTxs (GetXmrTxsRequest) returns (GetXmrTxsReply) { } @@ -905,10 +907,17 @@ message GetXmrSeedReply { string seed = 1; } -message GetNewDepositAddressRequest { +message GetXmrPrimaryAddressRequest { } -message GetNewDepositAddressReply { +message GetXmrPrimaryAddressReply { + string primary_address = 1; +} + +message GetXmrNewSubaddressRequest { +} + +message GetXmrNewSubaddressReply { string subaddress = 1; }