cryptoadvance / specter-desktop

A desktop GUI for Bitcoin Core optimised to work with hardware wallets
MIT License
802 stars 238 forks source link

Connection to local electrum server tries to use SOCKS Proxy even when Tor is disabled #2321

Open windsok opened 1 year ago

windsok commented 1 year ago

Describe the bug I have an electrs electrum server running on my local network on the same subnet (192.168.1.X).

When I attempt to connect to this electrum server with specter-desktop 2.0.1 it appears to try to use a SOCKS proxy on 127.0.0.1:9050 even though Tor is disabled in the settings.

To Reproduce Steps to reproduce the behavior:

  1. Start specter-desktop
  2. Check that Tor is disabled in the Tor settings
  3. Add a new electrum connection to a electrum server running on a local private network (eg 192.168.1.X)
  4. Observe that the connection fails, and the error logs indicate that it is attempting to connect via a SOCKS proxy on 127.0.0.1:9050

Expected behavior Specter connects directly to the Electrum server and does not try to use the SOCKS proxy

Additional context

2023-04-12T20:21:42.002Z [info] : stderr-SPECTERD: INFO in elsock: (re-)creating socket ...

2023-04-12T20:21:42.003Z [info] : stderr-SPECTERD: INFO in elsock: Connecting to 192.168.1.111:50001

2023-04-12T20:21:42.003Z [info] : stderr-SPECTERD: ERROR in elsock: Error connecting to SOCKS5 proxy localhost:9050: [Errno 111] Connection refused
Traceback (most recent call last):
  File "[socks.py](http://socks.py/)", line 787, in connect
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "cryptoadvance/spectrum/elsock.py", line 201, in _establish_socket
  File "[socks.py](http://socks.py/)", line 47, in wrapper
  File "[socks.py](http://socks.py/)", line 800, in connect
socks.ProxyConnectionError: Error connecting to SOCKS5 proxy localhost:9050: [Errno 111] Connection refused
emmanuelrosa commented 1 year ago

I have a local electrs server and was unable to connect to it. I think the issue in my case is that SOCKS should not be used for local connections (ex. 127.0.0.1, localhost).

I got Specter to connect to my local electrs by editing ~/.specter/config.json and setting _proxyurl to an empty string.

I do want it to use a SOCKS proxy for non-local connections. So let's see how this goes.

BitcoinMechanic commented 1 year ago

Did this work on Specter 2.0.0? I have found that I cannot get Specter to connect to a local electrs since version after 2.0.0, but that it worked great on 2.0.0 itself.

emmanuelrosa commented 1 year ago

I just tried Specter 2.0.2-pre2 and it doesn't have this problem.