pallas_validate/lib.rs
1//! Phase-1 (and optionally phase-2) Cardano transaction validation against
2//! the live ledger rules.
3//!
4//! Useful for clients that want to reject ill-formed or unenforceable
5//! transactions locally before submitting them, or to replay historical
6//! chains and confirm conformance with the protocol specification.
7//!
8//! # Usage
9//!
10//! ```ignore
11//! use pallas_validate::phase1::validate_tx;
12//!
13//! validate_tx(&tx, tx_index, &env, &utxos, &mut cert_state)?;
14//! ```
15//!
16//! [`phase1::validate_tx`] dispatches on the era encoded in the
17//! `Environment.prot_params` and routes to the matching era-specific
18//! validator ([`phase1::byron::validate_byron_tx`],
19//! [`phase1::shelley_ma::validate_shelley_ma_tx`],
20//! [`phase1::alonzo::validate_alonzo_tx`],
21//! [`phase1::babbage::validate_babbage_tx`],
22//! [`phase1::conway::validate_conway_tx`]).
23//!
24//! # Overview
25//!
26//! - [`phase1`] — phase-1 (structural / rule-based) validation, with one
27//! module per era: [`phase1::byron`], [`phase1::shelley_ma`],
28//! [`phase1::alonzo`], [`phase1::babbage`], [`phase1::conway`]. Top-level
29//! entry points are [`phase1::validate_tx`] (single tx) and
30//! [`phase1::validate_txs`] (LEDGERS sequence rule).
31//! - `phase2` — phase-2 (Plutus script execution) validation. Behind the
32//! `phase2` cargo feature.
33//! - [`utils`] — the shared input types every validator takes:
34//! [`utils::Environment`], [`utils::UTxOs`], [`utils::CertState`],
35//! [`utils::MultiEraProtocolParameters`], and the unified
36//! [`utils::ValidationError`] / [`utils::ValidationResult`] types.
37//!
38//! # Feature flags
39//!
40//! - `phase2` — pulls in Plutus script execution and exposes the `phase2`
41//! module.
42//!
43//! # Further reading
44//!
45//! - `docs/byron.md`, `docs/shelleyMA.md`, `docs/alonzo.md`,
46//! `docs/babbage.md` — mathematical specifications, one per era.
47//! - `tests/README.md` — test-suite layout and how to reproduce the per-era
48//! fixtures.
49//!
50//! # Usage as part of `pallas`
51//!
52//! When depending on the umbrella [`pallas`] crate, this crate is re-exported
53//! as `pallas::ledger::validate`.
54//!
55//! [`pallas`]: https://crates.io/crates/pallas
56
57/// Phase-1 (structural / rule-based) validation, with one module per era.
58pub mod phase1;
59/// Shared input types: [`utils::Environment`], [`utils::UTxOs`],
60/// [`utils::CertState`], [`utils::ValidationError`], and friends.
61pub mod utils;
62
63/// Phase-2 (Plutus script execution) validation (feature `phase2`).
64#[cfg(feature = "phase2")]
65pub mod phase2;