Compute a serialized keylet of a given type
Concepts
Tip
Not every Keylet type is supported by this utility function. If you need another Keylet type you can derive it yourself using util_sha512h and by checking the required fields here. A further Keylet tool may assist you.
Behaviour
- Compute a keylet of the specified
keylet_type
according to the parametersa
throughf
depending on type. - Write the serialized 34 byte keylet into
write_ptr
Definition
int64_t util_keylet (
uint32_t write_ptr,
uint32_t write_len,
uint32_t keylet_type,
uint32_t a,
uint32_t b,
uint32_t c,
uint32_t d,
uint32_t e,
uint32_t f
);
Example
uint8_t keylet[34];
if (util_keylet(keylet, 34, KEYLET_LINE,
hook_accid, 20,
account_field, 20,
currency_code, 20) != 34)
rollback("Keylet Failed.", 14, 1);
Parameters
Name | Type | Description |
---|---|---|
write_ptr | uint32_t | Pointer to a buffer the serialized keylet will be written to |
write_len | uint32_t | Length of output buffer, should be at least 34. |
keylet_type | uint32_t | One of the keylet types as defined in hookapi.h e.g. KEYLET_LINE for a trustline. |
a | uint32_t | See keylet table below |
b | uint32_t | See keylet table below |
c | uint32_t | See keylet table below |
d | uint32_t | See keylet table below |
e | uint32_t | See keylet table below |
f | uint32_t | See keylet table below |
Keylet Table
Keylet Type | Parameters |
---|---|
KEYLET_HOOK_STATE | a points to an Account IDb is the length of the Account ID (should be 20)c points to a hook state keyd is the length of the key (should be 32)e points to a hook state namespacef is the length of the namespace (should be 32) |
KEYLET_AMENDMENTS KEYLET_FEES KEYLET_NEGATIVE_UNL KEYLET_EMITTED_DIR | a , b , c , d , e , f must all be zero |
KEYLET_SKIP | Either:a , b , c , d , e , f all zeroOr: a is a LedgerIndex b is 1c , d , e , f must all be zero |
KEYLET_LINE | a points to the High Account IDb is the length of the above (should be 20)c points to the Low Account IDd is the length of the above (should be 20)e points to the Currency Codef is the length of the above (should be 20) |
KEYLET_QUALITY | a points to a serialized keyletb is the length of the above (should be 34)c is the high 32 bits of the uint64 to passd is the low 32 bits of the uint64 to passe , f must all be zero |
KEYLET_DEPOSIT_PREAUTH | a points to an Account IDb is the length (should be 20)c points to an Account IDd is the length (should be 20)e , f must all be zero |
KEYLET_UNCHECKED KEYLET_CHILD KEYLET_EMITTED_TXN | a points to a key.b is the length of the key (should be 32.)c , d , e , f must both be zero |
KEYLET_OWNER_DIR KEYLET_SIGNERS KEYLET_ACCOUNT KEYLET_HOOK | a points to an Account ID.b is the length (should be 20.)c , d , e , f must all be zero. |
KEYLET_PAGE | a points to a key.b is the length of the key (should be 32.)c is the high 32 bits of the uint64 to passd is the low 32 bits of the uint64 to passe , f must both be zero |
KEYLET_OFFER KEYLET_CHECK KEYLET_ESCROW KEYLET_NFT_OFFER | a points to an Account ID.b is the length (should be 20.)And Either: c is a 32bit unsigned integer (sequence)d is 0Or: c points to a 32 byte keyd is the length of the key (32).In both cases: e and f must be 0. |
KEYLET_PAYCHAN | a points to an Account IDb is the length (should be 20)c points to an Account IDd is the length (should be 20)And Either: e 32bit unsigned int to passf is zeroOr: e points to a 32 byte keyf is the length of the key (32) |
Return Code
Type | Description |
---|---|
int64_t | The number of bytes written, should always be 34. If negative, an error: OUT_OF_BOUNDS - pointers/lengths specified outside of hook memory. INVALID_ARGUMENT - Call didn't comply with the above table. TOO_SMALL - Writing buffer was smaller than 34 bytes. |