xrpl_mithril_tx/lib.rs
1#![doc(html_logo_url = "https://raw.githubusercontent.com/KyleWMiller/xrpl-mithril/main/assets/mithrilLogo.png")]
2//! Transaction building, autofilling, and submission for the XRPL.
3//!
4//! This crate provides:
5//! - Fluent transaction builders ([`builder`])
6//! - Fee, sequence, and `LastLedgerSequence` autofill ([`autofill`])
7//! - Typed signing via [`xrpl_mithril_models::transactions::wrapper::UnsignedTransaction`] /
8//! [`xrpl_mithril_models::transactions::wrapper::TypedSignedTransaction`]
9//! - Submit-and-wait with ledger tracking ([`submit`])
10//! - Reliable submission with retry on transient failures ([`reliable`])
11//!
12//! # Examples
13//!
14//! Full pipeline: build a payment, autofill network fields, sign, and submit.
15//!
16//! ```no_run
17//! use xrpl_mithril_tx::builder::PaymentBuilder;
18//! use xrpl_mithril_tx::reliable::submit_transaction;
19//! use xrpl_mithril_client::JsonRpcClient;
20//! use xrpl_mithril_wallet::{Wallet, Algorithm};
21//! use xrpl_mithril_types::{Amount, XrpAmount};
22//!
23//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
24//! // Connect to testnet
25//! let client = JsonRpcClient::new("https://s.altnet.rippletest.net:51234")?;
26//!
27//! // Load a funded wallet
28//! let wallet = Wallet::from_seed_encoded("sEdT7wHTCLzDG7Ue4312Kp4QA389Xmb")?;
29//!
30//! // Build a payment
31//! let unsigned = PaymentBuilder::new()
32//! .account(*wallet.account_id())
33//! .destination("rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe".parse()?)
34//! .amount(Amount::Xrp(XrpAmount::from_drops(1_000_000)?))
35//! .build()?;
36//!
37//! // Autofill, sign, and submit in one call
38//! let result = submit_transaction(&client, unsigned, &wallet).await?;
39//! println!("Validated in ledger {}: {}", result.ledger_index, result.result_code);
40//! # Ok(())
41//! # }
42//! ```
43
44#![forbid(unsafe_code)]
45
46pub mod autofill;
47pub mod builder;
48pub mod error;
49pub mod reliable;
50pub mod submit;
51
52pub use error::TxError;
53pub use reliable::{sign_transaction, submit_transaction};
54pub use submit::{submit_and_wait, TransactionResult};