Replace LNbits backend with Lightning.Pub #16
Labels
No labels
app:activities
app:chat
app:events
app:forum
app:libra
app:market
app:restaurant
app:tasks
app:wallet
app:webapp
bug
enhancement
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
aiolabs/webapp#16
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Migrate the payment backend from LNbits to Lightning.Pub, matching how ShockWallet integrates. This enables Nostr-native authentication (keypair instead of username/password) and aligns the app with the same Lightning infrastructure used by the ATM and other aiolabs projects.
Motivation
lamassu-next) already uses Lightning.Pub. Running LNbits as a separate service adds operational complexity.noffer(Nostr offers),ndebit(Nostr debit authorizations), and programmatic app user management — none of which are available in LNbits.Current Architecture (LNbits)
POST /api/v1/authPOST /api/v1/paymentswithX-Api-Key: {adminkey}POST /api/v1/paymentswith{ out: true }wss://lnbits/api/v1/ws/{inkey}POST /lnurlp/api/v1/linksTarget Architecture (Lightning.Pub)
POST /api/user/authPOST /api/user/invoice/new→{ amountSats, memo }POST /api/user/invoice/pay→{ invoice, amount }GET /api/user/info→{ balance, max_withdrawable }noffer(Nostr offer) replaces LNURLP pay linksLightning.Pub also supports Nostr-based RPC (NIP-44 encrypted events) as a transport, but the HTTP API is sufficient for the initial migration.
Implementation Plan
Phase 1: API Client + Auth (foundation)
New file:
src/lib/api/lightning-pub.tsshock-wallet/main/src/Api/pub/autogenerated/ts/http_client.tsnewInvoice(),payInvoice(),getUserInfo(),payAddress()AuthorizationheaderModify:
src/modules/base/auth/auth-service.tsnostr-toolsis already a dependency — usegenerateSecretKey()/getPublicKey()Modify:
src/app.config.tsVITE_LNBITS_BASE_URL→VITE_LIGHTNING_PUB_API_URLVITE_APP_ID(Lightning.Pub app identifier)VITE_LIGHTNING_PUB_PUBKEY(server's Nostr pubkey for encryption)Phase 2: Wallet Service (payments)
Rewrite:
src/modules/wallet/services/WalletService.tscreateInvoice(amount, memo)→client.newInvoice({ amountSats, memo })sendPayment(invoice)→client.payInvoice({ invoice, amount })getBalance()→client.getUserInfo().balancenofferin future)GET /api/user/operationsRewrite:
src/modules/wallet/services/WalletWebSocketService.tsgetUserInfo()on interval (the existingfallbackToPollingpath)Phase 3: Clean up
src/lib/api/lnbits.tsandsrc/lib/config/lnbits.tsPaymentService.tsif any LNbits-specific logic leaked in.env.examplewith new env varsbalance_msat→balancein sats)What stays the same
PaymentServiceorchestration layer (delegates to WalletService)light-bolt11-decoder)API Reference
Lightning.Pub HTTP endpoints (from protobuf definitions):
Estimate
~500 lines of new code across 5 files. The modular DI architecture makes this a clean swap — service implementations change but interfaces stay the same.
Risks