support getXmrPrimaryAddress(), getXmrNewSubaddress()

This commit is contained in:
woodser 2022-05-15 13:46:01 -04:00
parent fa15612586
commit ffccf83ac5
4 changed files with 47 additions and 14 deletions

View File

@ -268,13 +268,17 @@ public class CoreApi {
public BalancesInfo getBalances(String currencyCode) { public BalancesInfo getBalances(String currencyCode) {
return walletsService.getBalances(currencyCode); return walletsService.getBalances(currencyCode);
} }
public String getXmrSeed() { public String getXmrSeed() {
return walletsService.getXmrSeed(); return walletsService.getXmrSeed();
} }
public String getNewDepositAddress() { public String getXmrPrimaryAddress() {
return walletsService.getNewDepositAddress(); return walletsService.getXmrPrimaryAddress();
}
public String getXmrNewSubaddress() {
return walletsService.getXmrNewSubaddress();
} }
public List<MoneroTxWallet> getXmrTxs() { public List<MoneroTxWallet> getXmrTxs() {

View File

@ -160,12 +160,16 @@ class CoreWalletsService {
return new BalancesInfo(getBtcBalances(), getXmrBalances()); return new BalancesInfo(getBtcBalances(), getXmrBalances());
} }
} }
String getXmrSeed() { String getXmrSeed() {
return xmrWalletService.getWallet().getMnemonic(); return xmrWalletService.getWallet().getMnemonic();
} }
String getNewDepositAddress() { String getXmrPrimaryAddress() {
return xmrWalletService.getWallet().getPrimaryAddress();
}
String getXmrNewSubaddress() {
accountService.checkAccountOpen(); accountService.checkAccountOpen();
return xmrWalletService.getWallet().createSubaddress(0).getAddress(); return xmrWalletService.getWallet().createSubaddress(0).getAddress();
} }

View File

@ -28,8 +28,10 @@ import bisq.proto.grpc.GetBalancesReply;
import bisq.proto.grpc.GetBalancesRequest; import bisq.proto.grpc.GetBalancesRequest;
import bisq.proto.grpc.GetFundingAddressesReply; import bisq.proto.grpc.GetFundingAddressesReply;
import bisq.proto.grpc.GetFundingAddressesRequest; import bisq.proto.grpc.GetFundingAddressesRequest;
import bisq.proto.grpc.GetNewDepositAddressRequest; import bisq.proto.grpc.GetXmrNewSubaddressRequest;
import bisq.proto.grpc.GetNewDepositAddressReply; import bisq.proto.grpc.GetXmrPrimaryAddressReply;
import bisq.proto.grpc.GetXmrPrimaryAddressRequest;
import bisq.proto.grpc.GetXmrNewSubaddressReply;
import bisq.proto.grpc.GetXmrTxsRequest; import bisq.proto.grpc.GetXmrTxsRequest;
import bisq.proto.grpc.GetXmrTxsReply; import bisq.proto.grpc.GetXmrTxsReply;
import bisq.proto.grpc.CreateXmrTxRequest; import bisq.proto.grpc.CreateXmrTxRequest;
@ -132,13 +134,27 @@ class GrpcWalletsService extends WalletsImplBase {
exceptionHandler.handleException(log, cause, responseObserver); exceptionHandler.handleException(log, cause, responseObserver);
} }
} }
@Override
public void getXmrPrimaryAddress(GetXmrPrimaryAddressRequest req,
StreamObserver<GetXmrPrimaryAddressReply> responseObserver) {
try {
var reply = GetXmrPrimaryAddressReply.newBuilder()
.setPrimaryAddress(coreApi.getXmrPrimaryAddress())
.build();
responseObserver.onNext(reply);
responseObserver.onCompleted();
} catch (Throwable cause) {
exceptionHandler.handleException(log, cause, responseObserver);
}
}
@Override @Override
public void getNewDepositAddress(GetNewDepositAddressRequest req, public void getXmrNewSubaddress(GetXmrNewSubaddressRequest req,
StreamObserver<GetNewDepositAddressReply> responseObserver) { StreamObserver<GetXmrNewSubaddressReply> responseObserver) {
try { try {
String subaddress = coreApi.getNewDepositAddress(); String subaddress = coreApi.getXmrNewSubaddress();
var reply = GetNewDepositAddressReply.newBuilder() var reply = GetXmrNewSubaddressReply.newBuilder()
.setSubaddress(subaddress) .setSubaddress(subaddress)
.build(); .build();
responseObserver.onNext(reply); responseObserver.onNext(reply);

View File

@ -858,7 +858,9 @@ service Wallets {
} }
rpc GetXmrSeed (GetXmrSeedRequest) returns (GetXmrSeedReply) { 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) { rpc GetXmrTxs (GetXmrTxsRequest) returns (GetXmrTxsReply) {
} }
@ -905,10 +907,17 @@ message GetXmrSeedReply {
string seed = 1; string seed = 1;
} }
message GetNewDepositAddressRequest { message GetXmrPrimaryAddressRequest {
} }
message GetNewDepositAddressReply { message GetXmrPrimaryAddressReply {
string primary_address = 1;
}
message GetXmrNewSubaddressRequest {
}
message GetXmrNewSubaddressReply {
string subaddress = 1; string subaddress = 1;
} }