feat(machine): use Nostr events for LNURL-withdraw completion notification #24
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?
The ATM currently polls the Lightning.Pub withdraw extension HTTP API every 2 seconds to detect when an LNURL-withdraw has been claimed:
This works but is not "the Lightning.Pub way" - which uses Nostr as the communication layer.
Proposed Solution
Implement Nostr-native withdrawal completion notifications:
Withdraw Extension Changes (Lightning.Pub):
unique_hash,amount_sats,payment_hash, completion timestampATM Changes:
Benefits
Implementation Notes
The withdraw extension already has access to
ctx.publishNostrEvent()- seesrc/extensions/context.ts:186-188. The Marketplace extension uses this pattern successfully for product updates.Suggested event structure:
Related
apps/machine/src/services/lightning.ts:266-307lightning-pub/withdraw/src/extensions/context.tsLNbits side is ready —
subscribe_payments({tag:"withdraw", link_id})The exact pain point this issue describes (2-second HTTP polling against LP's withdraw extension for
:unique_hash/:id_unique_hashclaim status) is what the LNbitsnostr-native-transportwork has been building toward. Status as of LNbits commit085fd501+aiolabs/withdrawcommit82a6d4a:End-to-end flow, no polling, no HTTP:
lnurlw_create_link({title, min_withdrawable, max_withdrawable, uses, wait_time, is_unique})→ returns the link record includingid,unique_hash,uses,is_unique.subscribe_payments({tag: "withdraw", link_id: <link.id>, max_seconds: 300})→ returns{subscription_id, expires_at}.Payment.extra = {tag: "withdraw", withdrawal_link_id: <id>}.085fd501) routes the settlement through the subscription module → ATM gets an encrypted kind-21000 push event with the fullPaymentobject.Verified end-to-end with
~/dev/lnbits/nostr-transport/misc-aio/test_lnurlw_flow.py: link create + subscribe ack + customer redemption simulation + push received with matchingextra.withdrawal_link_idandstatus=success. Sub-second delivery from settlement.Sub-link disambiguation for
is_unique=True: the newlnurlw_unique_hashes({id})RPC (aiolabs/withdraw commit82a6d4a) returns the canonical list of unredeemedid_unique_hashvalues for the link — so when a settlement push arrives the ATM can match it back to a specific sub-link if needed (the push itself carrieswithdrawal_link_idbut not the sub-link hash; if you need per-sub-link tracking, mint a separate link for each sub-use, or correlate via amount + timing).This makes #25 (the unique-mode +
id_unique_hashissue) cleanly implementable too.Net: issue closeable once the ATM's
client.tsadapter swaps the polling loop for a subscription. The LNbits surface is in place and stable.