util_raddr

Convert a 20 byte Account ID to an r-address

Behaviour

  • Read a 20 byte Account ID from the read_ptr
  • Write the equivalent r-address for that Account ID to write_ptr

Required attributes

  • Name
    write_ptr
    Type
    uint32_t
    Description

    Pointer to a buffer of a suitable size to store the output r-address. Recommend at least 35 bytes.

  • Name
    write_len
    Type
    uint32_t
    Description

    Length of the output buffer.

  • Name
    read_ptr
    Type
    uint32_t
    Description

    Pointer to the Account ID.

  • Name
    read_len
    Type
    uint32_t
    Description

    The length of the input. Always 20.

util_raddr

uint8_t raddr_out[40];
uint8_t acc_id[20] =
{
    0x2dU, 0xd8U, 0xaaU, 0xdbU, 0x4eU, 0x15U,               
    0xebU, 0xeaU,  0xeU, 0xfdU, 0x78U, 0xd1U, 0xb0U,
    0x35U, 0x91U,  0x4U, 0x7bU, 0xfaU, 0x1eU,  0xeU
};
int64_t bytes_written = 
    util_raddr(raddr_out, sizeof(raddr_out), acc_id, 20);

Return Code int64_t

The number of bytes written (the length of the output r-address).

Error CodeDescription
OUT_OF_BOUNDSError code indicating pointers/lengths specified outside of hook memory.
INVALID_ARGUMENTError code indicating read_len was not 20.
TOO_SMALLError code indicating write_len was not large enough to store the produced r-address.

Was this page helpful?