WalletMachineMemo constructor
Throws ArgumentError on empty bytes or a blank purpose: both are
host bugs, and the honest answer is a refusal before anything reaches a
permanent ledger — not a silently dropped memo or an undisclosed one.
Implementation
WalletMachineMemo({required List<int> bytes, required String purpose})
: bytes = List<int>.unmodifiable(bytes),
purpose = _sanitizePurpose(purpose) {
if (this.bytes.isEmpty) {
throw ArgumentError.value(
bytes,
'bytes',
'a machine memo with no bytes is nothing to attach',
);
}
if (this.purpose.isEmpty) {
throw ArgumentError.value(
purpose,
'purpose',
'bytes cannot be attached without a human-readable purpose — the user '
'is told what is being added to their transaction',
);
}
if (this.purpose.length > purposeMaxChars) {
throw ArgumentError.value(
purpose,
'purpose',
'a purpose line is one sentence the user reads at the authorization '
'step, not a document (max $purposeMaxChars characters)',
);
}
}