lnbits / withdraw

LNbits Withdraw Extension
MIT License
6 stars 9 forks source link

bug: increment before paying #23

Closed dni closed 7 months ago

dni commented 7 months ago

fixes issue in used withdraws

thespielplatz commented 7 months ago

Hey Ho thank you! We are waiting for this fix 🥰

thespielplatz commented 7 months ago

Just an idea, because now a withdraw link can be used =+1 and get's marked as "It has been used and can't be used in the future, which is good ;) ... but if the pay_invoice is throwing an exception or the payment is still pending (and will be later invalid) the counter used is not decreased.

We can work around this, but we can't relate between lnurlw and the payments the apipayments table. (btw. we is Satoshi Engineering 👋)

Could you (maybe) add the lnurlw_id to the apipayments.extra field?

https://github.com/lnbits/withdraw/blob/2fc4fad7579531ea81dd0caca3724e00ed5fa34a/lnurl.py#L115 like

        payment_hash = await pay_invoice(
            wallet_id=link.wallet,
            payment_request=pr,
            max_sat=link.max_withdrawable,
            extra={"tag": "withdraw", "lnurlw_id": link.id },
        )

(Sorry for not dooing a merge request, haven't figured out how to dev on lnbits with an extension 🙈)

Cheers and Thanks for your fast responses, Fil