Skip to main content

Installation

Or in Cargo.toml:
Requirements: Rust 1.75+, Tokio async runtime

Quickstart

The fastest path uses ManagedProvider — no Lightning node needed, 0.3% fee:
For sovereign mode (0% fee), implement the LightningProvider trait — see Custom provider below.

Custom provider


Options

Deprecated: with_address()

Options::with_address(address) was removed in v1.4.0. Use Options::new(sats, ManagedProvider::new(address)) instead:

l402_middleware(opts: Options)

Returns an axum::middleware::Layer compatible with axum 0.8+.

Behavior

402 response body


on_payment callback


Feature flags

Disable axum-middleware to use only the core verification functions without axum or reqwest:

Verification

SHA256(preimage) == paymentHash is verified locally using the sha2 crate — no network call on the hot path. Token expiry is checked in the same operation.

Error codes


Running