openAccount method

Future<void> openAccount(
  1. String? password
)

Opens an account with the Haveno backend, ensuring the gRPC channel is connected before making the request.

Throws:

  • DaemonNotConnectedException if the Haveno daemon is not connected.
  • GrpcError if any gRPC error occurs during the request, with custom handling for invalid password errors.

Parameters:

  • password: The password for the account. If null, the default behavior will be applied.

Implementation

Future<void> openAccount(String? password) async {
  // Check if the Haveno channel is connected
  if (!havenoChannel.isConnected) {
    // Throw custom exception if not connected
    throw DaemonNotConnectedException();
  }

  try {
    // Make gRPC call to open the account
    await havenoChannel.accountClient!.openAccount(OpenAccountRequest(
      password: password,  // Send password (could be null)
    ));
  } on GrpcError catch (e) {
    // Handle gRPC error (e.g., invalid password error)
    handleGrpcError(e);
  }
}