github.com/decred/dcrlnd@v0.7.6/docs/INSTALL.md (about) 1 # Table of Contents 2 * [Installation](#installation) 3 * [Preliminaries](#preliminaries) 4 * [Installing dcrlnd](#installing-dcrlnd) 5 * [Available Backend Operating Modes](#available-backend-operating-modes) 6 * [dcrd Options](#dcrd-options) 7 * [Using dcrd](#using-dcrd) 8 * [Installing dcrd](#installing-dcrd) 9 * [Starting dcrd](#starting-dcrd) 10 * [Running dcrlnd using the dcrd backend](#running-dcrlnd-using-the-dcrd-backend) 11 * [Macaroons](#macaroons) 12 * [Network Reachability](#network-reachability) 13 * [Simnet vs. Testnet Development](#simnet-vs-testnet-development) 14 * [Creating an dcrlnd.conf (Optional)](#creating-an-dcrlndconf-optional) 15 16 # Installation 17 18 ### Preliminaries 19 In order to work with [`dcrlnd`](https://github.com/decred/dcrlnd), 20 the following build dependencies are required: 21 22 * **Go:** `dcrlnd` is written in Go. To install, run one of the following commands: 23 24 25 **Note**: The minimum version of Go supported is Go 1.19. We recommend that 26 users use the latest version of Go, which at the time of writing is 27 [`1.20`](https://blog.golang.org/go1.20). 28 29 30 On Linux: 31 ``` 32 sudo apt-get install golang-1.19-go 33 ``` 34 > Note that golang-1.19-go puts binaries in /usr/lib/go-1.19/bin. If you want them on your PATH, you need to make that change yourself. Alternatively, you can run: 35 ``` 36 sudo ln -s /usr/lib/go-1.19/bin/go /usr/local/bin/go 37 ``` 38 39 On Mac OS X: 40 ``` 41 brew install go 42 ``` 43 44 On FreeBSD: 45 ``` 46 pkg install go 47 ``` 48 49 Alternatively, one can download the pre-compiled binaries hosted on the 50 [golang download page](https://golang.org/dl/). If one seeks to install 51 from source, then more detailed installation instructions can be found 52 [here](http://golang.org/doc/install). 53 54 At this point, you should set your `$GOPATH` environment variable, which 55 represents the path to your workspace. By default, `$GOPATH` is set to 56 `~/go`. You will also need to add `$GOPATH/bin` to your `PATH`. This ensures 57 that your shell will be able to detect the binaries you install. 58 59 ```bash 60 export GOPATH=~/gocode 61 export PATH=$PATH:$GOPATH/bin 62 ``` 63 64 We recommend placing the above in your .bashrc or in a setup script so that 65 you can avoid typing this every time you open a new terminal window. 66 67 * **go modules:** This project uses [go modules](https://github.com/golang/go/wiki/Modules) 68 to manage dependencies as well as to provide *reproducible builds*. 69 70 Usage of go modules (with go 1.19) means that you no longer need to clone 71 `dcrlnd` into your `$GOPATH` for development purposes. Instead, your 72 `dcrlnd` repo can now live anywhere! 73 74 ### Installing dcrlnd 75 76 With the preliminary steps completed, to install `dcrlnd`, `dcrlncli`, and all 77 related dependencies run the following commands: 78 ``` 79 git clone https://github.com/decred/dcrlnd 80 cd dcrlnd 81 go install ./cmd/dcrlnd 82 go install ./cmd/dcrlncli 83 ``` 84 85 The command above will install the current _master_ branch of `dcrlnd`. If you 86 wish to install a tagged release of `dcrlnd` (as the master branch can at times be 87 unstable), then [visit then release page to locate the latest 88 release](https://github.com/decred/dcrlnd/releases). Assuming the name 89 of the release is `v0.x.x`, then you can compile this release from source with 90 a small modification to the above command: 91 ``` 92 git clone https://github.com/decred/dcrlnd 93 cd dcrlnd 94 git checkout v0.x.x 95 go install ./cmd/dcrlnd 96 go install ./cmd/dcrlncli 97 ``` 98 99 100 **NOTE**: Our instructions still use the `$GOPATH` directory from prior 101 versions of Go, but with go 1.11, it's now possible for `dcrlnd` to live 102 _anywhere_ on your file system. 103 104 Alternatively, if you want to automatically include commit metadata on your 105 binary (which might help debugging issues or keeping track of things when 106 running multiple versions simultaneously) you can use `make`: 107 108 ``` 109 make install 110 111 On FreeBSD, use gmake instead of make. 112 113 Alternatively, if one doesn't wish to use `make`, then the `go` commands can be 114 used directly: 115 ```shell 116 ⛰ go install -v ./... 117 >>>>>>> f99cf4f7c (multi: Remove GO111MODULE env variable in Makefile) 118 ``` 119 120 **Updating** 121 122 To update your version of `dcrlnd` to the latest version run the following 123 commands: 124 ``` 125 cd $GOPATH/src/github.com/decred/dcrlnd 126 git pull 127 go install ./cmd/dcrlnd 128 go install ./cmd/dcrlncli 129 ``` 130 131 **Tests** 132 133 To check that `dcrlnd` was installed properly run the following command: 134 ``` 135 make check 136 ``` 137 138 # Available Backend Operating Modes 139 140 In order to run, `dcrlnd` requires, that the user specify a chain backend. At 141 the time of writing of this document, only the `dcrd` backend can be used. We 142 currently *require* `--txindex` when running with `dcrd`. 143 144 145 The set of arguments for each of the backend modes is as follows: 146 147 ## dcrd Options 148 ``` 149 dcrd: 150 --dcrd.dir= The base directory that contains the node's data, logs, configuration file, etc. (default: /Users/roasbeef/Library/Application Support/Dcrd) 151 --dcrd.rpchost= The daemon's rpc listening address. If a port is omitted, then the default port for the selected chain parameters will be used. (default: localhost) 152 --dcrd.rpcuser= Username for RPC connections 153 --dcrd.rpcpass= Password for RPC connections 154 --dcrd.rpccert= File containing the daemon's certificate file (default: /Users/roasbeef/Library/Application Support/Dcrd/rpc.cert) 155 --dcrd.rawrpccert= The raw bytes of the daemon's PEM-encoded certificate chain which will be used to authenticate the RPC connection. 156 ``` 157 158 ## Using dcrd 159 160 ### Installing dcrd 161 162 Use the official [dcrd install 163 instructions](https://github.com/decred/dcrd/#installing-and-updating), 164 preferably with one of the release-worthy builds. 165 166 Alternatively, when setting up a new machine for testing you can use `make` to 167 install a dcrd version that is compatible with dcrlnd: 168 169 ``` 170 make dcrd 171 ``` 172 173 ### Starting dcrd 174 175 Running the following command will create `rpc.cert` and default `dcrd.conf`. 176 177 ``` 178 dcrd --testnet --rpcuser=REPLACEME --rpcpass=REPLACEME --txindex 179 ``` 180 If you want to use `dcrlnd` on testnet, `dcrd` needs to first fully sync the 181 testnet blockchain. Depending on your hardware, this may take up to a few hours. 182 183 While `dcrd` is syncing you can check on its progress using dcrd's `getinfo` 184 RPC command: 185 ``` 186 dcrctl --testnet --rpcuser=REPLACEME --rpcpass=REPLACEME getinfo 187 { 188 "version": 120000, 189 "protocolversion": 70002, 190 "blocks": 1114996, 191 "timeoffset": 0, 192 "connections": 7, 193 "proxy": "", 194 "difficulty": 422570.58270815, 195 "testnet": true, 196 "relayfee": 0.00001, 197 "errors": "" 198 } 199 ``` 200 201 Additionally, you can monitor dcrd's logs to track its syncing progress in real 202 time. 203 204 You can test your `dcrd` node's connectivity using the `getpeerinfo` command: 205 ``` 206 dcrctl --testnet --rpcuser=REPLACEME --rpcpass=REPLACEME getpeerinfo | more 207 ``` 208 209 ### Running dcrlnd using the dcrd backend 210 211 If you are on testnet, run this command after `dcrd` has finished syncing. 212 Otherwise, replace `--testnet` with `--simnet`. If you are 213 installing `dcrlnd` in preparation for the 214 [tutorial](http://dev.lightning.community/tutorial), you may skip this step. 215 ``` 216 dcrlnd --testnet --debuglevel=debug --dcrd.rpcuser=kek --dcrd.rpcpass=kek --externalip=X.X.X.X 217 ``` 218 219 # Macaroons 220 221 `dcrlnd`'s authentication system is called **macaroons**, which are 222 decentralized bearer credentials allowing for delegation, attenuation, and other 223 cool features. You can learn more about them in Alex Akselrod's [writeup on 224 the original lnd issue](https://github.com/lightningnetwork/lnd/issues/20). 225 226 Running `dcrlnd` for the first time will by default generate the 227 `admin.macaroon`, `read_only.macaroon`, and `macaroons.db` files that are used 228 to authenticate into `dcrlnd`. They will be stored in the network directory 229 (default: `lnddir/data/chain/decred/mainnet`) so that it's possible to use a 230 distinct password for mainnet, testnet, simnet, etc. Note that if you specified 231 an alternative data directory (via the `--datadir` argument), you will have to 232 additionally pass the updated location of the `admin.macaroon` file into 233 `dcrlncli` using the `--macaroonpath` argument. 234 235 To disable macaroons for testing, pass the `--no-macaroons` flag into *both* 236 `dcrlnd` and `dcrlncli`. 237 238 # Network Reachability 239 240 If you'd like to signal to other nodes on the network that you'll accept 241 incoming channels (as peers need to connect inbound to initiate a channel 242 funding workflow), then the `--externalip` flag should be set to your publicly 243 reachable IP address. 244 245 # Simnet vs. Testnet Development 246 247 If you are doing local development, such as for the tutorial, you'll want to 248 start both `dcrd` and `dcrlnd` in the `simnet` mode. Simnet is similar to 249 regtest in that you'll be able to instantly mine blocks as needed to test 250 `dcrlnd` locally. In order to start either daemon in the `simnet` mode use 251 `simnet` instead of `testnet`, adding the `--simnet` flag instead of the 252 `--testnet` flag. 253 254 Another relevant command line flag for local testing of new `dcrlnd` 255 developments is the `--debughtlc` flag. When starting `dcrlnd` with this flag, 256 it'll be able to automatically settle a special type of HTLC sent to it. This 257 means that you won't need to manually insert invoices in order to test payment 258 connectivity. To send this "special" HTLC type, include the `--debugsend` 259 command at the end of your `sendpayment` commands. 260 261 262 # Creating a dcrlnd.conf (Optional) 263 264 Optionally, if you'd like to have a persistent configuration between `dcrlnd` 265 launches, allowing you to simply type `dcrlnd --testnet` 266 at the command line, you can create an `dcrlnd.conf`. 267 268 **On MacOS, located at:** 269 `/Users/[username]/Library/Application Support/dcrlnd/dcrlnd.conf` 270 271 **On Linux, located at:** 272 `~/.dcrlnd/dcrlnd.conf` 273 274 Here's a sample `dcrlnd.conf` for `dcrd` to get you started: 275 ``` 276 [Application Options] 277 debuglevel=trace 278 maxpendingchannels=10 279 280 [Decred] 281 testnet=1 282 ``` 283 284 Notice the `[Decred]` section. This section houses the parameters for the 285 Decred chain. See a more detailed sample config file available 286 [here](https://github.com/decred/dcrlnd/blob/master/sample-dcrlnd.conf) 287 and explore the other sections for node configuration.