Expand description
§rustywallet-lightning
Lightning Network utilities for Bitcoin wallets.
This crate provides tools for working with the Lightning Network, including BOLT11 invoice parsing/creation, BOLT12 offers, payment hash handling, and node identity derivation.
§Features
- BOLT11 Invoices: Parse and create Lightning invoices
- BOLT12 Offers: Parse and create reusable payment offers
- Payment Hashes: Generate and verify payment hashes/preimages
- Node Identity: Derive node ID from HD seed
- Route Hints: Parse and create route hints
- Channel Points: Handle channel point references
§Quick Start
use rustywallet_lightning::prelude::*;
// Generate payment hash from preimage
let preimage = PaymentPreimage::random();
let hash = preimage.payment_hash();
println!("Payment hash: {}", hash);
// Verify preimage matches hash
assert!(hash.verify(&preimage));§BOLT12 Offers
use rustywallet_lightning::bolt12::{Bolt12Offer, OfferBuilder};
// Create an offer
let offer = OfferBuilder::new()
.description("Coffee")
.amount_msats(10_000)
.build()
.unwrap();
println!("Offer: {}", offer.encode());
// Parse an offer
let parsed = Bolt12Offer::parse(&offer.encode()).unwrap();
assert_eq!(parsed.description(), "Coffee");§Node Identity
use rustywallet_lightning::node::NodeIdentity;
// Derive node identity from 64-byte seed
let seed = [0u8; 64]; // In practice, use a proper seed
let identity = NodeIdentity::from_seed(&seed).unwrap();
println!("Node ID: {}", identity.node_id());Re-exports§
pub use bolt11::Bolt11Invoice;pub use bolt11::InvoiceBuilder;pub use bolt11::InvoiceData;pub use bolt12::Bolt12Offer;pub use bolt12::OfferBuilder;pub use bolt12::OfferAmount;pub use bolt12::BlindedPath;pub use channel::ChannelPoint;pub use error::LightningError;pub use node::NodeIdentity;pub use payment::PaymentHash;pub use payment::PaymentPreimage;pub use route::RouteHint;pub use route::RouteHintHop;
Modules§
- bolt11
- BOLT11 invoice parsing and creation.
- bolt12
- BOLT12 Offers support.
- channel
- Channel point handling.
- error
- Error types for Lightning Network operations.
- node
- Node identity and key derivation.
- payment
- Payment hash and preimage handling.
- prelude
- Prelude module for convenient imports.
- route
- Route hints for Lightning payments.