Compute a serialized keylet of a given type

Concepts

Behaviour

  • Compute a keylet of the specified keylet_type according to the parameters a through f 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

a points to an Account ID
b is the length (should be 20)
c, d, e, f must all be zero

KEYLET_HOOK_STATE

a points to an Account ID
b is the length of the Account ID (should be 20)
c points to a hook state key
d is the length of the key (should be 32)
e, f must both be zero

KEYLET_ACCOUNT

a points to an Account ID
b is the length (should be 20)
c, d, e, f must all be zero

KEYLET_AMENDMENTS

a, b, c, d, e, f must all be zero

KEYLET_CHILD

a points to a key
b is the length of the key (should be 32)
c, d, e, f must all ​be zero

KEYLET_SKIP

Either:
a, b, c, d, e, f all zero
Or:
a is a LedgerIndex
b is non-zero
c, d, e, f must all ​be zero

KEYLET_FEES

a, b, c, d, e, f must all be zero

KEYLET_NEGATIVE_UNL

a, b, c, d, e, f must all be zero

KEYLET_LINE

a points to the High Account ID
b is the length of the above (should be 20)
c points to the Low Account ID
d is the length of the above (should be 20)
e points to the Currency Code
f is the length of the above (should be 20)

KEYLET_OFFER

a points to an Account ID
b is the length (should be 20)
c is a 32bit unsigned integer
d, e, f must all be zero

KEYLET_QUALITY

a points to a serialized keylet
b is the length of the above (should be 34)
c is the high 32 bits of the uint64 to pass
d is the low 32 bits of the uint64 to pass
e, f must all be zero

KEYLET_EMITTED_DIR

a, b, c, d, e, f must all be zero

KEYLET_SIGNERS

a points to an Account ID.
b is the length (should be 20.)
c, d, e, f must all be zero.

KEYLET_CHECK

a points to an Account ID.
b is the length (should be 20.)
c is a 32bit unsigned integer
d, e, f must all be zero.

KEYLET_DEPOSIT_PREAUTH

a points to an Account ID
b is the length (should be 20)
c points to an Account ID
d is the length (should be 20)
e, f must all be zero

KEYLET_UNCHECKED

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

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 pass
d is the low 32 bits of the uint64 to pass
e, f must both ​be zero

KEYLET_ESCROW

a points to an Account ID.
b is the length (should be 20.)
c is a 32bit unsigned integer
d, e, f must all be zero.

KEYLET_PAYCHAN

a points to an Account ID
b is the length (should be 20)
c points to an Account ID
d is the length (should be 20)
e 32bit unsigned int to pass
f must be zero

KEYLET_EMITTED

a points to a key.
b is the length of the key (should be 32.)
c, d, e, f must both ​be zero

Return Code

Type

Description

int64_t

The number of bytes written, should always be 32.

If negative, an error:
OUT_OF_BOUNDS

  • pointers/lengths specified outside of hook memory.

INVALID_ARGUMENT

  • Call didn't comply with the above table