Skip to content

Commit

Permalink
Add rpc method 'getpaymentaccts'
Browse files Browse the repository at this point in the history
This addresses task 5 in issue 4257
	bisq-network#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.
	bisq-network#4322
  • Loading branch information
ghubstan committed Jun 19, 2020
1 parent 1930411 commit 435672a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
18 changes: 18 additions & 0 deletions cli/src/main/java/bisq/cli/CliMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import bisq.proto.grpc.GetAddressBalanceRequest;
import bisq.proto.grpc.GetBalanceRequest;
import bisq.proto.grpc.GetFundingAddressesRequest;
import bisq.proto.grpc.GetPaymentAccountsRequest;
import bisq.proto.grpc.GetVersionGrpc;
import bisq.proto.grpc.GetVersionRequest;
import bisq.proto.grpc.LockWalletRequest;
Expand All @@ -45,6 +46,7 @@

import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;

import lombok.extern.slf4j.Slf4j;

Expand All @@ -61,6 +63,7 @@ public class CliMain {

private enum Method {
createpaymentacct,
getpaymentaccts,
getversion,
getbalance,
getaddressbalance,
Expand Down Expand Up @@ -200,6 +203,20 @@ public static void run(String[] args) {
out.println(format("payment account %s saved", accountName));
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: {
var request = LockWalletRequest.newBuilder().build();
walletsService.lockWallet(request);
Expand Down Expand Up @@ -273,6 +290,7 @@ private static void printHelp(OptionParser parser, PrintStream stream) {
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", "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", "unlockwallet", "password timeout",
"Store wallet password in memory for timeout seconds");
Expand Down
5 changes: 5 additions & 0 deletions cli/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,11 @@
[ "$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" {
run ./bisq-cli
[ "$status" -eq 1 ]
Expand Down

0 comments on commit 435672a

Please sign in to comment.