Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check lightning invoice in-flight #306

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

check lightning invoice in-flight #306

wants to merge 1 commit into from

Conversation

callebtc
Copy link
Collaborator

@callebtc callebtc commented Aug 25, 2023

First draft of an async payment flow. Makes use of previous changes to NUT-07: add new field pending.

Closes #244

Changes

  • Adds a new parameter blocking=False to the POST /melt endpoint which makes it return immediately and pay the invoice in the background.
  • The wallet then checks for proof states instead of waiting for the endpoint to return as it did before.
  • If the proof states indicate that the invoice is paid, wallet goes on as usual

Todo

  • store_lightning_invoice only stores the invoice after payment, should store before and update later
  • need to come up with a way to check information about the invoice, otherwise we can't get the preimage of a paid invoice. If there should be a new endpoint to check an invoice state, it should be tied to the proofs used to mint for that invoice, otherwise other users can look up the preimage

# run asynchronously if blocking is False
if not blocking:
asyncio.create_task(ledger.melt(payload.proofs, payload.pr, payload.outputs))
resp = GetMeltResponse(paid=False, preimage=None, change=None)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably return HTTP 202 Accepted?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Nuts] Notes: Async LN payment endpoint design
2 participants