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 python32# Copyright (c) 2018-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.5"""Verify that starting bitcoin with -h works as expected."""7from test_framework.test_framework import BitcoinTestFramework8from test_framework.util import assert_equal10class HelpTest(BitcoinTestFramework):11def set_test_params(self):12self.setup_clean_chain = True13self.num_nodes = 115def setup_network(self):16self.add_nodes(self.num_nodes)17# Don't start the node19def get_node_output(self, *, ret_code_expected):20ret_code = self.nodes[0].process.wait(timeout=60)21assert_equal(ret_code, ret_code_expected)22self.nodes[0].stdout.seek(0)23self.nodes[0].stderr.seek(0)24out = self.nodes[0].stdout.read()25err = self.nodes[0].stderr.read()26self.nodes[0].stdout.close()27self.nodes[0].stderr.close()29# Clean up TestNode state30self.nodes[0].running = False31self.nodes[0].process = None32self.nodes[0].rpc_connected = False33self.nodes[0].rpc = None35return out, err37def run_test(self):38self.log.info("Start bitcoin with -h for help text")39self.nodes[0].start(extra_args=['-h'])40# Node should exit immediately and output help to stdout.41output, _ = self.get_node_output(ret_code_expected=0)42assert b'Options' in output43self.log.info(f"Help text received: {output[0:60]} (...)")45self.log.info("Start bitcoin with -version for version information")46self.nodes[0].start(extra_args=['-version'])47# Node should exit immediately and output version to stdout.48output, _ = self.get_node_output(ret_code_expected=0)49assert b'version' in output50self.log.info(f"Version text received: {output[0:60]} (...)")52# Test that arguments not in the help results in an error53self.log.info("Start bitcoind with -fakearg to make sure it does not start")54self.nodes[0].start(extra_args=['-fakearg'])55# Node should exit immediately and output an error to stderr56_, output = self.get_node_output(ret_code_expected=1)57assert b'Error parsing command line arguments' in output58self.log.info(f"Error message received: {output[0:60]} (...)")61if __name__ == '__main__':62HelpTest(__file__).main()
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.