Installation
Cargo.toml:
Quick start
l402kit::Options
| Field | Type | Required | Description |
|---|---|---|---|
price_sats | u64 | ✅ | Amount in satoshis per call |
lightning_address | String | ✅ | Your Lightning address (you@blink.sv) |
invoice_expiry | u32 | — | Invoice TTL in seconds (default: 3600) |
l402_middleware(opts: Options)
Returns an axum::middleware::Layer compatible with axum 0.8+.
First call (no token):
Verification
The middleware verifiesSHA256(preimage) == paymentHash using the sha2 crate — no external call on the hot path.
Features
The crate has a single feature flag:axum-middleware if you only need the core verify_token function.
Error codes
| Status | Meaning |
|---|---|
402 | No payment token — pay the invoice |
401 | Invalid preimage (wrong payment proof) |
401 | Replayed token (already used) |
Contact
shinydapps@gmail.com · crates.io/crates/l402kit