- Read a 32 byte Hook State key from the
- Write the data (value) at that key to the buffer pointed to by
int64_t state ( uint32_t write_ptr, uint32_t write_len, uint32_t kread_ptr, uint32_t kread_len );
#define SBUF(str) (uint32_t)(str), sizeof(str) if (state(SBUF(vault), SBUF(vault_key)) != 16) rollback(SBUF("Error: could not read state!"), 1);
|write_ptr||uint32_t||A pointer to the buffer to write the data in the Hook State into.|
|write_len||uint32_t||The length of the write buffer.|
|kread_ptr||uint32_t||Pointer to a buffer containing the Hook State key.|
|kread_len||uint32_t||The length of the Hook State key. (Should be 32.)|
Ensure you check the return value. A state lookup can fail of a range of reasons and the buffer will then contain whatever it did before the call (typically all zeros).
|int64_t||The number of bytes written to the write buffer.|
If negative, an error:
- pointers/lengths specified outside of hook memory.
- the specified Hook State key doesn't have an associated value on the ledger at the time of the call.
- the key specified by
- the output buffer was too small to store the Hook State data.