Skip to main content

Module tx

Module tx 

Source
Expand description

Lighter L2 transaction encoding.

Each L2 transaction body is reduced to a sequence of Goldilocks field elements in a fixed order, hashed with Poseidon2 to a single Fp5 digest, optionally aggregated with a hash of the per-tx L2TxAttributes, and emitted as 40 canonical little-endian bytes. The resulting hash is what super::schnorr::PrivateKey::sign consumes; the venue’s sequencer recomputes the same hash and rejects the transaction on mismatch.

The wire-format tx_info is a JSON object with field order matching the upstream lighter-go txtypes.L2*TxInfo Go structs. The signature is base64-encoded after s_le || e_le byte assembly. See sign_tx for the full pipeline.

Phase E covers the trading critical path: CreateOrderTxInfo, CancelOrderTxInfo, ModifyOrderTxInfo, plus ApproveIntegratorTxInfo off the hot path. Subsequent tx types follow the same template once a use case lands.

Structs§

ApproveIntegratorTxInfo
ApproveIntegrator (tx_type = 45): approves an integrator account index.
CancelAllOrdersTxInfo
CancelAllOrders (tx_type = 16): account-wide cancel directive.
CancelOrderTxInfo
CancelOrder (tx_type = 15): cancels a single live order by index.
CreateOrderTxInfo
CreateOrder (tx_type = 14) — submits a new order to the sequencer.
L2TxAttributes
Per-transaction L2 attributes.
ModifyOrderTxInfo
ModifyOrder (tx_type = 17) — amends size / price on a live order.
OrderInfo
Common per-order body fields shared by CreateOrderTxInfo and the not-yet-implemented CreateGroupedOrders variant.
SignedTx
Outcome of sign_tx: the deterministic message hash plus the (s, e) Schnorr signature.
TxContext
Common context wrapping a tx body: account, key, nonce, expiry.
TxInfoJson
JSON renderer for the L2 tx_info wire payload.
UpdateLeverageTxInfo
UpdateLeverage (tx_type = 20): change leverage / margin mode for a market.

Constants§

TX_HASH_BYTES
Canonical wire length of a Lighter L2 message hash: 40-byte LE Fp5.

Traits§

LighterTx
Marker trait every signed L2 transaction implements.

Functions§

compute_tx_hash
Compute the signed message hash for any LighterTx.
sign_tx
Sign any LighterTx under (sk, k) and return the 80-byte signature alongside the 40-byte tx hash.