diff --git a/lnbits/wallets/__init__.py b/lnbits/wallets/__init__.py index f3f25103..8a2ca1a5 100644 --- a/lnbits/wallets/__init__.py +++ b/lnbits/wallets/__init__.py @@ -1,12 +1,12 @@ # flake8: noqa -from .void import VoidWallet from .clightning import CLightningWallet -from .lntxbot import LntxbotWallet -from .opennode import OpenNodeWallet -from .lnpay import LNPayWallet -from .lnbits import LNbitsWallet -from .lndrest import LndRestWallet -from .spark import SparkWallet from .eclair import EclairWallet from .fake import FakeWallet +from .lnbits import LNbitsWallet +from .lndrest import LndRestWallet +from .lnpay import LNPayWallet +from .lntxbot import LntxbotWallet +from .opennode import OpenNodeWallet +from .spark import SparkWallet +from .void import VoidWallet diff --git a/lnbits/wallets/eclair.py b/lnbits/wallets/eclair.py index 59d2ffdf..9b5aca7d 100644 --- a/lnbits/wallets/eclair.py +++ b/lnbits/wallets/eclair.py @@ -1,21 +1,24 @@ -import trio -import json -import httpx -import random +import asyncio import base64 +import json +import random import urllib.parse from os import getenv -from typing import Optional, AsyncGenerator -from trio_websocket import open_websocket_url +from typing import AsyncGenerator, Optional + +import httpx +from websockets import connect from .base import ( - StatusResponse, InvoiceResponse, PaymentResponse, PaymentStatus, + StatusResponse, + Unsupported, Wallet, ) + class EclairError(Exception): pass @@ -154,11 +157,11 @@ class EclairWallet(Wallet): while True: try: - async with open_websocket_url(ws_url, extra_headers=[('Authorization', self.auth["Authorization"])]) as ws: - message = await ws.get_message() + async with connect(ws_url, extra_headers=[('Authorization', self.auth["Authorization"])]) as ws: + message = await ws.recv() print('Received message: %s' % message) - if "payment-received" in message["type"]: + if "type" in message and "payment-received" in message.type: yield message["paymentHash"] except OSError as ose: @@ -166,4 +169,4 @@ class EclairWallet(Wallet): pass print("lost connection to eclair's websocket, retrying in 5 seconds") - await trio.sleep(5) + await asyncio.sleep(5)