util_keylet
Concepts
Section titled “Concepts”Behaviour
Section titled “Behaviour”- Compute a keylet of the specified
keylet_typeaccording to the parametersathroughfdepending on type. - Write the serialized 34 byte keylet into
write_ptr
Definition
Section titled “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);function util_keylet( keylet_type: number, accountid: ByteArray | HexString, statekey: ByteArray | HexString, namespace: ByteArray | HexString ): ErrorCode | ByteArrayExample
Section titled “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);if (util_keylet( KEYLET_LINE, hook_accid, account_field, currency_code ).length < 34) rollback("Keylet Failed.", 1)Parameters
Section titled “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 |
| Name | Type | Description |
|---|---|---|
| keylet_type | The type of the keylet to create | |
| accountid | (Optional) First piece of data for the keylet, can be an array of numbers, a string, or a number. | |
| statekey | (Optional) Second piece of data for the keylet, can be an array of numbers, a string, or a number. | |
| namespace | (Optional) Third piece of data for the keylet, can be an array of numbers, a string, or a number. |
Keylet Table
Section titled “Keylet Table”| Keylet Type | Parameters |
|---|---|
| KEYLET_HOOK_STATE |
|
KEYLET_AMENDMENTS | a, b, c, d, e, f must all be zero |
| KEYLET_SKIP | Either: |
| KEYLET_LINE |
|
| KEYLET_QUALITY |
|
| KEYLET_DEPOSIT_PREAUTH |
|
KEYLET_UNCHECKED |
|
KEYLET_OWNER_DIR |
|
| KEYLET_PAGE |
|
KEYLET_OFFER |
|
| KEYLET_PAYCHAN |
|
Return Code
Section titled “Return Code”| Type | Description |
|---|---|
| int64_t | The number of bytes written, should always be 34. |
| Type | Description |
|---|---|
| number | ErrorCode if there is an error in creating the keylet, otherwise returns the generated keylet as an array of numbers. |