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) The Bitcoin Core developers3# Distributed under the MIT software license, see the accompanying4# file COPYING or https://opensource.org/license/mit.5export LC_ALL=C.UTF-86set -o errexit -o pipefail8# Source the common prelude, which:9# 1. Checks if we're at the top directory of the Bitcoin Core repository10# 2. Defines a few common functions and variables11#12# shellcheck source=libexec/prelude.bash13source "$(dirname "${BASH_SOURCE[0]}")/libexec/prelude.bash"16###################17## Sanity Checks ##18###################20################21# Required non-builtin commands should be invokable22################24check_tools cat diff gpg26################27# Required env vars should be non-empty28################30cmd_usage() {31cat <<EOF32Synopsis:34env GUIX_SIGS_REPO=<path/to/guix.sigs> [ SIGNER=<signer> ] ./contrib/guix/guix-verify36Example overriding signer's manifest to use as base38env GUIX_SIGS_REPO=/home/dongcarl/guix.sigs SIGNER=achow101 ./contrib/guix/guix-verify40EOF41}43if [ -z "$GUIX_SIGS_REPO" ]; then44cmd_usage45exit 146fi48################49# GUIX_SIGS_REPO should exist as a directory50################52if [ ! -d "$GUIX_SIGS_REPO" ]; then53cat << EOF54ERR: The specified GUIX_SIGS_REPO is not an existent directory:56'$GUIX_SIGS_REPO'58Hint: Please clone the guix.sigs repository and point to it with the59GUIX_SIGS_REPO environment variable.61EOF62cmd_usage63exit 164fi66##############67## Verify ##68##############70OUTSIGDIR_BASE="${GUIX_SIGS_REPO}/${VERSION}"71echo "Looking for signature directories in '${OUTSIGDIR_BASE}'"72echo ""74# Usage: verify compare_manifest current_manifest75verify() {76local compare_manifest="$1"77local current_manifest="$2"78if ! gpg --quiet --batch --verify "$current_manifest".asc "$current_manifest" 1>&2; then79echo "ERR: Failed to verify GPG signature in '${current_manifest}'"80echo ""81echo "Hint: Either the signature is invalid or the public key is missing"82echo ""83failure=184elif ! diff --report-identical "$compare_manifest" "$current_manifest" 1>&2; then85echo "ERR: The SHA256SUMS attestation in these two directories differ:"86echo " '${compare_manifest}'"87echo " '${current_manifest}'"88echo ""89failure=190else91echo "Verified: '${current_manifest}'"92echo ""93fi94}96shopt -s nullglob97all_noncodesigned=( "$OUTSIGDIR_BASE"/*/noncodesigned.SHA256SUMS )98shopt -u nullglob100echo "--------------------"101echo ""102if (( ${#all_noncodesigned[@]} )); then103compare_noncodesigned="${all_noncodesigned[0]}"104if [[ -n "$SIGNER" ]]; then105signer_noncodesigned="$OUTSIGDIR_BASE/$SIGNER/noncodesigned.SHA256SUMS"106if [[ -f "$signer_noncodesigned" ]]; then107echo "Using $SIGNER's manifest as the base to compare against"108compare_noncodesigned="$signer_noncodesigned"109else110echo "Unable to find $SIGNER's manifest, using the first one found"111fi112else113echo "No SIGNER provided, using the first manifest found"114fi116for current_manifest in "${all_noncodesigned[@]}"; do117verify "$compare_noncodesigned" "$current_manifest"118done120echo "DONE: Checking output signatures for noncodesigned.SHA256SUMS"121echo ""122else123echo "WARN: No signature directories with noncodesigned.SHA256SUMS found"124echo ""125fi127shopt -s nullglob128all_all=( "$OUTSIGDIR_BASE"/*/all.SHA256SUMS )129shopt -u nullglob131echo "--------------------"132echo ""133if (( ${#all_all[@]} )); then134compare_all="${all_all[0]}"135if [[ -n "$SIGNER" ]]; then136signer_all="$OUTSIGDIR_BASE/$SIGNER/all.SHA256SUMS"137if [[ -f "$signer_all" ]]; then138echo "Using $SIGNER's manifest as the base to compare against"139compare_all="$signer_all"140else141echo "Unable to find $SIGNER's manifest, using the first one found"142fi143else144echo "No SIGNER provided, using the first manifest found"145fi147for current_manifest in "${all_all[@]}"; do148verify "$compare_all" "$current_manifest"149done151# Sanity check: there should be no entries that exist in152# noncodesigned.SHA256SUMS that doesn't exist in all.SHA256SUMS153if [[ "$(comm -23 <(sort "$compare_noncodesigned") <(sort "$compare_all") | wc -c)" -ne 0 ]]; then154echo "ERR: There are unique lines in noncodesigned.SHA256SUMS which"155echo " do not exist in all.SHA256SUMS, something went very wrong."156exit 1157fi159echo "DONE: Checking output signatures for all.SHA256SUMS"160echo ""161else162echo "WARN: No signature directories with all.SHA256SUMS found"163echo ""164fi166echo "===================="167echo ""168if (( ${#all_noncodesigned[@]} + ${#all_all[@]} == 0 )); then169echo "ERR: Unable to perform any verifications as no signature directories"170echo " were found"171echo ""172exit 1173fi175if [ -n "$failure" ]; then176exit 1177fi
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.