Skip to content

Commit ddd23bd

Browse files
laanwjknst
authored andcommitted
Merge bitcoin#22235: script: add script to generate example bitcoin.conf
b42643c doc: update init.cpp -conf help text (josibake) 970b998 doc: update devtools, release-process readmes (josibake) 50635d2 build: include bitcoin.conf in build outputs (josibake) 6aac946 doc: update bitcoin-conf.md (Josiah Baker) 1c7e820 script: add script to generate example bitcoin.conf (josibake) b483084 doc: replace bitcoin.conf with placeholder file (josibake) Pull request description: create a script for parsing the output from `bitcoind --help` to create an example conf file for new users ## problem per bitcoin#10746 , `bitcoin.conf` not being put into the data directory during installation causes some confusion for users when running bitcoin. in the discussion on the issue, one proposed solution was to have an example config file and instruct users to `cp` it into their data directory after startup. in addition to bitcoin#10746 , there have been other requests for a "skeleton config file" (bitcoin#19641) to help users get started with configuring bitcoind. the main issue with an example config file is that it creates a second source of truth regarding what options are available for configuring bitcoind. this means any changes to the options (including the addition or removal of options) would have to be updated for the command line and also updated in the example file. this PR addresses this issue by providing a script to generate an example file directly from the `bitcoind --help` on-demand by running `contrib/devtools/gen-bitcoin-conf.sh`. this solution was originally proposed on bitcoin#10746 and would also solve bitcoin#19641 . this guarantees any changes made to the command-line options or the command-line options help would also be reflected in the example file after compiling and running the script. the main purpose of this script is to generate a config file to be included with releases, same as `gen-manpages.sh`. this ensures every release also includes an up-to-date, full example config file for users to edit. the script is also available for users who compile from source for generating an example config for their compiled binary. ## special considerations this removes the `bitcoin.conf` example file from the repo as it is now generated by this script. the original example file did contain extra text related to how to use certain options but going forward all option help docs should be moved into `init.cpp` this also edits `init.cpp` to have the option help indicate that `-conf` is not usable from the config file. this is similar to how `-includeconf` 's help indicates it cannot be used from the command line ACKs for top commit: laanwj: Tested and code review ACK b42643c Tree-SHA512: 4546e0cef92aa1398da553294ce4712d02e616dd72dcbe0b921af474e54f24750464ec813661f1283802472d1e8774e634dd1cc26fbf1f13286d3e0406c02c09
1 parent 162dc78 commit ddd23bd

File tree

7 files changed

+113
-189
lines changed

7 files changed

+113
-189
lines changed

contrib/debian/examples/dash.conf

Lines changed: 1 addition & 185 deletions
Original file line numberDiff line numberDiff line change
@@ -1,185 +1 @@
1-
##
2-
## dash.conf configuration file. Lines beginning with # are comments.
3-
##
4-
5-
# Network-related settings:
6-
7-
# Note that if you use testnet or regtest, particularly with the options
8-
# addnode, connect, port, bind, rpcport, rpcbind or wallet, you will also
9-
# want to read "[Sections]" further down.
10-
11-
# Run on the test network instead of the real dash network.
12-
#testnet=0
13-
14-
# Run a regression test network
15-
#regtest=0
16-
17-
# Connect via a SOCKS5 proxy
18-
#proxy=127.0.0.1:9050
19-
20-
# Bind to given address and always listen on it. Use [host]:port notation for IPv6
21-
#bind=<addr>
22-
23-
# Bind to given address and add permission flags to peers connecting to it. Use [host]:port notation for IPv6
24-
#whitebind=perm@<addr>
25-
26-
##############################################################
27-
## Quick Primer on addnode vs connect ##
28-
## Let's say for instance you use addnode=4.2.2.4 ##
29-
## addnode will connect you to and tell you about the ##
30-
## nodes connected to 4.2.2.4. In addition it will tell ##
31-
## the other nodes connected to it that you exist so ##
32-
## they can connect to you. ##
33-
## connect will not do the above when you 'connect' to it. ##
34-
## It will *only* connect you to 4.2.2.4 and no one else.##
35-
## ##
36-
## So if you're behind a firewall, or have other problems ##
37-
## finding nodes, add some using 'addnode'. ##
38-
## ##
39-
## If you want to stay private, use 'connect' to only ##
40-
## connect to "trusted" nodes. ##
41-
## ##
42-
## If you run multiple nodes on a LAN, there's no need for ##
43-
## all of them to open lots of connections. Instead ##
44-
## 'connect' them all to one node that is port forwarded ##
45-
## and has lots of connections. ##
46-
## Thanks goes to [Noodle] on Freenode. ##
47-
##############################################################
48-
49-
# Use as many addnode= settings as you like to connect to specific peers
50-
#addnode=69.164.218.197
51-
#addnode=10.0.0.2:9999
52-
53-
# Alternatively use as many connect= settings as you like to connect ONLY to specific peers
54-
#connect=69.164.218.197
55-
#connect=10.0.0.1:9999
56-
57-
# Listening mode, enabled by default except when 'connect' is being used
58-
#listen=1
59-
60-
# Port on which to listen for connections (default: 9999, testnet: 19999, regtest: 19899)
61-
#port=
62-
63-
# Maximum number of inbound + outbound connections (default: 125). This option
64-
# applies only if inbound connections are enabled; otherwise, the number of connections
65-
# will not be more than 11: 8 full-relay connections, 2 block-relay-only ones, and
66-
# occasionally 1 short-lived feeler or extra outbound block-relay-only connection.
67-
# These limits do not apply to connections added manually with the -addnode
68-
# configuration option or the addnode RPC, which have a separate limit of 8 connections.
69-
#maxconnections=
70-
71-
# Maximum upload bandwidth target in MiB per day (e.g. 'maxuploadtarget=1024' is 1 GiB per day).
72-
# This limits the upload bandwidth for those with bandwidth limits. 0 = no limit (default: 0).
73-
# -maxuploadtarget does not apply to peers with 'download' permission.
74-
# For more information on reducing bandwidth utilization, see: doc/reduce-traffic.md.
75-
#maxuploadtarget=
76-
77-
#
78-
# JSON-RPC options (for controlling a running Dash/dashd process)
79-
#
80-
81-
# server=1 tells Dash-Qt and dashd to accept JSON-RPC commands
82-
#server=0
83-
84-
# Bind to given address to listen for JSON-RPC connections.
85-
# Refer to the manpage or dashd -help for further details.
86-
#rpcbind=<addr>
87-
88-
# If no rpcpassword is set, rpc cookie auth is sought. The default `-rpccookiefile` name
89-
# is .cookie and found in the `-datadir` being used for dashd. This option is typically used
90-
# when the server and client are run as the same user.
91-
#
92-
# If not, you must set rpcuser and rpcpassword to secure the JSON-RPC API.
93-
#
94-
# The config option `rpcauth` can be added to server startup argument. It is set at initialization time
95-
# using the output from the script in share/rpcauth/rpcauth.py after providing a username:
96-
#
97-
# ./share/rpcauth/rpcauth.py alice
98-
# String to be appended to dash.conf:
99-
# rpcauth=alice:f7efda5c189b999524f151318c0c86$d5b51b3beffbc02b724e5d095828e0bc8b2456e9ac8757ae3211a5d9b16a22ae
100-
# Your password:
101-
# DONT_USE_THIS_YOU_WILL_GET_ROBBED_8ak1gI25KFTvjovL3gAM967mies3E=
102-
#
103-
# On client-side, you add the normal user/password pair to send commands:
104-
#rpcuser=alice
105-
#rpcpassword=DONT_USE_THIS_YOU_WILL_GET_ROBBED_8ak1gI25KFTvjovL3gAM967mies3E=
106-
#
107-
# You can even add multiple entries of these to the server conf file, and client can use any of them:
108-
# rpcauth=bob:b2dd077cb54591a2f3139e69a897ac$4e71f08d48b4347cf8eff3815c0e25ae2e9a4340474079f55705f40574f4ec99
109-
110-
# How many seconds Dash Core will wait for a complete RPC HTTP request.
111-
# after the HTTP connection is established.
112-
#rpcclienttimeout=30
113-
114-
# By default, only RPC connections from localhost are allowed.
115-
# Specify as many rpcallowip= settings as you like to allow connections from other hosts,
116-
# either as a single IPv4/IPv6 or with a subnet specification.
117-
118-
# NOTE: opening up the RPC port to hosts outside your local trusted network is NOT RECOMMENDED,
119-
# because the rpcpassword is transmitted over the network unencrypted.
120-
121-
# server=1 tells Dash-Qt to accept JSON-RPC commands.
122-
# it is also read by dashd to determine if RPC should be enabled
123-
#rpcallowip=10.1.1.34/255.255.255.0
124-
#rpcallowip=1.2.3.4/24
125-
#rpcallowip=2001:db8:85a3:0:0:8a2e:370:7334/96
126-
127-
# Listen for RPC connections on this TCP port:
128-
#rpcport=9998
129-
130-
# You can use Dash or dashd to send commands to Dash/dashd
131-
# running on another host using this option:
132-
#rpcconnect=127.0.0.1
133-
134-
# Wallet options
135-
136-
# Specify where to find wallet, lockfile and logs. If not present, those files will be
137-
# created as new.
138-
#wallet=</path/to/dir>
139-
140-
# Create transactions that have enough fees so they are likely to begin confirmation within n blocks (default: 6).
141-
# This setting is over-ridden by the -paytxfee option.
142-
#txconfirmtarget=n
143-
144-
# Pay a transaction fee every time you send dash.
145-
#paytxfee=0.000x
146-
147-
# Miscellaneous options
148-
149-
# Pre-generate this many public/private key pairs, so wallet backups will be valid for
150-
# both prior transactions and several dozen future transactions.
151-
#keypool=100
152-
153-
# Maintain coinstats index used by the gettxoutsetinfo RPC (default: 0).
154-
#coinstatsindex=1
155-
156-
# Enable pruning to reduce storage requirements by deleting old blocks.
157-
# This mode is incompatible with -txindex, -coinstatsindex and -rescan.
158-
# 0 = default (no pruning).
159-
# 1 = allows manual pruning via RPC.
160-
# >=945 = target to stay under in MiB.
161-
#prune=945
162-
163-
# User interface options
164-
165-
# Start Dash minimized
166-
#min=1
167-
168-
# Minimize to the system tray
169-
#minimizetotray=1
170-
171-
# [Sections]
172-
# Most options apply to mainnet, testnet and regtest.
173-
# If you want to confine an option to just one network, you should add it in the
174-
# relevant section below.
175-
# EXCEPTIONS: The options addnode, connect, port, bind, rpcport, rpcbind and wallet
176-
# only apply to mainnet unless they appear in the appropriate section below.
177-
178-
# Options only for mainnet
179-
[main]
180-
181-
# Options only for testnet
182-
[test]
183-
184-
# Options only for regtest
185-
[regtest]
1+
# This is a placeholder file. Please follow the instructions in `contrib/devtools/README.md` to generate a dash.conf file.

contrib/devtools/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,21 @@ example:
9090
BUILDDIR=$PWD/build contrib/devtools/gen-manpages.py
9191
```
9292

93+
gen-dash-conf.sh
94+
===================
95+
96+
Generates a dash.conf file in `contrib/debian/examples/` by parsing the output from `dashd --help`. This script is run during the
97+
release process to include a dash.conf with the release binaries and can also be run by users to generate a file locally.
98+
When generating a file as part of the release process, make sure to commit the changes after running the script.
99+
100+
With in-tree builds this tool can be run from any directory within the
101+
repository. To use this tool with out-of-tree builds set `BUILDDIR`. For
102+
example:
103+
104+
```bash
105+
BUILDDIR=$PWD/build contrib/devtools/gen-dash-conf.sh
106+
```
107+
93108
github-merge.py
94109
===============
95110

contrib/devtools/gen-dash-conf.sh

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
#!/usr/bin/env bash
2+
# Copyright (c) 2021 The Bitcoin Core developers
3+
# Distributed under the MIT software license, see the accompanying
4+
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
5+
6+
export LC_ALL=C
7+
TOPDIR=${TOPDIR:-$(git rev-parse --show-toplevel)}
8+
BUILDDIR=${BUILDDIR:-$TOPDIR}
9+
BINDIR=${BINDIR:-$BUILDDIR/src}
10+
DASHD=${DASHD:-$BINDIR/dashd}
11+
SHARE_EXAMPLES_DIR=${SHARE_EXAMPLES_DIR:-$TOPDIR/contrib/debian/examples/}
12+
EXAMPLE_CONF_FILE=${EXAMPLE_CONF_FILE:-$SHARE_EXAMPLES_DIR/dash.conf}
13+
14+
[ ! -x "$DASHD" ] && echo "$DASHD not found or not executable." && exit 1
15+
16+
DIRTY=""
17+
VERSION_OUTPUT=$($DASHD --version)
18+
if [[ $VERSION_OUTPUT == *"dirty"* ]]; then
19+
DIRTY="${DIRTY}${DASHD}\n"
20+
fi
21+
22+
if [ -n "$DIRTY" ]
23+
then
24+
echo -e "WARNING: $DASHD was built from a dirty tree.\n"
25+
echo -e "To safely generate a dash.conf file, please commit your changes to $DASHD, rebuild, then run this script again.\n"
26+
fi
27+
28+
echo 'Generating example dash.conf file in contrib/debian/examples/'
29+
30+
# create the directory, if it doesn't exist
31+
mkdir -p "${SHARE_EXAMPLES_DIR}"
32+
33+
# create the header text
34+
cat > "${EXAMPLE_CONF_FILE}" << 'EOF'
35+
##
36+
## dash.conf configuration file.
37+
## Generated by contrib/devtools/gen-dash-conf.sh.
38+
##
39+
## Lines beginning with # are comments.
40+
## All possible configuration options are provided. To use, copy this file
41+
## to your data directory (default or specified by -datadir), uncomment
42+
## options you would like to change, and save the file.
43+
##
44+
45+
46+
### Options
47+
EOF
48+
49+
# parse the output from dashd --help
50+
# adding newlines is a bit funky to ensure portability for BSD
51+
# see here for more details: https://stackoverflow.com/a/24575385
52+
${DASHD} --help \
53+
| sed '1,/Print this help message and exit/d' \
54+
| sed -E 's/^[[:space:]]{2}\-/#/' \
55+
| sed -E 's/^[[:space:]]{7}/# /' \
56+
| sed -E '/[=[:space:]]/!s/#.*$/&=1/' \
57+
| awk '/^#[a-z]/{x=$0;next}{if (NF==0) print x"\n",x="";else print}' \
58+
| sed 's,\(^[[:upper:]].*\)\:$,\
59+
### \1,' \
60+
| sed 's/[[:space:]]*$//' >> "${EXAMPLE_CONF_FILE}"
61+
62+
# create the footer text
63+
cat >> "${EXAMPLE_CONF_FILE}" << 'EOF'
64+
65+
# [Sections]
66+
# Most options will apply to all networks. To confine an option to a specific
67+
# network, add it under the relevant section below.
68+
#
69+
# Note: If not specified under a network section, the options addnode, connect,
70+
# port, bind, rpcport, rpcbind, and wallet will only apply to mainnet.
71+
72+
# Options for mainnet
73+
[main]
74+
75+
# Options for testnet
76+
[test]
77+
78+
# Options for regtest
79+
[regtest]
80+
EOF

contrib/guix/libexec/build.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,10 @@ mkdir -p "$DISTSRC"
355355
;;
356356
esac
357357

358+
# copy over the example dash.conf file. if contrib/devtools/gen-dash-conf.sh
359+
# has not been run before buildling, this file will be a stub
360+
cp "${DISTSRC}/contrib/debian/examples/dash.conf" "${DISTNAME}/"
361+
358362
# Finally, deterministically produce {non-,}debug binary tarballs ready
359363
# for release
360364
case "$HOST" in

doc/dash-conf.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,12 @@ Windows | `%APPDATA%\DashCore\` | `C:\Users\username\AppData\Roaming\DashCore\da
6363
Linux | `$HOME/.dashcore/` | `/home/username/.dashcore/dash.conf`
6464
macOS | `$HOME/Library/Application Support/DashCore/` | `/Users/username/Library/Application Support/DashCore/dash.conf`
6565

66-
You can find an example dash.conf file in [share/examples/dash.conf](../share/examples/dash.conf).
66+
An example configuration file can be generated by [contrib/devtools/gen-dash-conf.sh](../contrib/devtools/gen-dash-conf.sh).
67+
Run this script after compiling to generate an up-to-date configuration file.
68+
The output is placed under `contrib/debian/examples/dash.conf`.
69+
To use the generated configuration file, copy the example file into your data directory and edit it there, like so:
70+
71+
```
72+
# example copy command for linux user
73+
cp contrib/debian/examples/dash.conf ~/.dashcore
74+
```

doc/release-process.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
Release Process
22
====================
33

4-
* [ ] Update translations, see [translation_process.md](https://github.com/dashpay/dash/blob/master/doc/translation_process.md#synchronising-translations).
5-
* [ ] Update manpages (after rebuilding the binaries), see [gen-manpages.py](https://github.com/bitcoin/bitcoin/blob/master/contrib/devtools/README.md#gen-manpagespy).
4+
* [ ] Update translations, see [translation_process.md](https://github.com/dashpay/dash/blob/develop/doc/translation_process.md#synchronising-translations).
5+
* [ ] Update manpages (after rebuilding the binaries), see [gen-manpages.py](https://github.com/dashpay/dash/blob/develop/contrib/devtools/README.md#gen-manpagespy).
6+
* [ ] Update dash.conf and commit, see [gen-dash-conf.sh](https://github.com/dashpay/dash/blob/develop/contrib/devtools/README.md#gen-dash-confsh).
67

78
Before every minor and major release:
89

src/init.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ void SetupServerArgs(ArgsManager& argsman)
520520
argsman.AddArg("-chainlocknotify=<cmd>", "Execute command when the best chainlock changes (%s in cmd is replaced by chainlocked block hash)", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
521521
#endif
522522
argsman.AddArg("-coinstatsindex", strprintf("Maintain coinstats index used by the gettxoutsetinfo RPC (default: %u)", DEFAULT_COINSTATSINDEX), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
523-
argsman.AddArg("-conf=<file>", strprintf("Specify path to read-only configuration file. Relative paths will be prefixed by datadir location. (default: %s)", BITCOIN_CONF_FILENAME), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
523+
argsman.AddArg("-conf=<file>", strprintf("Specify path to read-only configuration file. Relative paths will be prefixed by datadir location (only useable from command line, not configuration file) (default: %s)", BITCOIN_CONF_FILENAME), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
524524
argsman.AddArg("-datadir=<dir>", "Specify data directory", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
525525
argsman.AddArg("-dbbatchsize", strprintf("Maximum database write batch size in bytes (default: %u)", nDefaultDbBatchSize), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::OPTIONS);
526526
argsman.AddArg("-dbcache=<n>", strprintf("Maximum database cache size <n> MiB (%d to %d, default: %d). In addition, unused mempool memory is shared for this cache (see -maxmempool).", nMinDbCache, nMaxDbCache, nDefaultDbCache), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);

0 commit comments

Comments
 (0)