Skip to main content

Module current_tx

Module current_tx 

Source
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.

get_field and get_field_optional are generic over any type implementing crate::fields::decoder::FromCurrentTx — see crate::fields::decoder for how a type opts into that.

§Optional vs Required Fields

  • Required (get_field): Returns an error if the field is missing.
  • Optional (get_field_optional): Returns Ok(None) if the field is missing.

Concrete transaction wrappers (e.g., EscrowFinish) live in their respective companion crates (xrpl-escrow-stdlib for escrow flows).

Functions§

get_blob_field
Retrieves a Blob<N> field from the current transaction, writing the host’s bytes directly into the returned Blob<N>’s own storage. See the module comment block above for why Blob<N> gets a dedicated accessor instead of using get_field.
get_blob_field_optional
Optional variant of get_blob_field: returns Ok(None) if the field is not present, otherwise behaves identically (including the direct-write zero-copy behavior). Implemented in terms of get_blob_field itself rather than duplicating its body — Error::FieldNotFound round-trips exactly through Error::from_code/.code() (both are just FIELD_NOT_FOUND), so translating that one error case into None is all this needs to do.
get_field
Retrieves a field from the current transaction using an SField constant.
get_field_optional
Retrieves an optionally present field from the current transaction using an SField constant.