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#3# Copyright (c) 2020-present The Bitcoin Core developers4# Distributed under the MIT software license, see the accompanying5# file COPYING or http://www.opensource.org/licenses/mit-license.php.6#7# Check for circular dependencies9import os10import re11import subprocess12import sys14EXPECTED_CIRCULAR_DEPENDENCIES = (15"chainparamsbase -> common/args -> chainparamsbase",16"node/blockstorage -> validation -> node/blockstorage",17"node/utxo_snapshot -> validation -> node/utxo_snapshot",18"qt/addresstablemodel -> qt/walletmodel -> qt/addresstablemodel",19"qt/recentrequeststablemodel -> qt/walletmodel -> qt/recentrequeststablemodel",20"qt/sendcoinsdialog -> qt/walletmodel -> qt/sendcoinsdialog",21"qt/transactiontablemodel -> qt/walletmodel -> qt/transactiontablemodel",22"wallet/wallet -> wallet/walletdb -> wallet/wallet",23"kernel/coinstats -> validation -> kernel/coinstats",24"versionbits -> versionbits_impl -> versionbits",26# Temporary, removed in followup https://github.com/bitcoin/bitcoin/pull/2423027"index/base -> node/context -> net_processing -> index/blockfilterindex -> index/base",28)30CODE_DIR = "src"33def main():34circular_dependencies = []35exit_code = 037os.chdir(CODE_DIR)38files = subprocess.check_output(39['git', 'ls-files', '--', '*.h', '*.cpp'],40text=True,41).splitlines()43command = [sys.executable, "../contrib/devtools/circular-dependencies.py", *files]44dependencies_output = subprocess.run(45command,46stdout=subprocess.PIPE,47text=True,48)50for dependency_str in dependencies_output.stdout.rstrip().split("\n"):51circular_dependencies.append(52re.sub("^Circular dependency: ", "", dependency_str)53)55# Check for an unexpected dependencies56for dependency in circular_dependencies:57if dependency not in EXPECTED_CIRCULAR_DEPENDENCIES:58exit_code = 159print(60f'A new circular dependency in the form of "{dependency}" appears to have been introduced.\n',61file=sys.stderr,62)64# Check for missing expected dependencies65for expected_dependency in EXPECTED_CIRCULAR_DEPENDENCIES:66if expected_dependency not in circular_dependencies:67exit_code = 168print(69f'Good job! The circular dependency "{expected_dependency}" is no longer present.',70)71print(72f"Please remove it from EXPECTED_CIRCULAR_DEPENDENCIES in {__file__}",73)74print(75"to make sure this circular dependency is not accidentally reintroduced.\n",76)78sys.exit(exit_code)81if __name__ == "__main__":82main()
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.