Skip to content
LogoLogo

Lightning

Bitcoin payments over the Lightning Network

The Lightning payment method enables payments using Bitcoin over the Lightning Network within the MPP framework. Lightning supports two intents—charge for one-time payments and session for prepaid metered access—covering everything from single API calls to high-frequency streaming billing.

The implementation is provided by @buildonspark/lightning-mpp-sdk, which extends the mppx SDK with Lightning Network support alongside built-in methods like Stripe and Tempo. The reference implementation uses Spark for wallet and node operations, but the protocol works with any Lightning node or wallet that can create BOLT11 invoices and verify preimages.

Installation

Payments on Lightning

Lightning brings a distinct set of properties to MPP:

  • Cryptographic verification—The server checks sha256(preimage) == paymentHash with a single hash operation. Verification is entirely local and self-contained.
  • Synchronous settlement—Lightning HTLC settlement reveals the preimage atomically. The preimage is the proof of payment, available the instant the payment settles.
  • Global and permissionless—Bitcoin works identically in every jurisdiction. Anyone can participate without accounts, approvals, or special routing.
  • Self-custodial—Both client and server hold their own keys via Spark wallets. Funds stay under each party's control throughout the entire flow.

Choosing an intent

ChargeSession
PatternOne-time payment per requestPrepaid deposit, per-request billing
Latency overheadOne Lightning payment per requestNear-zero (bearer token after deposit)
ThroughputOne invoice + payment per requestHundreds of requests per session
Best forSingle API calls, content access, one-off purchasesLLM APIs, metered services, streaming
SettlementImmediate per-request via HTLCDeposit upfront, per-request deduction, refund on close

Intents