mirror of
https://github.com/lnbits/lnbits.git
synced 2025-07-15 23:42:36 +02:00
fix: wallets not loading when protobuf is missing
This commit is contained in:
@ -29,7 +29,7 @@ Using this wallet requires the installation of the `pylightning` Python package.
|
|||||||
|
|
||||||
### LND (gRPC)
|
### 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**
|
- `LNBITS_BACKEND_WALLET_CLASS`: **LndWallet**
|
||||||
- `LND_GRPC_ENDPOINT`: ip_address
|
- `LND_GRPC_ENDPOINT`: ip_address
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
|
imports_ok = True
|
||||||
try:
|
try:
|
||||||
|
from google import protobuf
|
||||||
import grpc
|
import grpc
|
||||||
except ImportError: # pragma: nocover
|
except ImportError: # pragma: nocover
|
||||||
grpc = None
|
imports_ok = False
|
||||||
|
|
||||||
|
|
||||||
import binascii
|
import binascii
|
||||||
import base64
|
import base64
|
||||||
@ -9,8 +12,9 @@ import hashlib
|
|||||||
from os import environ, error, getenv
|
from os import environ, error, getenv
|
||||||
from typing import Optional, Dict, AsyncGenerator
|
from typing import Optional, Dict, AsyncGenerator
|
||||||
|
|
||||||
import lnbits.wallets.lnd_grpc_files.lightning_pb2 as ln
|
if imports_ok:
|
||||||
import lnbits.wallets.lnd_grpc_files.lightning_pb2_grpc as lnrpc
|
import lnbits.wallets.lnd_grpc_files.lightning_pb2 as ln
|
||||||
|
import lnbits.wallets.lnd_grpc_files.lightning_pb2_grpc as lnrpc
|
||||||
|
|
||||||
from .base import (
|
from .base import (
|
||||||
StatusResponse,
|
StatusResponse,
|
||||||
@ -76,9 +80,9 @@ environ["GRPC_SSL_CIPHER_SUITES"] = "HIGH+ECDSA"
|
|||||||
|
|
||||||
class LndWallet(Wallet):
|
class LndWallet(Wallet):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
if grpc is None: # pragma: nocover
|
if not imports_ok: # pragma: nocover
|
||||||
raise ImportError(
|
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")
|
endpoint = getenv("LND_GRPC_ENDPOINT")
|
||||||
|
Reference in New Issue
Block a user