addConnection method

Future<bool?> addConnection(
  1. UrlConnection connection
)

Adds a new XMR connection to the list of available connections.

This method sends an AddConnectionRequest to add a new XMR node connection to the server.

Example:

await xmrConnectionsClient.addConnection(newConnection);
print('Connection added.');

Returns:

  • A Future containing true if the connection is successfully added.
  • null if an error occurs.

Implementation

Future<bool?> addConnection(UrlConnection connection) async {
  if (!havenoChannel.isConnected) {
    throw DaemonNotConnectedException();
  }
  try {
    await havenoChannel.xmrConnectionsClient!
        .addConnection(AddConnectionRequest(connection: connection));
    return true;
  } on GrpcError catch (e) {
    handleGrpcError(e);
  }
  return null;
}