Merge pull request #392 from arcbtc/FastAPI

cln sse should be working
This commit is contained in:
Arc 2021-11-03 22:36:13 +00:00 committed by GitHub
commit a823f450b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -183,11 +183,13 @@ class SparkWallet(Wallet):
raise KeyError("supplied an invalid checking_id") raise KeyError("supplied an invalid checking_id")
async def paid_invoices_stream(self) -> AsyncGenerator[str, None]: async def paid_invoices_stream(self) -> AsyncGenerator[str, None]:
url = self.url + "/stream?access-key=" + self.token url = f"{self.url}/stream?access-key={self.token}"
while True: while True:
try: try:
async with httpx.AsyncClient(timeout=None) as client: async with httpx.AsyncClient(
timeout=None, headers=self.token
) as client:
async with client.stream("GET", url) as r: async with client.stream("GET", url) as r:
async for line in r.aiter_lines(): async for line in r.aiter_lines():
if line.startswith("data:"): if line.startswith("data:"):