@axobot/mppx
v1.0.0
Published
Lightning-native Machine Payments Protocol SDK with pluggable payment adapters
Downloads
50
Maintainers
Readme
@axobot/mppx
Lightning-native Machine Payments Protocol SDK.
@axobot/mppx is an Axo-maintained implementation of MPP that keeps the
protocol public and portable while treating Lightning as a first-class
payment method.
It is intended to:
- follow the MPP and HTTP Payment Authentication specifications
- model Lightning
chargeandsessionflows directly - stay provider-agnostic at the adapter boundary
- ship a ZBD-backed adapter first
- remain useful outside Axo instead of becoming an Axo-only protocol fork
Why This Package Exists
Most public MPP implementation gravity is currently around Tempo/Spark. Axo wants a Lightning-native implementation where:
- BOLT11 invoices and preimages are first-class primitives
- session deposits, top-ups, and refunds work on Lightning
- the payment adapter can be swapped later for
lnd,cln, or others - Axo can use the package without owning a proprietary wire protocol
Protocol Compatibility
The official Lightning MPP drafts already define:
chargevia BOLT11 invoice + preimage proofsessionvia deposit invoice + preimage bearer token + top-up invoices + refund on close
Primary references:
Current Package Surface
Current implementation includes:
- Payment-auth challenge parsing
- canonical request and credential encoding helpers
- Lightning
chargecredential builders - Lightning
sessionopen / bearer / topUp / close credential builders - high-level helpers for paying charge challenges and opening/top-up/closing sessions
- BOLT11 payment hash extraction
- first ZBD Lightning adapter
- Axo extension support for
returnLightningAddress - refund helper that prefers
returnInvoiceand falls back toreturnLightningAddress
Package Shape
The package is currently organized into:
core- Payment-auth parsing and canonical encoding
- protocol-safe challenge and credential types
lightning- Lightning charge/session helpers
- invoice/preimage session primitives
adapters- ZBD adapter first
- future
lnd/clnadapters later
Axo Extension: returnLightningAddress
The current Lightning session draft uses returnInvoice as the native refund
field. @axobot/mppx also supports returnLightningAddress as an Axo
extension:
- if both are present,
returnInvoicewins - if only
returnLightningAddressis present, refund falls back to the adapter - this keeps the package ergonomic without throwing away spec-native behavior
Example
import {
createZbdLightningAdapter,
openLightningSession,
createLightningSessionBearerAuthorization,
} from "@axobot/mppx";
const adapter = createZbdLightningAdapter({
apiKey: process.env.ZBD_API_KEY!,
});
const session = await openLightningSession({
challenge,
adapter,
returnLightningAddress: "[email protected]",
});
const authorization = createLightningSessionBearerAuthorization({
challenge: bearerChallenge,
session,
});Scripts
npm run build
npm test
npm run typecheckStatus
Implemented:
- protocol primitives
- Lightning charge/session credential helpers
- first ZBD adapter
- initial high-level client helpers
Still pending:
- richer session manager state model
- fetch/client integration
- server middleware integration
- live validation of zero-amount invoice behavior against ZBD
- non-ZBD Lightning adapters
