LCOV - code coverage report
Current view: top level - src - clientversion.cpp (source / functions) Hit Total Coverage
Test: test_dash_coverage.info Lines: 19 44 43.2 %
Date: 2026-06-25 07:23:51 Functions: 3 5 60.0 %

          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 dashd and dash-qt, to make it harder for attackers to
      17             :  * target servers or GUI users specifically.
      18             :  */
      19             : const std::string CLIENT_NAME("Dash Core");
      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_DESCRIPTION ...", if the top commit is not tagged
      27             : //   - "// No build information available", if proper git information is not available
      28             : #endif
      29             : 
      30             : //! git will put "#define ARCHIVE_GIT_DESCRIPTION ..." on the next line inside archives. $Format:%n#define ARCHIVE_GIT_DESCRIPTION "%(describe:abbrev=12)"$
      31             : 
      32             : #if CLIENT_VERSION_IS_RELEASE
      33             :     #define BUILD_DESC "v" PACKAGE_VERSION
      34             :     #define BUILD_SUFFIX ""
      35             : #else
      36             :     #if defined(BUILD_GIT_DESCRIPTION)
      37             :         // build in a cloned folder
      38             :         #define BUILD_DESC BUILD_GIT_DESCRIPTION
      39             :         #define BUILD_SUFFIX ""
      40             :     #elif defined(ARCHIVE_GIT_DESCRIPTION)
      41             :         // build in a folder from git archive
      42             :         #define BUILD_DESC ARCHIVE_GIT_DESCRIPTION
      43             :         #define BUILD_SUFFIX ""
      44             :     #else
      45             :         #define BUILD_DESC "v" PACKAGE_VERSION
      46             :         #define BUILD_SUFFIX "-unk"
      47             :     #endif
      48             : #endif
      49             : 
      50           6 : std::string FormatVersion(int nVersion)
      51             : {
      52           6 :     return strprintf("%d.%d.%d", nVersion / 10000, (nVersion / 100) % 100, nVersion % 100);
      53             : }
      54             : 
      55         639 : std::string FormatFullVersion()
      56             : {
      57         639 :     static const std::string CLIENT_BUILD(BUILD_DESC BUILD_SUFFIX);
      58         639 :     return CLIENT_BUILD;
      59           0 : }
      60             : 
      61             : /**
      62             :  * Format the subversion field according to BIP 14 spec (https://github.com/bitcoin/bips/blob/master/bip-0014.mediawiki)
      63             :  */
      64           6 : std::string FormatSubVersion(const std::string& name, int nClientVersion, const std::vector<std::string>& comments)
      65             : {
      66           6 :     std::ostringstream ss;
      67           6 :     ss << "/";
      68           6 :     ss << name << ":" << FormatVersion(nClientVersion);
      69           6 :     if (!comments.empty())
      70             :     {
      71           4 :         std::vector<std::string>::const_iterator it(comments.begin());
      72           4 :         ss << "(" << *it;
      73           6 :         for(++it; it != comments.end(); ++it)
      74           2 :             ss << "; " << *it;
      75           4 :         ss << ")";
      76           4 :     }
      77           6 :     ss << "/";
      78           6 :     return ss.str();
      79           6 : }
      80             : 
      81           0 : std::string CopyrightHolders(const std::string& strPrefix, unsigned int nStartYear, unsigned int nEndYear)
      82             : {
      83           0 :     const auto copyright_devs = strprintf(_(COPYRIGHT_HOLDERS).translated, COPYRIGHT_HOLDERS_SUBSTITUTION);
      84           0 :     std::string strCopyrightHolders = strPrefix + strprintf(" %u-%u ", nStartYear, nEndYear) + copyright_devs;
      85             : 
      86             :     // Check for untranslated substitution to make sure Dash Core copyright is not removed by accident
      87           0 :     if (copyright_devs.find("Dash Core") == std::string::npos) {
      88           0 :         strCopyrightHolders += "\n" + strPrefix + strprintf(" %u-%u ", 2014, nEndYear) + "The Dash Core developers";
      89           0 :     }
      90             :     // Check for untranslated substitution to make sure Bitcoin Core copyright is not removed by accident
      91           0 :     if (copyright_devs.find("Bitcoin Core") == std::string::npos) {
      92           0 :         strCopyrightHolders += "\n" + strPrefix + strprintf(" %u-%u ", 2009, nEndYear) + "The Bitcoin Core developers";
      93           0 :     }
      94           0 :     return strCopyrightHolders;
      95           0 : }
      96             : 
      97           0 : std::string LicenseInfo()
      98             : {
      99           0 :     const std::string URL_SOURCE_CODE = "<https://github.com/dashpay/dash>";
     100             : 
     101           0 :     return CopyrightHolders(_("Copyright (C)").translated, 2014, COPYRIGHT_YEAR) + "\n" +
     102           0 :            "\n" +
     103           0 :            strprintf(_("Please contribute if you find %s useful. "
     104           0 :                        "Visit %s for further information about the software.").translated, PACKAGE_NAME, "<" PACKAGE_URL ">") +
     105           0 :            "\n" +
     106           0 :            strprintf(_("The source code is available from %s.").translated, URL_SOURCE_CODE) +
     107           0 :            "\n" +
     108           0 :            "\n" +
     109           0 :            _("This is experimental software.").translated + "\n" +
     110           0 :            strprintf(_("Distributed under the MIT software license, see the accompanying file %s or %s").translated, "COPYING", "<https://opensource.org/licenses/MIT>") +
     111             :            "\n";
     112           0 : }

Generated by: LCOV version 1.16