getBalances method
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:
- DaemonNotConnectedException if the service is not connected to the gRPC server.
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;
}