xrpl_wasm_stdlib/host/
host_bindings_trait.rs

1/// Trait defining all host functions available to WASM smart contracts.
2///
3/// This trait can be implemented by:
4/// - `HostBindings`: The production implementation that calls actual host functions
5/// - Mock implementations using `mockall` for testing
6///
7/// # Example
8///
9/// ```rust,ignore
10/// use xrpl_wasm_stdlib::host::{HostFunctions, HostBindings};
11///
12/// fn my_function<H: HostFunctions>(host: &H) {
13///     unsafe {
14///         let sqn = host.get_ledger_sqn();
15///         // ... use sqn
16///     }
17/// }
18///
19/// // In production code:
20/// let host = RealHostFunctions;
21/// my_function(&host);
22/// ```
23#[allow(unused)] // To remove warn when compiled for non-WASM targets
24#[cfg_attr(all(test, not(target_arch = "wasm32")), mockall::automock)]
25pub trait HostBindings {
26    // ###############################
27    // Host Function Category: getters
28    // ###############################
29
30    /// Retrieves the current ledger sequence number.
31    ///
32    /// This function populates a provided buffer with the ledger sequence number.
33    ///
34    /// # Returns
35    ///
36    /// - Returns the current ledger sequence number on success
37    /// - Returns a negative error code on failure. The list of error codes is defined in
38    ///   `../core/error_codes.rs`
39    ///
40    /// # Safety
41    /// This function is safe to call from WASM context
42    unsafe fn get_ledger_sqn(&self) -> i32;
43
44    /// Retrieves the parent ledger time.
45    ///
46    /// This function is used to obtain the parent ledger's timestamp as a byte array.
47    /// The timestamp is written into a provided output buffer.
48    ///
49    /// # Returns
50    ///
51    /// - Returns the parent ledger time on success
52    /// - Returns a negative error code on failure. The list of error codes is defined in
53    ///   `../core/error_codes.rs`
54    ///
55    /// # Safety
56    /// This function is safe to call from WASM context
57    unsafe fn get_parent_ledger_time(&self) -> i32;
58
59    /// Retrieves the hash of the parent ledger.
60    ///
61    /// This function fetches the hash of the parent ledger and stores it in the buffer provided.
62    /// The hash is expected to be written to the memory location pointed by `out_buff_ptr`,
63    /// and its length should not exceed the `out_buff_len`.
64    ///
65    /// # Parameters
66    /// - `out_buff_ptr`: A mutable pointer to a buffer where the parent ledger hash will be written.
67    ///   The buffer must be allocated and managed by the caller.
68    /// - `out_buff_len`: The maximum length of the buffer in bytes. This indicates the size of the
69    ///   buffer and ensures that the function does not write beyond the allowed length.
70    ///
71    /// # Returns
72    ///
73    /// - Returns a positive number of bytes wrote to an output buffer on success
74    /// - Returns a negative error code on failure. The list of error codes is defined in
75    ///   `../core/error_codes.rs`
76    ///
77    /// # Safety
78    /// Caller must ensure all pointer parameters point to valid memory
79    unsafe fn get_parent_ledger_hash(&self, out_buff_ptr: *mut u8, out_buff_len: usize) -> i32;
80
81    /// Retrieves the current transaction base fee.
82    ///
83    /// # Returns
84    ///
85    /// - Returns a positive transaction base fee on success.
86    /// - Returns a negative error code on failure. The list of error codes is defined in
87    ///   ../core/error_codes.rs
88    ///
89    /// # Safety
90    /// This function is safe to call from WASM context
91    unsafe fn get_base_fee(&self) -> i32;
92
93    /// Retrieves the state of an amendment and whether it's enabled or not.
94    ///
95    /// # Parameters
96    ///
97    /// - `amendment_ptr`: A raw pointer to the amendment. This can be either the uint256 that
98    ///   represents the hash of an amendment, or the string name of the
99    ///   amendment.
100    /// - `amendment_len`: The length of the amendment specified by `amendment_ptr`.
101    ///
102    /// # Returns
103    ///
104    /// - Returns a boolean 0 or 1 (whether the amendment is enabled or not) on success.
105    /// - Returns a negative error code on failure. The list of error codes is defined in
106    ///   ../core/error_codes.rs
107    ///
108    /// # Safety
109    /// Caller must ensure all pointer parameters point to valid memory
110    unsafe fn amendment_enabled(&self, amendment_ptr: *const u8, amendment_len: usize) -> i32;
111
112    /// Fetch a ledger entry pointed by the given keylet.
113    ///
114    /// This function uses the keylet to locate a ledger entry. If found, add it to the
115    /// cache. The cache can have up to 255 ledger entries. If `cache_num` is 0, the
116    /// new ledger entry will put in the next available cache space. If `cache_num` is not 0,
117    /// the new ledger entry will replace an existing ledger entry in the catch.
118    ///
119    /// # Parameters
120    ///
121    /// - `keylet_ptr`: A raw pointer to the keylet, which is a unique identifier used to
122    ///   locate or store data in the ledger.
123    /// - `keylet_len`: The length of the keylet specified by `keylet_ptr`.
124    /// - `cache_num`: The cache number to which the keylet will be placed in.
125    ///   If 0, the host will assign a new cache space.
126    ///
127    /// # Returns
128    ///
129    /// - Returns a positive cache number
130    /// - Returns a negative error code on failure
131    ///
132    /// # Safety
133    /// Caller must ensure all pointer parameters point to valid memory
134    unsafe fn cache_ledger_obj(
135        &self,
136        keylet_ptr: *const u8,
137        keylet_len: usize,
138        cache_num: i32,
139    ) -> i32;
140
141    /// Retrieves a specific transaction field and writes it into the provided output buffer.
142    ///
143    /// # Parameters
144    ///
145    /// * `field` - An integer value representing the specific transaction field to retrieve.
146    /// * `out_buff_ptr` - A mutable pointer to a buffer where the output data will be written.
147    /// * `out_buff_len` - The size (in bytes) of the buffer pointed to by `out_buff_ptr`.
148    ///
149    /// # Returns
150    ///
151    /// - Returns a positive number of bytes wrote to an output buffer on success
152    /// - Returns a negative error code on failure. The list of error codes is defined in
153    ///   `../core/error_codes.rs`
154    ///
155    /// # Safety
156    /// Caller must ensure all pointer parameters point to valid memory
157    unsafe fn get_tx_field(&self, field: i32, out_buff_ptr: *mut u8, out_buff_len: usize) -> i32;
158
159    /// Retrieves a specific field from the current ledger object and writes it into the provided buffer.
160    ///
161    /// # Parameters
162    /// - `field` (`i32`): The integer identifier for the desired field in the ledger object.
163    /// - `out_buff_ptr` (`*mut u8`): A mutable pointer to the memory location where the field data
164    ///   will be written. This should point to a pre-allocated buffer.
165    /// - `out_buff_len` (`usize`): The size (in bytes) of the buffer provided by `out_buff_ptr`.
166    ///
167    /// # Returns
168    ///
169    /// - Returns a positive number of bytes wrote to an output buffer on success
170    /// - Returns a negative error code on failure. The list of error codes is defined in
171    ///   `../core/error_codes.rs`
172    ///
173    /// # Safety
174    /// Caller must ensure all pointer parameters point to valid memory
175    unsafe fn get_current_ledger_obj_field(
176        &self,
177        field: i32,
178        out_buff_ptr: *mut u8,
179        out_buff_len: usize,
180    ) -> i32;
181
182    /// Retrieves a specific field from a ledger object based on the given parameters.
183    ///
184    /// # Parameters
185    ///
186    /// - `cache_num`: An integer representing the cache index of the ledger object.
187    /// - `field`: An integer representing the specific field to retrieve from the ledger object.
188    /// - `out_buff_ptr`: A mutable pointer to a buffer where the retrieved field data will be written.
189    /// - `out_buff_len`: The size of the output buffer in bytes.
190    ///
191    /// # Returns
192    ///
193    /// - Returns a positive number of bytes wrote to an output buffer on success
194    /// - Returns a negative error code on failure. The list of error codes is defined in
195    ///   `../core/error_codes.rs`
196    ///
197    /// # Safety
198    /// Caller must ensure all pointer parameters point to valid memory
199    unsafe fn get_ledger_obj_field(
200        &self,
201        cache_num: i32,
202        field: i32,
203        out_buff_ptr: *mut u8,
204        out_buff_len: usize,
205    ) -> i32;
206
207    /// Retrieves a nested field from the current ledger object and writes it into the provided buffer.
208    ///
209    /// # Parameters
210    /// - `locator_ptr`: A pointer to a byte array containing the locator for the nested field.
211    /// - `locator_len`: The length of the locator data in bytes.
212    /// - `out_buff_ptr`: A pointer to a mutable byte array where the resulting field data will be written.
213    /// - `out_buff_len`: The size of the output buffer in bytes.
214    ///
215    /// # Returns
216    ///
217    /// - Returns a positive number of bytes wrote to an output buffer on success
218    /// - Returns a negative error code on failure. The list of error codes is defined in
219    ///   `../core/error_codes.rs`
220    ///
221    /// # Safety
222    /// Caller must ensure all pointer parameters point to valid memory
223    unsafe fn get_tx_nested_field(
224        &self,
225        locator_ptr: *const u8,
226        locator_len: usize,
227        out_buff_ptr: *mut u8,
228        out_buff_len: usize,
229    ) -> i32;
230
231    /// Retrieves a specific nested field from the current ledger object.
232    ///
233    /// This function is designed to access a nested field within the ledger object
234    /// specified by the `locator`. The `locator` acts as a path or identifier to
235    /// the desired field. The resulting data is written to the `out_buff` buffer.
236    /// The function returns a status code indicating success or failure of the operation.
237    ///
238    /// # Parameters
239    /// - `locator_ptr`: A pointer to a byte array containing the locator for the nested field.
240    /// - `locator_len`: The length of the locator data in bytes.
241    /// - `out_buff_ptr`: A pointer to a mutable byte array where the resulting field data will be written.
242    /// - `out_buff_len`: The size of the output buffer in bytes.
243    ///
244    /// # Returns
245    ///
246    /// - Returns a positive number of bytes wrote to an output buffer on success
247    /// - Returns a negative error code on failure. The list of error codes is defined in
248    ///   `../core/error_codes.rs`
249    ///
250    /// # Safety
251    /// Caller must ensure all pointer parameters point to valid memory
252    unsafe fn get_current_ledger_obj_nested_field(
253        &self,
254        locator_ptr: *const u8,
255        locator_len: usize,
256        out_buff_ptr: *mut u8,
257        out_buff_len: usize,
258    ) -> i32;
259
260    /// Retrieves a nested field from a ledger object in a specific cache_num and writes the result into an output buffer.
261    ///
262    /// # Parameters
263    /// - `cache_num`: The cache index of the ledger object to access.
264    /// - `locator_ptr`: A pointer to the memory location containing the locator string data
265    ///   (used to identify the nested field in the ledger object).
266    /// - `locator_len`: The length of the locator string.
267    /// - `out_buff_ptr`: A pointer to the buffer where the retrieved nested field value will be written.
268    /// - `out_buff_len`: The size of the output buffer in bytes.
269    ///
270    /// # Returns
271    ///
272    /// - Returns a positive number of bytes wrote to an output buffer on success
273    /// - Returns a negative error code on failure. The list of error codes is defined in
274    ///   `../core/error_codes.rs`
275    ///
276    /// # Safety
277    /// Caller must ensure all pointer parameters point to valid memory
278    unsafe fn get_ledger_obj_nested_field(
279        &self,
280        cache_num: i32,
281        locator_ptr: *const u8,
282        locator_len: usize,
283        out_buff_ptr: *mut u8,
284        out_buff_len: usize,
285    ) -> i32;
286
287    /// Retrieves the length of an array based on the provided field value.
288    ///
289    /// # Parameters
290    /// - `field` (i32): The integer identifier for the desired field.
291    ///
292    /// # Returns
293    ///
294    /// - Returns a positive number of array length on success
295    /// - Returns a negative error code on failure. The list of error codes is defined in
296    ///   ../core/error_codes.rs
297    ///
298    /// # Safety
299    /// This function is safe to call from WASM context
300    unsafe fn get_tx_array_len(&self, field: i32) -> i32;
301
302    /// Retrieves the length of an array based on the provided field value.
303    ///
304    /// # Parameters
305    /// - `field` (i32): The integer identifier for the desired field.
306    ///
307    /// # Returns
308    ///
309    /// - Returns a positive number of array length on success
310    /// - Returns a negative error code on failure. The list of error codes is defined in
311    ///   ../core/error_codes.rs
312    ///
313    /// # Safety
314    /// This function is safe to call from WASM context
315    unsafe fn get_current_ledger_obj_array_len(&self, field: i32) -> i32;
316
317    /// Retrieves the length of an array based on the provided cache number and field value.
318    ///
319    /// # Parameters
320    /// - `cache_num`: The cache index of the ledger object to access.
321    /// - `field` (i32): The integer identifier for the desired field.
322    ///
323    /// # Returns
324    ///
325    /// - Returns a positive number of array length on success
326    /// - Returns a negative error code on failure. The list of error codes is defined in
327    ///   ../core/error_codes.rs
328    ///
329    /// # Safety
330    /// This function is safe to call from WASM context
331    unsafe fn get_ledger_obj_array_len(&self, cache_num: i32, field: i32) -> i32;
332
333    /// Retrieves the length of an array based on the provided locator.
334    ///
335    /// # Parameters
336    /// - `locator_ptr`: A pointer to a byte array containing the locator for the nested field.
337    /// - `locator_len`: The length of the locator data in bytes.
338    ///
339    /// # Returns
340    ///
341    /// - Returns a positive number of array length on success
342    /// - Returns a negative error code on failure. The list of error codes is defined in
343    ///   ../core/error_codes.rs
344    ///
345    /// # Safety
346    /// Caller must ensure all pointer parameters point to valid memory
347    unsafe fn get_tx_nested_array_len(&self, locator_ptr: *const u8, locator_len: usize) -> i32;
348
349    /// Retrieves the length of an array based on the provided locator.
350    ///
351    /// # Parameters
352    /// - `locator_ptr`: A pointer to a byte array containing the locator for the nested field.
353    /// - `locator_len`: The length of the locator data in bytes.
354    ///
355    /// # Returns
356    ///
357    /// - Returns a positive number of array length on success
358    /// - Returns a negative error code on failure. The list of error codes is defined in
359    ///   ../core/error_codes.rs
360    ///
361    /// # Safety
362    /// Caller must ensure all pointer parameters point to valid memory
363    unsafe fn get_current_ledger_obj_nested_array_len(
364        &self,
365        locator_ptr: *const u8,
366        locator_len: usize,
367    ) -> i32;
368
369    /// Retrieves the length of an array based on the provided locator.
370    ///
371    /// # Parameters
372    /// - `cache_num`: The cache index of the ledger object to access.
373    /// - `locator_ptr`: A pointer to a byte array containing the locator for the nested field.
374    /// - `locator_len`: The length of the locator data in bytes.
375    ///
376    /// # Returns
377    ///
378    /// - Returns a positive number of array length on success
379    /// - Returns a negative error code on failure. The list of error codes is defined in
380    ///   ../core/error_codes.rs
381    ///
382    /// # Safety
383    /// Caller must ensure all pointer parameters point to valid memory
384    unsafe fn get_ledger_obj_nested_array_len(
385        &self,
386        cache_num: i32,
387        locator_ptr: *const u8,
388        locator_len: usize,
389    ) -> i32;
390
391    // ###################################################
392    // Host Function Category: update current ledger entry
393    // ###################################################
394
395    /// Updates a data field of the current ledger entry
396    ///
397    /// # Parameters
398    ///
399    /// - `data_ptr`: A pointer to the data to be written.
400    /// - `data_len`: The size of the data.
401    ///
402    /// # Returns
403    ///
404    /// - 0 on success
405    /// - negative for an error
406    ///
407    /// # Safety
408    /// Caller must ensure all pointer parameters point to valid memory
409    unsafe fn update_data(&self, data_ptr: *const u8, data_len: usize) -> i32;
410
411    // ###################################################
412    // Host Function Category: hash and keylet computation
413    // ###################################################
414
415    /// Computes the first 32 bytes (half) of the SHA-512 hash for the given input data.
416    ///
417    /// # Parameters
418    ///
419    /// - `data_ptr`: A pointer to the input data to be hashed.
420    /// - `data_len`: The length, in bytes, of the input data.
421    /// - `out_buff_ptr`: A pointer to the buffer where the resulting 32-byte hash will be written.
422    /// - `out_buff_len`: The length, in bytes, of the output buffer.
423    ///
424    /// # Returns
425    ///
426    /// - Returns a positive number of bytes wrote to an output buffer on success
427    /// - Returns a negative error code on failure. The list of error codes is defined in
428    ///   ../core/error_codes.rs
429    ///
430    /// # Safety
431    /// Caller must ensure all pointer parameters point to valid memory
432    unsafe fn compute_sha512_half(
433        &self,
434        data_ptr: *const u8,
435        data_len: usize,
436        out_buff_ptr: *mut u8,
437        out_buff_len: usize,
438    ) -> i32;
439
440    /// Checks a key signature when provided the message and public key.
441    ///
442    /// # Parameters
443    /// - `message_ptr`: A pointer to the message data to be verified.
444    /// - `message_len`: The length, in bytes, of the message data.
445    /// - `signature_ptr`: A pointer to the signature data.
446    /// - `signature_len`: The length, in bytes, of the signature data.
447    /// - `pubkey_ptr`: A pointer to the public key data.
448    /// - `pubkey_len`: The length, in bytes, of the public key data.
449    ///
450    /// # Returns
451    ///
452    /// - Returns 1 if the signature is valid.
453    /// - Returns 0 if the signature is invalid.
454    /// - Returns a negative error code on failure. The list of error codes is defined in
455    ///   ../core/error_codes.rs
456    ///
457    /// # Safety
458    /// Caller must ensure all pointer parameters point to valid memory
459    unsafe fn check_sig(
460        &self,
461        message_ptr: *const u8,
462        message_len: usize,
463        signature_ptr: *const u8,
464        signature_len: usize,
465        pubkey_ptr: *const u8,
466        pubkey_len: usize,
467    ) -> i32;
468
469    /// Generates the keylet (key identifier) for a specific account.
470    ///
471    /// This function is used to calculate the account keylet in a cryptographic or
472    /// blockchain-based system. A keylet is typically used to identify an account or entity
473    /// in a secure and deterministic way.
474    ///
475    /// # Parameters
476    ///
477    /// - `account_ptr`: A pointer to the memory of the account identifier.
478    /// - `account_len`: The size (in bytes) of the data pointed to by `account_ptr`.
479    /// - `out_buff_ptr`: A pointer to the memory where the generated keylet will be stored.
480    /// - `out_buff_len`: The length (in bytes) of the buffer pointed to by `out_buff_ptr`.
481    ///
482    /// # Returns
483    ///
484    /// - Returns a positive number of bytes wrote to an output buffer on success
485    /// - Returns a negative error code on failure. The list of error codes is defined in
486    ///   `../core/error_codes.rs`
487    ///
488    /// # Safety
489    /// Caller must ensure all pointer parameters point to valid memory
490    unsafe fn account_keylet(
491        &self,
492        account_ptr: *const u8,
493        account_len: usize,
494        out_buff_ptr: *mut u8,
495        out_buff_len: usize,
496    ) -> i32;
497
498    /// Generates the keylet (key identifier) for a specific AMM.
499    ///
500    /// This function is used to calculate the AMM keylet in a cryptographic or
501    /// blockchain-based system. A keylet is typically used to identify an AMM or entity
502    /// in a secure and deterministic way.
503    ///
504    /// # Parameters
505    ///
506    /// - `issue1_ptr`: A pointer to the memory of the issue1 identifier.
507    /// - `issue1_len`: The size (in bytes) of the data pointed to by `issue1_ptr`.
508    /// - `issue2_ptr`: A pointer to the memory of the issue2 identifier.
509    /// - `issue2_len`: The size (in bytes) of the data pointed to by `issue2_ptr`.
510    /// - `out_buff_ptr`: A pointer to the memory where the generated keylet will be stored.
511    /// - `out_buff_len`: The length (in bytes) of the buffer pointed to by `out_buff_ptr`.
512    ///
513    /// # Returns
514    ///
515    /// - Returns a positive number of bytes wrote to an output buffer on success
516    /// - Returns a negative error code on failure. The list of error codes is defined in
517    ///   `../core/error_codes.rs`
518    ///
519    /// # Safety
520    /// Caller must ensure all pointer parameters point to valid memory
521    unsafe fn amm_keylet(
522        &self,
523        issue1_ptr: *const u8,
524        issue1_len: usize,
525        issue2_ptr: *const u8,
526        issue2_len: usize,
527        out_buff_ptr: *mut u8,
528        out_buff_len: usize,
529    ) -> i32;
530
531    /// Computes the Keylet for a check entry in a ledger.
532    ///
533    /// # Parameters
534    ///
535    /// - `account_ptr`: A pointer to the memory location of the accountID.
536    /// - `account_len`: The length of the accountID.
537    /// - `sequence`: The account sequence number associated with the check entry.
538    /// - `out_buff_ptr`: A pointer to the output buffer where the derived keylet will be stored.
539    /// - `out_buff_len`: The length of the output buffer.
540    ///
541    /// # Returns
542    ///
543    /// - Returns a positive number of bytes wrote to an output buffer on success
544    /// - Returns a negative error code on failure. The list of error codes is defined in
545    ///   ../core/error_codes.rs
546    ///
547    /// # Safety
548    /// Caller must ensure all pointer parameters point to valid memory
549    unsafe fn check_keylet(
550        &self,
551        account_ptr: *const u8,
552        account_len: usize,
553        sequence: i32,
554        out_buff_ptr: *mut u8,
555        out_buff_len: usize,
556    ) -> i32;
557
558    /// Generates a keylet for a credential.
559    ///
560    /// # Parameters
561    ///
562    /// * `subject_ptr`: A pointer to the memory location where the subject data begins.
563    /// * `subject_len`: The length of the subject data in bytes.
564    /// * `issuer_ptr`: A pointer to the memory location where the issuer data begins.
565    /// * `issuer_len`: The length of the issuer data in bytes.
566    /// * `cred_type_ptr`: A pointer to the memory location where the credential type data begins.
567    /// * `cred_type_len`: The length of the credential type data in bytes.
568    /// * `out_buff_ptr`: A pointer to the buffer where the generated keylet will be written.
569    /// * `out_buff_len`: The size of the output buffer in bytes.
570    ///
571    /// # Returns
572    ///
573    /// - Returns a positive number of bytes wrote to an output buffer on success
574    /// - Returns a negative error code on failure. The list of error codes is defined in
575    ///   `../core/error_codes.rs`
576    ///
577    /// # Safety
578    /// Caller must ensure all pointer parameters point to valid memory
579    #[allow(clippy::too_many_arguments)]
580    unsafe fn credential_keylet(
581        &self,
582        subject_ptr: *const u8,
583        subject_len: usize,
584        issuer_ptr: *const u8,
585        issuer_len: usize,
586        cred_type_ptr: *const u8,
587        cred_type_len: usize,
588        out_buff_ptr: *mut u8,
589        out_buff_len: usize,
590    ) -> i32;
591
592    /// Computes the Keylet for a delegate entry in a ledger.
593    ///
594    /// # Parameters
595    ///
596    /// - `account_ptr`: A pointer to the memory location of the accountID.
597    /// - `account_len`: The length of the accountID.
598    /// - `authorize_ptr`: A pointer to the memory location of the authorized account.
599    /// - `authorize_len`: The length of the authorized account.
600    /// - `out_buff_ptr`: A pointer to the output buffer where the derived keylet will be stored.
601    /// - `out_buff_len`: The length of the output buffer.
602    ///
603    /// # Returns
604    ///
605    /// - Returns a positive number of bytes wrote to an output buffer on success
606    /// - Returns a negative error code on failure. The list of error codes is defined in
607    ///   ../core/error_codes.rs
608    ///
609    /// # Safety
610    /// Caller must ensure all pointer parameters point to valid memory
611    unsafe fn delegate_keylet(
612        &self,
613        account_ptr: *const u8,
614        account_len: usize,
615        authorize_ptr: *const u8,
616        authorize_len: usize,
617        out_buff_ptr: *mut u8,
618        out_buff_len: usize,
619    ) -> i32;
620
621    /// Computes the Keylet for a deposit preauth entry in a ledger.
622    ///
623    /// # Parameters
624    ///
625    /// - `account_ptr`: A pointer to the memory location of the accountID.
626    /// - `account_len`: The length of the accountID.
627    /// - `authorize_ptr`: A pointer to the memory location of the authorized account.
628    /// - `authorize_len`: The length of the authorized account.
629    /// - `out_buff_ptr`: A pointer to the output buffer where the derived keylet will be stored.
630    /// - `out_buff_len`: The length of the output buffer.
631    ///
632    /// # Returns
633    ///
634    /// - Returns a positive number of bytes wrote to an output buffer on success
635    /// - Returns a negative error code on failure. The list of error codes is defined in
636    ///   ../core/error_codes.rs
637    ///
638    /// # Safety
639    /// Caller must ensure all pointer parameters point to valid memory
640    unsafe fn deposit_preauth_keylet(
641        &self,
642        account_ptr: *const u8,
643        account_len: usize,
644        authorize_ptr: *const u8,
645        authorize_len: usize,
646        out_buff_ptr: *mut u8,
647        out_buff_len: usize,
648    ) -> i32;
649
650    /// Computes the Keylet for a DID entry in a ledger.
651    ///
652    /// # Parameters
653    ///
654    /// - `account_ptr`: A pointer to the memory location of the accountID.
655    /// - `account_len`: The length of the accountID.
656    /// - `out_buff_ptr`: A pointer to the output buffer where the derived keylet will be stored.
657    /// - `out_buff_len`: The length of the output buffer.
658    ///
659    /// # Returns
660    ///
661    /// - Returns a positive number of bytes wrote to an output buffer on success
662    /// - Returns a negative error code on failure. The list of error codes is defined in
663    ///   ../core/error_codes.rs
664    ///
665    /// # Safety
666    /// Caller must ensure all pointer parameters point to valid memory
667    unsafe fn did_keylet(
668        &self,
669        account_ptr: *const u8,
670        account_len: usize,
671        out_buff_ptr: *mut u8,
672        out_buff_len: usize,
673    ) -> i32;
674
675    /// Computes the Keylet for an escrow entry in a ledger.
676    ///
677    /// # Parameters
678    ///
679    /// - `account_ptr`: A pointer to the memory location of the accountID.
680    /// - `account_len`: The length of the accountID.
681    /// - `sequence`: The account sequence number associated with the escrow entry.
682    /// - `out_buff_ptr`: A pointer to the output buffer where the derived keylet will be stored.
683    /// - `out_buff_len`: The length of the output buffer.
684    ///
685    /// # Returns
686    ///
687    /// - Returns a positive number of bytes wrote to an output buffer on success
688    /// - Returns a negative error code on failure. The list of error codes is defined in
689    ///   `../core/error_codes.rs`
690    ///
691    /// # Safety
692    /// Caller must ensure all pointer parameters point to valid memory
693    unsafe fn escrow_keylet(
694        &self,
695        account_ptr: *const u8,
696        account_len: usize,
697        sequence: i32,
698        out_buff_ptr: *mut u8,
699        out_buff_len: usize,
700    ) -> i32;
701
702    /// Computes the Keylet for a trustline entry in a ledger.
703    ///
704    /// # Parameters
705    ///
706    /// - `account1_ptr`: A pointer to the memory location of the first accountID.
707    /// - `account1_len`: The length of the first accountID.
708    /// - `account2_ptr`: A pointer to the memory location of the second accountID.
709    /// - `account2_len`: The length of the second accountID.
710    /// - `currency_ptr`: A pointer to the memory location of the currency.
711    /// - `currency_len`: The length of the currency.
712    /// - `out_buff_ptr`: A pointer to the output buffer where the derived keylet will be stored.
713    /// - `out_buff_len`: The length of the output buffer.
714    ///
715    /// # Returns
716    ///
717    /// - Returns a positive number of bytes wrote to an output buffer on success
718    /// - Returns a negative error code on failure. The list of error codes is defined in
719    ///   ../core/error_codes.rs
720    ///
721    /// # Safety
722    /// Caller must ensure all pointer parameters point to valid memory
723    #[allow(clippy::too_many_arguments)]
724    unsafe fn line_keylet(
725        &self,
726        account1_ptr: *const u8,
727        account1_len: usize,
728        account2_ptr: *const u8,
729        account2_len: usize,
730        currency_ptr: *const u8,
731        currency_len: usize,
732        out_buff_ptr: *mut u8,
733        out_buff_len: usize,
734    ) -> i32;
735
736    /// Computes the Keylet for an MPT issuance entry in a ledger.
737    ///
738    /// # Parameters
739    ///
740    /// - `issuer_ptr`: A pointer to the memory location of the accountID.
741    /// - `issuer_len`: The length of the accountID.
742    /// - `sequence`: The account sequence number associated with the MPT issuance entry.
743    /// - `out_buff_ptr`: A pointer to the output buffer where the derived keylet will be stored.
744    /// - `out_buff_len`: The length of the output buffer.
745    ///
746    /// # Returns
747    ///
748    /// - Returns a positive number of bytes wrote to an output buffer on success
749    /// - Returns a negative error code on failure. The list of error codes is defined in
750    ///   `../core/error_codes.rs`
751    ///
752    /// # Safety
753    /// Caller must ensure all pointer parameters point to valid memory
754    unsafe fn mpt_issuance_keylet(
755        &self,
756        issuer_ptr: *const u8,
757        issuer_len: usize,
758        sequence: i32,
759        out_buff_ptr: *mut u8,
760        out_buff_len: usize,
761    ) -> i32;
762
763    /// Computes the Keylet for an MPToken entry in a ledger.
764    ///
765    /// # Parameters
766    ///
767    /// - `mptid_ptr`: A pointer to the memory location of the MPTID.
768    /// - `mptid_len`: The length of the MPTID.
769    /// - `holder_ptr`: A pointer to the memory location of the holder account.
770    /// - `holder_len`: The length of the holder account.
771    /// - `out_buff_ptr`: A pointer to the output buffer where the derived keylet will be stored.
772    /// - `out_buff_len`: The length of the output buffer.
773    ///
774    /// # Returns
775    ///
776    /// - Returns a positive number of bytes wrote to an output buffer on success
777    /// - Returns a negative error code on failure. The list of error codes is defined in
778    ///   ../core/error_codes.rs
779    ///
780    /// # Safety
781    /// Caller must ensure all pointer parameters point to valid memory
782    unsafe fn mptoken_keylet(
783        &self,
784        mptid_ptr: *const u8,
785        mptid_len: usize,
786        holder_ptr: *const u8,
787        holder_len: usize,
788        out_buff_ptr: *mut u8,
789        out_buff_len: usize,
790    ) -> i32;
791
792    /// Computes the Keylet for an NFT offer entry in a ledger.
793    ///
794    /// # Parameters
795    ///
796    /// - `account_ptr`: A pointer to the memory location of the accountID.
797    /// - `account_len`: The length of the accountID.
798    /// - `sequence`: The account sequence number associated with the NFT offer entry.
799    /// - `out_buff_ptr`: A pointer to the output buffer where the derived keylet will be stored.
800    /// - `out_buff_len`: The length of the output buffer.
801    ///
802    /// # Returns
803    ///
804    /// - Returns a positive number of bytes wrote to an output buffer on success
805    /// - Returns a negative error code on failure. The list of error codes is defined in
806    ///   ../core/error_codes.rs
807    ///
808    /// # Safety
809    /// Caller must ensure all pointer parameters point to valid memory
810    unsafe fn nft_offer_keylet(
811        &self,
812        account_ptr: *const u8,
813        account_len: usize,
814        sequence: i32,
815        out_buff_ptr: *mut u8,
816        out_buff_len: usize,
817    ) -> i32;
818
819    /// Computes the Keylet for an offer entry in a ledger.
820    ///
821    /// # Parameters
822    ///
823    /// - `account_ptr`: A pointer to the memory location of the accountID.
824    /// - `account_len`: The length of the accountID.
825    /// - `sequence`: The account sequence number associated with the offer entry.
826    /// - `out_buff_ptr`: A pointer to the output buffer where the derived keylet will be stored.
827    /// - `out_buff_len`: The length of the output buffer.
828    ///
829    /// # Returns
830    ///
831    /// - Returns a positive number of bytes wrote to an output buffer on success
832    /// - Returns a negative error code on failure. The list of error codes is defined in
833    ///   ../core/error_codes.rs
834    ///
835    /// # Safety
836    /// Caller must ensure all pointer parameters point to valid memory
837    unsafe fn offer_keylet(
838        &self,
839        account_ptr: *const u8,
840        account_len: usize,
841        sequence: i32,
842        out_buff_ptr: *mut u8,
843        out_buff_len: usize,
844    ) -> i32;
845
846    /// Generates a keylet associated with an oracle's account and document ID.
847    ///
848    /// # Parameters
849    ///
850    /// - `account_ptr`: A pointer to the memory location of the accountID.
851    /// - `account_len`: The length of the accountID.
852    /// - `document_id`: An integer representing the ID of the document associated with the oracle.
853    /// - `out_buff_ptr`: A pointer to a pre-allocated buffer where the resulting keylet will be
854    ///   written.
855    /// - `out_buff_len`: The size of the output buffer in bytes.
856    ///
857    /// # Returns
858    ///
859    /// - Returns a positive number of bytes wrote to an output buffer on success
860    /// - Returns a negative error code on failure. The list of error codes is defined in
861    ///   `../core/error_codes.rs`
862    ///
863    /// # Safety
864    /// Caller must ensure all pointer parameters point to valid memory
865    unsafe fn oracle_keylet(
866        &self,
867        account_ptr: *const u8,
868        account_len: usize,
869        document_id: i32,
870        out_buff_ptr: *mut u8,
871        out_buff_len: usize,
872    ) -> i32;
873
874    /// Computes the Keylet for a payment channel entry in a ledger.
875    ///
876    /// # Parameters
877    ///
878    /// - `account_ptr`: A pointer to the memory location of the accountID.
879    /// - `account_len`: The length of the accountID.
880    /// - `destination_ptr`: A pointer to the memory location of the destination.
881    /// - `destination_len`: The length of the destination.
882    /// - `sequence`: The account sequence number associated with the payment channel entry.
883    /// - `out_buff_ptr`: A pointer to the output buffer where the derived keylet will be stored.
884    /// - `out_buff_len`: The length of the output buffer.
885    ///
886    /// # Returns
887    ///
888    /// - Returns a positive number of bytes wrote to an output buffer on success
889    /// - Returns a negative error code on failure. The list of error codes is defined in
890    ///   ../core/error_codes.rs
891    ///
892    /// # Safety
893    /// Caller must ensure all pointer parameters point to valid memory
894    #[allow(clippy::too_many_arguments)]
895    unsafe fn paychan_keylet(
896        &self,
897        account_ptr: *const u8,
898        account_len: usize,
899        destination_ptr: *const u8,
900        destination_len: usize,
901        sequence: i32,
902        out_buff_ptr: *mut u8,
903        out_buff_len: usize,
904    ) -> i32;
905
906    /// Computes the Keylet for a permissioned domain entry in a ledger.
907    ///
908    /// # Parameters
909    ///
910    /// - `account_ptr`: A pointer to the memory location of the accountID.
911    /// - `account_len`: The length of the accountID.
912    /// - `sequence`: The account sequence number associated with the permissioned domain entry.
913    /// - `out_buff_ptr`: A pointer to the output buffer where the derived keylet will be stored.
914    /// - `out_buff_len`: The length of the output buffer.
915    ///
916    /// # Returns
917    ///
918    /// - Returns a positive number of bytes wrote to an output buffer on success
919    /// - Returns a negative error code on failure. The list of error codes is defined in
920    ///   ../core/error_codes.rs
921    ///
922    /// # Safety
923    /// Caller must ensure all pointer parameters point to valid memory
924    unsafe fn permissioned_domain_keylet(
925        &self,
926        account_ptr: *const u8,
927        account_len: usize,
928        sequence: i32,
929        out_buff_ptr: *mut u8,
930        out_buff_len: usize,
931    ) -> i32;
932
933    /// Computes the Keylet for a signer entry in a ledger.
934    ///
935    /// # Parameters
936    ///
937    /// - `account_ptr`: A pointer to the memory location of the accountID.
938    /// - `account_len`: The length of the accountID.
939    /// - `out_buff_ptr`: A pointer to the output buffer where the derived keylet will be stored.
940    /// - `out_buff_len`: The length of the output buffer.
941    ///
942    /// # Returns
943    ///
944    /// - Returns a positive number of bytes wrote to an output buffer on success
945    /// - Returns a negative error code on failure. The list of error codes is defined in
946    ///   ../core/error_codes.rs
947    ///
948    /// # Safety
949    /// Caller must ensure all pointer parameters point to valid memory
950    unsafe fn signers_keylet(
951        &self,
952        account_ptr: *const u8,
953        account_len: usize,
954        out_buff_ptr: *mut u8,
955        out_buff_len: usize,
956    ) -> i32;
957
958    /// Computes the Keylet for a ticket entry in a ledger.
959    ///
960    /// # Parameters
961    ///
962    /// - `account_ptr`: A pointer to the memory location of the accountID.
963    /// - `account_len`: The length of the accountID.
964    /// - `sequence`: The account sequence number associated with the ticket entry.
965    /// - `out_buff_ptr`: A pointer to the output buffer where the derived keylet will be stored.
966    /// - `out_buff_len`: The length of the output buffer.
967    ///
968    /// # Returns
969    ///
970    /// - Returns a positive number of bytes wrote to an output buffer on success
971    /// - Returns a negative error code on failure. The list of error codes is defined in
972    ///   ../core/error_codes.rs
973    ///
974    /// # Safety
975    /// Caller must ensure all pointer parameters point to valid memory
976    unsafe fn ticket_keylet(
977        &self,
978        account_ptr: *const u8,
979        account_len: usize,
980        sequence: i32,
981        out_buff_ptr: *mut u8,
982        out_buff_len: usize,
983    ) -> i32;
984
985    /// Computes the Keylet for a vault entry in a ledger.
986    ///
987    /// # Parameters
988    ///
989    /// - `account_ptr`: A pointer to the memory location of the accountID.
990    /// - `account_len`: The length of the accountID.
991    /// - `sequence`: The account sequence number associated with the vault entry.
992    /// - `out_buff_ptr`: A pointer to the output buffer where the derived keylet will be stored.
993    /// - `out_buff_len`: The length of the output buffer.
994    ///
995    /// # Returns
996    ///
997    /// - Returns a positive number of bytes wrote to an output buffer on success
998    /// - Returns a negative error code on failure. The list of error codes is defined in
999    ///   ../core/error_codes.rs
1000    ///
1001    /// # Safety
1002    /// Caller must ensure all pointer parameters point to valid memory
1003    unsafe fn vault_keylet(
1004        &self,
1005        account_ptr: *const u8,
1006        account_len: usize,
1007        sequence: i32,
1008        out_buff_ptr: *mut u8,
1009        out_buff_len: usize,
1010    ) -> i32;
1011
1012    // #############################
1013    // Host Function Category: NFT
1014    // #############################
1015
1016    /// Retrieves the URI details of a specific NFT (Non-Fungible Token) associated with a given account.
1017    ///
1018    /// # Parameters
1019    ///
1020    /// - `account_ptr`: A pointer to the memory location of the accountID.
1021    /// - `account_len`: The length of the accountID.
1022    /// - `nft_id_ptr`: A pointer to the memory location containing the NFT identifier.
1023    /// - `nft_id_len`: The length of the NFT identifier in bytes.
1024    /// - `out_buff_ptr`: A mutable pointer to the memory location where the retrieved NFT URI
1025    ///   will be written.
1026    /// - `out_buff_len`: The maximum length of the output buffer.
1027    ///
1028    /// # Returns
1029    ///
1030    /// - Returns a positive number of bytes wrote to an output buffer on success
1031    /// - Returns a negative error code on failure. The list of error codes is defined in
1032    ///   `../core/error_codes.rs`
1033    ///
1034    /// # Safety
1035    /// Caller must ensure all pointer parameters point to valid memory
1036    unsafe fn get_nft(
1037        &self,
1038        account_ptr: *const u8,
1039        account_len: usize,
1040        nft_id_ptr: *const u8,
1041        nft_id_len: usize,
1042        out_buff_ptr: *mut u8,
1043        out_buff_len: usize,
1044    ) -> i32;
1045
1046    /// Retrieves the issuer of a specific NFT (Non-Fungible Token).
1047    ///
1048    /// # Parameters
1049    ///
1050    /// - `nft_id_ptr`: A pointer to the memory location containing the NFT identifier.
1051    /// - `nft_id_len`: The length of the NFT identifier in bytes.
1052    /// - `out_buff_ptr`: A mutable pointer to the memory location where the retrieved issuer
1053    ///   account will be written.
1054    /// - `out_buff_len`: The maximum length of the output buffer.
1055    ///
1056    /// # Returns
1057    ///
1058    /// - Returns a positive number of bytes wrote to an output buffer on success
1059    /// - Returns a negative error code on failure. The list of error codes is defined in
1060    ///   ../core/error_codes.rs
1061    ///
1062    /// # Safety
1063    /// Caller must ensure all pointer parameters point to valid memory
1064    unsafe fn get_nft_issuer(
1065        &self,
1066        nft_id_ptr: *const u8,
1067        nft_id_len: usize,
1068        out_buff_ptr: *mut u8,
1069        out_buff_len: usize,
1070    ) -> i32;
1071
1072    /// Retrieves the taxon of a specific NFT (Non-Fungible Token).
1073    ///
1074    /// # Parameters
1075    ///
1076    /// - `nft_id_ptr`: A pointer to the memory location containing the NFT identifier.
1077    /// - `nft_id_len`: The length of the NFT identifier in bytes.
1078    /// - `out_buff_ptr`: A mutable pointer to the memory location where the retrieved taxon
1079    ///   will be written.
1080    /// - `out_buff_len`: The maximum length of the output buffer.
1081    ///
1082    /// # Returns
1083    ///
1084    /// - Returns a positive number of bytes wrote to an output buffer on success
1085    /// - Returns a negative error code on failure. The list of error codes is defined in
1086    ///   ../core/error_codes.rs
1087    ///
1088    /// # Safety
1089    /// Caller must ensure all pointer parameters point to valid memory
1090    unsafe fn get_nft_taxon(
1091        &self,
1092        nft_id_ptr: *const u8,
1093        nft_id_len: usize,
1094        out_buff_ptr: *mut u8,
1095        out_buff_len: usize,
1096    ) -> i32;
1097
1098    /// Retrieves the flags of a specific NFT (Non-Fungible Token).
1099    ///
1100    /// # Parameters
1101    ///
1102    /// - `nft_id_ptr`: A pointer to the memory location containing the NFT identifier.
1103    /// - `nft_id_len`: The length of the NFT identifier in bytes.
1104    ///
1105    /// # Returns
1106    ///
1107    /// - Returns a positive flags value on success, which is a bitmask representing the NFT's flags
1108    /// - Returns a negative error code on failure. The list of error codes is defined in
1109    ///   ../core/error_codes.rs
1110    ///
1111    /// # Safety
1112    /// Caller must ensure all pointer parameters point to valid memory
1113    unsafe fn get_nft_flags(&self, nft_id_ptr: *const u8, nft_id_len: usize) -> i32;
1114
1115    /// Retrieves the transfer fee of a specific NFT (Non-Fungible Token).
1116    ///
1117    /// # Parameters
1118    ///
1119    /// - `nft_id_ptr`: A pointer to the memory location containing the NFT identifier.
1120    /// - `nft_id_len`: The length of the NFT identifier in bytes.
1121    ///
1122    /// # Returns
1123    ///
1124    /// - Returns a positive transfer fee value on success
1125    /// - Returns a negative error code on failure. The list of error codes is defined in
1126    ///   ../core/error_codes.rs
1127    ///
1128    /// # Safety
1129    /// Caller must ensure all pointer parameters point to valid memory
1130    unsafe fn get_nft_transfer_fee(&self, nft_id_ptr: *const u8, nft_id_len: usize) -> i32;
1131
1132    /// Retrieves the serial number of a specific NFT (Non-Fungible Token).
1133    ///
1134    /// # Parameters
1135    ///
1136    /// - `nft_id_ptr`: A pointer to the memory location containing the NFT identifier.
1137    /// - `nft_id_len`: The length of the NFT identifier in bytes.
1138    /// - `out_buff_ptr`: A mutable pointer to the memory location where the retrieved serial
1139    ///   number will be written.
1140    /// - `out_buff_len`: The maximum length of the output buffer.
1141    ///
1142    /// # Returns
1143    ///
1144    /// - Returns a positive number of bytes wrote to an output buffer on success
1145    /// - Returns a negative error code on failure. The list of error codes is defined in
1146    ///   ../core/error_codes.rs
1147    ///
1148    /// # Safety
1149    /// Caller must ensure all pointer parameters point to valid memory
1150    unsafe fn get_nft_serial(
1151        &self,
1152        nft_id_ptr: *const u8,
1153        nft_id_len: usize,
1154        out_buff_ptr: *mut u8,
1155        out_buff_len: usize,
1156    ) -> i32;
1157
1158    // #############################
1159    // Host Function Category: FLOAT
1160    // #############################
1161
1162    /// Converts a signed 64-bit integer to an opaque float representation
1163    /// # Parameters
1164    /// * `in_int` - The input integer to convert
1165    /// * `out_buff` - Pointer to output buffer where the float will be written
1166    /// * `rounding_mode` - Rounding mode to use for the conversion
1167    /// # Returns
1168    /// 8 on success, error code otherwise
1169    ///
1170    /// # Safety
1171    /// Caller must ensure all pointer parameters point to valid memory
1172    unsafe fn float_from_int(
1173        &self,
1174        in_int: i64,
1175        out_buff: *mut u8,
1176        out_buff_len: usize,
1177        rounding_mode: i32,
1178    ) -> i32;
1179
1180    /// Converts an unsigned integer to an opaque float representation
1181    /// # Parameters
1182    /// * `in_uint_ptr` - Pointer to the input unsigned integer
1183    /// * `out_buff` - Pointer to output buffer where the float will be written
1184    /// * `rounding_mode` - Rounding mode to use for the conversion
1185    /// # Returns
1186    /// 8 on success, error code otherwise
1187    ///
1188    /// # Safety
1189    /// Caller must ensure all pointer parameters point to valid memory
1190    unsafe fn float_from_uint(
1191        &self,
1192        in_uint_ptr: *const u8,
1193        in_uint_len: usize,
1194        out_buff: *mut u8,
1195        out_buff_len: usize,
1196        rounding_mode: i32,
1197    ) -> i32;
1198
1199    /// Creates a float from explicit exponent and mantissa values
1200    /// # Parameters
1201    /// * `exponent` - The exponent value
1202    /// * `mantissa` - The mantissa value
1203    /// * `out_buff` - Pointer to output buffer where the float will be written
1204    /// * `rounding_mode` - Rounding mode to use for the operation
1205    /// # Returns
1206    /// 8 on success, error code otherwise
1207    ///
1208    /// # Safety
1209    /// Caller must ensure all pointer parameters point to valid memory
1210    unsafe fn float_set(
1211        &self,
1212        exponent: i32,
1213        mantissa: i64,
1214        out_buff: *mut u8,
1215        out_buff_len: usize,
1216        rounding_mode: i32,
1217    ) -> i32;
1218
1219    /// Compares two opaque float values
1220    /// # Parameters
1221    /// * `in_buff1` - Pointer to first float value
1222    /// * `in_buff2` - Pointer to second float value
1223    /// # Returns
1224    /// 0 if equal, 1 if first > second, 2 if first < second,
1225    ///
1226    /// # Safety
1227    /// Caller must ensure all pointer parameters point to valid memory
1228    unsafe fn float_compare(
1229        &self,
1230        in_buff1: *const u8,
1231        in_buff1_len: usize,
1232        in_buff2: *const u8,
1233        in_buff2_len: usize,
1234    ) -> i32;
1235
1236    /// Adds two opaque float values
1237    /// # Parameters
1238    /// * `in_buff1` - Pointer to first float value
1239    /// * `in_buff2` - Pointer to second float value
1240    /// * `out_buff` - Pointer to output buffer where result will be written
1241    /// * `rounding_mode` - Rounding mode to use for the addition
1242    /// # Returns
1243    /// 8 on success, error code otherwise
1244    ///
1245    /// # Safety
1246    /// Caller must ensure all pointer parameters point to valid memory
1247    #[allow(clippy::too_many_arguments)]
1248    unsafe fn float_add(
1249        &self,
1250        in_buff1: *const u8,
1251        in_buff1_len: usize,
1252        in_buff2: *const u8,
1253        in_buff2_len: usize,
1254        out_buff: *mut u8,
1255        out_buff_len: usize,
1256        rounding_mode: i32,
1257    ) -> i32;
1258
1259    /// Subtracts two opaque float values
1260    /// # Parameters
1261    /// * `in_buff1` - Pointer to first float value
1262    /// * `in_buff2` - Pointer to second float value
1263    /// * `out_buff` - Pointer to output buffer where result will be written
1264    /// * `rounding_mode` - Rounding mode to use for the subtraction
1265    /// # Returns
1266    /// 8 on success, error code otherwise
1267    ///
1268    /// # Safety
1269    /// Caller must ensure all pointer parameters point to valid memory
1270    #[allow(clippy::too_many_arguments)]
1271    unsafe fn float_subtract(
1272        &self,
1273        in_buff1: *const u8,
1274        in_buff1_len: usize,
1275        in_buff2: *const u8,
1276        in_buff2_len: usize,
1277        out_buff: *mut u8,
1278        out_buff_len: usize,
1279        rounding_mode: i32,
1280    ) -> i32;
1281
1282    /// Multiplies two opaque float values
1283    /// # Parameters
1284    /// * `in_buff1` - Pointer to first float value
1285    /// * `in_buff2` - Pointer to second float value
1286    /// * `out_buff` - Pointer to output buffer where result will be written
1287    /// * `rounding_mode` - Rounding mode to use for the multiplication
1288    /// # Returns
1289    /// 8 on success, error code otherwise
1290    ///
1291    /// # Safety
1292    /// Caller must ensure all pointer parameters point to valid memory
1293    #[allow(clippy::too_many_arguments)]
1294    unsafe fn float_multiply(
1295        &self,
1296        in_buff1: *const u8,
1297        in_buff1_len: usize,
1298        in_buff2: *const u8,
1299        in_buff2_len: usize,
1300        out_buff: *mut u8,
1301        out_buff_len: usize,
1302        rounding_mode: i32,
1303    ) -> i32;
1304
1305    /// Divides two opaque float values
1306    /// # Parameters
1307    /// * `in_buff1` - Pointer to dividend float value
1308    /// * `in_buff2` - Pointer to divisor float value
1309    /// * `out_buff` - Pointer to output buffer where result will be written
1310    /// * `rounding_mode` - Rounding mode to use for the division
1311    /// # Returns
1312    /// 8 on success, error code otherwise
1313    ///
1314    /// # Safety
1315    /// Caller must ensure all pointer parameters point to valid memory
1316    #[allow(clippy::too_many_arguments)]
1317    unsafe fn float_divide(
1318        &self,
1319        in_buff1: *const u8,
1320        in_buff1_len: usize,
1321        in_buff2: *const u8,
1322        in_buff2_len: usize,
1323        out_buff: *mut u8,
1324        out_buff_len: usize,
1325        rounding_mode: i32,
1326    ) -> i32;
1327
1328    /// Calculates the nth power of an opaque float value
1329    /// # Parameters
1330    /// * `in_buff` - Pointer to input float value
1331    /// * `in_int` - The power to calculate (e.g., 2 for square)
1332    /// * `out_buff` - Pointer to output buffer where result will be written
1333    /// * `rounding_mode` - Rounding mode to use for the operation
1334    /// # Returns
1335    /// 8 on success, error code otherwise
1336    ///
1337    /// # Safety
1338    /// Caller must ensure all pointer parameters point to valid memory
1339    unsafe fn float_pow(
1340        &self,
1341        in_buff: *const u8,
1342        in_buff_len: usize,
1343        in_int: i32,
1344        out_buff: *mut u8,
1345        out_buff_len: usize,
1346        rounding_mode: i32,
1347    ) -> i32;
1348
1349    /// Calculates the nth root of an opaque float value
1350    /// # Parameters
1351    /// * `in_buff` - Pointer to input float value
1352    /// * `in_int` - The root to calculate (e.g., 2 for square root)
1353    /// * `out_buff` - Pointer to output buffer where result will be written
1354    /// * `rounding_mode` - Rounding mode to use for the operation
1355    /// # Returns
1356    /// 8 on success, error code otherwise
1357    ///
1358    /// # Safety
1359    /// Caller must ensure all pointer parameters point to valid memory
1360    unsafe fn float_root(
1361        &self,
1362        in_buff: *const u8,
1363        in_buff_len: usize,
1364        in_int: i32,
1365        out_buff: *mut u8,
1366        out_buff_len: usize,
1367        rounding_mode: i32,
1368    ) -> i32;
1369
1370    /// Calculates the natural logarithm of an opaque float value
1371    /// # Arguments
1372    /// * `in_buff` - Pointer to input float value
1373    /// * `out_buff` - Pointer to output buffer where result will be written
1374    /// * `rounding_mode` - Rounding mode to use for the operation
1375    /// # Returns
1376    /// 8 on success, error code otherwise
1377    ///
1378    /// # Safety
1379    /// Caller must ensure all pointer parameters point to valid memory
1380    unsafe fn float_log(
1381        &self,
1382        in_buff: *const u8,
1383        in_buff_len: usize,
1384        out_buff: *mut u8,
1385        out_buff_len: usize,
1386        rounding_mode: i32,
1387    ) -> i32;
1388
1389    // #############################
1390    // Host Function Category: TRACE
1391    // #############################
1392
1393    /// Print to the trace log on XRPLd. Any XRPLd instance set to \"trace\" log level will see this.
1394    ///
1395    /// # Parameters
1396    /// - `msg_read_ptr`: A pointer to an array containing text characters (in either utf8).
1397    /// - `msg_read_len`: The byte length of the text to send to the trace log.
1398    /// - `data_read_ptr`: A pointer to an array of bytes containing arbitrary data.
1399    /// - `data_read_len`: The byte length of the data to send to the trace log.
1400    /// - `as_hex`: If 0 treat the data_read_ptr as pointing at a string of text, otherwise treat it
1401    ///   as data and print hex.
1402    ///
1403    /// # Returns
1404    ///
1405    /// Returns an integer representing the result of the operation. A value of `0` or higher
1406    /// signifies the number of message bytes that were written to the trace function. Non-zero
1407    /// values indicate an error that corresponds to a known error code (e.g., incorrect buffer
1408    /// sizes).
1409    ///
1410    /// # Safety
1411    /// Caller must ensure all pointer parameters point to valid memory
1412    unsafe fn trace(
1413        &self,
1414        msg_read_ptr: *const u8,
1415        msg_read_len: usize,
1416        data_read_ptr: *const u8,
1417        data_read_len: usize,
1418        as_hex: i32,
1419    ) -> i32;
1420
1421    /// Print a number to the trace log on XRPLd. Any XRPLd instance set to \"trace\" log level will
1422    /// see this.
1423    ///
1424    /// # Parameters
1425    /// * `msg_read_ptr`: A pointer to an array containing text characters (in either utf8).
1426    /// * `msg_read_len`: The byte length of the text to send to the trace log.
1427    /// * `number`: Any integer you wish to display after the text.
1428    ///
1429    /// # Returns
1430    ///
1431    /// Returns an integer representing the result of the operation. A value of `0` or higher
1432    /// signifies the number of message bytes that were written to the trace function. Non-zero
1433    /// values indicate an error that corresponds to a known error code (e.g., incorrect buffer
1434    /// sizes).
1435    ///
1436    /// # Safety
1437    /// Caller must ensure all pointer parameters point to valid memory
1438    unsafe fn trace_num(&self, msg_read_ptr: *const u8, msg_read_len: usize, number: i64) -> i32;
1439
1440    /// Print an account to the trace log on XRPLd. Any XRPLd instance set to \"trace\" log level will
1441    /// see this.
1442    ///
1443    /// # Parameters
1444    /// * `msg_read_ptr`: A pointer to an array containing text characters (in either utf8).
1445    /// * `msg_read_len`: The byte length of the text to send to the trace log.
1446    /// * `account_ptr`: A pointer to an account.
1447    /// * `account_len`: The byte length of the account.
1448    ///
1449    /// # Returns
1450    ///
1451    /// Returns an integer representing the result of the operation. A value of `0` or higher
1452    /// signifies the number of message bytes that were written to the trace function. Non-zero
1453    /// values indicate an error that corresponds to a known error code (e.g., incorrect buffer
1454    /// sizes).
1455    ///
1456    /// # Safety
1457    /// Caller must ensure all pointer parameters point to valid memory
1458    unsafe fn trace_account(
1459        &self,
1460        msg_read_ptr: *const u8,
1461        msg_read_len: usize,
1462        account_ptr: *const u8,
1463        account_len: usize,
1464    ) -> i32;
1465
1466    /// Print an OpaqueFloat number to the trace log on XRPLd. Any XRPLd instance set to \"trace\"
1467    /// log level will see this.
1468    ///
1469    /// # Parameters
1470    /// * `msg_read_ptr`: A pointer to an array containing text characters (in either utf8).
1471    /// * `msg_read_len`: The byte length of the text to send to the trace log.
1472    /// * `opaque_float_ptr`: A pointer to an array of 8 bytes containing the u64 opaque pointer value.
1473    ///
1474    /// # Returns
1475    ///
1476    /// Returns an integer representing the result of the operation. A value of `0` or higher
1477    /// signifies the number of message bytes that were written to the trace function. Non-zero
1478    /// values indicate an error that corresponds to a known error code (e.g., incorrect buffer
1479    /// sizes).
1480    ///
1481    /// # Safety
1482    /// Caller must ensure all pointer parameters point to valid memory
1483    unsafe fn trace_opaque_float(
1484        &self,
1485        msg_read_ptr: *const u8,
1486        msg_read_len: usize,
1487        opaque_float_ptr: *const u8,
1488        opaque_float_len: usize,
1489    ) -> i32;
1490
1491    /// Print an amount to the trace log on XRPLd. Any XRPLd instance set to \"trace\" log level will
1492    /// see this.
1493    ///
1494    /// # Parameters
1495    /// * `msg_read_ptr`: A pointer to an array containing text characters (in either utf8).
1496    /// * `msg_read_len`: The byte length of the text to send to the trace log.
1497    /// * `amount_ptr`: A pointer to an amount.
1498    /// * `amount_len`: The byte length of the amount.
1499    ///
1500    /// # Returns
1501    ///
1502    /// Returns an integer representing the result of the operation. A value of `0` or higher
1503    /// signifies the number of message bytes that were written to the trace function. Non-zero
1504    /// values indicate an error that corresponds to a known error code (e.g., incorrect buffer
1505    /// sizes).
1506    ///
1507    /// # Safety
1508    /// Caller must ensure all pointer parameters point to valid memory
1509    unsafe fn trace_amount(
1510        &self,
1511        msg_read_ptr: *const u8,
1512        msg_read_len: usize,
1513        amount_ptr: *const u8,
1514        amount_len: usize,
1515    ) -> i32;
1516}