Browse Source

better handling of missing dependencies on lndgrpc.

atmext
fiatjaf 4 years ago
parent
commit
1ce9936561
  1. 11
      lnbits/wallets/lndgrpc.py

11
lnbits/wallets/lndgrpc.py

@ -9,7 +9,6 @@ try:
except ImportError: # pragma: nocover except ImportError: # pragma: nocover
purerpc = None purerpc = None
import trio # type: ignore
import binascii import binascii
import base64 import base64
import hashlib import hashlib
@ -40,10 +39,8 @@ class LndWallet(Wallet):
if lndgrpc is None: # pragma: nocover if lndgrpc is None: # pragma: nocover
raise ImportError("The `lndgrpc` library must be installed to use `LndWallet`.") raise ImportError("The `lndgrpc` library must be installed to use `LndWallet`.")
if purerpc is None: if purerpc is None: # pragma: nocover
import warnings raise ImportError("The `purerpc` library must be installed to use `LndWallet`.")
warnings.warn("To enable invoices subscription on `LndWallet` the `purerpc` library must be nistalled.")
endpoint = getenv("LND_GRPC_ENDPOINT") endpoint = getenv("LND_GRPC_ENDPOINT")
self.endpoint = endpoint[:-1] if endpoint.endswith("/") else endpoint self.endpoint = endpoint[:-1] if endpoint.endswith("/") else endpoint
@ -118,10 +115,6 @@ class LndWallet(Wallet):
return PaymentStatus(True) return PaymentStatus(True)
async def paid_invoices_stream(self) -> AsyncGenerator[str, None]: async def paid_invoices_stream(self) -> AsyncGenerator[str, None]:
if not purerpc:
trio.sleep(5)
yield ""
async with purerpc.secure_channel( async with purerpc.secure_channel(
self.endpoint, self.endpoint,
self.port, self.port,

Loading…
Cancel
Save