Expand description
§Current Transaction Retrieval Module
This module provides utilities for retrieving typed fields from the current XRPL transaction
within the context of XRPL Programmability. It offers a safe, type-safe
interface over the low-level host functions for accessing transaction data, such as from an
EscrowFinish transaction.
§Overview
When processing XRPL transactions in a permissionless programmability environment, you often need to extract specific fields like account IDs, hashes, public keys, and other data. This module provides convenient wrapper functions that handle the low-level buffer management and error handling required to safely retrieve these fields.
§Field Types Supported
- AccountID: 20-byte account identifiers
- u32: 32-bit unsigned integers
- Hash256: 256-bit cryptographic hashes
- PublicKey: 33-byte public keys
- Blob: Variable-length binary data
§Optional vs Required Fields
The module provides both optional and required variants for field retrieval:
- Required variants (e.g.,
get_u32_field): Return an error if the field is missing - Optional variants (e.g.,
get_optional_u32_field): ReturnNoneif the field is missing
§Error Handling
All functions return Result<T> or Result<Option<T>> types that encapsulate
the custom error handling required for the XRPL Programmability environment.
§Safety Considerations
- All functions use fixed-size buffers appropriate for their data types
- Buffer sizes are validated against expected field sizes
- Unsafe operations are contained within the low-level host function calls
- Memory safety is ensured through proper buffer management
- Field codes are validated by the underlying host functions
§Performance Notes
- All functions are marked
#[inline]to minimize call overhead - Buffer allocations are stack-based and have minimal cost
- Host function calls are the primary performance bottleneck
§Example
Get sender Account and optional flags:
use xrpl_wasm_stdlib::core::current_tx::escrow_finish::EscrowFinish;
use xrpl_wasm_stdlib::core::current_tx::traits::TransactionCommonFields;
let tx = EscrowFinish;
let account = tx.get_account().unwrap_or_panic();
let _flags = tx.get_flags().unwrap_or_panic();Modules§
- escrow_
finish - EscrowFinish
- traits
- Transaction Field Access Traits
Traits§
- Current
TxField Getter - Trait for types that can be retrieved from current transaction fields.
Functions§
- get_
field - Retrieves a field from the current transaction.
- get_
field_ optional - Retrieves an optionally present field from the current transaction.