Skip to content

Commit be24760

Browse files
committed
Add multi-step top-up flow with QR invoice support
Redesign budget modal from single screen to multi-step flow: - Step 1: Balance display with single Top Up button - Step 2: Preset amount tiles (50/100/500/1000) + custom input - Step 3: QR code invoice with copy button and balance polling Sphinx users skip to payment directly. WebLN users pick amount then pay via extension. Manual users (L402 but no wallet) get QR invoice flow via /top_up_lsat with 5-minute polling timeout. Adds qrcode.react, topUpLsat/topUpConfirm API functions, and plan doc for future no-wallet invoice flow via /buy_lsat.
1 parent df608bb commit be24760

File tree

6 files changed

+436
-114
lines changed

6 files changed

+436
-114
lines changed

package-lock.json

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"lsat-js": "^2.0.6",
1818
"lucide-react": "^1.7.0",
1919
"next": "16.2.2",
20+
"qrcode.react": "^4.2.0",
2021
"react": "19.2.4",
2122
"react-dom": "19.2.4",
2223
"shadcn": "^4.1.2",

plans/invoice-payment-flow.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Invoice Payment Flow (No Wallet, No L402)
2+
3+
## Problem
4+
Users without Sphinx or a WebLN extension have no way to get an initial L402 token. The current flows all require a browser extension or the Sphinx app to return the payment preimage.
5+
6+
## Existing Boltwall Endpoints
7+
- `POST /buy_lsat` — returns 402 with `www-authenticate` header containing macaroon + invoice
8+
- `GET /preimage?macaroon=<macaroon>` — returns preimage once invoice is paid
9+
- `POST /top_up_lsat` — generates top-up invoice for existing L402
10+
- `POST /top_up_confirm` — confirms top-up payment
11+
12+
## Proposed Flow
13+
14+
1. User clicks "Top Up" with no wallet detected
15+
2. Frontend calls `POST /buy_lsat` with amount
16+
3. Parse macaroon + invoice from `www-authenticate` header
17+
4. Show invoice as QR code (scannable from any Lightning wallet)
18+
5. Poll `GET /preimage?macaroon=<macaroon>` every 3 seconds
19+
6. Once paid, server returns `{ success: true, preimage: "..." }`
20+
7. Store `L402 macaroon:preimage` in localStorage
21+
8. User is fully authenticated — no extension needed
22+
23+
## UX Questions (Unresolved)
24+
- Should we show the raw L402 token to the user? They'd need it if they clear localStorage
25+
- Should there be a way to paste/import an L402 token?
26+
- How do we communicate that the token lives in localStorage and is session-tied?
27+
- For CLI/agent users: they manage their own L402s, this flow is humans-only
28+
29+
## What's Already Built
30+
- Multi-step budget modal with QR code support (qrcode.react installed)
31+
- `topUpLsat()` and `topUpConfirm()` API functions in `src/lib/sphinx/payment.ts`
32+
- Manual top-up flow for users who already have an L402
33+
34+
## What's Needed
35+
- Frontend: Add buy_lsat QR flow to the "no wallet, no L402" state in budget modal
36+
- Frontend: Poll `/preimage` endpoint instead of `/balance` for initial purchase
37+
- No backend changes — all endpoints already exist

0 commit comments

Comments
 (0)