util_accid

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

Required attributes

  • Name
    write_ptr
    Type
    uint32_t
    Description

    Pointer to a buffer of a suitable size to store the output Account ID. Must be at least 20 bytes.

  • Name
    write_len
    Type
    uint32_t
    Description

    Length of the output buffer.

  • Name
    read_ptr
    Type
    uint32_t
    Description

    Pointer to the r-address.

  • Name
    read_len
    Type
    uint32_t
    Description

    The length of the r-address.

util_raddr

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

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_ptr pointed at something which wasn't a valid r-address.
TOO_SMALLError code indicating write_len was not large enough to store the produced Account ID. (Should be 20 bytes).
TOO_BIGError code indicating read_len was longer than an r-address can be.

Was this page helpful?