mirror of
https://github.com/lnbits/lnbits.git
synced 2025-03-26 17:51:53 +01:00
fix: wallets not loading when protobuf is missing
This commit is contained in:
parent
a50c7b6e3a
commit
8ea2d20389
@ -29,7 +29,7 @@ Using this wallet requires the installation of the `pylightning` Python package.
|
||||
|
||||
### LND (gRPC)
|
||||
|
||||
Using this wallet requires the installation of the `grpcio` Python packages.
|
||||
Using this wallet requires the installation of the `grpcio` and `protobuf` Python packages.
|
||||
|
||||
- `LNBITS_BACKEND_WALLET_CLASS`: **LndWallet**
|
||||
- `LND_GRPC_ENDPOINT`: ip_address
|
||||
|
@ -1,7 +1,10 @@
|
||||
imports_ok = True
|
||||
try:
|
||||
from google import protobuf
|
||||
import grpc
|
||||
except ImportError: # pragma: nocover
|
||||
grpc = None
|
||||
imports_ok = False
|
||||
|
||||
|
||||
import binascii
|
||||
import base64
|
||||
@ -9,8 +12,9 @@ import hashlib
|
||||
from os import environ, error, getenv
|
||||
from typing import Optional, Dict, AsyncGenerator
|
||||
|
||||
import lnbits.wallets.lnd_grpc_files.lightning_pb2 as ln
|
||||
import lnbits.wallets.lnd_grpc_files.lightning_pb2_grpc as lnrpc
|
||||
if imports_ok:
|
||||
import lnbits.wallets.lnd_grpc_files.lightning_pb2 as ln
|
||||
import lnbits.wallets.lnd_grpc_files.lightning_pb2_grpc as lnrpc
|
||||
|
||||
from .base import (
|
||||
StatusResponse,
|
||||
@ -76,9 +80,9 @@ environ["GRPC_SSL_CIPHER_SUITES"] = "HIGH+ECDSA"
|
||||
|
||||
class LndWallet(Wallet):
|
||||
def __init__(self):
|
||||
if grpc is None: # pragma: nocover
|
||||
if not imports_ok: # pragma: nocover
|
||||
raise ImportError(
|
||||
"The `grpcio` library must be installed to use `GRPC LndWallet`. Alternatively try using the LndRESTWallet."
|
||||
"The `grpcio` and `protobuf` library must be installed to use `GRPC LndWallet`. Alternatively try using the LndRESTWallet."
|
||||
)
|
||||
|
||||
endpoint = getenv("LND_GRPC_ENDPOINT")
|
||||
|
Loading…
x
Reference in New Issue
Block a user