getAlby / lightning-browser-extension

The Bitcoin Lightning Browser extension that connects to different wallet interfaces and brings deep lightning integration to the web
https://getalby.com
MIT License
523 stars 193 forks source link

[Feature] Pay multiple HODL invoices #2455

Open LukasBahrenberg opened 1 year ago

LukasBahrenberg commented 1 year ago

Feature description

In the case of HODL invoices it should be possible to pay multiple HODL invoices in a row w/o waiting for a successful settlement of previous ones.

The idea behind HODL invoices is that the preimage revelation / invoice settlement is not done immediately by the recipent upon receiving a payment. Instead, it can be revealed depending on some external condition at some point in the future.

Describe the solution

A solution in Alby could be to not wait for the standard response meaning an immediate revelation of the preimage when paying a HODL invoice.

Describe alternatives

@reneaaron suggested in #2142:

There is still the idea of sendPaymentAsync to prevent users from having to close the popup manually.

Additional context

This issue is related to PR #2151 and the original issue #2142.

I tested the webln.request() methods addholdinvoice and settleinvoice when connected to LND via Alby/REST. It works except for one (minor) thing:

I set a "remember" in Alby for webln.sendPayment() with a budget for my test site allowing me to make multiple payments in a row non-interactively. Now, if I try to pay multiple HODL invoices in a row, it throws me the following error and prevents me from running webln.sendPayment() again:

inpageScriptWebLN.bundle.js:1 Uncaught (in promise) Error: window.webln call already executing
    at r (inpageScriptWebLN.bundle.js:1:357)
r @ inpageScriptWebLN.bundle.js:1

I suppose this has to do with getting no response for webln.sendPayment() in case of paying a HODL invoice. This is not too bad as e.g. a page reload solves this. I wonder, however, what happens in the background. Is Alby still waiting for a response for all the paid HODL invoices? Does this accumulate somehow?

@bumi answered to this:

Currently Alby protects the user from too many requests by the website and thus does not allow parallel requests - the hold invoice keeps the connection open, so this is a problem I guess.

Are you working on this?

None

rolznz commented 10 months ago

Hi, we are planning to implement webln.sendPaymentAsync. Unfortunately we will have no callback for now, as normally waiting for the invoice to settle times out in the http request of the connector.

Also: allowances/remember me won't be supported initially, as we cannot easily track the status of HODL payments in the extension.