calculateTxIDs static method

List<String> calculateTxIDs(
  1. List signedTxnBase64List
)

Implementation

static List<String> calculateTxIDs(List signedTxnBase64List) {
  return signedTxnBase64List.map((signedTxnBase64) {
    // Step 1: Decode base64
    final signedTxnBytes = base64.decode(signedTxnBase64);

    // Step 2: Extract canonical txn
    final canonicalTxnBytes = _extractCanonicalTransaction(signedTxnBytes);

    // Step 3: Prefix with "TX"
    final prefix = ascii.encode('TX');
    final prefixedBytes =
        Uint8List.fromList([...prefix, ...canonicalTxnBytes]);

    // Step 4: SHA-512/256
    final digest = SHA512tDigest(32);
    digest.update(prefixedBytes, 0, prefixedBytes.length);
    final hash = Uint8List(32);
    digest.doFinal(hash, 0);

    // Step 5: Base32
    return bytesToBase32(hash);
  }).toList();
}