getPaymentAccounts method

Future<List<PaymentAccount>> getPaymentAccounts()

Fetches all the payment accounts associated with the current user.

Returns a List of PaymentAccount if the operation is successful.

Throws a DaemonNotConnectedException if the client is not connected. Returns an empty list if the operation fails.

Implementation

Future<List<PaymentAccount>> getPaymentAccounts() async {
  if (!havenoChannel.isConnected) {
    throw DaemonNotConnectedException();
  }
  List<PaymentAccount> paymentAccounts = [];
  try {
    final getPaymentAccountsReply = await havenoChannel
        .paymentAccountsClient!
        .getPaymentAccounts(GetPaymentAccountsRequest());
    paymentAccounts = getPaymentAccountsReply.paymentAccounts;
    return paymentAccounts;
  } on GrpcError catch (e) {
    handleGrpcError(e);
    return paymentAccounts;
  }
}