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

Convert an r-address into a 20 byte Account ID

Behaviour

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

Definition

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

Example

uint8_t accid_out[20];
uint8_t raddr_in[] = "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh";

int64_t bytes_written = 
    util_accid(accid_out, 20, raddr_in, sizeof(raddr_in)-1);
// NB: if specified as a c-string as above, account for the nul char

Parameters

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

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_ptr pointed at something which wasn't a valid r-address.

TOO_SMALL
- write_len was not large enough to store produced Account ID. (Should be 20 bytes).

TOO_BIG
- read_len was longer than an r-address can be.