Skip to content

check lightning invoice in-flight#306

Draft
callebtc wants to merge 1 commit intomainfrom
nut05/async_melt
Draft

check lightning invoice in-flight#306
callebtc wants to merge 1 commit intomainfrom
nut05/async_melt

Conversation

@callebtc
Copy link
Copy Markdown
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
Copy Markdown
Contributor

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?

@ye0man ye0man added this to nutshell Jan 21, 2026
@github-project-automation github-project-automation bot moved this to Backlog in nutshell Jan 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

[Nuts] Notes: Async LN payment endpoint design

3 participants