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 2924 : std::string FormatVersion(int nVersion) 51 : { 52 2924 : return strprintf("%d.%d.%d", nVersion / 10000, (nVersion / 100) % 100, nVersion % 100); 53 : } 54 : 55 7998 : std::string FormatFullVersion() 56 : { 57 7998 : static const std::string CLIENT_BUILD(BUILD_DESC BUILD_SUFFIX); 58 7998 : 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 2924 : std::string FormatSubVersion(const std::string& name, int nClientVersion, const std::vector<std::string>& comments) 65 : { 66 2924 : std::ostringstream ss; 67 2924 : ss << "/"; 68 2924 : ss << name << ":" << FormatVersion(nClientVersion); 69 2924 : if (!comments.empty()) 70 : { 71 2922 : std::vector<std::string>::const_iterator it(comments.begin()); 72 2922 : ss << "(" << *it; 73 2946 : for(++it; it != comments.end(); ++it) 74 24 : ss << "; " << *it; 75 2922 : ss << ")"; 76 2922 : } 77 2924 : ss << "/"; 78 2924 : return ss.str(); 79 2924 : } 80 : 81 6 : std::string CopyrightHolders(const std::string& strPrefix, unsigned int nStartYear, unsigned int nEndYear) 82 : { 83 6 : const auto copyright_devs = strprintf(_(COPYRIGHT_HOLDERS).translated, COPYRIGHT_HOLDERS_SUBSTITUTION); 84 6 : 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 6 : 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 6 : if (copyright_devs.find("Bitcoin Core") == std::string::npos) { 92 6 : strCopyrightHolders += "\n" + strPrefix + strprintf(" %u-%u ", 2009, nEndYear) + "The Bitcoin Core developers"; 93 6 : } 94 6 : return strCopyrightHolders; 95 6 : } 96 : 97 6 : std::string LicenseInfo() 98 : { 99 6 : const std::string URL_SOURCE_CODE = "<https://github.com/dashpay/dash>"; 100 : 101 12 : return CopyrightHolders(_("Copyright (C)").translated, 2014, COPYRIGHT_YEAR) + "\n" + 102 6 : "\n" + 103 6 : strprintf(_("Please contribute if you find %s useful. " 104 12 : "Visit %s for further information about the software.").translated, PACKAGE_NAME, "<" PACKAGE_URL ">") + 105 6 : "\n" + 106 12 : strprintf(_("The source code is available from %s.").translated, URL_SOURCE_CODE) + 107 6 : "\n" + 108 6 : "\n" + 109 12 : _("This is experimental software.").translated + "\n" + 110 12 : strprintf(_("Distributed under the MIT software license, see the accompanying file %s or %s").translated, "COPYING", "<https://opensource.org/licenses/MIT>") + 111 : "\n"; 112 6 : }