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 python33import json4import sys5import subprocess6from pathlib import Path9def main():10"""Tests ordered roughly from faster to slower."""11expect_code(run_verify("", "pub", '0.32'), 4, "Nonexistent version should fail")12expect_code(run_verify("", "pub", '0.32.awefa.12f9h'), 11, "Malformed version should fail")13expect_code(run_verify('--min-good-sigs 20', "pub", "22.0"), 9, "--min-good-sigs 20 should fail")15print("- testing verification (22.0-x86_64-linux-gnu.tar.gz)", flush=True)16_220_x86_64_linux_gnu = run_verify("--json", "pub", "22.0-x86_64-linux-gnu.tar.gz")17try:18result = json.loads(_220_x86_64_linux_gnu.stdout.decode())19except Exception:20print("failed on 22.0-x86_64-linux-gnu.tar.gz --json:")21print_process_failure(_220_x86_64_linux_gnu)22raise24expect_code(_220_x86_64_linux_gnu, 0, "22.0-x86_64-linux-gnu.tar.gz should succeed")25v = result['verified_binaries']26assert result['good_trusted_sigs']27assert len(v) == 128assert v['bitcoin-22.0-x86_64-linux-gnu.tar.gz'] == '59ebd25dd82a51638b7a6bb914586201e67db67b919b2a1ff08925a7936d1b16'30print("- testing verification (22.0)", flush=True)31_220 = run_verify("--json", "pub", "22.0")32try:33result = json.loads(_220.stdout.decode())34except Exception:35print("failed on 22.0 --json:")36print_process_failure(_220)37raise39expect_code(_220, 0, "22.0 should succeed")40v = result['verified_binaries']41assert result['good_trusted_sigs']42assert v['bitcoin-22.0-aarch64-linux-gnu.tar.gz'] == 'ac718fed08570a81b3587587872ad85a25173afa5f9fbbd0c03ba4d1714cfa3e'43assert v['bitcoin-22.0-osx64.tar.gz'] == '2744d199c3343b2d94faffdfb2c94d75a630ba27301a70e47b0ad30a7e0155e9'44assert v['bitcoin-22.0-x86_64-linux-gnu.tar.gz'] == '59ebd25dd82a51638b7a6bb914586201e67db67b919b2a1ff08925a7936d1b16'47def run_verify(global_args: str, command: str, command_args: str) -> subprocess.CompletedProcess:48maybe_here = Path.cwd() / 'verify.py'49path = maybe_here if maybe_here.exists() else Path.cwd() / 'contrib' / 'verify-binaries' / 'verify.py'51if command == "pub":52command += " --cleanup"54return subprocess.run(55f"{path} {global_args} {command} {command_args}",56stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)59def expect_code(completed: subprocess.CompletedProcess, expected_code: int, msg: str):60if completed.returncode != expected_code:61print(f"{msg!r} failed: got code {completed.returncode}, expected {expected_code}")62print_process_failure(completed)63sys.exit(1)64else:65print(f"✓ {msg!r} passed")68def print_process_failure(completed: subprocess.CompletedProcess):69print(f"stdout:\n{completed.stdout.decode()}")70print(f"stderr:\n{completed.stderr.decode()}")73if __name__ == '__main__':74main()
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.