From 5ef416593748d9f2aac566df8b6ea9f2f7fbae97 Mon Sep 17 00:00:00 2001 From: callebtc <93376500+callebtc@users.noreply.github.com> Date: Sun, 30 Oct 2022 01:10:20 +0200 Subject: [PATCH] warning --- cashu/tor/tor.py | 10 ++++++++++ cashu/wallet/wallet.py | 10 ++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/cashu/tor/tor.py b/cashu/tor/tor.py index 8adf1c7..fbadfd8 100755 --- a/cashu/tor/tor.py +++ b/cashu/tor/tor.py @@ -31,7 +31,15 @@ class TorProxy: logger.debug("Starting") self.run_daemon() + def check_platform(self): + if platform.system() == "Linux": + if platform.machine() != "x86_64": + return False + return True + def run_daemon(self): + if not self.check_platform(): + return cmd = [ f"{self.tor_path()}", "--defaults-torrc", @@ -92,6 +100,8 @@ class TorProxy: return self.tor_proc and self.tor_proc.poll() is None def wait_until_startup(self, verbose=False): + if not self.check_platform(): + return if self.is_port_open(): return if self.tor_proc is None: diff --git a/cashu/wallet/wallet.py b/cashu/wallet/wallet.py index c01869f..28ef712 100644 --- a/cashu/wallet/wallet.py +++ b/cashu/wallet/wallet.py @@ -62,10 +62,16 @@ class LedgerAPI: def _set_requests(self): s = requests.Session() s.headers.update({"Client-version": VERSION}) + socks_host, socks_port = None, None if TOR: tor = TorProxy(keep_alive=True) - tor.wait_until_startup(verbose=True) - socks_host, socks_port = "localhost", 9050 + if not tor.check_platform(): + print( + "WARNING: The built-in Tor bundle is not supported on your System. Please install Tor and set the SOCKS_HOST and SOCKS_PORT variables in your Cashu configuration .env file (recommended) or turn off tor by setting TOR=false (not recommended)." + ) + else: + tor.wait_until_startup(verbose=True) + socks_host, socks_port = "localhost", 9050 else: socks_host, socks_port = SOCKS_HOST, SOCKS_PORT