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{ pkgs ? import <nixpkgs> {}2, crossPkgs ? import <nixpkgs> {}3, enableLibcxx ? false # Whether to use libc++ toolchain and libraries instead of libstdc++4, minimal ? false # Whether to create minimal shell without extra tools (faster when cross compiling)5, capnprotoVersion ? null6, capnprotoSanitizers ? null # Optional sanitizers to build cap'n proto with7, cmakeVersion ? null8, libcxxSanitizers ? null # Optional LLVM_USE_SANITIZER value to use for libc++, see https://llvm.org/docs/CMake.html9}:11let12lib = pkgs.lib;13llvmBase = crossPkgs.llvmPackages_21;14llvm = llvmBase // lib.optionalAttrs (libcxxSanitizers != null) {15libcxx = llvmBase.libcxx.override {16devExtraCmakeFlags = [ "-DLLVM_USE_SANITIZER=${libcxxSanitizers}" ];17};18};19capnprotoHashes = {20"0.7.0" = "sha256-Y/7dUOQPDHjniuKNRw3j8dG1NI9f/aRWpf8V0WzV9k8=";21"0.7.1" = "sha256-3cBpVmpvCXyqPUXDp12vCFCk32ZXWpkdOliNH37UwWE=";22"0.8.0" = "sha256-rfiqN83begjJ9eYjtr21/tk1GJBjmeVfa3C3dZBJ93w=";23"0.8.1" = "sha256-OZqNVYdyszro5rIe+w6YN00g6y8U/1b8dKYc214q/2o=";24"0.9.0" = "sha256-yhbDcWUe6jp5PbIXzn5EoKabXiWN8lnS08hyfxUgEQ0=";25"0.9.2" = "sha256-BspWOPZcP5nCTvmsDE62Zutox+aY5pw42d6hpH3v4cM=";26"0.10.0" = "sha256-++F4l54OMTDnJ+FO3kV/Y/VLobKVRk461dopanuU3IQ=";27"0.10.4" = "sha256-45sxnVyyYIw9i3sbFZ1naBMoUzkpP21WarzR5crg4X8=";28"1.0.0" = "sha256-NLTFJdeOzqhk4ATvkc17Sh6g/junzqYBBEoXYGH/czo=";29"1.0.2" = "sha256-LVdkqVBTeh8JZ1McdVNtRcnFVwEJRNjt0JV2l7RkuO8=";30"1.1.0" = "sha256-gxkko7LFyJNlxpTS+CWOd/p9x/778/kNIXfpDGiKM2A=";31"1.2.0" = "sha256-aDcn4bLZGq8915/NPPQsN5Jv8FRWd8cAspkG3078psc=";32};33capnprotoBase = if capnprotoVersion == null then crossPkgs.capnproto else crossPkgs.capnproto.overrideAttrs (old: {34version = capnprotoVersion;35src = crossPkgs.fetchFromGitHub {36owner = "capnproto";37repo = "capnproto";38rev = "v${capnprotoVersion}";39hash = lib.attrByPath [capnprotoVersion] "" capnprotoHashes;40};41patches = lib.optionals (lib.versionAtLeast capnprotoVersion "0.9.0" && lib.versionOlder capnprotoVersion "0.10.4") [ ./ci/patches/spaceship.patch ];42cmakeFlags = (old.cmakeFlags or []) ++ (lib.optionals (lib.versionAtLeast "1.1.0" capnprotoVersion) ["-DCMAKE_POLICY_VERSION_MINIMUM=3.5"]);43} // (lib.optionalAttrs (lib.versionOlder capnprotoVersion "0.10") {44env = { }; # Drop -std=c++20 flag forced by nixpkgs45}));46capnproto = (capnprotoBase.overrideAttrs (old: lib.optionalAttrs (capnprotoSanitizers != null) {47env = (old.env or { }) // {48CXXFLAGS =49lib.concatStringsSep " " [50(old.env.CXXFLAGS or "")51"-fsanitize=${capnprotoSanitizers}"52"-fno-omit-frame-pointer"53"-g"54];55};56})).override (lib.optionalAttrs enableLibcxx { clangStdenv = llvm.libcxxStdenv; });57clang = if enableLibcxx then llvm.libcxxClang else llvm.clang;58clang-tools = llvm.clang-tools.override { inherit enableLibcxx; };59cmakeHashes = {60"3.12.4" = "sha256-UlVYS/0EPrcXViz/iULUcvHA5GecSUHYS6raqbKOMZQ=";61};62cmakeBuild = if cmakeVersion == null then pkgs.cmake else (pkgs.cmake.overrideAttrs (old: {63version = cmakeVersion;64src = pkgs.fetchurl {65url = "https://cmake.org/files/v${lib.versions.majorMinor cmakeVersion}/cmake-${cmakeVersion}.tar.gz";66hash = lib.attrByPath [cmakeVersion] "" cmakeHashes;67};68patches = [];69})).override { isMinimalBuild = true; };70in crossPkgs.mkShell {71buildInputs = [72capnproto73];74nativeBuildInputs = with pkgs; [75cmakeBuild76include-what-you-use77ninja78] ++ lib.optionals (!minimal) [79clang80clang-tools81];83# Tell IWYU where its libc++ mapping lives84IWYU_MAPPING_FILE = if enableLibcxx then "${llvm.libcxx.dev}/include/c++/v1/libcxx.imp" else null;85}
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.