MarsPay V2 is a modular backend service designed to integrate Lightning payments into any 1v1 game. It provides a WebSocket API for real-time communication, handles LNURL generation and withdrawal via LNbits, and exposes REST endpoints for LNbits webhooks.
This backend abstracts payment logic and session tracking, letting game developers focus on gameplay while enabling Lightning-native features like deposits and real-time player payouts.
- ⚡ Lightning-native: Integrates seamlessly with LNbits for LNURLp (pay) and LNURLw (withdraw) flows
- 🔌 Socket.IO API: Real-time communication layer for any frontend game client
- 🎮 Session management: Dynamic sessions with Player 1 / Player 2 roles
- 📤 Webhook endpoint: Handles LNbits callbacks for payment and withdrawal confirmation
git clone https://github.com/francismars/marspayV2.git
cd marspayV2npm installnpx tsx src/index.tsnpx tsc
node dist/index.jsCreate a .env file for the configuration:
LNBITS_URL=
LNBITS_IP=
LNBITS_KEY=
LNBITS_DEPOSITHOOK=
LNBITS_WITHDRAWHOOK=
ADMIN_PASSWORD=Clients connect via WebSocket and join sessions by session ID. Example events:
getGameMenuInfosgetDuelInfosgameFinished(winnerP)postGameInfoRequestcreateWithdrawalPostGame
Triggered by LNbits when a user pays sats via LNURLp.
Triggered by LNbits when a user withdraws sats via LNURLw.
- A game starts and creates a
sessionID - The game calls the API to generate LNURLp links via LNbits
- Payments are received and handled live via Socket.IO
- LNURLw generated for the winner to withdraw
- Withdrawals are notified via webhook
MIT © 2025 FrancisMars
Feel free to fork, open issues, or contribute improvements for more game use cases, wallets, or modes. PRs welcome!