getBalances method

Future<BalancesInfo?> getBalances()

Retrieves the balances of the wallet.

This method sends a GetBalancesRequest to the Haveno gRPC server and retrieves the wallet's balances. If the Haveno client is not connected, a DaemonNotConnectedException is thrown.

Example:

final balances = await walletService.getBalances();
print('Available balance: ${balances?.available}');

Returns:

  • A Future containing BalancesInfo if successful.
  • null if an error occurs.

Throws:

Implementation

Future<BalancesInfo?> getBalances() async {
  if (!havenoChannel.isConnected) {
    throw DaemonNotConnectedException();
  }
  try {
    final getBalancesReply = await havenoChannel.walletsClient!
        .getBalances(GetBalancesRequest());

    return getBalancesReply.balances;
  } on GrpcError catch (e) {
    handleGrpcError(e);
  }
  return null;
}