Class MemoRules
The limits a node puts on Memos before it will accept a transaction at all.
Inheritance
Namespace: Xrpl.Models.Transactions
Assembly: Xrpl.dll
Syntax
public static class MemoRules
Remarks
These are local checks in rippled's passesLocalChecks → isMemoOkay
(src/libxrpl/protocol/STTx.cpp). A transaction that fails them is not relayed, never
reaches a ledger and costs no fee - but the consumer only finds out after building,
autofilling and signing it, and the refusal does not say which field was at fault. Checking
the same rules before signing turns that into an exception that names the problem.
Two of the five rules the node applies are already enforced by the binary codec, so they are
deliberately not repeated here: a member other than MemoType, MemoData or
MemoFormat inside a Memo is refused when the blob is built, and so is a value
that is not hex. Re-checking them would mean two places to keep in step with one truth.
Fields
| Edit this page View SourceMaxSerializedLength
The largest the serialized Memos array may be, in bytes.
Declaration
public const int MaxSerializedLength = 1024
Field Value
| Type | Description |
|---|---|
| int |
Remarks
The limit is on the array as a whole, so several memos do not raise it. In practice this
leaves 1019 bytes of MemoData in a single memo carrying nothing else.
Methods
| Edit this page View SourceTryGetSerializedLength(IEnumerable<MemoWrapper>, out int)
Measures the SDK's typed Memos (TransactionCommon.Memos,
MemoWrapper elements) with the same rules as
TryGetSerializedLength(object, out int).
Declaration
public static bool TryGetSerializedLength(IEnumerable<MemoWrapper> memos, out int length)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<MemoWrapper> | memos | The memos of a transaction, or |
| int | length | The serialized length in bytes, to compare with MaxSerializedLength; |
Returns
| Type | Description |
|---|---|
| bool |
|
TryGetSerializedLength(object, out int)
Measures a Memos array the way the node measures it, so a caller can show how much
room is left before the limit instead of finding out when signing is refused.
Declaration
public static bool TryGetSerializedLength(object memos, out int length)
Parameters
| Type | Name | Description |
|---|---|---|
| object | memos | The value of the transaction's |
| int | length | The length in bytes of the array as it would be serialized in the transaction, to compare
with MaxSerializedLength; |
Returns
| Type | Description |
|---|---|
| bool |
|
Remarks
This is the figure Validate(object) compares with the limit, so a form and the
signing check cannot disagree. rippled serializes the array with STArray::add:
each element is its object start marker, the fields, and the object end marker; the
array's own markers are not part of the length it compares.
Each field costs one byte of field id plus its length prefix (one byte up to 192 bytes,
two up to 12480) plus the value. A memo costs two more for its start and end markers. A
single memo of n bytes of MemoData with a ten-byte MemoFormat such as
text/plain and no MemoType therefore measures n + 17 once n is
193 or more, and a memo of data alone measures n + 5 (n + 4 below 193, where
the length prefix is one byte).
Validate(object)
Checks a transaction's Memos against the rules a node applies locally.
Declaration
public static void Validate(object memos)
Parameters
| Type | Name | Description |
|---|---|---|
| object | memos | The value of the transaction's |
Exceptions
| Type | Condition |
|---|---|
| ValidationException | When the array is too large, an element is not a |