These docs are for v2.0. Click to read the latest docs for v3.0.

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

Definition

int64_t util_raddr (
    uint32_t write_ptr,
    uint32_t write_len,
    uint32_t read_ptr,
    uint32_t read_len
);

Example

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);

Parameters

NameTypeDescription
write_ptruint32_tPointer to a buffer of a suitable size to store the output r-address. Recommend at least 35 bytes.
write_lenuint32_tLength of the output buffer.
read_ptruint32_tPointer to the Account ID.
read_lenuint32_tThe length of the input. Always 20.

Return Code

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

If negative, an error:
OUT_OF_BOUNDS
- pointers/lengths specified outside of hook memory.

INVALID_ARGUMENT
- read_len was not 20.

TOO_SMALL
- write_len was not large enough to store produced r-address in.