getBlockByHash method

Future<RpcBlock> getBlockByHash(
  1. String hash, {
  2. bool includeTransactions = true,
})

Implementation

Future<RpcBlock> getBlockByHash(
  String hash, {
  bool includeTransactions = true,
}) async {
  final message = KaspadMessage(
    getBlockRequest: GetBlockRequestMessage(
      hash: hash,
      includeTransactions: includeTransactions,
    ),
  );

  final result = await _singleRequest(message);
  final error = result.getBlockResponse.error;
  if (error.message.isNotEmpty) {
    throw RpcException(error);
  }

  return result.getBlockResponse.block;
}