Rust Lightning

Rust Lightning (LDK) is a highly performant and flexible implementation of the Lightning Network protocol written in Rust. The primary crate, lightning, is runtime-agnostic, allowing for custom implementations of data persistence, chain interactions, and networking.

Key Features

  • Runtime-agnostic: Provides flexibility in choosing data persistence, chain interactions, and networking.
  • BOLT Specifications: Implements all of the BOLT specifications.
  • Production Ready: In production use since 2021.
  • Security Audited: Regular security audits to ensure safety.

Crates

The Rust Lightning project includes several crates:

  1. lightning: Core of the LDK library, implementing the Lightning protocol, channel state machine, and on-chain logic. Supports no-std and exposes low-level interfaces.
  2. lightning-background-processor: Utilities to perform required background tasks.
  3. lightning-block-sync: Utilities for fetching chain data and feeding it into Rust Lightning.
  4. lightning-invoice: Data structures for parsing and serializing BOLT #11 Lightning invoices.
  5. lightning-net-tokio: Network stack implementation using the Tokio async runtime.
  6. lightning-persister: Utilities for managing channel data persistence and retrieval.
  7. lightning-rapid-gossip-sync: Client for rapid gossip graph syncing, primarily aimed at mobile clients.

About

LDK/Rust Lightning allows you to build a Lightning node without needing to handle the complexities of the Lightning state machine, routing, and on-chain punishment code. It provides a clean API for integrating custom features such as chain sync, key management, data storage, and backup logic.

For an out-of-the-box Lightning node based on LDK, see Sensei. LDK provides APIs for:

  • On-disk storage: Store channel state in any way you want.
  • Blockchain data: Simple API for block headers and transaction information.
  • UTXO management: Notifies users when UTXOs are theirs again after channel closure.
  • Networking: Default implementation using TCP sockets, with flexibility for custom networking solutions.
  • Private keys: Users can provide private keys to LDK in any way they wish.

Building from Source

To build Rust Lightning from source, follow these steps:

  1. Clone the repository:

    git clone https://github.com/lightningdevkit/rust-lightning.git
    cd rust-lightning
  2. Build the project:

    cargo build --release

Running Tests

To run the tests:

cargo test --all-features

Documentation

Comprehensive documentation for Rust Lightning is available on docs.rs.

Project Architecture

For a high-level API introduction, see ARCH.md.

Similar Projects