fetchVersion method

Future<String?> fetchVersion()

Fetches the current version of the Haveno daemon from the gRPC server.

This method sends a GetVersionRequest to the Haveno gRPC server and retrieves the current version of the daemon, storing it in _version. If the Haveno client is not connected, a DaemonNotConnectedException is thrown.

Example:

final fetchedVersion = await versionClient.fetchVersion();
print(fetchedVersion); // Outputs the current daemon version

Returns:

  • A Future containing the fetched version as a String.
  • null if an error occurs during the fetch operation.

Throws:

Implementation

Future<String?> fetchVersion() async {
  // Check if the Haveno client is connected to the gRPC server.
  if (!havenoChannel.isConnected) {
    throw DaemonNotConnectedException();
  }
  try {
    // Send the GetVersionRequest to the Haveno gRPC server.
    final versionReply =
        await havenoChannel.versionClient!.getVersion(GetVersionRequest());
    // Return the version.
    return versionReply.version;
  } on GrpcError catch (e) {
    // Handle gRPC errors using the GrpcErrorHandler mixin.
    handleGrpcError(e);
  }
  // Return null if an error occurs.
  return null;
}