From 90a162f0ea3fda9d8e639718a7f49e59ebc78950 Mon Sep 17 00:00:00 2001 From: nahuhh <50635951+nahuhh@users.noreply.github.com> Date: Sat, 12 Jul 2025 04:40:50 +0000 Subject: [PATCH] wow: reuse threadPollXMRChainstate & monerod_proxy_config --- basicswap/basicswap.py | 28 +--------------------------- basicswap/bin/prepare.py | 38 +++++--------------------------------- 2 files changed, 6 insertions(+), 60 deletions(-) diff --git a/basicswap/basicswap.py b/basicswap/basicswap.py index 1ff4327..7b03eb7 100644 --- a/basicswap/basicswap.py +++ b/basicswap/basicswap.py @@ -259,32 +259,6 @@ def threadPollXMRChainState(swap_client, coin_type): ) # Random to stagger updates -def threadPollWOWChainState(swap_client, coin_type): - ci = swap_client.ci(coin_type) - cc = swap_client.coin_clients[coin_type] - while not swap_client.chainstate_delay_event.is_set(): - try: - new_height: int = ci.getChainHeight() - if new_height != cc["chain_height"]: - swap_client.log.debug( - f"New {ci.ticker()} block at height: {new_height}" - ) - with swap_client.mxDB: - cc["chain_height"] = new_height - - checkAndNotifyBalanceChange( - swap_client, coin_type, ci, cc, new_height, "block" - ) - - except Exception as e: - swap_client.log.warning( - f"threadPollWOWChainState {ci.ticker()}, error: {e}" - ) - swap_client.chainstate_delay_event.wait( - random.randrange(20, 30) - ) # Random to stagger updates - - def threadPollChainState(swap_client, coin_type): ci = swap_client.ci(coin_type) cc = swap_client.coin_clients[coin_type] @@ -1150,7 +1124,7 @@ class BasicSwap(BaseApp, UIApp): thread_func = { Coins.XMR: threadPollXMRChainState, - Coins.WOW: threadPollWOWChainState, + Coins.WOW: threadPollXMRChainState, }.get( c, threadPollChainState ) # default case diff --git a/basicswap/bin/prepare.py b/basicswap/bin/prepare.py index 898d493..25091b9 100755 --- a/basicswap/bin/prepare.py +++ b/basicswap/bin/prepare.py @@ -356,21 +356,6 @@ monero_wallet_rpc_proxy_config = [ # 'daemon-ssl-allow-any-cert=1', moved to startup flag ] -wownerod_proxy_config = [ - f"proxy={TOR_PROXY_HOST}:{TOR_PROXY_PORT}", - "proxy-allow-dns-leaks=0", - "no-igd=1", # Disable UPnP port mapping - "hide-my-port=1", # Don't share the p2p port - "p2p-bind-ip=127.0.0.1", # Don't broadcast ip - "in-peers=0", # Changes "error" in log to "incoming connections disabled" - "out-peers=24", - f"tx-proxy=tor,{TOR_PROXY_HOST}:{TOR_PROXY_PORT},disable_noise,16", # Outgoing tx relay to onion -] - -wownero_wallet_rpc_proxy_config = [ - # 'daemon-ssl-allow-any-cert=1', moved to startup flag -] - default_socket = socket.socket default_socket_timeout = socket.getdefaulttimeout() default_socket_getaddrinfo = socket.getaddrinfo @@ -1223,16 +1208,12 @@ def prepareDataDir(coin, settings, chain, particl_mnemonic, extra_opts={}): if coin == "monero": if XMR_RPC_USER != "": fp.write(f"rpc-login={XMR_RPC_USER}:{XMR_RPC_PWD}\n") - if tor_control_password is not None: - for opt_line in monerod_proxy_config: - fp.write(opt_line + "\n") - if coin == "wownero": if WOW_RPC_USER != "": fp.write(f"rpc-login={WOW_RPC_USER}:{WOW_RPC_PWD}\n") - if tor_control_password is not None: - for opt_line in wownerod_proxy_config: - fp.write(opt_line + "\n") + if tor_control_password is not None: + for opt_line in monerod_proxy_config: + fp.write(opt_line + "\n") wallets_dir = core_settings.get("walletsdir", data_dir) if not os.path.exists(wallets_dir): @@ -1567,27 +1548,18 @@ def modify_tor_config( # Disable tor first for line in fp_in: skip_line: bool = False - if coin == "monero": + if coin in ("wownero", "monero"): for opt_line in monerod_proxy_config: setting: str = opt_line[0 : opt_line.find("=") + 1] if line.startswith(setting): skip_line = True break - if coin == "wownero": - for opt_line in wownerod_proxy_config: - setting: str = opt_line[0 : opt_line.find("=") + 1] - if line.startswith(setting): - skip_line = True - break if not skip_line: fp.write(line) if enable: - if coin == "monero": + if coin in ("wownero", "monero"): for opt_line in monerod_proxy_config: fp.write(opt_line + "\n") - if coin == "wownero": - for opt_line in wownerod_proxy_config: - fp.write(opt_line + "\n") with open(wallet_conf_path, "w") as fp: with open(wallet_conf_path + ".last") as fp_in: