Evaluate Lightning.Pub triggers as backup payment confirmation #32
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?
Lightning.Pub supports HTTP callback triggers — when an invoice is paid, it fires an HTTP GET to a registered URL. Evaluate whether this is worth adding as a redundant payment confirmation path alongside the existing Nostr subscription.
Current Approach
The ATM watches for invoice payment via Nostr relay subscription (
kind 21000LiveUserOperation events). When Lightning.Pub detects payment, it publishes an event → ATM receives it → firesINVOICE_PAIDinto the state machine. There's also polling-based balance watching as a fallback.How Triggers Would Work
When creating an invoice, pass
http_callback_url:Lightning.Pub hits that URL on payment settlement. The ATM would run a small local HTTP server to receive callbacks.
Trade-offs
Pros:
Against (current assessment):
Recommendation
Low priority. Revisit if relay reliability becomes an issue during field testing. The better investment is ensuring aggressive Nostr reconnection logic during active transactions (see the relay connection handling in
packages/lightning/src/client.ts).Related
triggerPaidCallback()inlightning-pub/dev/src/services/main/index.tswatchInvoice()inpackages/lightning/src/client.ts:376Rescope: under LNbits the backup-confirmation question is webhooks vs
subscribe_paymentsThe original write-up evaluated Lightning.Pub's
http_callback_urlon/api/user/invoice/newas a redundant path alongside the LPkind 21000 GetLiveUserOperationssubscription. With the ATM moving to LNbits as the payment backend (see #22), the LP-specific framing no longer applies. The underlying question stays valid; the surfaces change.LNbits equivalent surfaces:
Primary (nostr push):
subscribe_payments({payment_hash})over the nostr transport. Real-time, encrypted, no public HTTP endpoint, mirrors the LP subscription pattern. This is the recommended primary path.Backup A — LNbits per-invoice webhook:
create_invoice({webhook: "https://..."})accepts a callback URL that LNbits POSTs on settlement. Requires the ATM to expose an HTTP endpoint, which conflicts with the no-HTTP stance. Not recommended.Backup B — LNURL-withdraw webhook: the
withdrawextension's link-levelwebhook_urlfires on redemption (views_lnurl.py:152-196). Same trade-off — exposes a public ATM endpoint. Important caveat from the withdraw-extension review: webhook dispatch failures are silently logged (views_lnurl.py:191-196); the link'susedcounter is already incremented andLnurlSuccessResponse()already returned. The ATM must not treat webhook delivery as ground truth for settlement.Backup C — poll
get_payment({payment_hash}): worst-case fallback if the subscription drops mid-flow and reconnect is in progress.Recommendation given the new architecture:
subscribe_paymentsas the primary path — same shape as the LP subscription this issue contemplated, with the new outgoing-payment fanout covering ndebit-equivalent and LNURL-withdraw cases (LNbits PR #4, commit085fd501).get_paymentonly after subscription reconnect, to catch settlements that fired during the relay disconnect window.This shifts the issue from "LP triggers as backup" to "LNbits webhook surface as backup," with a stronger recommendation against using webhooks at all on a no-HTTP ATM. Worth keeping the issue open if a "subscription dropped mid-flow, what's the recovery story" exercise is needed; otherwise can be closed.