OpenViSTAI · Agents · Blockchain · Crypto
Menu
Payments & Stablecoins

Ln Paywall

Ln Paywall is an open-source Go middleware library that lets API services charge Bitcoin Lightning payments per request. It issues a BOLT-11 invoice for an initial request and checks a paid invoice’s preimage on retry before passing the request to the next middleware or handler.

Independent OpenViST project profile, based on linked sources.

Ln Paywall — OpenViST project profile in Payments & Stablecoins.
OpenViST project illustration. See the linked sources for product details.
Understand the project

Practical overview

When it fits

Use it when integrating per-request Bitcoin Lightning billing into a Go web service and you can provide a supported Lightning node connection and preimage storage.

Who it is for

  • Go API developers adding pay-per-call access to selected endpoints.
  • Go service operators who need to choose preimage storage based on persistence and deployment scale.
  • Go developers consuming APIs protected by Ln Paywall through its client package.

Documented uses

  • Require a Lightning payment before serving a protected API request.
  • Check that a submitted preimage corresponds to a paid invoice and has not already been used.
  • Choose a preimage cache appropriate to a single instance or horizontally scaled service.
  • Consume a paywalled API using the supplied Go client package.
Before you choose

Requirements & limits

The project is published as a public repository under the MPL-2.0 license.

  • The middleware supports net/http Handler and HandlerFunc, Gin and Echo; the README also identifies gorilla/mux, httprouter and chi as compatible with its net/http middleware.
  • The documented payment cycle uses HTTP 402 with a BOLT-11 invoice, followed by a retry carrying the paid invoice’s hex-encoded preimage in X-Preimage.
  • The middleware requires a running Lightning node; the README describes lnd and c-lightning with Lightning Charge integrations.
  • A Go map is neither persistent nor suitable for sharing used-preimage state across instances; bbolt persists locally but remains file-based; Redis supports persistent storage across horizontally scaled services.
  • The client package is for Go consumers of paywalled APIs. The API gateway for services in other languages is described as roadmap, not a current library feature.

Check current requirements in the official documentation. Source-based guidance does not mean OpenViST has run or independently tested this project.

Source-based practical guide

Prepare Lightning node and preimage storage prerequisites

Identify a supported Lightning node connection and storage option before integrating Ln Paywall into a Go API.

Before you start

  • A running Lightning Network node. The README lists lnd and c-lightning with Lightning Charge as supported integrations.
  • For lnd, the node must listen for gRPC connections; external connections require suitable listening configuration and a TLS certificate covering the external IP address.
  • A preimage storage option: Go map, bbolt or Redis.

Steps

  1. Choose a documented Lightning integration: lnd, or c-lightning used with Lightning Charge.

  2. Select preimage storage according to deployment needs: Go map for non-persistent single-instance use, bbolt for persistent file-based single-instance use, or Redis for persistent storage usable across horizontally scaled services.

  3. For Redis, arrange the required local or remote TCP connection and administration; the README advises using password configuration in production.

Expected outcome

A documented node and storage approach is selected for a later Go middleware integration.

Guide limitations

  • This is prerequisite planning, not a middleware installation or deployment procedure.
  • A Go map does not persist used preimages and cannot share them across horizontally scaled instances.
  • bbolt persists data but is file-based and cannot be shared across horizontally scaled instances.
  • Redis requires a TCP connection and administration.
  • Eclair is listed as not implemented; vanilla c-lightning without Lightning Charge is not supported in the described setup.
Evidence and transparency

Sources & review

Source record details
Source availability
Active
Sources checked
17 October 2026
Original website title
philippgille/ln-paywall · Official homepage title · retained in its source language