Change tor

Time: 5 minutes

Tor needs a few modifications so that you can communicate with LND from the outside. This way you can connect a mobile wallet to your Lightning node and use it anywhere.

Notice. As soon as someone gets hold of your macaroon files, your funds are no longer safe. You can also skip the Tor part and only use Lightning when you are on the same network as your node. Or use DDNS.

Open torrc:

sudo nano /etc/tor/torrc

In the torrc file (we have previously been here), add the following lines after what is already there.

SOCKSPort 9050
HiddenServiceDir /var/lib/tor/lightning/rest
HiddenServiceVersion 3
HiddenServicePort 8080 127.0.0.1:8080
HiddenServiceDir /var/lib/tor/lightning/rpc
HiddenServiceVersion 3
HiddenServicePort 10009 127.0.0.1:10009

Save the file with the key combination Ctrl + X. Enter Y in response to the prompt to save.

Create directories with:

sudo mkdir /var/lib/tor/lightning
sudo mkdir /var/lib/tor/lightning/rest
sudo mkdir /var/lib/tor/lightning/rpc

Give the appropriate permissions with:

sudo chown -R debian-tor:debian-tor /var/lib/tor/lightning/rest
sudo chown -R debian-tor:debian-tor /var/lib/tor/lightning/rpc
sudo chmod 700 /var/lib/tor/lightning/rest
sudo chmod 700 /var/lib/tor/lightning/rpc

Tor should now be restarted.

sudo systemctl restart tor

Onion addresses

You get the onion addresses with:

sudo cat /var/lib/tor/lightning/rest/hostname
sudo cat /var/lib/tor/lightning/rpc/hostname