]> Git Repo - VerusCoin.git/blame - src/clientversion.cpp
PBaaS refund fix to fund refund transactions with gateway deposits
[VerusCoin.git] / src / clientversion.cpp
CommitLineData
f914f1a7 1// Copyright (c) 2012-2014 The Bitcoin Core developers
6395ba30 2// Distributed under the MIT software license, see the accompanying
bc909a7a 3// file COPYING or https://www.opensource.org/licenses/mit-license.php .
a20c0d0f 4
71697f97 5#include "clientversion.h"
a20c0d0f 6
6e5fd003
WL
7#include "tinyformat.h"
8
51ed9ec9 9#include <string>
611116d4 10
899d8cf5
JG
11#include <boost/preprocessor/arithmetic/add.hpp>
12#include <boost/preprocessor/arithmetic/sub.hpp>
13#include <boost/preprocessor/comparison/equal.hpp>
14#include <boost/preprocessor/comparison/less.hpp>
15#include <boost/preprocessor/control/if.hpp>
16
6395ba30
MF
17/**
18 * Name of client reported in the 'version' message. Report the same name
19 * for both bitcoind and bitcoin-core, to make it harder for attackers to
20 * target servers or GUI users specifically.
21 */
5bd677f5 22const std::string CLIENT_NAME("MagicBean");
a20c0d0f 23
6395ba30
MF
24/**
25 * Client version number
26 */
20e01b1a 27#define CLIENT_VERSION_SUFFIX ""
a20c0d0f 28
a20c0d0f 29
6395ba30
MF
30/**
31 * The following part of the code determines the CLIENT_BUILD variable.
32 * Several mechanisms are used for this:
33 * * first, if HAVE_BUILD_INFO is defined, include build.h, a file that is
34 * generated by the build environment, possibly containing the output
35 * of git-describe in a macro called BUILD_DESC
36 * * secondly, if this is an exported version of the code, GIT_ARCHIVE will
37 * be defined (automatically using the export-subst git attribute), and
38 * GIT_COMMIT will contain the commit id.
39 * * then, three options exist for determining CLIENT_BUILD:
40 * * if BUILD_DESC is defined, use that literally (output of git-describe)
41 * * if not, but GIT_COMMIT is defined, use v[maj].[min].[rev].[build]-g[commit]
42 * * otherwise, use v[maj].[min].[rev].[build]-unk
43 * finally CLIENT_VERSION_SUFFIX is added
44 */
45
46//! First, include build.h if requested
a20c0d0f 47#ifdef HAVE_BUILD_INFO
20e01b1a 48#include "build.h"
a20c0d0f
PW
49#endif
50
8b78a819
T
51//! git will put "#define GIT_ARCHIVE 1" on the next line inside archives.
52#define GIT_ARCHIVE 1
a20c0d0f 53#ifdef GIT_ARCHIVE
8b78a819
T
54#define GIT_COMMIT_ID "a86845f3dc"
55#define GIT_COMMIT_DATE "Wed, 21 Feb 2018 16:15:11 +0200"
a20c0d0f
PW
56#endif
57
f6908714 58#define RENDER_BETA_STRING(num) "-beta" DO_STRINGIZE(num)
899d8cf5
JG
59#define RENDER_RC_STRING(num) "-rc" DO_STRINGIZE(num)
60#define RENDER_DEV_STRING(num) "-" DO_STRINGIZE(num)
61
62#define RENDER_BUILD(build) \
63 BOOST_PP_IF( \
64 BOOST_PP_LESS(build, 25), \
65 RENDER_BETA_STRING(BOOST_PP_ADD(build, 1)), \
66 BOOST_PP_IF( \
67 BOOST_PP_LESS(build, 50), \
68 RENDER_RC_STRING(BOOST_PP_SUB(build, 24)), \
69 BOOST_PP_IF( \
70 BOOST_PP_EQUAL(build, 50), \
71 "", \
72 RENDER_DEV_STRING(BOOST_PP_SUB(build, 50)))))
73
48bb727d 74#define BUILD_DESC_WITH_SUFFIX(maj, min, rev, build, suffix) \
899d8cf5 75 "v" DO_STRINGIZE(maj) "." DO_STRINGIZE(min) "." DO_STRINGIZE(rev) RENDER_BUILD(build) "-" DO_STRINGIZE(suffix)
3d20cd5f 76
48bb727d 77#define BUILD_DESC_FROM_COMMIT(maj, min, rev, build, commit) \
899d8cf5 78 "v" DO_STRINGIZE(maj) "." DO_STRINGIZE(min) "." DO_STRINGIZE(rev) RENDER_BUILD(build) "-g" commit
a20c0d0f 79
48bb727d 80#define BUILD_DESC_FROM_UNKNOWN(maj, min, rev, build) \
899d8cf5 81 "v" DO_STRINGIZE(maj) "." DO_STRINGIZE(min) "." DO_STRINGIZE(rev) RENDER_BUILD(build) "-unk"
a20c0d0f
PW
82
83#ifndef BUILD_DESC
20e01b1a 84#ifdef BUILD_SUFFIX
48bb727d 85#define BUILD_DESC BUILD_DESC_WITH_SUFFIX(CLIENT_VERSION_MAJOR, CLIENT_VERSION_MINOR, CLIENT_VERSION_REVISION, CLIENT_VERSION_BUILD, BUILD_SUFFIX)
20e01b1a 86#elif defined(GIT_COMMIT_ID)
48bb727d 87#define BUILD_DESC BUILD_DESC_FROM_COMMIT(CLIENT_VERSION_MAJOR, CLIENT_VERSION_MINOR, CLIENT_VERSION_REVISION, CLIENT_VERSION_BUILD, GIT_COMMIT_ID)
20e01b1a 88#else
48bb727d 89#define BUILD_DESC BUILD_DESC_FROM_UNKNOWN(CLIENT_VERSION_MAJOR, CLIENT_VERSION_MINOR, CLIENT_VERSION_REVISION, CLIENT_VERSION_BUILD)
20e01b1a 90#endif
a20c0d0f
PW
91#endif
92
93#ifndef BUILD_DATE
20e01b1a
PW
94#ifdef GIT_COMMIT_DATE
95#define BUILD_DATE GIT_COMMIT_DATE
96#else
97#define BUILD_DATE __DATE__ ", " __TIME__
98#endif
a20c0d0f
PW
99#endif
100
101const std::string CLIENT_BUILD(BUILD_DESC CLIENT_VERSION_SUFFIX);
102const std::string CLIENT_DATE(BUILD_DATE);
6e5fd003 103
5b3bc971 104std::string FormatVersion(int nVersion)
6e5fd003 105{
899d8cf5 106 if (nVersion % 100 < 25)
f6908714 107 return strprintf("%d.%d.%d-beta%d", nVersion / 1000000, (nVersion / 10000) % 100, (nVersion / 100) % 100, (nVersion % 100)+1);
899d8cf5
JG
108 if (nVersion % 100 < 50)
109 return strprintf("%d.%d.%d-rc%d", nVersion / 1000000, (nVersion / 10000) % 100, (nVersion / 100) % 100, (nVersion % 100)-24);
110 else if (nVersion % 100 == 50)
20e01b1a 111 return strprintf("%d.%d.%d", nVersion / 1000000, (nVersion / 10000) % 100, (nVersion / 100) % 100);
6e5fd003 112 else
899d8cf5 113 return strprintf("%d.%d.%d-%d", nVersion / 1000000, (nVersion / 10000) % 100, (nVersion / 100) % 100, (nVersion % 100)-50);
6e5fd003
WL
114}
115
116std::string FormatFullVersion()
117{
118 return CLIENT_BUILD;
119}
120
f6908714
A
121/**
122 * Format the subversion field according to BIP 14 spec (https://github.com/bitcoin/bips/blob/master/bip-0014.mediawiki)
6395ba30 123 */
6e5fd003
WL
124std::string FormatSubVersion(const std::string& name, int nClientVersion, const std::vector<std::string>& comments)
125{
126 std::ostringstream ss;
127 ss << "/";
128 ss << name << ":" << FormatVersion(nClientVersion);
129 if (!comments.empty())
5f4bcf6b
CF
130 {
131 std::vector<std::string>::const_iterator it(comments.begin());
132 ss << "(" << *it;
133 for(++it; it != comments.end(); ++it)
134 ss << "; " << *it;
135 ss << ")";
136 }
6e5fd003
WL
137 ss << "/";
138 return ss.str();
f6908714 139}
This page took 0.254725 seconds and 4 git commands to generate.