aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/release-process.txt2
-rw-r--r--src/bignum.h6
-rw-r--r--src/bitcoinrpc.cpp3
-rw-r--r--src/db.cpp10
-rw-r--r--src/main.cpp11
-rw-r--r--src/main.h7
-rw-r--r--src/net.cpp15
-rw-r--r--src/net.h12
-rw-r--r--src/serialize.h76
-rw-r--r--src/uint256.h6
-rw-r--r--src/util.cpp14
-rw-r--r--src/util.h4
12 files changed, 96 insertions, 70 deletions
diff --git a/doc/release-process.txt b/doc/release-process.txt
index 14d8efeb32..ee1a5d4a34 100644
--- a/doc/release-process.txt
+++ b/doc/release-process.txt
@@ -1,6 +1,6 @@
* update (commit) version in sources
bitcoin-qt.pro
- src/serialize.h
+ src/main.h (CLIENT_VERSION : PROTOCOL_VERSION in serialize.h is updated only on protocol changes)
share/setup.nsi
doc/README*
diff --git a/src/bignum.h b/src/bignum.h
index 1a2406b935..f5d545f07e 100644
--- a/src/bignum.h
+++ b/src/bignum.h
@@ -338,19 +338,19 @@ public:
return ToString(16);
}
- unsigned int GetSerializeSize(int nType=0, int nVersion=VERSION) const
+ unsigned int GetSerializeSize(int nType=0, int nVersion=PROTOCOL_VERSION) const
{
return ::GetSerializeSize(getvch(), nType, nVersion);
}
template<typename Stream>
- void Serialize(Stream& s, int nType=0, int nVersion=VERSION) const
+ void Serialize(Stream& s, int nType=0, int nVersion=PROTOCOL_VERSION) const
{
::Serialize(s, getvch(), nType, nVersion);
}
template<typename Stream>
- void Unserialize(Stream& s, int nType=0, int nVersion=VERSION)
+ void Unserialize(Stream& s, int nType=0, int nVersion=PROTOCOL_VERSION)
{
std::vector<unsigned char> vch;
::Unserialize(s, vch, nType, nVersion);
diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp
index bb8d8e2d77..f29b9dd50e 100644
--- a/src/bitcoinrpc.cpp
+++ b/src/bitcoinrpc.cpp
@@ -304,7 +304,8 @@ Value getinfo(const Array& params, bool fHelp)
"Returns an object containing various state info.");
Object obj;
- obj.push_back(Pair("version", (int)VERSION));
+ obj.push_back(Pair("version", (int)CLIENT_VERSION));
+ obj.push_back(Pair("protocolversion",(int)PROTOCOL_VERSION));
obj.push_back(Pair("balance", ValueFromAmount(pwalletMain->GetBalance())));
obj.push_back(Pair("blocks", (int)nBestHeight));
obj.push_back(Pair("connections", (int)vNodes.size()));
diff --git a/src/db.cpp b/src/db.cpp
index 9ac93b3506..696fc736e0 100644
--- a/src/db.cpp
+++ b/src/db.cpp
@@ -131,7 +131,7 @@ CDB::CDB(const char* pszFile, const char* pszMode) : pdb(NULL)
{
bool fTmp = fReadOnly;
fReadOnly = false;
- WriteVersion(VERSION);
+ WriteVersion(CLIENT_VERSION);
fReadOnly = fTmp;
}
@@ -236,7 +236,7 @@ bool CDB::Rewrite(const string& strFile, const char* pszSkip)
{
// Update version:
ssValue.clear();
- ssValue << VERSION;
+ ssValue << CLIENT_VERSION;
}
Dbt datKey(&ssKey[0], ssKey.size());
Dbt datValue(&ssValue[0], ssValue.size());
@@ -931,7 +931,7 @@ int CWalletDB::LoadWallet(CWallet* pwallet)
{
int nMinVersion = 0;
ssValue >> nMinVersion;
- if (nMinVersion > VERSION)
+ if (nMinVersion > CLIENT_VERSION)
return DB_TOO_NEW;
}
}
@@ -956,13 +956,13 @@ int CWalletDB::LoadWallet(CWallet* pwallet)
if (fIsEncrypted && (nFileVersion == 40000 || nFileVersion == 50000))
return DB_NEED_REWRITE;
- if (nFileVersion < VERSION) // Update
+ if (nFileVersion < CLIENT_VERSION) // Update
{
// Get rid of old debug.log file in current directory
if (nFileVersion <= 105 && !pszSetDataDir[0])
unlink("debug.log");
- WriteVersion(VERSION);
+ WriteVersion(CLIENT_VERSION);
}
return DB_LOAD_OK;
diff --git a/src/main.cpp b/src/main.cpp
index a7871fcc16..1da28d4d9f 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -17,6 +17,11 @@ using namespace boost;
// Global state
//
+// Name of client reported in the 'version' message. Report the same name
+// for both bitcoind and bitcoin-qt, to make it harder for attackers to
+// target servers or GUI users specifically.
+const std::string CLIENT_NAME("bitcoin-qt");
+
CCriticalSection cs_setpwalletRegistered;
set<CWallet*> setpwalletRegistered;
@@ -1847,9 +1852,9 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
// Change version
if (pfrom->nVersion >= 209)
pfrom->PushMessage("verack");
- pfrom->vSend.SetVersion(min(pfrom->nVersion, VERSION));
+ pfrom->vSend.SetVersion(min(pfrom->nVersion, PROTOCOL_VERSION));
if (pfrom->nVersion < 209)
- pfrom->vRecv.SetVersion(min(pfrom->nVersion, VERSION));
+ pfrom->vRecv.SetVersion(min(pfrom->nVersion, PROTOCOL_VERSION));
if (!pfrom->fInbound)
{
@@ -1902,7 +1907,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
else if (strCommand == "verack")
{
- pfrom->vRecv.SetVersion(min(pfrom->nVersion, VERSION));
+ pfrom->vRecv.SetVersion(min(pfrom->nVersion, PROTOCOL_VERSION));
}
diff --git a/src/main.h b/src/main.h
index 3870cee864..e519ef6551 100644
--- a/src/main.h
+++ b/src/main.h
@@ -27,6 +27,10 @@ class CRequestTracker;
class CNode;
class CBlockIndex;
+static const int CLIENT_VERSION = 59900;
+static const bool VERSION_IS_BETA = true;
+extern const std::string CLIENT_NAME;
+
static const unsigned int MAX_BLOCK_SIZE = 1000000;
static const unsigned int MAX_BLOCK_SIZE_GEN = MAX_BLOCK_SIZE/2;
static const int MAX_BLOCK_SIGOPS = MAX_BLOCK_SIZE/50;
@@ -1521,6 +1525,7 @@ public:
bool AppliesTo(int nVersion, std::string strSubVerIn) const
{
+ // TODO: rework for client-version-embedded-in-strSubVer ?
return (IsInEffect() &&
nMinVer <= nVersion && nVersion <= nMaxVer &&
(setSubVer.empty() || setSubVer.count(strSubVerIn)));
@@ -1528,7 +1533,7 @@ public:
bool AppliesToMe() const
{
- return AppliesTo(VERSION, ::pszSubVer);
+ return AppliesTo(PROTOCOL_VERSION, FormatSubVersion(CLIENT_NAME, CLIENT_VERSION, std::vector<std::string>()));
}
bool RelayTo(CNode* pnode) const
diff --git a/src/net.cpp b/src/net.cpp
index 50d28913e0..7d2f18b2d0 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -727,6 +727,21 @@ void CNode::Cleanup()
}
+void CNode::PushVersion()
+{
+ /// when NTP implemented, change to just nTime = GetAdjustedTime()
+ int64 nTime = (fInbound ? GetAdjustedTime() : GetTime());
+ CAddress addrYou = (fUseProxy ? CAddress("0.0.0.0") : addr);
+ CAddress addrMe = (fUseProxy ? CAddress("0.0.0.0") : addrLocalHost);
+ RAND_bytes((unsigned char*)&nLocalHostNonce, sizeof(nLocalHostNonce));
+ PushMessage("version", PROTOCOL_VERSION, nLocalServices, nTime, addrYou, addrMe,
+ nLocalHostNonce, FormatSubVersion(CLIENT_NAME, CLIENT_VERSION, std::vector<string>()), nBestHeight);
+}
+
+
+
+
+
std::map<unsigned int, int64> CNode::setBanned;
CCriticalSection CNode::cs_setBanned;
diff --git a/src/net.h b/src/net.h
index 03da382df3..c2637dc6ac 100644
--- a/src/net.h
+++ b/src/net.h
@@ -355,18 +355,8 @@ public:
- void PushVersion()
- {
- /// when NTP implemented, change to just nTime = GetAdjustedTime()
- int64 nTime = (fInbound ? GetAdjustedTime() : GetTime());
- CAddress addrYou = (fUseProxy ? CAddress("0.0.0.0") : addr);
- CAddress addrMe = (fUseProxy ? CAddress("0.0.0.0") : addrLocalHost);
- RAND_bytes((unsigned char*)&nLocalHostNonce, sizeof(nLocalHostNonce));
- PushMessage("version", VERSION, nLocalServices, nTime, addrYou, addrMe,
- nLocalHostNonce, std::string(pszSubVer), nBestHeight);
- }
-
+ void PushVersion();
void PushMessage(const char* pszCommand)
diff --git a/src/serialize.h b/src/serialize.h
index efa59808f5..d3f6b7d703 100644
--- a/src/serialize.h
+++ b/src/serialize.h
@@ -60,9 +60,7 @@ class CDataStream;
class CAutoFile;
static const unsigned int MAX_SIZE = 0x02000000;
-static const int VERSION = 59900;
-static const char* pszSubVer = "";
-static const bool VERSION_IS_BETA = true;
+static const int PROTOCOL_VERSION = 60000;
// Used to bypass the rule against non-const reference to temporary
// where it makes sense with wrappers such as CFlatData or CTxDB
@@ -91,7 +89,7 @@ enum
};
#define IMPLEMENT_SERIALIZE(statements) \
- unsigned int GetSerializeSize(int nType=0, int nVersion=VERSION) const \
+ unsigned int GetSerializeSize(int nType=0, int nVersion=PROTOCOL_VERSION) const \
{ \
CSerActionGetSerializeSize ser_action; \
const bool fGetSize = true; \
@@ -105,7 +103,7 @@ enum
return nSerSize; \
} \
template<typename Stream> \
- void Serialize(Stream& s, int nType=0, int nVersion=VERSION) const \
+ void Serialize(Stream& s, int nType=0, int nVersion=PROTOCOL_VERSION) const \
{ \
CSerActionSerialize ser_action; \
const bool fGetSize = false; \
@@ -115,7 +113,7 @@ enum
{statements} \
} \
template<typename Stream> \
- void Unserialize(Stream& s, int nType=0, int nVersion=VERSION) \
+ void Unserialize(Stream& s, int nType=0, int nVersion=PROTOCOL_VERSION) \
{ \
CSerActionUnserialize ser_action; \
const bool fGetSize = false; \
@@ -362,43 +360,43 @@ template<typename Stream, typename C> void Unserialize(Stream& is, std::basic_st
// vector
template<typename T, typename A> unsigned int GetSerializeSize_impl(const std::vector<T, A>& v, int nType, int nVersion, const boost::true_type&);
template<typename T, typename A> unsigned int GetSerializeSize_impl(const std::vector<T, A>& v, int nType, int nVersion, const boost::false_type&);
-template<typename T, typename A> inline unsigned int GetSerializeSize(const std::vector<T, A>& v, int nType, int nVersion=VERSION);
+template<typename T, typename A> inline unsigned int GetSerializeSize(const std::vector<T, A>& v, int nType, int nVersion=PROTOCOL_VERSION);
template<typename Stream, typename T, typename A> void Serialize_impl(Stream& os, const std::vector<T, A>& v, int nType, int nVersion, const boost::true_type&);
template<typename Stream, typename T, typename A> void Serialize_impl(Stream& os, const std::vector<T, A>& v, int nType, int nVersion, const boost::false_type&);
-template<typename Stream, typename T, typename A> inline void Serialize(Stream& os, const std::vector<T, A>& v, int nType, int nVersion=VERSION);
+template<typename Stream, typename T, typename A> inline void Serialize(Stream& os, const std::vector<T, A>& v, int nType, int nVersion=PROTOCOL_VERSION);
template<typename Stream, typename T, typename A> void Unserialize_impl(Stream& is, std::vector<T, A>& v, int nType, int nVersion, const boost::true_type&);
template<typename Stream, typename T, typename A> void Unserialize_impl(Stream& is, std::vector<T, A>& v, int nType, int nVersion, const boost::false_type&);
-template<typename Stream, typename T, typename A> inline void Unserialize(Stream& is, std::vector<T, A>& v, int nType, int nVersion=VERSION);
+template<typename Stream, typename T, typename A> inline void Unserialize(Stream& is, std::vector<T, A>& v, int nType, int nVersion=PROTOCOL_VERSION);
// others derived from vector
-extern inline unsigned int GetSerializeSize(const CScript& v, int nType, int nVersion=VERSION);
-template<typename Stream> void Serialize(Stream& os, const CScript& v, int nType, int nVersion=VERSION);
-template<typename Stream> void Unserialize(Stream& is, CScript& v, int nType, int nVersion=VERSION);
+extern inline unsigned int GetSerializeSize(const CScript& v, int nType, int nVersion=PROTOCOL_VERSION);
+template<typename Stream> void Serialize(Stream& os, const CScript& v, int nType, int nVersion=PROTOCOL_VERSION);
+template<typename Stream> void Unserialize(Stream& is, CScript& v, int nType, int nVersion=PROTOCOL_VERSION);
// pair
-template<typename K, typename T> unsigned int GetSerializeSize(const std::pair<K, T>& item, int nType, int nVersion=VERSION);
-template<typename Stream, typename K, typename T> void Serialize(Stream& os, const std::pair<K, T>& item, int nType, int nVersion=VERSION);
-template<typename Stream, typename K, typename T> void Unserialize(Stream& is, std::pair<K, T>& item, int nType, int nVersion=VERSION);
+template<typename K, typename T> unsigned int GetSerializeSize(const std::pair<K, T>& item, int nType, int nVersion=PROTOCOL_VERSION);
+template<typename Stream, typename K, typename T> void Serialize(Stream& os, const std::pair<K, T>& item, int nType, int nVersion=PROTOCOL_VERSION);
+template<typename Stream, typename K, typename T> void Unserialize(Stream& is, std::pair<K, T>& item, int nType, int nVersion=PROTOCOL_VERSION);
// 3 tuple
-template<typename T0, typename T1, typename T2> unsigned int GetSerializeSize(const boost::tuple<T0, T1, T2>& item, int nType, int nVersion=VERSION);
-template<typename Stream, typename T0, typename T1, typename T2> void Serialize(Stream& os, const boost::tuple<T0, T1, T2>& item, int nType, int nVersion=VERSION);
-template<typename Stream, typename T0, typename T1, typename T2> void Unserialize(Stream& is, boost::tuple<T0, T1, T2>& item, int nType, int nVersion=VERSION);
+template<typename T0, typename T1, typename T2> unsigned int GetSerializeSize(const boost::tuple<T0, T1, T2>& item, int nType, int nVersion=PROTOCOL_VERSION);
+template<typename Stream, typename T0, typename T1, typename T2> void Serialize(Stream& os, const boost::tuple<T0, T1, T2>& item, int nType, int nVersion=PROTOCOL_VERSION);
+template<typename Stream, typename T0, typename T1, typename T2> void Unserialize(Stream& is, boost::tuple<T0, T1, T2>& item, int nType, int nVersion=PROTOCOL_VERSION);
// 4 tuple
-template<typename T0, typename T1, typename T2, typename T3> unsigned int GetSerializeSize(const boost::tuple<T0, T1, T2, T3>& item, int nType, int nVersion=VERSION);
-template<typename Stream, typename T0, typename T1, typename T2, typename T3> void Serialize(Stream& os, const boost::tuple<T0, T1, T2, T3>& item, int nType, int nVersion=VERSION);
-template<typename Stream, typename T0, typename T1, typename T2, typename T3> void Unserialize(Stream& is, boost::tuple<T0, T1, T2, T3>& item, int nType, int nVersion=VERSION);
+template<typename T0, typename T1, typename T2, typename T3> unsigned int GetSerializeSize(const boost::tuple<T0, T1, T2, T3>& item, int nType, int nVersion=PROTOCOL_VERSION);
+template<typename Stream, typename T0, typename T1, typename T2, typename T3> void Serialize(Stream& os, const boost::tuple<T0, T1, T2, T3>& item, int nType, int nVersion=PROTOCOL_VERSION);
+template<typename Stream, typename T0, typename T1, typename T2, typename T3> void Unserialize(Stream& is, boost::tuple<T0, T1, T2, T3>& item, int nType, int nVersion=PROTOCOL_VERSION);
// map
-template<typename K, typename T, typename Pred, typename A> unsigned int GetSerializeSize(const std::map<K, T, Pred, A>& m, int nType, int nVersion=VERSION);
-template<typename Stream, typename K, typename T, typename Pred, typename A> void Serialize(Stream& os, const std::map<K, T, Pred, A>& m, int nType, int nVersion=VERSION);
-template<typename Stream, typename K, typename T, typename Pred, typename A> void Unserialize(Stream& is, std::map<K, T, Pred, A>& m, int nType, int nVersion=VERSION);
+template<typename K, typename T, typename Pred, typename A> unsigned int GetSerializeSize(const std::map<K, T, Pred, A>& m, int nType, int nVersion=PROTOCOL_VERSION);
+template<typename Stream, typename K, typename T, typename Pred, typename A> void Serialize(Stream& os, const std::map<K, T, Pred, A>& m, int nType, int nVersion=PROTOCOL_VERSION);
+template<typename Stream, typename K, typename T, typename Pred, typename A> void Unserialize(Stream& is, std::map<K, T, Pred, A>& m, int nType, int nVersion=PROTOCOL_VERSION);
// set
-template<typename K, typename Pred, typename A> unsigned int GetSerializeSize(const std::set<K, Pred, A>& m, int nType, int nVersion=VERSION);
-template<typename Stream, typename K, typename Pred, typename A> void Serialize(Stream& os, const std::set<K, Pred, A>& m, int nType, int nVersion=VERSION);
-template<typename Stream, typename K, typename Pred, typename A> void Unserialize(Stream& is, std::set<K, Pred, A>& m, int nType, int nVersion=VERSION);
+template<typename K, typename Pred, typename A> unsigned int GetSerializeSize(const std::set<K, Pred, A>& m, int nType, int nVersion=PROTOCOL_VERSION);
+template<typename Stream, typename K, typename Pred, typename A> void Serialize(Stream& os, const std::set<K, Pred, A>& m, int nType, int nVersion=PROTOCOL_VERSION);
+template<typename Stream, typename K, typename Pred, typename A> void Unserialize(Stream& is, std::set<K, Pred, A>& m, int nType, int nVersion=PROTOCOL_VERSION);
@@ -411,19 +409,19 @@ template<typename Stream, typename K, typename Pred, typename A> void Unserializ
// Thanks to Boost serialization for this idea.
//
template<typename T>
-inline unsigned int GetSerializeSize(const T& a, long nType, int nVersion=VERSION)
+inline unsigned int GetSerializeSize(const T& a, long nType, int nVersion=PROTOCOL_VERSION)
{
return a.GetSerializeSize((int)nType, nVersion);
}
template<typename Stream, typename T>
-inline void Serialize(Stream& os, const T& a, long nType, int nVersion=VERSION)
+inline void Serialize(Stream& os, const T& a, long nType, int nVersion=PROTOCOL_VERSION)
{
a.Serialize(os, (int)nType, nVersion);
}
template<typename Stream, typename T>
-inline void Unserialize(Stream& is, T& a, long nType, int nVersion=VERSION)
+inline void Unserialize(Stream& is, T& a, long nType, int nVersion=PROTOCOL_VERSION)
{
a.Unserialize(is, (int)nType, nVersion);
}
@@ -857,39 +855,39 @@ public:
typedef vector_type::const_iterator const_iterator;
typedef vector_type::reverse_iterator reverse_iterator;
- explicit CDataStream(int nTypeIn=SER_NETWORK, int nVersionIn=VERSION)
+ explicit CDataStream(int nTypeIn=SER_NETWORK, int nVersionIn=PROTOCOL_VERSION)
{
Init(nTypeIn, nVersionIn);
}
- CDataStream(const_iterator pbegin, const_iterator pend, int nTypeIn=SER_NETWORK, int nVersionIn=VERSION) : vch(pbegin, pend)
+ CDataStream(const_iterator pbegin, const_iterator pend, int nTypeIn=SER_NETWORK, int nVersionIn=PROTOCOL_VERSION) : vch(pbegin, pend)
{
Init(nTypeIn, nVersionIn);
}
#if !defined(_MSC_VER) || _MSC_VER >= 1300
- CDataStream(const char* pbegin, const char* pend, int nTypeIn=SER_NETWORK, int nVersionIn=VERSION) : vch(pbegin, pend)
+ CDataStream(const char* pbegin, const char* pend, int nTypeIn=SER_NETWORK, int nVersionIn=PROTOCOL_VERSION) : vch(pbegin, pend)
{
Init(nTypeIn, nVersionIn);
}
#endif
- CDataStream(const vector_type& vchIn, int nTypeIn=SER_NETWORK, int nVersionIn=VERSION) : vch(vchIn.begin(), vchIn.end())
+ CDataStream(const vector_type& vchIn, int nTypeIn=SER_NETWORK, int nVersionIn=PROTOCOL_VERSION) : vch(vchIn.begin(), vchIn.end())
{
Init(nTypeIn, nVersionIn);
}
- CDataStream(const std::vector<char>& vchIn, int nTypeIn=SER_NETWORK, int nVersionIn=VERSION) : vch(vchIn.begin(), vchIn.end())
+ CDataStream(const std::vector<char>& vchIn, int nTypeIn=SER_NETWORK, int nVersionIn=PROTOCOL_VERSION) : vch(vchIn.begin(), vchIn.end())
{
Init(nTypeIn, nVersionIn);
}
- CDataStream(const std::vector<unsigned char>& vchIn, int nTypeIn=SER_NETWORK, int nVersionIn=VERSION) : vch((char*)&vchIn.begin()[0], (char*)&vchIn.end()[0])
+ CDataStream(const std::vector<unsigned char>& vchIn, int nTypeIn=SER_NETWORK, int nVersionIn=PROTOCOL_VERSION) : vch((char*)&vchIn.begin()[0], (char*)&vchIn.end()[0])
{
Init(nTypeIn, nVersionIn);
}
- void Init(int nTypeIn=SER_NETWORK, int nVersionIn=VERSION)
+ void Init(int nTypeIn=SER_NETWORK, int nVersionIn=PROTOCOL_VERSION)
{
nReadPos = 0;
nType = nTypeIn;
@@ -1103,7 +1101,7 @@ public:
}
template<typename Stream>
- void Serialize(Stream& s, int nType=0, int nVersion=VERSION) const
+ void Serialize(Stream& s, int nType=0, int nVersion=PROTOCOL_VERSION) const
{
// Special case: stream << stream concatenates like stream += stream
if (!vch.empty())
@@ -1212,7 +1210,7 @@ public:
typedef FILE element_type;
- CAutoFile(FILE* filenew=NULL, int nTypeIn=SER_DISK, int nVersionIn=VERSION)
+ CAutoFile(FILE* filenew=NULL, int nTypeIn=SER_DISK, int nVersionIn=PROTOCOL_VERSION)
{
file = filenew;
nType = nTypeIn;
diff --git a/src/uint256.h b/src/uint256.h
index 3e20201387..b6132822c5 100644
--- a/src/uint256.h
+++ b/src/uint256.h
@@ -364,19 +364,19 @@ public:
}
- unsigned int GetSerializeSize(int nType=0, int nVersion=VERSION) const
+ unsigned int GetSerializeSize(int nType=0, int nVersion=PROTOCOL_VERSION) const
{
return sizeof(pn);
}
template<typename Stream>
- void Serialize(Stream& s, int nType=0, int nVersion=VERSION) const
+ void Serialize(Stream& s, int nType=0, int nVersion=PROTOCOL_VERSION) const
{
s.write((char*)pn, sizeof(pn));
}
template<typename Stream>
- void Unserialize(Stream& s, int nType=0, int nVersion=VERSION)
+ void Unserialize(Stream& s, int nType=0, int nVersion=PROTOCOL_VERSION)
{
s.read((char*)pn, sizeof(pn));
}
diff --git a/src/util.cpp b/src/util.cpp
index 236c7f7c44..ef276e5103 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -4,6 +4,7 @@
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
#include "headers.h"
#include "strlcpy.h"
+#include <boost/algorithm/string/join.hpp>
#include <boost/program_options/detail/config_file.hpp>
#include <boost/program_options/parsers.hpp>
#include <boost/filesystem.hpp>
@@ -1001,7 +1002,7 @@ string FormatVersion(int nVersion)
string FormatFullVersion()
{
- string s = FormatVersion(VERSION) + pszSubVer;
+ string s = FormatVersion(CLIENT_VERSION);
if (VERSION_IS_BETA) {
s += "-";
s += _("beta");
@@ -1009,6 +1010,17 @@ string FormatFullVersion()
return s;
}
+// Format the subversion field according to BIP 14 spec (https://en.bitcoin.it/wiki/BIP_0014)
+std::string FormatSubVersion(const std::string& name, int nClientVersion, const std::vector<std::string>& comments)
+{
+ std::ostringstream ss;
+ ss << "/";
+ ss << name << ":" << FormatVersion(nClientVersion);
+ if (!comments.empty())
+ ss << "(" << boost::algorithm::join(comments, "; ") << ")";
+ ss << "/";
+ return ss.str();
+}
diff --git a/src/util.h b/src/util.h
index 7b7eaf6dbb..d9a0841a61 100644
--- a/src/util.h
+++ b/src/util.h
@@ -204,7 +204,7 @@ void SetMockTime(int64 nMockTimeIn);
int64 GetAdjustedTime();
void AddTimeData(unsigned int ip, int64 nTime);
std::string FormatFullVersion();
-
+std::string FormatSubVersion(const std::string& name, int nClientVersion, const std::vector<std::string>& comments);
@@ -558,7 +558,7 @@ inline uint256 Hash(const T1 p1begin, const T1 p1end,
}
template<typename T>
-uint256 SerializeHash(const T& obj, int nType=SER_GETHASH, int nVersion=VERSION)
+uint256 SerializeHash(const T& obj, int nType=SER_GETHASH, int nVersion=PROTOCOL_VERSION)
{
// Most of the time is spent allocating and deallocating CDataStream's
// buffer. If this ever needs to be optimized further, make a CStaticStream