Bitcoin Core 28.0.0
P2P Digital Currency
Loading...
Searching...
No Matches
clientversion.cpp
Go to the documentation of this file.
1// Copyright (c) 2012-2022 The Bitcoin Core developers
2// Distributed under the MIT software license, see the accompanying
3// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5#include <config/bitcoin-config.h> // IWYU pragma: keep
6
7#include <clientversion.h>
8#include <util/string.h>
9#include <util/translation.h>
10
11#include <tinyformat.h>
12
13#include <string>
14#include <vector>
15
16using util::Join;
17
23const std::string CLIENT_NAME("Satoshi");
24
25
26#ifdef HAVE_BUILD_INFO
27#include <obj/build.h>
28// The <obj/build.h>, which is generated by the build environment (share/genbuild.sh),
29// could contain only one line of the following:
30// - "#define BUILD_GIT_TAG ...", if the top commit is tagged
31// - "#define BUILD_GIT_COMMIT ...", if the top commit is not tagged
32// - "// No build information available", if proper git information is not available
33#endif
34
36
37#ifdef BUILD_GIT_TAG
38 #define BUILD_DESC BUILD_GIT_TAG
39 #define BUILD_SUFFIX ""
40#else
41 #define BUILD_DESC "v" PACKAGE_VERSION
42 #if CLIENT_VERSION_IS_RELEASE
43 #define BUILD_SUFFIX ""
44 #elif defined(BUILD_GIT_COMMIT)
45 #define BUILD_SUFFIX "-" BUILD_GIT_COMMIT
46 #elif defined(GIT_COMMIT_ID)
47 #define BUILD_SUFFIX "-g" GIT_COMMIT_ID
48 #else
49 #define BUILD_SUFFIX "-suse"
50 #endif
51#endif
52
53static std::string FormatVersion(int nVersion)
54{
55 return strprintf("%d.%d.%d", nVersion / 10000, (nVersion / 100) % 100, nVersion % 100);
56}
57
58std::string FormatFullVersion()
59{
60 static const std::string CLIENT_BUILD(BUILD_DESC BUILD_SUFFIX);
61 return CLIENT_BUILD;
62}
63
67std::string FormatSubVersion(const std::string& name, int nClientVersion, const std::vector<std::string>& comments)
68{
69 std::string comments_str;
70 if (!comments.empty()) comments_str = strprintf("(%s)", Join(comments, "; "));
71 return strprintf("/%s:%s%s/", name, FormatVersion(nClientVersion), comments_str);
72}
73
74std::string CopyrightHolders(const std::string& strPrefix)
75{
76 const auto copyright_devs = strprintf(_(COPYRIGHT_HOLDERS).translated, COPYRIGHT_HOLDERS_SUBSTITUTION);
77 std::string strCopyrightHolders = strPrefix + copyright_devs;
78
79 // Make sure Bitcoin Core copyright is not removed by accident
80 if (copyright_devs.find("Bitcoin Core") == std::string::npos) {
81 strCopyrightHolders += "\n" + strPrefix + "The Bitcoin Core developers";
82 }
83 return strCopyrightHolders;
84}
85
86std::string LicenseInfo()
87{
88 const std::string URL_SOURCE_CODE = "<https://github.com/bitcoin/bitcoin>";
89
90 return CopyrightHolders(strprintf(_("Copyright (C) %i-%i").translated, 2009, COPYRIGHT_YEAR) + " ") + "\n" +
91 "\n" +
92 strprintf(_("Please contribute if you find %s useful. "
93 "Visit %s for further information about the software.").translated, PACKAGE_NAME, "<" PACKAGE_URL ">") +
94 "\n" +
95 strprintf(_("The source code is available from %s.").translated, URL_SOURCE_CODE) +
96 "\n" +
97 "\n" +
98 _("This is experimental software.").translated + "\n" +
99 strprintf(_("Distributed under the MIT software license, see the accompanying file %s or %s").translated, "COPYING", "<https://opensource.org/licenses/MIT>") +
100 "\n";
101}
#define PACKAGE_NAME
#define COPYRIGHT_YEAR
#define PACKAGE_URL
#define COPYRIGHT_HOLDERS_SUBSTITUTION
#define COPYRIGHT_HOLDERS
std::string CopyrightHolders(const std::string &strPrefix)
std::string FormatSubVersion(const std::string &name, int nClientVersion, const std::vector< std::string > &comments)
Format the subversion field according to BIP 14 spec (https://github.com/bitcoin/bips/blob/master/bip...
#define BUILD_SUFFIX
#define BUILD_DESC
git will put "#define GIT_COMMIT_ID ..." on the next line inside archives.
static std::string FormatVersion(int nVersion)
std::string FormatFullVersion()
std::string LicenseInfo()
Returns licensing information (for -version)
const std::string CLIENT_NAME
auto Join(const C &container, const S &separator, UnaryOp unary_op)
Join all container items.
Definition string.h:115
const char * name
Definition rest.cpp:49
std::string translated
Definition translation.h:20
#define strprintf
Format arguments and return the string or write to given std::ostream (see tinyformat::format doc for...
bilingual_str _(ConstevalStringLiteral str)
Translation function.
Definition translation.h:80