Skip to main content

Installation

Requirements: Go 1.21+

Quickstart

Get Blink credentials free at dashboard.blink.sv. Payments go directly to your wallet.

Self-hosted mode (bring your own provider)


l402.Options


l402.Middleware(opts Options, next http.Handler) http.Handler

Returns an http.Handler compatible with net/http, Chi, Gorilla Mux, and any standard Go HTTP framework.

Behavior

402 response body


LightningProvider interface


OnPayment callback


Verification

SHA256(preimage) == paymentHash is verified locally in memory � sub-millisecond, no network call on the hot path. Token expiry (exp field in the macaroon) is checked in the same operation. The replay guard uses an in-memory map by default (safe for a single process). For multi-instance deployments, use a shared store (Redis or similar) � which adds a 5�50 ms round-trip per verified request.

Chi router example

l402.Middleware returns a standard http.Handler, so it works directly with Chi’s r.Handle:

Error codes


Running