SatSale

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

commit 25786fedc88d6f23a51f3b32e9f27fed157799a1
parent 0e773d27ced33b1509e00c7cc8a8a8695f95b9ff
Author: nickfarrow <nick@nickfarrow.com>
Date:   Sat, 19 Mar 2022 15:38:10 +1100

clarify unix domain socket over ssh

Diffstat:
Mconfig.toml | 4++--
Mgateways/ssh_tunnel.py | 74+++++++++++++++++++++++++++++++++-----------------------------------------
Mnode/clightning.py | 2+-
3 files changed, 36 insertions(+), 44 deletions(-)

diff --git a/config.toml b/config.toml @@ -54,8 +54,8 @@ onchain_dust_limit = 0.00000546 # Or clightning #pay_method = "clightning" -# If remote clightning, make sure `ssh -nNT -L lightning-rpc:{clightning_rpc_file} {tunnel_host}` -# creates a lightning-rpc unix domain socket +# If remote clightning, make sure `ssh -nNT -L {local_lightning-rpc}:{remote_lightning-rpc} {tunnel_host}` +# creates a lightning-rpc unix domain socket. (use full paths local: /home/install/satsale/lightning-rpc) #clightning_rpc_file = "/home/user/.lightning/lightning-rpc" ####################### diff --git a/gateways/ssh_tunnel.py b/gateways/ssh_tunnel.py @@ -10,57 +10,49 @@ from node import bitcoind def open_tunnel(host, port): # If tunnel is required (might make things easier) try: - if config.tunnel_host is not None: - command = [ - "ssh", - config.tunnel_host, - "-q", - "-N", - "-L", - "{}:localhost:{}".format(port, port), - ] - logging.info("Opening tunnel to {}.".format(" ".join(command))) - tunnel_proc = subprocess.Popen(command) - return tunnel_proc - - else: - tunnel_proc = None + command = [ + "ssh", + config.tunnel_host, + "-q", + "-N", + "-L", + "{}:localhost:{}".format(port, port), + ] + logging.info("Opening tunnel to {}.".format(" ".join(command))) + return subprocess.Popen(command) + except Exception as e: logging.error("FAILED TO OPEN TUNNEL. Exception: {}".format(e)) - tunnel_proc = None - pass - return + + return None def clightning_unix_domain_socket_ssh(rpc_store_dir=None): if rpc_store_dir is None: rpc_store_dir = os.getcwd() + local_file = rpc_store_dir + "/lightning-rpc" + # ssh -nNT -L lightning-rpc:~/.lightning/lightning-rpc config.tunnel_host - if config.tunnel_host is not None: - try: - command = [ - "ssh", - "-nNT", - "-L", - "lightning-rpc:{}".format(config.clightning_rpc_file), - "{}".format(config.tunnel_host), - ] - logging.info("Opening tunnel to {}.".format(" ".join(command))) - tunnel_proc = subprocess.Popen(command) - return tunnel_proc - - except Exception as e: - logging.error( - "FAILED TO OPEN UNIX DOMAIN SOCKET OVER SSH. Exception: {}".format(e) - ) - tunnel_proc = None - pass - - else: - tunnel_proc = None + try: + command = [ + "ssh", + "-nNT", + "-L", + "{}:{}".format(local_file, config.clightning_rpc_file), + "{}".format(config.tunnel_host), + ] + logging.info("Opening tunnel to {}.".format(" ".join(command))) + tunnel_proc = subprocess.Popen(command) + return tunnel_proc - return + except Exception as e: + logging.error( + "FAILED TO OPEN UNIX DOMAIN SOCKET OVER SSH. Exception: {}".format(e) + ) + return None + + return None def close_tunnel(): diff --git a/node/clightning.py b/node/clightning.py @@ -28,7 +28,7 @@ class clightning: for i in range(config.connection_attempts): try: logging.info("Attempting to connect to clightning...") - self.clightning = LightningRpc(config.clightning_rpc_file) + self.clightning = LightningRpc("lightning-rpc") logging.info("Getting clightning info...") info = self.clightning.getinfo()