Skip to main content

witness_verify/
main.rs

1//! Independent verification of an xrpl-witness archive, without us and
2//! without a node.
3//!
4//! - `archive`: segment seals, the seal chain, the signature of every validation;
5//! - `quorum`: whether each ledger is confirmed under a given trust policy;
6//! - `export`: an evidence package for a single ledger;
7//! - `evidence`: checking such a package without the archive, a node, or us.
8//!
9//! The result is JSON on stdout. Exit code 1 means something did not match,
10//! 2 means the check could not be carried out.
11
12mod archive;
13mod evidence;
14mod quorum;
15
16use clap::{Parser, Subcommand};
17
18#[derive(Debug, Parser)]
19#[command(
20    version,
21    about = "Verify an xrpl-witness archive: seals, signatures, quorum"
22)]
23struct Cli {
24    #[command(subcommand)]
25    command: Command,
26}
27
28#[derive(Debug, Subcommand)]
29enum Command {
30    /// Seals, the chain, and the signature of every validation.
31    Archive(archive::ArchiveArgs),
32    /// Quorum under a trust policy for a range of ledgers.
33    Quorum(quorum::QuorumArgs),
34    /// Build an evidence package for a single ledger.
35    Export(evidence::ExportArgs),
36    /// Check an evidence package against your own trust policy.
37    Evidence(evidence::CheckArgs),
38}
39
40fn main() {
41    let cli = Cli::parse();
42    let result = match &cli.command {
43        Command::Archive(a) => archive::run(a),
44        Command::Quorum(q) => quorum::run(q),
45        Command::Export(e) => evidence::export(e),
46        Command::Evidence(c) => evidence::check(c),
47    };
48    match result {
49        Ok(true) => {}
50        Ok(false) => std::process::exit(1),
51        Err(e) => {
52            eprintln!("error: {e}");
53            std::process::exit(2);
54        }
55    }
56}