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) == paymentHashwith 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
| Charge | Session | |
|---|---|---|
| Pattern | One-time payment per request | Prepaid deposit, per-request billing |
| Latency overhead | One Lightning payment per request | Near-zero (bearer token after deposit) |
| Throughput | One invoice + payment per request | Hundreds of requests per session |
| Best for | Single API calls, content access, one-off purchases | LLM APIs, metered services, streaming |
| Settlement | Immediate per-request via HTLC | Deposit upfront, per-request deduction, refund on close |