rustywallet_lightning/
lib.rs

1//! # rustywallet-lightning
2//!
3//! Lightning Network utilities for Bitcoin wallets.
4//!
5//! This crate provides tools for working with the Lightning Network,
6//! including BOLT11 invoice parsing/creation, BOLT12 offers, payment hash handling,
7//! and node identity derivation.
8//!
9//! ## Features
10//!
11//! - **BOLT11 Invoices**: Parse and create Lightning invoices
12//! - **BOLT12 Offers**: Parse and create reusable payment offers
13//! - **Payment Hashes**: Generate and verify payment hashes/preimages
14//! - **Node Identity**: Derive node ID from HD seed
15//! - **Route Hints**: Parse and create route hints
16//! - **Channel Points**: Handle channel point references
17//!
18//! ## Quick Start
19//!
20//! ```rust
21//! use rustywallet_lightning::prelude::*;
22//!
23//! // Generate payment hash from preimage
24//! let preimage = PaymentPreimage::random();
25//! let hash = preimage.payment_hash();
26//! println!("Payment hash: {}", hash);
27//!
28//! // Verify preimage matches hash
29//! assert!(hash.verify(&preimage));
30//! ```
31//!
32//! ## BOLT12 Offers
33//!
34//! ```rust
35//! use rustywallet_lightning::bolt12::{Bolt12Offer, OfferBuilder};
36//!
37//! // Create an offer
38//! let offer = OfferBuilder::new()
39//!     .description("Coffee")
40//!     .amount_msats(10_000)
41//!     .build()
42//!     .unwrap();
43//! println!("Offer: {}", offer.encode());
44//!
45//! // Parse an offer
46//! let parsed = Bolt12Offer::parse(&offer.encode()).unwrap();
47//! assert_eq!(parsed.description(), "Coffee");
48//! ```
49//!
50//! ## Node Identity
51//!
52//! ```rust
53//! use rustywallet_lightning::node::NodeIdentity;
54//!
55//! // Derive node identity from 64-byte seed
56//! let seed = [0u8; 64]; // In practice, use a proper seed
57//! let identity = NodeIdentity::from_seed(&seed).unwrap();
58//! println!("Node ID: {}", identity.node_id());
59//! ```
60
61pub mod bolt11;
62pub mod bolt12;
63pub mod channel;
64pub mod error;
65pub mod node;
66pub mod payment;
67pub mod prelude;
68pub mod route;
69
70#[cfg(test)]
71mod tests;
72
73// Re-export main types
74pub use bolt11::{Bolt11Invoice, InvoiceBuilder, InvoiceData};
75pub use bolt12::{Bolt12Offer, OfferBuilder, OfferAmount, BlindedPath};
76pub use channel::ChannelPoint;
77pub use error::LightningError;
78pub use node::NodeIdentity;
79pub use payment::{PaymentHash, PaymentPreimage};
80pub use route::{RouteHint, RouteHintHop};