github.com/btcsuite/btcd@v0.24.0/docs/configuration.md (about) 1 # Configuration 2 3 btcd has a number of [configuration](https://pkg.go.dev/github.com/btcsuite/btcd) 4 options, which can be viewed by running: `$ btcd --help`. 5 6 ## Peer server listen interface 7 8 btcd allows you to bind to specific interfaces which enables you to setup 9 configurations with varying levels of complexity. The listen parameter can be 10 specified on the command line as shown below with the -- prefix or in the 11 configuration file without the -- prefix (as can all long command line options). 12 The configuration file takes one entry per line. 13 14 **NOTE:** The listen flag can be specified multiple times to listen on multiple 15 interfaces as a couple of the examples below illustrate. 16 17 Command Line Examples: 18 19 |Flags|Comment| 20 |----------|------------| 21 |--listen=|all interfaces on default port which is changed by `--testnet` and `--regtest` (**default**)| 22 |--listen=0.0.0.0|all IPv4 interfaces on default port which is changed by `--testnet` and `--regtest`| 23 |--listen=::|all IPv6 interfaces on default port which is changed by `--testnet` and `--regtest`| 24 |--listen=:8333|all interfaces on port 8333| 25 |--listen=0.0.0.0:8333|all IPv4 interfaces on port 8333| 26 |--listen=[::]:8333|all IPv6 interfaces on port 8333| 27 |--listen=127.0.0.1:8333|only IPv4 localhost on port 8333| 28 |--listen=[::1]:8333|only IPv6 localhost on port 8333| 29 |--listen=:8336|all interfaces on non-standard port 8336| 30 |--listen=0.0.0.0:8336|all IPv4 interfaces on non-standard port 8336| 31 |--listen=[::]:8336|all IPv6 interfaces on non-standard port 8336| 32 |--listen=127.0.0.1:8337 --listen=[::1]:8333|IPv4 localhost on port 8337 and IPv6 localhost on port 8333| 33 |--listen=:8333 --listen=:8337|all interfaces on ports 8333 and 8337| 34 35 The following config file would configure btcd to only listen on localhost for both IPv4 and IPv6: 36 37 ```text 38 [Application Options] 39 40 listen=127.0.0.1:8333 41 listen=[::1]:8333 42 ``` 43 44 In addition, if you are starting btcd with TLS and want to make it 45 available via a hostname, then you will need to generate the TLS 46 certificates for that host. For example, 47 48 ``` 49 gencerts --host=myhostname.example.com --directory=/home/me/.btcd/ 50 ``` 51 52 ## RPC server listen interface 53 54 btcd allows you to bind the RPC server to specific interfaces which enables you 55 to setup configurations with varying levels of complexity. The `rpclisten` 56 parameter can be specified on the command line as shown below with the -- prefix 57 or in the configuration file without the -- prefix (as can all long command line 58 options). The configuration file takes one entry per line. 59 60 A few things to note regarding the RPC server: 61 62 * The RPC server will **not** be enabled unless the `rpcuser` and `rpcpass` 63 options are specified. 64 * When the `rpcuser` and `rpcpass` and/or `rpclimituser` and `rpclimitpass` 65 options are specified, the RPC server will only listen on localhost IPv4 and 66 IPv6 interfaces by default. You will need to override the RPC listen 67 interfaces to include external interfaces if you want to connect from a remote 68 machine. 69 * The RPC server has TLS enabled by default, even for localhost. You may use 70 the `--notls` option to disable it, but only when all listeners are on 71 localhost interfaces. 72 * The `--rpclisten` flag can be specified multiple times to listen on multiple 73 interfaces as a couple of the examples below illustrate. 74 * The RPC server is disabled by default when using the `--regtest` and 75 `--simnet` networks. You can override this by specifying listen interfaces. 76 77 Command Line Examples: 78 79 |Flags|Comment| 80 |----------|------------| 81 |--rpclisten=|all interfaces on default port which is changed by `--testnet`| 82 |--rpclisten=0.0.0.0|all IPv4 interfaces on default port which is changed by `--testnet`| 83 |--rpclisten=::|all IPv6 interfaces on default port which is changed by `--testnet`| 84 |--rpclisten=:8334|all interfaces on port 8334| 85 |--rpclisten=0.0.0.0:8334|all IPv4 interfaces on port 8334| 86 |--rpclisten=[::]:8334|all IPv6 interfaces on port 8334| 87 |--rpclisten=127.0.0.1:8334|only IPv4 localhost on port 8334| 88 |--rpclisten=[::1]:8334|only IPv6 localhost on port 8334| 89 |--rpclisten=:8336|all interfaces on non-standard port 8336| 90 |--rpclisten=0.0.0.0:8336|all IPv4 interfaces on non-standard port 8336| 91 |--rpclisten=[::]:8336|all IPv6 interfaces on non-standard port 8336| 92 |--rpclisten=127.0.0.1:8337 --listen=[::1]:8334|IPv4 localhost on port 8337 and IPv6 localhost on port 8334| 93 |--rpclisten=:8334 --listen=:8337|all interfaces on ports 8334 and 8337| 94 95 The following config file would configure the btcd RPC server to listen to all interfaces on the default port, including external interfaces, for both IPv4 and IPv6: 96 97 ```text 98 [Application Options] 99 100 rpclisten= 101 ``` 102 103 ## Default ports 104 105 While btcd is highly configurable when it comes to the network configuration, 106 the following is intended to be a quick reference for the default ports used so 107 port forwarding can be configured as required. 108 109 btcd provides a `--upnp` flag which can be used to automatically map the bitcoin 110 peer-to-peer listening port if your router supports UPnP. If your router does 111 not support UPnP, or you don't wish to use it, please note that only the bitcoin 112 peer-to-peer port should be forwarded unless you specifically want to allow RPC 113 access to your btcd from external sources such as in more advanced network 114 configurations. 115 116 |Name|Port| 117 |----|----| 118 |Default Bitcoin peer-to-peer port|TCP 8333| 119 |Default RPC port|TCP 8334| 120 121 ## Using bootstrap.dat 122 123 ### What is bootstrap.dat? 124 125 It is a flat, binary file containing bitcoin blockchain data starting from the 126 genesis block and continuing through a relatively recent block height depending 127 on the last time it was updated. 128 129 See [this](https://bitcointalk.org/index.php?topic=145386.0) thread on 130 bitcointalk for more details. 131 132 **NOTE:** Using bootstrap.dat is entirely optional. Btcd will download the 133 block chain from other peers through the Bitcoin protocol with no extra 134 configuration needed. 135 136 ### What are the pros and cons of using bootstrap.dat? 137 138 Pros: 139 140 * Typically accelerates the initial process of bringing up a new node as it 141 downloads from public P2P nodes and generally is able to achieve faster 142 download speeds 143 * It is particularly beneficial when bringing up multiple nodes as you only need 144 to download the data once 145 146 Cons: 147 148 * Requires you to setup and configure a torrent client if you don't already have 149 one available 150 * Requires roughly twice as much disk space since you'll need the flat file as 151 well as the imported database 152 153 ### Where do I get bootstrap.dat? 154 155 The bootstrap.dat file is made available via a torrent. See 156 [this](https://bitcointalk.org/index.php?topic=145386.0) thread on bitcointalk 157 for the torrent download details. 158 159 ### How do I know I can trust the bootstrap.dat I downloaded? 160 161 You don't need to trust the file as the `addblock` utility verifies every block 162 using the same rules that are used when downloading the block chain normally 163 through the Bitcoin protocol. Additionally, the chain rules contain hard-coded 164 checkpoints for the known-good block chain at periodic intervals. This ensures 165 that not only is it a valid chain, but it is the same chain that everyone else 166 is using. 167 168 ### How do I use bootstrap.dat with btcd? 169 170 btcd comes with a separate utility named `addblock` which can be used to import 171 `bootstrap.dat`. This approach is used since the import is a one-time operation 172 and we prefer to keep the daemon itself as lightweight as possible. 173 174 1. Stop btcd if it is already running. This is required since addblock needs to 175 access the database used by btcd and it will be locked if btcd is using it. 176 2. Note the path to the downloaded bootstrap.dat file. 177 3. Run the addblock utility with the `-i` argument pointing to the location of 178 boostrap.dat: 179 180 **Windows:** 181 182 ```bat 183 "%PROGRAMFILES%\Btcd Suite\Btcd\addblock" -i C:\Path\To\bootstrap.dat 184 ``` 185 186 **Linux/Unix/BSD/POSIX:** 187 188 ```bash 189 $GOPATH/bin/addblock -i /path/to/bootstrap.dat 190 ```