michaelWuensch / BitBanana

Lightning Node Management for Android
https://bitbanana.app
MIT License
90 stars 11 forks source link

Cannot connect to LND via Tor #67

Closed djesys closed 5 months ago

djesys commented 5 months ago

Hi there, I´ve been trying very hard to connect to my node over tor. I was using this tutorial: https://github.com/alexbosworth/run-lnd and have LND running and synced. When pasting the generated LNDCONNECT string I am getting "The provided host or port is invalid", no matter if I have Orbot running or not.

in lnd.conf, I have:

[tor] tor.active=1 tor.v3=1 tor.password=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx tlsextradomain=xxxxxxxxxxxxxxxxxxxxxxxxxxxxx.onion

plus all the other default settings from the tutorial.

my /etc/tor/torrc

ControlPort 9051 HashedControlPassword 16:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx CookieAuthentication 1 CookieAuthFileGroupReadable 1 Log notice stdout SOCKSPort 9050

lncli getinfo:

{ "version": "0.17.3-beta commit=v0.17.3-beta", "commit_hash": "13aa7f99248c7ee63989d3b62e0cbfe86d7b0964", "identity_pubkey": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "alias": "YOUR_ALIAS", "color": "#000000", "num_pending_channels": 0, "num_active_channels": 0, "num_inactive_channels": 0, "num_peers": 5, "block_height": 825071, "block_hash": "000000000000000000031cb6b4df6a1238403d07055b05cdac52c126b71dd4f3", "best_header_timestamp": "1704846931", "synced_to_chain": true, "synced_to_graph": true, "testnet": false, "chains": [ { "chain": "bitcoin", "network": "mainnet" } ], "uris": [ "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.onion:9735" ],

port 9735 is OPEN.

LNDCONNECT-STRING: lndconnect://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.onion:9735?cert=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Also no success with ZAP or ZEUS.

Please, what am I missing here, I feel very close. Thanks

michaelWuensch commented 5 months ago

Hi, first of all, Orbot is not needed, BitBanana suports tor natively. The problem is most likely that you are trying to connect on port 9735 which is the port for the lightning peer 2 peer protocol. But what you want to connect to is the api that lnd exposes which is on 10009 for gRPC. Therefore, in BitBanana go to manage nodes and edit the connection settings and change the port to 10009 and save.

djesys commented 5 months ago

Hi again,

I did lndconnect - j, then exchanged clearnet ip in output with my xxxxxxxx.onion address on port 10009 (opened in firewall) .

Pasted that into BitBanana and getting this after a while

Connection failed.

UNAVAILABLE: Response returned from proxy was not successful (expected 2xx, got 502 Bad Gateway (unexpected close)). Response body:

Server:

curl --socks5 localhost:9050 --socks5-hostname localhost:9050 -s https://check.torproject.org/ | cat | grep -m 1 Congratulations | xargs

Congratulations. This browser is configured to use Tor.

Is the certificate connected to my clearnet ip ? Could it be a cert issue ?

Thanks so much

On 11. Jan 2024, at 04:38, Michael Wünsch @.***> wrote:

Hi, first of all, Orbot is not needed, BitBanana suports tor natively. The problem is most likely that you are trying to connect on port 9735 which is the port for the lightning peer 2 peer protocol. But what you want to connect to is the api that lnd exposes which is on 10009 for gRPC. Therefore, in BitBanana got to manage nodes and edit the connection settings and change the port to 10009 and save.

— Reply to this email directly, view it on GitHub https://github.com/michaelWuensch/BitBanana/issues/67#issuecomment-1886497513, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABCPAQXPRTWSXUGDWMG3K63YN6JGZAVCNFSM6AAAAABBT7RYNOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOBWGQ4TONJRGM. You are receiving this because you authored the thread.

djesys commented 5 months ago

Just tried this on the server:

lndconnect --lnddir=/home/.lnd -j @.*** --port 10009 -j

Result:

lndconnect://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%4xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.onion:10009?cert=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Noticed cert is the same.

Pasted into bitbanana

The provided host or port is invalid.

On 11. Jan 2024, at 04:38, Michael Wünsch @.***> wrote:

Hi, first of all, Orbot is not needed, BitBanana suports tor natively. The problem is most likely that you are trying to connect on port 9735 which is the port for the lightning peer 2 peer protocol. But what you want to connect to is the api that lnd exposes which is on 10009 for gRPC. Therefore, in BitBanana got to manage nodes and edit the connection settings and change the port to 10009 and save.

— Reply to this email directly, view it on GitHub https://github.com/michaelWuensch/BitBanana/issues/67#issuecomment-1886497513, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABCPAQXPRTWSXUGDWMG3K63YN6JGZAVCNFSM6AAAAABBT7RYNOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOBWGQ4TONJRGM. You are receiving this because you authored the thread.

michaelWuensch commented 5 months ago

Hi, when connecting over tor, the certificate isn't even needed. Tor already ensures you are connected with the correct service. Therefore when connecting over Tor BitBanana does not even check the cert. What is needed though is the admin macaroon (macaroon = fancy cookie), which defines what access the API user has. Admin macaroon grants access to everything. So in your lndconnect command you have to add the admin macaroon path.

djesys commented 5 months ago

Hi, so I added this to /etc/tor/torrc

HiddenServiceDir /var/lib/tor/lnd HiddenServicePort 10009 127.0.0.1:10009

and used this string to create an lndconnect string:

lndconnect --adminmacaroonpath=/home/user/.lnd/data/chain/bitcoin/mainnet/admin.macaroon --port=10009 --host=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.onion -j

The result I pasted into bitbanana. Response continues

Connection failed.

UNAVAILABLE: Response returned from proxy was not successful (expected 2xx, got 502 Bad Gateway (unexpected close)). Response body:

nmap: 9050/tcp open tor-socks 9051/tcp open tor-control 9735/tcp open unknown 10009/tcp open swdtp-sv

curl --socks5 localhost:9050 --socks5-hostname localhost:9050 -s https://check.torproject.org/ | cat | grep -m 1 Congratulations | xargs Congratulations. This browser is configured to use Tor.

Firewall 10009 is open, even though propably not necessary.

I am out of ideas now.

michaelWuensch commented 5 months ago

Hm, me too. I myself actually use preconfigured setups like Start9 or Umbrel instead of setting up everything on my own. Therefore I don't have to much experience with it. What I can see from your posts looks correct. In general Tor connection is not very reliable. Connecting to my nodes with tor often works, then sometimes it doesn't for a few hours or so without me changing anything. I cannot remember though if that error message you get was one of the temporary failures. I personally switched to using Tailscale VPN to connect to my nodes. The user experience is so much better as it is way faster and much more reliable. But of course not as private.

I guess it is still the same with ZEUS? (For ZEUS you need to use port 8080 as ZEUS only supports REST, not gRPC)

djesys commented 5 months ago

I can confirm connecting to clearnet IP works. So, it´s something Tor-related. I will give tailscale a shot, just hoping the setup is straight forward.