getPaymentMethods method

Future<List<PaymentMethod>?> getPaymentMethods()

Fetches the list of all available payment methods from the Haveno daemon.

Returns a List of PaymentMethod 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<PaymentMethod>?> getPaymentMethods() async {
  if (!havenoChannel.isConnected) {
    throw DaemonNotConnectedException();
  }
  List<PaymentMethod> paymentMethods = [];
  try {
    final getPaymentMethodsReply = await havenoChannel.paymentAccountsClient!
        .getPaymentMethods(GetPaymentMethodsRequest());
    paymentMethods = getPaymentMethodsReply.paymentMethods;
    return paymentMethods;
  } on GrpcError catch (e) {
    handleGrpcError(e);
    return paymentMethods;
  }
}