github.com/decred/dcrlnd@v0.7.6/docs/watchtower.md (about)

     1  # Private Altruist Watchtowers
     2  
     3  As of v0.7.0, `lnd` supports the ability to run a private, altruist watchtower
     4  as a fully-integrated subsystem of `lnd`. Watchtowers act as a second line of
     5  defense in responding to malicious or accidental breach scenarios in the event
     6  that the client’s node is offline or unable to respond at the time of a breach,
     7  offering greater degree of safety to channel funds.
     8  
     9  In contrast to a _reward watchtower_ which demand a portion of the channel funds
    10  as a reward for fulfilling its duty, an _altruist watchtower_ returns all of the
    11  victim’s funds (minus on-chain fees) without taking a cut. Reward watchtowers
    12  will be enabled in a subsequent release, though are still undergoing further
    13  testing and refinement.
    14  
    15  In addition, `lnd` can now be configured to operate as a _watchtower client_,
    16  backing up encrypted breach-remedy transactions (aka. justice transactions) to
    17  other altruist watchtowers. The watchtower stores fixed-size, encrypted blobs
    18  and is only able to decrypt and publish the justice transaction after the
    19  offending party has broadcast a revoked commitment state. Client communications
    20  with a watchtower are encrypted and authenticated using ephemeral keypairs,
    21  mitigating the amount of tracking the watchtower can perform on its clients
    22  using long-term identifiers.
    23  
    24  Note that we have chosen to deploy a restricted set of features in this release
    25  that can begin to provide meaningful security to `lnd` users. Many more
    26  watchtower-related features are nearly complete or have meaningful progress, and
    27  we will continue to ship them as they receive further testing and become safe to
    28  release.
    29  
    30  Note: *For now, watchtowers will only backup the `to_local` and `to_remote` outputs
    31  from revoked commitments; backing up HTLC outputs is slated to be deployed in a
    32  future release, as the protocol can be extended to include the extra signature
    33  data in the encrypted blobs.*
    34  
    35  ## Configuring a Watchtower
    36  
    37  To set up a watchtower, command line users should compile in the
    38  `watchtowerrpc` subserver, which will offer the ability to interface with the
    39  tower via gRPC or `lncli`.
    40  
    41  The minimal configuration needed to activate the tower is `watchtower.active=1`.
    42  
    43  Retrieving information about your tower’s configurations can be done using
    44  `lncli tower info`:
    45  
    46  ```
    47  🏔 lncli tower info
    48  {
    49          "pubkey": "03281d603b2c5e19b8893a484eb938d7377179a9ef1a6bca4c0bcbbfc291657b63",
    50          "listeners": [
    51                  "[::]:9911"
    52          ],
    53          "uris": null,
    54  }
    55  ```
    56  
    57  The entire set of watchtower configuration options can be found using 
    58  `lnd -h`:
    59  
    60  ```
    61  watchtower:
    62        --watchtower.active                                     If the watchtower should be active or not
    63        --watchtower.towerdir=                                  Directory of the watchtower.db (default: $HOME/.lnd/data/watchtower)
    64        --watchtower.listen=                                    Add interfaces/ports to listen for peer connections
    65        --watchtower.externalip=                                Add interfaces/ports where the watchtower can accept peer connections
    66        --watchtower.readtimeout=                               Duration the watchtower server will wait for messages to be received before hanging up on client connections
    67        --watchtower.writetimeout=                              Duration the watchtower server will wait for messages to be written before hanging up on client connections
    68  ```
    69  
    70  ### Listening Interfaces
    71  
    72  By default, the watchtower will listen on `:9911` which specifies port `9911`
    73  listening on all available interfaces. Users may configure their own listeners
    74  via the `--watchtower.listen=` option. You can verify your configuration by
    75  checking the `"listeners"` field in `lncli tower info`. If you're having trouble
    76  connecting to your watchtower, ensure that `<port>` is open or your proxy is
    77  properly configured to point to an active listener.
    78  
    79  ### External IP Addresses
    80  
    81  Additionally, users can specify their tower’s external IP address(es) using
    82  `watchtower.externalip=`, which will expose the full tower URIs
    83  (pubkey@host:port) over RPC or `lncli tower info`: 
    84  
    85  ```
    86          ...
    87          "uris": [
    88                  "03281d603b2c5e19b8893a484eb938d7377179a9ef1a6bca4c0bcbbfc291657b63@1.2.3.4:9911"
    89          ]
    90  ```
    91  
    92  The watchtower's URIs can be given to clients in order to connect and use the
    93  tower with the following command:
    94  
    95  ```
    96  🏔 lncli wtclient add 03281d603b2c5e19b8893a484eb938d7377179a9ef1a6bca4c0bcbbfc291657b63@1.2.3.4:9911
    97  ```
    98  
    99  If the watchtower's clients will need remote access, be sure to either:
   100   - Open port 9911 or a port chosen via `watchtower.listen`.
   101   - Use a proxy to direct traffic from an open port to the watchtower's listening
   102     address.
   103  
   104  ### Tor Hidden Services
   105  
   106  Watchtowers have tor hidden service support and can automatically generate a
   107  hidden service on startup with the following flags:
   108  
   109  ```
   110  🏔 lnd --tor.active --tor.v3 --watchtower.active
   111  ```
   112  
   113  The onion address is then shown in the "uris" field when queried with `lncli tower info`:
   114  
   115  ```
   116  ...
   117  "uris": [
   118          "03281d603b2c5e19b8893a484eb938d7377179a9ef1a6bca4c0bcbbfc291657b63@bn2kxggzjysvsd5o3uqe4h7655u7v2ydhxzy7ea2fx26duaixlwuguad.onion:9911"
   119  ]
   120  ```
   121  
   122  Note: *The watchtower’s public key is distinct from `lnd`’s node public key. For
   123  now this acts as a soft whitelist as it requires clients to know the tower’s
   124  public key in order to use it for backups before more advanced whitelisting
   125  features are implemented. We recommend NOT disclosing this public key openly,
   126  unless you are prepared to open your tower up to the entire Internet.*
   127  
   128  ### Watchtower Database Directory
   129  
   130  The watchtower's database can be moved using the `watchtower.towerdir=`
   131  configuration option. Note that a trailing `/bitcoin/mainnet/watchtower.db`
   132  will be appended to the chosen directory to isolate databases for different
   133  chains, so setting `watchtower.towerdir=/path/to/towerdir` will yield a
   134  watchtower database at `/path/to/towerdir/bitcoin/mainnet/watchtower.db`.
   135  
   136  On Linux, for example, the default watchtower database will be located at:
   137  
   138  ```
   139  /$USER/.lnd/data/watchtower/bitcoin/mainnet/watchtower.db
   140  ```
   141  
   142  ## Configuring a Watchtower Client
   143  
   144  In order to set up a watchtower client, you’ll need two things:
   145  
   146  1. The watchtower client must be enabled with the `--wtclient.active` flag.
   147  
   148  ```
   149  🏔 lnd --wtclient.active
   150  ```
   151  
   152  2. The watchtower URI of an active watchtower.
   153  
   154  ```
   155  🏔 lncli wtclient add 03281d603b2c5e19b8893a484eb938d7377179a9ef1a6bca4c0bcbbfc291657b63@1.2.3.4:9911
   156  ```
   157  
   158  Multiple watchtowers can be configured through this method.
   159  
   160  ### Justice Fee Rates
   161  
   162  Users may optionally configure the fee rate of justice transactions by setting
   163  the `wtclient.sweep-fee-rate` option, which accepts values in sat/byte. The
   164  default value is 10 sat/byte, though users may choose to target higher rates to
   165  offer greater priority during fee-spikes. Modifying the `sweep-fee-rate` will
   166  be applied to all new updates after the daemon has been restarted.
   167  
   168  ### Monitoring
   169  
   170  With the addition of the `lncli wtclient` command, users are now able to
   171  interact with the watchtower client directly to obtain/modify information about
   172  the set of registered watchtowers.
   173  
   174  As as example, with the `lncli wtclient tower` command, you can obtain the
   175  number of sessions currently negotiated with the watchtower added above and
   176  determine whether it is currently being used for backups through the
   177  `active_session_candidate` value.
   178  
   179  ```
   180  🏔 lncli wtclient tower 03281d603b2c5e19b8893a484eb938d7377179a9ef1a6bca4c0bcbbfc291657b63
   181  {
   182  	"pubkey": "03281d603b2c5e19b8893a484eb938d7377179a9ef1a6bca4c0bcbbfc291657b63",
   183  	"addresses": [
   184  		"1.2.3.4:9911"
   185  	],
   186  	"active_session_candidate": true,
   187  	"num_sessions": 1,
   188  	"sessions": []
   189  }
   190  ```
   191  
   192  To obtain information about the watchtower's sessions, users can use the
   193  `--include_sessions` flag.
   194  
   195  ```
   196  🏔 lncli wtclient tower --include_sessions 03281d603b2c5e19b8893a484eb938d7377179a9ef1a6bca4c0bcbbfc291657b63
   197  {
   198          "pubkey": "03281d603b2c5e19b8893a484eb938d7377179a9ef1a6bca4c0bcbbfc291657b63",
   199          "addresses": [
   200                  "1.2.3.4:9911"
   201          ],
   202          "active_session_candidate": true,
   203          "num_sessions": 1,
   204          "sessions": [
   205                  {
   206                          "num_backups": 0,
   207                          "num_pending_backups": 0,
   208                          "max_backups": 1024,
   209                          "sweep_sat_per_byte": 10
   210                  }
   211          ]
   212  }
   213  ```
   214  
   215  The entire set of watchtower client configuration options can be found with
   216  `lncli wtclient -h`:
   217  
   218  ```
   219  NAME:
   220     lncli wtclient - Interact with the watchtower client.
   221  
   222  USAGE:
   223     lncli wtclient command [command options] [arguments...]
   224  
   225  COMMANDS:
   226       add     Register a watchtower to use for future sessions/backups.
   227       remove  Remove a watchtower to prevent its use for future sessions/backups.
   228       towers  Display information about all registered watchtowers.
   229       tower   Display information about a specific registered watchtower.
   230       stats   Display the session stats of the watchtower client.
   231       policy  Display the active watchtower client policy configuration.
   232  
   233  OPTIONS:
   234     --help, -h  show help
   235  ```