Set up an LND watchtower and connect a client

A watchtower monitors the bitcoin blockchain for any transaction attempting to steal from its client by closing a channel with a previous, invalid state. If a breach is found the watchtower immediately broadcasts a punisher transaction moving all funds in the channel to the on-chain wallet of its client.

If there are two nodes in your control from lnd v0.7.0 you can set them up to look out for each other. Best to be done with nodes in two separate physical location so any unexpected loss of contact can be covered for.

Update LND

Check https://github.com/lightningnetwork/lnd/releases/arrow-up-right for the latest version and release notes. Update manuallyarrow-up-right or use an automated helper scriptarrow-up-right to update lnd on a RaspiBlitz or a compatible system.

Set up the Watchtower

Run the commands in the node`s terminal # stands for $ sudo

  • Change the lnd.conf:

    # nano /mnt/hdd/lnd/lnd.conf

  • insert the lines on the end of the file:

    [Watchtower]
    watchtower.active=1
    • the watchtower listens on the port 9911 by default, but can be set to any other unused port with: watchtower.listen=0.0.0.0:PORT in the config file.

    • The IP address 0.0.0.0 is used to accept connections from everywhere (default setting)

  • allow the port through the firewall: # ufw allow 9911 comment "watchtower" # ufw enable

  • restart lnd # systemctl restart lnd

  • forward the port 9911 on the router

  • Check in the log if the service is working: # tail -n 10000 /mnt/hdd/lnd/logs/bitcoin/mainnet/lnd.log

    Sample log output:

    2019-06-21 09:08:58.544 [INF] WTWR: Starting watchtower
    2019-06-21 09:08:58.544 [INF] WTWR: Starting lookout
    2019-06-21 09:08:58.544 [INF] WTWR: Starting lookout from chain tip
    2019-06-21 09:08:58.544 [INF] WTWR: Lookout started successfully
    2019-06-21 09:08:58.545 [INF] WTWR: Starting watchtower server
    2019-06-21 09:08:58.544 [INF] DISC: Attempting to bootstrap with: Authenticated Channel Graph
    2019-06-21 09:08:58.545 [INF] CMGR: Server listening on 127.0.0.1:9911
    2019-06-21 09:08:58.545 [INF] NTFN: New block epoch subscription
    2019-06-21 09:08:58.545 [INF] WTWR: Watchtower server started successfully
    2019-06-21 09:08:58.546 [INF] WTWR: Watchtower started successfully
    2019-06-21 09:08:58.547 [INF] CHBU: Swapping old multi backup file from /home/bitcoin/.lnd/data/chain/bitcoin/mainnet/temp-dont-use.backup to /home/bitcoin/.lnd/data/chain/bitcoin/mainnet/channel.backup
    2019-06-21 09:08:58.575 [INF] DISC: Obtained 3 addrs to bootstrap network
    2019-06-21 13:10:27.014 [INF] WTWR: Watchtower started successfully
    2019-06-21 13:14:50.743 [INF] WTWR: Accepted incoming peer 02b5792e533ad17fc77db13093ad84ea304c5069018f97083e3a8c6a2eac95a63f@171.25.193.25:34413
    2019-06-21 13:14:51.074 [INF] WTWR: Accepted session for 02b5792e533ad17fc77db13093ad84ea304c5069018f97083e3a8c6a2eac95a63f
    2019-06-21 13:14:51.074 [INF] WTWR: Releasing incoming peer 02b5792e533ad17fc77db13093ad84ea304c5069018f97083e3a8c6a2eac95a63f@171.25.193.25:34413

    Filter the relevant messages continuously with (press CTRL+C to exit): # tail -f -n 10000 /mnt/hdd/lnd/logs/bitcoin/mainnet/lnd.log | grep WTWR

  • Take note of the pubkey from: $ lncli tower info

    The watchtower`s pubkey is distinct from the pubkey of the lnd node.

Set up the node to be monitored (the watchtower client)

  • Change the lnd.conf:

    # nano /mnt/hdd/lnd/lnd.conf

  • insert the lines on the end of the file:

    Add a watchtower from the command line (can add multiple one-by-one):

  • Use the watchtower-pubkey noted previously from $ lncli tower info.

  • For a clearnet client the host needs to be the clearnet IP (or dynamicDNS) of the watchtower even if the watchtower is running behind Tor.

  • Restart lnd # systemctl restart lnd

  • Check in the log if the service is working: # tail -n 100 /mnt/hdd/lnd/logs/bitcoin/mainnet/lnd.log

    Sample log output:

    Filter the relevant messages continuously with (press CTRL+C to exit): # tail -f -n 10000 /mnt/hdd/lnd/logs/bitcoin/mainnet/lnd.log | grep WTCL

    To have more information in the log add the line to the lnd.conf file:

    or run the command on the go: lncli debuglevel --level=WTWR=debug,WTCL=debug

    Sample result in the log:

    Sit back and enjoy that now there is no way to cheat your node even when it is offline!

Setup for nodes behind Tor

Both nodes (the watchtower and the client) must be behind Tor to be able to communicate.

Tor Watchtower setup

  • Change the lnd.conf:

    # nano /mnt/hdd/lnd/lnd.conf

  • insert the lines on the end of the file:

  • Edit the Tor config file of the watchtower: # nano /etc/tor/torrc

    add the lines:

  • restart Tor and lnd with systemctl: # systemctl restart tor # systemctl restart lnd

  • Take note of the watchtower's onion address by running: # cat /mnt/hdd/tor/lndWT9911/hostname

  • Take note of the watchtower-pubkey by running $ lncli tower info

  • Filter the log continuously with (CTRL+C to exit): # tail -f -n 10000 /mnt/hdd/lnd/logs/bitcoin/mainnet/lnd.log | grep WTWR

    Example output on the watchtower side:

Tor Watchtower Client setup

  • Change the lnd.conf:

    # nano /mnt/hdd/lnd/lnd.conf

  • insert the lines on the end of the file:

  • Add a watchtower from the command line (can add multiple one-by-one):

    • The details of a test node are prefilled. Connections are welcome, but there is no guarantee for this service to stay online.

    • Use the watchtower-pubkey noted previously from $ lncli tower info.

    • The host is watchtower's .onion address noted previously from: # cat /mnt/hdd/tor/lndWT9911/hostname

  • restart lnd with systemctl: # systemctl restart lnd

  • Check which watchtowers are listening: $ lncli wtclient towers

    Example output:

  • Filter the log continuously with (CTRL+C to exit): # tail -f -n 10000 /mnt/hdd/lnd/logs/bitcoin/mainnet/lnd.log | grep WTCL

    Example output on the client side:

Remove inactive towers

  • Run in the terminal:

More info:

https://github.com/lightningnetwork/lnd/blob/master/docs/watchtower.mdarrow-up-right

Latest lnd release notes: https://github.com/lightningnetwork/lnd/releasesarrow-up-right

https://thebitcoinnews.com/watchtowers-are-coming-to-lightning/arrow-up-right

https://bitcoinops.org/en/newsletters/2019/06/19/arrow-up-right

Will O`Beirne shows in this article (and GitHub repo) how to demonstrate a breach and the actions of a watchtower on a simulated network: https://medium.com/@wbobeirne/testing-out-watchtowers-with-a-simulated-breach-f1ad22c01112arrow-up-right

SLP83 Conner Fromknecht – Bitcoin Lightning Watchtowers in depth podcast: https://stephanlivera.com/episode/83arrow-up-right transcript: http://diyhpl.us/wiki/transcripts/stephan-livera-podcast/2019-06-24-conner-fromknecht-stephan-livera/arrow-up-right

Check for some altruistic watchtowers and share your own: https://github.com/openoms/lightning-node-management/issues/4arrow-up-right

Last updated