LCOV - code coverage report
Current view: top level - src - clientversion.cpp (source / functions) Hit Total Coverage
Test: coverage.lcov Lines: 44 46 95.7 %
Date: 2022-04-21 14:51:19 Functions: 5 5 100.0 %
Legend: Modified by patch:
Lines: hit not hit | Branches: + taken - not taken # not executed

Not modified by patch:
Lines: hit not hit | Branches: + taken - not taken # not executed
Branches: 5 6 83.3 %

           Branch data     Line data    Source code
#       1                 :            : // Copyright (c) 2012-2021 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 <clientversion.h>
#       6                 :            : #include <util/translation.h>
#       7                 :            : 
#       8                 :            : #include <tinyformat.h>
#       9                 :            : 
#      10                 :            : #include <sstream>
#      11                 :            : #include <string>
#      12                 :            : #include <vector>
#      13                 :            : 
#      14                 :            : /**
#      15                 :            :  * Name of client reported in the 'version' message. Report the same name
#      16                 :            :  * for both bitcoind and bitcoin-qt, to make it harder for attackers to
#      17                 :            :  * target servers or GUI users specifically.
#      18                 :            :  */
#      19                 :            : const std::string CLIENT_NAME("Satoshi");
#      20                 :            : 
#      21                 :            : 
#      22                 :            : #ifdef HAVE_BUILD_INFO
#      23                 :            : #include <obj/build.h>
#      24                 :            : // The <obj/build.h>, which is generated by the build environment (share/genbuild.sh),
#      25                 :            : // could contain only one line of the following:
#      26                 :            : //   - "#define BUILD_GIT_TAG ...", if the top commit is tagged
#      27                 :            : //   - "#define BUILD_GIT_COMMIT ...", if the top commit is not tagged
#      28                 :            : //   - "// No build information available", if proper git information is not available
#      29                 :            : #endif
#      30                 :            : 
#      31                 :            : //! git will put "#define GIT_COMMIT_ID ..." on the next line inside archives. $Format:%n#define GIT_COMMIT_ID "%H"$
#      32                 :            : 
#      33                 :            : #ifdef BUILD_GIT_TAG
#      34                 :            :     #define BUILD_DESC BUILD_GIT_TAG
#      35                 :            :     #define BUILD_SUFFIX ""
#      36                 :            : #else
#      37                 :       1652 :     #define BUILD_DESC "v" PACKAGE_VERSION
#      38                 :            :     #if CLIENT_VERSION_IS_RELEASE
#      39                 :            :         #define BUILD_SUFFIX ""
#      40                 :            :     #elif defined(BUILD_GIT_COMMIT)
#      41                 :       1652 :         #define BUILD_SUFFIX "-" BUILD_GIT_COMMIT
#      42                 :            :     #elif defined(GIT_COMMIT_ID)
#      43                 :            :         #define BUILD_SUFFIX "-g" GIT_COMMIT_ID
#      44                 :            :     #else
#      45                 :            :         #define BUILD_SUFFIX "-unk"
#      46                 :            :     #endif
#      47                 :            : #endif
#      48                 :            : 
#      49                 :            : static std::string FormatVersion(int nVersion)
#      50                 :        757 : {
#      51                 :        757 :     return strprintf("%d.%d.%d", nVersion / 10000, (nVersion / 100) % 100, nVersion % 100);
#      52                 :        757 : }
#      53                 :            : 
#      54                 :            : std::string FormatFullVersion()
#      55                 :       1652 : {
#      56                 :       1652 :     static const std::string CLIENT_BUILD(BUILD_DESC BUILD_SUFFIX);
#      57                 :       1652 :     return CLIENT_BUILD;
#      58                 :       1652 : }
#      59                 :            : 
#      60                 :            : /**
#      61                 :            :  * Format the subversion field according to BIP 14 spec (https://github.com/bitcoin/bips/blob/master/bip-0014.mediawiki)
#      62                 :            :  */
#      63                 :            : std::string FormatSubVersion(const std::string& name, int nClientVersion, const std::vector<std::string>& comments)
#      64                 :        757 : {
#      65                 :        757 :     std::ostringstream ss;
#      66                 :        757 :     ss << "/";
#      67                 :        757 :     ss << name << ":" << FormatVersion(nClientVersion);
#      68         [ +  + ]:        757 :     if (!comments.empty())
#      69                 :        754 :     {
#      70                 :        754 :         std::vector<std::string>::const_iterator it(comments.begin());
#      71                 :        754 :         ss << "(" << *it;
#      72         [ +  + ]:        765 :         for(++it; it != comments.end(); ++it)
#      73                 :         11 :             ss << "; " << *it;
#      74                 :        754 :         ss << ")";
#      75                 :        754 :     }
#      76                 :        757 :     ss << "/";
#      77                 :        757 :     return ss.str();
#      78                 :        757 : }
#      79                 :            : 
#      80                 :            : std::string CopyrightHolders(const std::string& strPrefix)
#      81                 :          3 : {
#      82                 :          3 :     const auto copyright_devs = strprintf(_(COPYRIGHT_HOLDERS).translated, COPYRIGHT_HOLDERS_SUBSTITUTION);
#      83                 :          3 :     std::string strCopyrightHolders = strPrefix + copyright_devs;
#      84                 :            : 
#      85                 :            :     // Make sure Bitcoin Core copyright is not removed by accident
#      86         [ -  + ]:          3 :     if (copyright_devs.find("Bitcoin Core") == std::string::npos) {
#      87                 :          0 :         strCopyrightHolders += "\n" + strPrefix + "The Bitcoin Core developers";
#      88                 :          0 :     }
#      89                 :          3 :     return strCopyrightHolders;
#      90                 :          3 : }
#      91                 :            : 
#      92                 :            : std::string LicenseInfo()
#      93                 :          3 : {
#      94                 :          3 :     const std::string URL_SOURCE_CODE = "<https://github.com/bitcoin/bitcoin>";
#      95                 :            : 
#      96                 :          3 :     return CopyrightHolders(strprintf(_("Copyright (C) %i-%i").translated, 2009, COPYRIGHT_YEAR) + " ") + "\n" +
#      97                 :          3 :            "\n" +
#      98                 :          3 :            strprintf(_("Please contribute if you find %s useful. "
#      99                 :          3 :                        "Visit %s for further information about the software.").translated, PACKAGE_NAME, "<" PACKAGE_URL ">") +
#     100                 :          3 :            "\n" +
#     101                 :          3 :            strprintf(_("The source code is available from %s.").translated, URL_SOURCE_CODE) +
#     102                 :          3 :            "\n" +
#     103                 :          3 :            "\n" +
#     104                 :          3 :            _("This is experimental software.").translated + "\n" +
#     105                 :          3 :            strprintf(_("Distributed under the MIT software license, see the accompanying file %s or %s").translated, "COPYING", "<https://opensource.org/licenses/MIT>") +
#     106                 :          3 :            "\n";
#     107                 :          3 : }

Generated by: LCOV version 0-eol-96201-ge66f56f4af6a