Bitcoin Core  27.99.0
P2P Digital Currency
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 #if defined(HAVE_CONFIG_H)
7 #endif
8 
9 #include <clientversion.h>
10 #include <util/translation.h>
11 
12 #include <tinyformat.h>
13 
14 #include <sstream>
15 #include <string>
16 #include <vector>
17 
23 const 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 "-unk"
50  #endif
51 #endif
52 
53 static std::string FormatVersion(int nVersion)
54 {
55  return strprintf("%d.%d.%d", nVersion / 10000, (nVersion / 100) % 100, nVersion % 100);
56 }
57 
58 std::string FormatFullVersion()
59 {
60  static const std::string CLIENT_BUILD(BUILD_DESC BUILD_SUFFIX);
61  return CLIENT_BUILD;
62 }
63 
67 std::string FormatSubVersion(const std::string& name, int nClientVersion, const std::vector<std::string>& comments)
68 {
69  std::ostringstream ss;
70  ss << "/";
71  ss << name << ":" << FormatVersion(nClientVersion);
72  if (!comments.empty())
73  {
74  std::vector<std::string>::const_iterator it(comments.begin());
75  ss << "(" << *it;
76  for(++it; it != comments.end(); ++it)
77  ss << "; " << *it;
78  ss << ")";
79  }
80  ss << "/";
81  return ss.str();
82 }
83 
84 std::string CopyrightHolders(const std::string& strPrefix)
85 {
86  const auto copyright_devs = strprintf(_(COPYRIGHT_HOLDERS).translated, COPYRIGHT_HOLDERS_SUBSTITUTION);
87  std::string strCopyrightHolders = strPrefix + copyright_devs;
88 
89  // Make sure Bitcoin Core copyright is not removed by accident
90  if (copyright_devs.find("Bitcoin Core") == std::string::npos) {
91  strCopyrightHolders += "\n" + strPrefix + "The Bitcoin Core developers";
92  }
93  return strCopyrightHolders;
94 }
95 
96 std::string LicenseInfo()
97 {
98  const std::string URL_SOURCE_CODE = "<https://github.com/bitcoin/bitcoin>";
99 
100  return CopyrightHolders(strprintf(_("Copyright (C) %i-%i").translated, 2009, COPYRIGHT_YEAR) + " ") + "\n" +
101  "\n" +
102  strprintf(_("Please contribute if you find %s useful. "
103  "Visit %s for further information about the software.").translated, PACKAGE_NAME, "<" PACKAGE_URL ">") +
104  "\n" +
105  strprintf(_("The source code is available from %s.").translated, URL_SOURCE_CODE) +
106  "\n" +
107  "\n" +
108  _("This is experimental software.").translated + "\n" +
109  strprintf(_("Distributed under the MIT software license, see the accompanying file %s or %s").translated, "COPYING", "<https://opensource.org/licenses/MIT>") +
110  "\n";
111 }
#define PACKAGE_NAME
#define COPYRIGHT_YEAR
#define PACKAGE_URL
#define COPYRIGHT_HOLDERS_SUBSTITUTION
#define COPYRIGHT_HOLDERS
const std::string CLIENT_NAME("Satoshi")
Name of client reported in the 'version' message.
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 char * name
Definition: rest.cpp:50
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...
Definition: tinyformat.h:1162
bilingual_str _(const char *psz)
Translation function.
Definition: translation.h:74