getTransactionById method

Future<TransactionResponse> getTransactionById({
  1. List<int> transactionIdBytes = const [],
  2. String transactionIdString = "",
  3. double? confidence,
  4. CallOptions? options,
})

////////////////////////// Transactions Returns a TransactionResponse object for the transaction at the given transactionId and confidence.

transactionIdBytes is an List of integers representing the transaction ID to retrieve

transactionIdString is an String representing the transaction ID to retrieve

confidence is a double representing the confidence factor of the transaction to retrieve.

options is a CallOptions object that can be used to set additional options for the RPC request.

Throws an Exception if transaction ID validation fails or an error occurs during the RPC request.

Implementation

/// Returns a [TransactionResponse] object for the transaction at the given [transactionId] and [confidence].
///
/// [transactionIdBytes] is an [List] of integers representing the transaction ID to retrieve
///
/// [transactionIdString] is an [String] representing the transaction ID to retrieve
///
/// [confidence] is a [double] representing the confidence factor of the transaction to retrieve.
///
/// [options] is a [CallOptions] object that can be used to set additional options for the RPC request.
///
/// Throws an [Exception] if transaction ID validation fails or an error occurs during the RPC request.
Future<TransactionResponse> getTransactionById({
  List<int> transactionIdBytes = const [],
  String transactionIdString = "",
  double? confidence,
  CallOptions? options,
}) async {
  if (transactionIdBytes.isEmpty && transactionIdString.isEmpty) {
    throw Exception(ErrorMessages.missingTransactionId);
  }

  final GetTransactionByIdRequest request = GetTransactionByIdRequest(
    confidenceFactor: getConfidenceFactorFromDouble(confidence),
    transactionId: !transactionIdBytes.isEmpty
        ? getTransactionIdFromList(transactionIdBytes)
        : getTransactionIdFromString(transactionIdString),
  );
  final TransactionResponse response =
      await genusTransactionStub.getTransactionById(
    request,
    options: options,
  );
  return response;
}