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