Skip to content

sto_subfield

Serialized Objects
  • Parse a STObject pointed to by read_ptr
  • Find the field specified by field_id
  • If the field is found, and:
    1. It is an array, then return the start and length of the array including the leadin/leadout bytes, or
    1. It is not an array, then return the start and length of the PAYLOAD of the field (excluding the leadin bytes).
int64_t sto_subfield (
uint32_t read_ptr,
uint32_t read_len,
uint32_t field_id
);
#define SUB_OFFSET(x) ((int32_t)(x >> 32))
#define SUB_LENGTH(x) ((int32_t)(x & 0xFFFFFFFFULL))
int64_t memos_lookup =
sto_subfield(txn_ptr, txn_len, sfMemos);
if (memos_lookup < 0)
{
// sfMemos was not found in the STObject pointed at by memo_ptr
}
else
{
// sfMemos was found and its location is as follows:
uint8_t* memos_ptr = SUB_OFFSET(memos_lookup) + memos_ptr;
int64_t memos_len = SUB_LENGTH(memos_lookup);
}
NameTypeDescription
read_ptruint32_tPointer to the buffer containing the STObject
read_lenuint32_tLength of STObject
field_iduint32_t

The sf code of the field you are searching for.

To compute this manually take the serialized type and shift it into the 16 highest bits of uint32_t, then take the field and place it in the 16 lowest bits.

For example:
sfEmitNonce has type 5 and field 11 thus its value is 0x050BU

TypeDescription
int64_t

The location of the field within the specified buffer:
- The high 32 bits are the offset location.
- The low 32 bits are the length.

If negative, an error:
OUT_OF_BOUNDS
- pointers/lengths specified outside of hook memory.

TOO_SMALL
- Input buffer isn’t large enough to possibly contain a valid STObject.

DOESNT_EXIST
- The searched for field isn’t present in the supplied STObject.

PARSE_ERROR
- The supplied STObject is malformed or not an STObject.