SatSale

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 2443987663f7272d8e7a2b4cf2ad4f2898875739
parent 77c7162afa6c4701e969607705a0cf8373e31551
Author: nickfarrow <nick@nickfarrow.com>
Date:   Sun, 20 Mar 2022 12:58:55 +1100

reliable remote node connection with delays and fix remote clightning

Diffstat:
Mgateways/ssh_tunnel.py | 5++++-
Mnode/bitcoind.py | 10++++++----
Mnode/clightning.py | 17+++++++++++++----
Mnode/lnd.py | 2+-
4 files changed, 24 insertions(+), 10 deletions(-)

diff --git a/gateways/ssh_tunnel.py b/gateways/ssh_tunnel.py @@ -61,7 +61,10 @@ def rm_lightning_rpc_file(): def close_tunnels(ssh_processes): for proc in ssh_processes: - proc.kill() + try: + proc.kill() + except Exception as e: + continue if config.clightning_rpc_file is not None: rm_lightning_rpc_file() diff --git a/node/bitcoind.py b/node/bitcoind.py @@ -39,8 +39,9 @@ class btcd: rpc_credentials_str = open(config.rpc_cookie_file, "r").read() (username, password) = rpc_credentials_str.split(":") else: - raise Exception("rpc_cookie_file {} not found".format( - config.rpc_cookie_file)) + raise Exception( + "rpc_cookie_file {} not found".format(config.rpc_cookie_file) + ) else: username = config.username password = config.password @@ -83,7 +84,7 @@ class btcd: except Exception as e: logging.error(e) - time.sleep(config.pollrate) + time.sleep(2) logging.info( "Attempting again... {}/{}...".format( i + 1, config.connection_attempts @@ -97,7 +98,8 @@ class btcd: def create_qr(self, uuid, address, value): qr_str = "bitcoin:{}?amount={}&label={}".format( - address, btc_amount_format(value), uuid) + address, btc_amount_format(value), uuid + ) img = qrcode.make(qr_str) img.save("static/qr_codes/{}.png".format(uuid)) diff --git a/node/clightning.py b/node/clightning.py @@ -27,19 +27,28 @@ class clightning: for i in range(config.connection_attempts): try: - logging.info("Attempting to connect to clightning...") - self.clightning = LightningRpc("lightning-rpc") + if config.tunnel_host is None: + rpc_file = config.clightning_rpc_file + else: + rpc_file = "lightning-rpc" + + logging.info( + "Attempting to connect to clightning with unix domain socket: {}".format( + rpc_file + ) + ) + self.clightning = LightningRpc(rpc_file) logging.info("Getting clightning info...") info = self.clightning.getinfo() logging.info(info) - logging.info("Successfully clightning lnd.") + logging.info("Successfully connected to clightning.") break except Exception as e: logging.error(e) - time.sleep(config.pollrate) + time.sleep(2) logging.info( "Attempting again... {}/{}...".format( i + 1, config.connection_attempts diff --git a/node/lnd.py b/node/lnd.py @@ -55,7 +55,7 @@ class lnd: except Exception as e: logging.error(e) - time.sleep(config.pollrate) + time.sleep(2) logging.info( "Attempting again... {}/{}...".format( i + 1, config.connection_attempts