Added internal payment listener to paid invoices and splitpayments

This commit is contained in:
benarc 2021-10-18 13:24:32 +01:00
parent 3285e9d3c9
commit cf6fae2ca7
3 changed files with 7 additions and 8 deletions

View file

@ -32,8 +32,6 @@ except ImportError: # pragma: nocover
from typing_extensions import TypedDict from typing_extensions import TypedDict
class PaymentFailure(Exception): class PaymentFailure(Exception):
pass pass
@ -155,9 +153,10 @@ async def pay_invoice(
) )
# notify receiver asynchronously # notify receiver asynchronously
from lnbits.tasks import internal_invoice_paid
await internal_invoice_paid.send(internal_checking_id) from lnbits.tasks import internal_invoice_queue
await internal_invoice_queue.put(internal_checking_id)
else: else:
# actually pay the external invoice # actually pay the external invoice
payment: PaymentResponse = await WALLET.pay_invoice(payment_request) payment: PaymentResponse = await WALLET.pay_invoice(payment_request)

View file

@ -3,7 +3,7 @@ import json
from lnbits.core.models import Payment from lnbits.core.models import Payment
from lnbits.core.crud import create_payment from lnbits.core.crud import create_payment
from lnbits.core import db as core_db from lnbits.core import db as core_db
from lnbits.tasks import register_invoice_listener # , internal_invoice_paid from lnbits.tasks import register_invoice_listener, internal_invoice_queue
from lnbits.helpers import urlsafe_short_hash from lnbits.helpers import urlsafe_short_hash
from .crud import get_targets from .crud import get_targets
@ -78,5 +78,5 @@ async def on_invoice_paid(payment: Payment) -> None:
) )
# manually send this for now # manually send this for now
# await internal_invoice_paid.send(internal_checking_id) await internal_invoice_queue.put(internal_checking_id)
return return

View file

@ -53,7 +53,7 @@
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5> <h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
<code <code
>curl -X GET {{ request.url_root }}api/v1/livestream -H "X-Api-Key: {{ >curl -X GET {{ request.url_root }}api/v1/livestream -H "X-Api-Key: {{
g.user.wallets[0].inkey }}" user.wallets[0].inkey }}"
</code> </code>
</q-card-section> </q-card-section>
</q-card> </q-card>
@ -79,7 +79,7 @@
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5> <h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
<code <code
>curl -X PUT {{ request.url_root }}api/v1/splitpayments/targets -H >curl -X PUT {{ request.url_root }}api/v1/splitpayments/targets -H
"X-Api-Key: {{ g.user.wallets[0].adminkey }}" -H 'Content-Type: "X-Api-Key: {{ user.wallets[0].adminkey }}" -H 'Content-Type:
application/json' -d '{"targets": [{"wallet": &lt;wallet id or invoice application/json' -d '{"targets": [{"wallet": &lt;wallet id or invoice
key&gt;, "alias": &lt;name to identify this&gt;, "percent": &lt;number key&gt;, "alias": &lt;name to identify this&gt;, "percent": &lt;number
between 1 and 100&gt;}, ...]}' between 1 and 100&gt;}, ...]}'