Add rpc method 'getpaymentaccts'

This addresses task 5 in issue 4257
	https://github.com/bisq-network/bisq/issues/4257

This new gRPC PaymentAccounts service method displays the user's
saved payment accounts.

A unit test to check a successful return status code was added
to cli/test.sh.

This PR should be reviewed/merged after PR 4322.
	https://github.com/bisq-network/bisq/pull/4322
This commit is contained in:
ghubstan 2020-06-19 12:45:04 -03:00
parent 1930411e61
commit 435672a5ee
No known key found for this signature in database
GPG Key ID: E35592D6800A861E
2 changed files with 23 additions and 0 deletions

View File

@ -21,6 +21,7 @@ import bisq.proto.grpc.CreatePaymentAccountRequest;
import bisq.proto.grpc.GetAddressBalanceRequest; import bisq.proto.grpc.GetAddressBalanceRequest;
import bisq.proto.grpc.GetBalanceRequest; import bisq.proto.grpc.GetBalanceRequest;
import bisq.proto.grpc.GetFundingAddressesRequest; import bisq.proto.grpc.GetFundingAddressesRequest;
import bisq.proto.grpc.GetPaymentAccountsRequest;
import bisq.proto.grpc.GetVersionGrpc; import bisq.proto.grpc.GetVersionGrpc;
import bisq.proto.grpc.GetVersionRequest; import bisq.proto.grpc.GetVersionRequest;
import bisq.proto.grpc.LockWalletRequest; import bisq.proto.grpc.LockWalletRequest;
@ -45,6 +46,7 @@ import java.math.BigDecimal;
import java.util.List; import java.util.List;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -61,6 +63,7 @@ public class CliMain {
private enum Method { private enum Method {
createpaymentacct, createpaymentacct,
getpaymentaccts,
getversion, getversion,
getbalance, getbalance,
getaddressbalance, getaddressbalance,
@ -200,6 +203,20 @@ public class CliMain {
out.println(format("payment account %s saved", accountName)); out.println(format("payment account %s saved", accountName));
return; return;
} }
case getpaymentaccts: {
var request = GetPaymentAccountsRequest.newBuilder().build();
var reply = paymentAccountsService.getPaymentAccounts(request);
var columnFormatSpec = "%-41s %-25s %-14s %s";
out.println(format(columnFormatSpec, "ID", "Name", "Currency", "Payment Method"));
out.println(reply.getPaymentAccountsList().stream()
.map(a -> format(columnFormatSpec,
a.getId(),
a.getAccountName(),
a.getSelectedTradeCurrency().getCode(),
a.getPaymentMethod().getId()))
.collect(Collectors.joining("\n")));
return;
}
case lockwallet: { case lockwallet: {
var request = LockWalletRequest.newBuilder().build(); var request = LockWalletRequest.newBuilder().build();
walletsService.lockWallet(request); walletsService.lockWallet(request);
@ -273,6 +290,7 @@ public class CliMain {
stream.format("%-22s%-50s%s%n", "getaddressbalance", "address", "Get server wallet address balance"); stream.format("%-22s%-50s%s%n", "getaddressbalance", "address", "Get server wallet address balance");
stream.format("%-22s%-50s%s%n", "getfundingaddresses", "", "Get BTC funding addresses"); stream.format("%-22s%-50s%s%n", "getfundingaddresses", "", "Get BTC funding addresses");
stream.format("%-22s%-50s%s%n", "createpaymentacct", "account name, account number, currency code", "Create PerfectMoney dummy account"); stream.format("%-22s%-50s%s%n", "createpaymentacct", "account name, account number, currency code", "Create PerfectMoney dummy account");
stream.format("%-22s%-50s%s%n", "getpaymentaccts", "", "Get user payment accounts");
stream.format("%-22s%-50s%s%n", "lockwallet", "", "Remove wallet password from memory, locking the wallet"); stream.format("%-22s%-50s%s%n", "lockwallet", "", "Remove wallet password from memory, locking the wallet");
stream.format("%-22s%-50s%s%n", "unlockwallet", "password timeout", stream.format("%-22s%-50s%s%n", "unlockwallet", "password timeout",
"Store wallet password in memory for timeout seconds"); "Store wallet password in memory for timeout seconds");

View File

@ -171,6 +171,11 @@
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
} }
@test "test getpaymentaccts" {
run ./bisq-cli --password=xyz getpaymentaccts
[ "$status" -eq 0 ]
}
@test "test help displayed on stderr if no options or arguments" { @test "test help displayed on stderr if no options or arguments" {
run ./bisq-cli run ./bisq-cli
[ "$status" -eq 1 ] [ "$status" -eq 1 ]