Inside Bitcoin
Opening the selected file…
Inside Bitcoin
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
1#!/usr/bin/env bash2# Copyright (c) 2021-present The Bitcoin Core developers3# Distributed under the MIT software license, see the accompanying4# file COPYING or http://www.opensource.org/licenses/mit-license.php.6export LC_ALL=C.UTF-87TOPDIR=${TOPDIR:-$(git rev-parse --show-toplevel)}8BUILDDIR=${BUILDDIR:-$TOPDIR/build}9BINDIR=${BINDIR:-$BUILDDIR/bin}10BITCOIND=${BITCOIND:-$BINDIR/bitcoind}11SHARE_EXAMPLES_DIR=${SHARE_EXAMPLES_DIR:-$TOPDIR/share/examples}12EXAMPLE_CONF_FILE=${EXAMPLE_CONF_FILE:-$SHARE_EXAMPLES_DIR/bitcoin.conf}14[ ! -x "$BITCOIND" ] && echo "$BITCOIND not found or not executable." && exit 116DIRTY=""17VERSION_OUTPUT=$($BITCOIND --version)18if [[ $VERSION_OUTPUT == *"dirty"* ]]; then19DIRTY="${DIRTY}${BITCOIND}\n"20fi22if [ -n "$DIRTY" ]23then24echo -e "WARNING: $BITCOIND was built from a dirty tree.\n"25echo -e "To safely generate a bitcoin.conf file, please commit your changes to $BITCOIND, rebuild, then run this script again.\n"26fi28echo 'Generating example bitcoin.conf file in share/examples/'30# create the directory, if it doesn't exist31mkdir -p "${SHARE_EXAMPLES_DIR}"33# create the header text34cat > "${EXAMPLE_CONF_FILE}" << 'EOF'35##36## bitcoin.conf configuration file.37## Generated by contrib/devtools/gen-bitcoin-conf.sh.38##39## Lines beginning with # are comments.40## All possible configuration options are provided. To use, copy this file41## to your data directory (default or specified by -datadir), uncomment42## options you would like to change, and save the file.43##46### Options47EOF49# parse the output from bitcoind --help50# adding newlines is a bit funky to ensure portability for BSD51# see here for more details: https://stackoverflow.com/a/2457538552${BITCOIND} --help \53| sed '1,/Options:/d' \54| sed -E '/^[[:space:]]{2}-help/,/^[[:space:]]*$/d' \55| sed -E 's/^[[:space:]]{2}\-/#/' \56| sed -E 's/^[[:space:]]{7}/# /' \57| sed -E '/[=[:space:]]/!s/#.*$/&=1/' \58| awk '/^#[a-z]/{x=$0;next}{if (NF==0) print x"\n",x="";else print}' \59| sed 's,\(^[[:upper:]].*\)\:$,\60### \1,' \61| sed 's/[[:space:]]*$//' >> "${EXAMPLE_CONF_FILE}"63# create the footer text64cat >> "${EXAMPLE_CONF_FILE}" << 'EOF'66# [Sections]67# Most options will apply to all networks. To confine an option to a specific68# network, add it under the relevant section below.69#70# Note: If not specified under a network section, the options addnode, connect,71# port, bind, rpcport, rpcbind, and wallet will only apply to mainnet.73# Options for mainnet74[main]76# Options for testnet377[test]79# Options for testnet480[testnet4]82# Options for signet83[signet]85# Options for regtest86[regtest]87EOF
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.