Cash-in: Detect ndebit claim success and show confirmation to user #17
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?
After displaying an ndebit QR code for cash-in, the ATM has no way to detect when the user successfully claims the sats. The user scans, their wallet processes the debit request, Lightning.Pub pays their invoice, but the ATM screen remains static.
Current flow:
Desired flow:
Solution
Subscribe to Lightning.Pub events to detect when the debit was processed successfully.
Option A: Listen for GetLiveUserOperations (Recommended)
Similar to how we detect invoice payments for cash-out (#11), we can listen for outgoing payment operations:
Option B: Poll GetPaymentState
For ndebit, we're making an outgoing payment, so
GetPaymentStateshould work (unlike cash-out where we create invoices):Option C: Track via Kind 21002 Response
When Lightning.Pub processes the debit request, it sends a Kind 21002 response. We could listen for this:
UI Changes
When claim is detected:
State Machine Updates
Acceptance Criteria
Priority
P1 - Important UX improvement for cash-in flow
Related
packages/lightning/TROUBLESHOOTING.md- Issue #9 documents GetLiveUserOperations patternLNbits gives outcome parity (not protocol parity) for ndebit-success detection
ndebit is Lightning.Pub-specific (CLINK). LNbits has no CLINK support and the
nostr-native-transportwork (see #22) does not add it. So the LP-sideGetLiveDebitRequests/RespondToDebitsubscription path stays exactly as written in this issue.However, the detection this issue asks for — "did the ATM's outgoing payment for the customer succeed?" — is now reachable two equivalent ways post-migration:
CLINK path (unchanged): subscribe to LP's
kind 21000 GetLiveUserOperations, filter by request type / payment hash. This is what the existinglamassu-next/packages/lightning/src/client.tsdoes.LNbits path (new): if the funds-bearing wallet is on LNbits,
subscribe_payments({wallet_id: <atm_wallet>, payment_hash: <hash>})over the nostr transport. The ATM gets a real-time encrypted push event the moment the outgoing payment settles, including the fullPaymentobject (status, amount, fee, extra).Recent LNbits commit
085fd501fixes the gap that previously made outgoing payments invisible to subscribers — now both incoming AND outgoing settlements fan out toinvoice_listeners, so the ATM-sidesubscribe_paymentsfilter matches outgoing settlements correctly. Verified end-to-end with--flow lnurlwin the LNbits driver script.Optional session-correlation tip: the
extradict onpay_invoiceis opaque to LNbits — passextra={"session_id": "..."}at payment time and the subscription push echoes it back unchanged. Useful for matching the outgoing payment to a specific cash-in session without amount/timing heuristics.Net: if the ATM still pays from LP, this issue is unchanged. If/when the ATM pays from an LNbits wallet (post-migration),
subscribe_paymentsis the equivalent surface — same UX, different protocol.