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
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
write_ptr
uint32_t
Pointer to a buffer of a suitable size to store the output Account ID. Must be at least 20 bytes.
write_len
uint32_t
Length of the output buffer.
read_ptr
uint32_t
Pointer to the r-address.
read_len
uint32_t
The length of the r-address.
Return Code
int64_t
The 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.
Last updated
Was this helpful?