Serialize and output a field from the originating transaction
Behaviour
- Find the specified sffield in the originating transaction
- Write the serialized version of the field to the output buffer
Definition
int64_t otxn_field (
    uint32_t write_ptr,
    uint32_t write_len,
  	uint32_t field_id
);
Example
int64_t account_field_len = 
    otxn_field(account_field, 20, sfAccount);
Parameters
| Name | Type | Description | 
|---|---|---|
| write_ptr | uint32_t | Pointer to a buffer of a suitable size to store the output. | 
| write_len | uint32_t | Length of the output buffer. | 
| field_id | uint32_t | The sfcode of the field you are searching for.To compute this manually take the serialized typeand shift it into the 16 highest bits of uint32_t, then take thefieldand place it in the 16 lowest bits.For example: sfEmitNoncehastype5 andfield11 thus its value is0x050BU | 
Important
The field code is not written to the output buffer, only the payload of the field is.
At time of writing for Hooks Public Testnet,
STI_ACCOUNTfields likesfAccountare returned without the leading variable length byte.
Return Code
| Type | Description | 
|---|---|
| int64_t | The number of bytes written If negative, an error: OUT_OF_BOUNDS- pointers/lengths specified outside of hook memory. TOO_SMALL- output buffer was not large enough to hold the serialized field INVALID_FIELD- the sffield_id was invalidDOESNT_EXIST- the field was not found in the originating transaction |