should be working

This commit is contained in:
benarc
2021-10-10 23:57:15 +01:00
parent 7dd29b3eca
commit 9ff1313b0b
6 changed files with 269 additions and 186 deletions
+9 -12
View File
@@ -1,23 +1,20 @@
import asyncio
import json
import trio # type: ignore
import httpx
from lnbits.core.models import Payment
from lnbits.core.crud import create_payment
from lnbits.core import db as core_db
from lnbits.tasks import register_invoice_listener, internal_invoice_paid
from lnbits.helpers import urlsafe_short_hash
from lnbits.core.models import Payment
from lnbits.tasks import register_invoice_listener
from .crud import get_jukebox, update_jukebox_payment
async def register_listeners():
invoice_paid_chan_send, invoice_paid_chan_recv = trio.open_memory_channel(2)
register_invoice_listener(invoice_paid_chan_send)
await wait_for_paid_invoices(invoice_paid_chan_recv)
async def wait_for_paid_invoices():
invoice_queue = asyncio.Queue()
register_invoice_listener(invoice_queue)
async def wait_for_paid_invoices(invoice_paid_chan: trio.MemoryReceiveChannel):
async for payment in invoice_paid_chan:
while True:
payment = await invoice_queue.get()
await on_invoice_paid(payment)