Skip to main content

rshooks_api/api/
ledger.rs

1use super::*;
2
3/// Retreive the 20 byte Account ID the Hook is executing on
4#[inline(always)]
5pub fn hook_account(accid: &mut [u8]) -> Result<i64> {
6    buf_write(accid, _c::hook_account)
7}
8
9/// Retreive the 32 byte namespace biased SHA512H of the currently executing Hook
10#[inline(always)]
11pub fn hook_hash(hash: &mut [u8], hook_no: i32) -> Result<i64> {
12    let res = unsafe { _c::hook_hash(hash.as_ptr() as u32, hash.len() as u32, hook_no as i32) };
13
14    result_i64(res)
15}
16
17/// Fetch the fee base of the current ledger
18#[inline(always)]
19pub fn fee_base() -> i64 {
20    unsafe { _c::fee_base() }
21}
22
23/// Fetch the current ledger sequence number
24#[inline(always)]
25pub fn ledger_seq() -> i64 {
26    unsafe { _c::ledger_seq() }
27}
28
29/// Retreive the 32 byte namespace biased SHA512H of the last closed ledger
30#[inline(always)]
31pub fn ledger_last_hash(hash: &mut [u8]) -> Result<i64> {
32    buf_write(hash, _c::ledger_last_hash)
33}
34
35/// Generate a 32 byte nonce for use in an emitted transaction
36#[inline(always)]
37pub fn ledger_nonce(n: &mut [u8]) -> Result<i64> {
38    buf_write(n, _c::ledger_nonce)
39}