getAmountBytes method

ByteArray getAmountBytes()

Converts the current amount (BigInt) to an 8-byte little-endian array.

Implementation

ByteArray getAmountBytes() {
  final buffer = Uint8List(TXAMOUNT);
  final byteData = ByteData.view(buffer.buffer);
  // Convert BigInt to int for putUint64. This assumes the BigInt fits in 64 bits.
  byteData.setUint64(0, _amount.toInt(), Endian.little);
  return buffer;
}