mirror of
https://github.com/RoboSats/robosats.git
synced 2024-12-13 19:06:26 +00:00
Fix exceptions for no CLN nodes
This commit is contained in:
parent
5d5435e7a1
commit
067ba38668
@ -19,17 +19,18 @@ from . import primitives_pb2 as primitives__pb2
|
||||
#######
|
||||
|
||||
# Load the client's certificate and key
|
||||
with open(os.path.join(config("CLN_DIR"), "client.pem"), "rb") as f:
|
||||
CLN_DIR = config("CLN_DIR", cast=str, default="/cln/testnet/")
|
||||
with open(os.path.join(CLN_DIR, "client.pem"), "rb") as f:
|
||||
client_cert = f.read()
|
||||
with open(os.path.join(config("CLN_DIR"), "client-key.pem"), "rb") as f:
|
||||
with open(os.path.join(CLN_DIR, "client-key.pem"), "rb") as f:
|
||||
client_key = f.read()
|
||||
|
||||
# Load the server's certificate
|
||||
with open(os.path.join(config("CLN_DIR"), "server.pem"), "rb") as f:
|
||||
with open(os.path.join(CLN_DIR, "server.pem"), "rb") as f:
|
||||
server_cert = f.read()
|
||||
|
||||
|
||||
CLN_GRPC_HOST = config("CLN_GRPC_HOST")
|
||||
CLN_GRPC_HOST = config("CLN_GRPC_HOST", cast=str, default="localhost:9999")
|
||||
DISABLE_ONCHAIN = config("DISABLE_ONCHAIN", cast=bool, default=True)
|
||||
MAX_SWAP_AMOUNT = config("MAX_SWAP_AMOUNT", cast=int, default=500000)
|
||||
|
||||
|
@ -1,16 +1,16 @@
|
||||
from decouple import config
|
||||
|
||||
LN_vendor = config("LNVENDOR", cast=str, default="LND")
|
||||
LNVENDOR = config("LNVENDOR", cast=str, default="LND")
|
||||
|
||||
if LN_vendor == "LND":
|
||||
if LNVENDOR == "LND":
|
||||
from api.lightning.lnd import LNDNode
|
||||
|
||||
LNNode = LNDNode
|
||||
elif LN_vendor == "CLN":
|
||||
elif LNVENDOR == "CLN":
|
||||
from api.lightning.cln import CLNNode
|
||||
|
||||
LNNode = CLNNode
|
||||
else:
|
||||
raise ValueError(
|
||||
f'Invalid Lightning Node vendor: {LN_vendor}. Must be either "LND" or "CLN"'
|
||||
f'Invalid Lightning Node vendor: {LNVENDOR}. Must be either "LND" or "CLN"'
|
||||
)
|
||||
|
17
api/utils.py
17
api/utils.py
@ -14,6 +14,7 @@ logger = logging.getLogger("api.utils")
|
||||
|
||||
TOR_PROXY = config("TOR_PROXY", default="127.0.0.1:9050")
|
||||
USE_TOR = config("USE_TOR", cast=bool, default=True)
|
||||
LNVENDOR = config("LNVENDOR", cast=str, default="LND")
|
||||
|
||||
|
||||
def get_session():
|
||||
@ -144,10 +145,12 @@ lnd_version_cache = {}
|
||||
|
||||
@ring.dict(lnd_version_cache, expire=3600)
|
||||
def get_lnd_version():
|
||||
try:
|
||||
from api.lightning.lnd import LNDNode
|
||||
|
||||
from api.lightning.lnd import LNDNode
|
||||
|
||||
return LNDNode.get_version()
|
||||
return LNDNode.get_version()
|
||||
except Exception:
|
||||
return None
|
||||
|
||||
|
||||
cln_version_cache = {}
|
||||
@ -155,10 +158,12 @@ cln_version_cache = {}
|
||||
|
||||
@ring.dict(cln_version_cache, expire=3600)
|
||||
def get_cln_version():
|
||||
try:
|
||||
from api.lightning.cln import CLNNode
|
||||
|
||||
from api.lightning.cln import CLNNode
|
||||
|
||||
return CLNNode.get_version()
|
||||
return CLNNode.get_version()
|
||||
except Exception:
|
||||
return None
|
||||
|
||||
|
||||
robosats_commit_cache = {}
|
||||
|
Loading…
Reference in New Issue
Block a user