encodeMemo static method

Uint8List encodeMemo(
  1. String memo
)

Encodes a memo into the 16-byte reference field.

The text uses A-Z, 0-9, and -, and the unused bytes are zero. Groups of letters and groups of digits must alternate.

Implementation

static Uint8List encodeMemo(String memo) {
  if (memo.length > 16) {
    throw ArgumentError('A reference is at most 16 bytes');
  }
  final out = Uint8List(16);
  out.setRange(0, memo.length, memo.codeUnits);
  if (!isValidReference(out)) {
    throw ArgumentError('Invalid reference "$memo"');
  }
  return out;
}