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// Copyright (c) 2012-present The Bitcoin Core developers2// Distributed under the MIT software license, see the accompanying3// file COPYING or http://www.opensource.org/licenses/mit-license.php.5#include <bitcoin-build-config.h> // IWYU pragma: keep7#include <clientversion.h>9#include <tinyformat.h>10#include <util/string.h>12#include <string>13#include <vector>15using util::Join;17/**18* Name of client reported in the 'version' message. Report the same name19* for both bitcoind and bitcoin-qt, to make it harder for attackers to20* target servers or GUI users specifically.21*/22const std::string UA_NAME("Satoshi");25#include <bitcoin-build-info.h> // IWYU pragma: keep26// The <bitcoin-build-info.h>, which is generated by the build environment (cmake/script/GenerateBuildInfo.cmake),27// could contain only one line of the following:28// - "#define BUILD_GIT_TAG ...", if the top commit is tagged29// - "#define BUILD_GIT_COMMIT ...", if the top commit is not tagged30// - "// No build information available", if proper git information is not available32// git will expand the next line to "#define GIT_COMMIT_ID ..." inside archives:33//34#define GIT_COMMIT_ID "f0de87f040621468b956f01f526a43a010310501"36#ifdef BUILD_GIT_TAG37#define BUILD_DESC BUILD_GIT_TAG38#define BUILD_SUFFIX ""39#else40#define BUILD_DESC "v" CLIENT_VERSION_STRING41#if CLIENT_VERSION_IS_RELEASE42#define BUILD_SUFFIX ""43#elif defined(BUILD_GIT_COMMIT)44#define BUILD_SUFFIX "-" BUILD_GIT_COMMIT45#elif defined(GIT_COMMIT_ID)46#define BUILD_SUFFIX "-g" GIT_COMMIT_ID47#else48#define BUILD_SUFFIX "-unk"49#endif50#endif52static std::string FormatVersion(int nVersion)53{54return strprintf("%d.%d.%d", nVersion / 10000, (nVersion / 100) % 100, nVersion % 100);55}57std::string FormatFullVersion()58{59static const std::string CLIENT_BUILD(BUILD_DESC BUILD_SUFFIX);60return CLIENT_BUILD;61}63/**64* Format the subversion field according to BIP 14 spec (https://github.com/bitcoin/bips/blob/master/bip-0014.mediawiki)65*/66std::string FormatSubVersion(const std::string& name, int nClientVersion, const std::vector<std::string>& comments)67{68std::string comments_str;69if (!comments.empty()) comments_str = strprintf("(%s)", Join(comments, "; "));70return strprintf("/%s:%s%s/", name, FormatVersion(nClientVersion), comments_str);71}