diff --git a/basicswap/basicswap.py b/basicswap/basicswap.py index 84f6225..c870622 100644 --- a/basicswap/basicswap.py +++ b/basicswap/basicswap.py @@ -445,7 +445,7 @@ class BasicSwap(BaseApp, UIApp): ) self._max_check_loop_blocks = self.settings.get("max_check_loop_blocks", 100000) self._bid_expired_leeway = 5 - self._use_direct_message_routes = False + self._use_direct_message_routes = True self.swaps_in_progress = dict() @@ -3981,6 +3981,11 @@ class BasicSwap(BaseApp, UIApp): if self._use_direct_message_routes is False: return None, False + try: + net_i = self.getActiveNetworkInterface(2) + except Exception as e: # noqa: F841 + return None, False + # Look for active route message_route = self.getMessageRoute(1, addr_from, addr_to, cursor=cursor) self.log.debug(f"Using active message route: {message_route}") @@ -3993,7 +3998,6 @@ class BasicSwap(BaseApp, UIApp): if message_route: return message_route.record_id, False - net_i = self.getActiveNetworkInterface(2) cmd_id = net_i.send_command("/connect") response = net_i.wait_for_command_response(cmd_id) connReqInvitation = response["resp"]["connReqInvitation"] diff --git a/basicswap/bin/run.py b/basicswap/bin/run.py index 3d46798..39e9a09 100755 --- a/basicswap/bin/run.py +++ b/basicswap/bin/run.py @@ -122,6 +122,7 @@ def startDaemon(node_dir, bin_dir, daemon_bin, opts=[], extra_config={}): cwd=datadir_path, ), opened_files, + os.path.basename(daemon_bin), ) @@ -152,6 +153,7 @@ def startXmrDaemon(node_dir, bin_dir, daemon_bin, opts=[]): cwd=datadir_path, ), [file_stdout, file_stderr], + os.path.basename(daemon_bin), ) @@ -215,6 +217,7 @@ def startXmrWalletDaemon(node_dir, bin_dir, wallet_bin, opts=[]): cwd=data_dir, ), [wallet_stdout, wallet_stderr], + os.path.basename(wallet_bin), ) @@ -340,7 +343,7 @@ def runClient( ) ) pid = daemons[-1].handle.pid - swap_client.log.info(f"Started Simpelx client {pid}") + swap_client.log.info(f"Started Simplex client {pid}") for c, v in settings["chainclients"].items(): if len(start_only_coins) > 0 and c not in start_only_coins: @@ -569,13 +572,13 @@ def runClient( closed_pids = [] for d in daemons: - swap_client.log.info(f"Interrupting {d.handle.pid}") + swap_client.log.info(f"Interrupting {d.name} {d.handle.pid}") try: d.handle.send_signal( signal.CTRL_C_EVENT if os.name == "nt" else signal.SIGINT ) except Exception as e: - swap_client.log.info(f"Interrupting {d.handle.pid}, error {e}") + swap_client.log.info(f"Interrupting {d.name} {d.handle.pid}, error {e}") for d in daemons: try: d.handle.wait(timeout=120) diff --git a/basicswap/network/simplex_chat.py b/basicswap/network/simplex_chat.py index b43581f..4ef774f 100644 --- a/basicswap/network/simplex_chat.py +++ b/basicswap/network/simplex_chat.py @@ -78,7 +78,7 @@ def startSimplexClient( db_path = os.path.join(data_path, "simplex_client_data") args = [bin_path, "-d", db_path, "-s", server_address, "-p", str(websocket_port)] - if not os.path.exists(db_path): + if not os.path.exists(db_path + "_chat.db"): # Need to set initial profile through CLI # TODO: Must be a better way? init_args = args + ["-e", "/help"] # Run command ro exit client @@ -103,4 +103,5 @@ def startSimplexClient( cwd=data_path, ), opened_files, + "simplex-chat", ) diff --git a/basicswap/util/daemon.py b/basicswap/util/daemon.py index 4a8da8f..430cd60 100644 --- a/basicswap/util/daemon.py +++ b/basicswap/util/daemon.py @@ -6,8 +6,9 @@ class Daemon: - __slots__ = ("handle", "files") + __slots__ = ("handle", "files", "name") - def __init__(self, handle, files): + def __init__(self, handle, files, name): self.handle = handle self.files = files + self.name = name diff --git a/tests/basicswap/extended/test_simplex.py b/tests/basicswap/extended/test_simplex.py index bc7a716..5f3c07a 100644 --- a/tests/basicswap/extended/test_simplex.py +++ b/tests/basicswap/extended/test_simplex.py @@ -446,7 +446,6 @@ class Test(BaseTest): @classmethod def addCoinSettings(cls, settings, datadir, node_id): - settings["networks"] = [ { "type": "simplex", @@ -463,7 +462,7 @@ class Test(BaseTest): swap_clients = self.swap_clients for sc in swap_clients: - sc._use_direct_messages = False + sc._use_direct_message_routes = False assert len(swap_clients[0].active_networks) == 1 assert swap_clients[0].active_networks[0]["type"] == "simplex" @@ -521,7 +520,7 @@ class Test(BaseTest): swap_clients = self.swap_clients for sc in swap_clients: - sc._use_direct_messages = False + sc._use_direct_message_routes = False assert len(swap_clients[0].active_networks) == 1 assert swap_clients[0].active_networks[0]["type"] == "simplex"