From 5cd2a640a5ef867c376582810b1dd4b6fa43df5e Mon Sep 17 00:00:00 2001 From: Gavin Andresen Date: Mon, 19 Dec 2011 17:08:25 -0500 Subject: [PATCH 01/34] Use std::numeric_limits<> for typesafe INT_MAX/etc (this fixes a Mac OS X gitian build error for 0.5.x) --- src/bignum.h | 4 ++-- src/headers.h | 4 ---- src/main.cpp | 2 +- src/main.h | 12 ++++++------ src/net.cpp | 6 +++--- src/protocol.cpp | 2 +- src/rpc.cpp | 8 ++++---- src/serialize.h | 8 ++++---- src/util.cpp | 2 +- src/util.h | 6 +----- src/wallet.cpp | 2 +- 11 files changed, 24 insertions(+), 32 deletions(-) diff --git a/src/bignum.h b/src/bignum.h index bd42f77c..4a3fb38b 100644 --- a/src/bignum.h +++ b/src/bignum.h @@ -116,9 +116,9 @@ public: { unsigned long n = BN_get_word(this); if (!BN_is_negative(this)) - return (n > INT_MAX ? INT_MAX : n); + return (n > std::numeric_limits::max() ? std::numeric_limits::max() : n); else - return (n > INT_MAX ? INT_MIN : -(int)n); + return (n > std::numeric_limits::max() ? std::numeric_limits::min() : -(int)n); } void setint64(int64 n) diff --git a/src/headers.h b/src/headers.h index 537d405b..9b880c15 100644 --- a/src/headers.h +++ b/src/headers.h @@ -21,9 +21,6 @@ // Include boost/foreach here as it defines __STDC_LIMIT_MACROS on some systems. #include -#ifndef __STDC_LIMIT_MACROS -#define __STDC_LIMIT_MACROS // to enable UINT64_MAX from stdint.h -#endif #if (defined(__unix__) || defined(unix)) && !defined(USG) #include // to get BSD define @@ -52,7 +49,6 @@ #include #include #include -#include #include #include #include diff --git a/src/main.cpp b/src/main.cpp index ee814aa5..0f45b2e1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -372,7 +372,7 @@ bool CTransaction::AcceptToMemoryPool(CTxDB& txdb, bool fCheckInputs, bool* pfMi return error("AcceptToMemoryPool() : coinbase as individual tx"); // To help v0.1.5 clients who would see it as a negative number - if ((int64)nLockTime > INT_MAX) + if ((int64)nLockTime > std::numeric_limits::max()) return error("AcceptToMemoryPool() : not accepting nLockTime beyond 2038 yet"); // Rather not work on nonstandard transactions (unless -testnet) diff --git a/src/main.h b/src/main.h index 930f5187..7aa660db 100644 --- a/src/main.h +++ b/src/main.h @@ -253,17 +253,17 @@ public: CTxIn() { - nSequence = UINT_MAX; + nSequence = std::numeric_limits::max(); } - explicit CTxIn(COutPoint prevoutIn, CScript scriptSigIn=CScript(), unsigned int nSequenceIn=UINT_MAX) + explicit CTxIn(COutPoint prevoutIn, CScript scriptSigIn=CScript(), unsigned int nSequenceIn=std::numeric_limits::max()) { prevout = prevoutIn; scriptSig = scriptSigIn; nSequence = nSequenceIn; } - CTxIn(uint256 hashPrevTx, unsigned int nOut, CScript scriptSigIn=CScript(), unsigned int nSequenceIn=UINT_MAX) + CTxIn(uint256 hashPrevTx, unsigned int nOut, CScript scriptSigIn=CScript(), unsigned int nSequenceIn=std::numeric_limits::max()) { prevout = COutPoint(hashPrevTx, nOut); scriptSig = scriptSigIn; @@ -279,7 +279,7 @@ public: bool IsFinal() const { - return (nSequence == UINT_MAX); + return (nSequence == std::numeric_limits::max()); } friend bool operator==(const CTxIn& a, const CTxIn& b) @@ -303,7 +303,7 @@ public: str += strprintf(", coinbase %s", HexStr(scriptSig).c_str()); else str += strprintf(", scriptSig=%s", scriptSig.ToString().substr(0,24).c_str()); - if (nSequence != UINT_MAX) + if (nSequence != std::numeric_limits::max()) str += strprintf(", nSequence=%u", nSequence); str += ")"; return str; @@ -460,7 +460,7 @@ public: return false; bool fNewer = false; - unsigned int nLowest = UINT_MAX; + unsigned int nLowest = std::numeric_limits::max(); for (unsigned int i = 0; i < vin.size(); i++) { if (vin[i].nSequence != old.vin[i].nSequence) diff --git a/src/net.cpp b/src/net.cpp index a9f6c87b..2ff539a1 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -251,8 +251,8 @@ bool Lookup(const char *pszName, vector& vaddr, int nServices, int nMa else pszColon[0] = 0; port = portParsed; - if (port < 0 || port > USHRT_MAX) - port = USHRT_MAX; + if (port < 0 || port > std::numeric_limits::max()) + port = std::numeric_limits::max(); } } @@ -1489,7 +1489,7 @@ void ThreadOpenConnections2(void* parg) // Choose an address to connect to based on most recently seen // CAddress addrConnect; - int64 nBest = INT64_MIN; + int64 nBest = std::numeric_limits::min(); // Only connect to one address per a.b.?.? range. // Do this here so we don't have to critsect vNodes inside mapAddresses critsect. diff --git a/src/protocol.cpp b/src/protocol.cpp index a22eba48..8314e2bb 100644 --- a/src/protocol.cpp +++ b/src/protocol.cpp @@ -224,7 +224,7 @@ bool CAddress::IsValid() const if (memcmp(pchReserved, pchIPv4+3, sizeof(pchIPv4)-3) == 0) return false; - return (ip != 0 && ip != INADDR_NONE && port != htons(USHRT_MAX)); + return (ip != 0 && ip != INADDR_NONE && port != htons(std::numeric_limits::max())); } unsigned char CAddress::GetByte(int n) const diff --git a/src/rpc.cpp b/src/rpc.cpp index acd7a893..786bf298 100644 --- a/src/rpc.cpp +++ b/src/rpc.cpp @@ -875,7 +875,7 @@ struct tallyitem tallyitem() { nAmount = 0; - nConf = INT_MAX; + nConf = std::numeric_limits::max(); } }; @@ -927,7 +927,7 @@ Value ListReceived(const Array& params, bool fByAccounts) continue; int64 nAmount = 0; - int nConf = INT_MAX; + int nConf = std::numeric_limits::max(); if (it != mapTally.end()) { nAmount = (*it).second.nAmount; @@ -947,7 +947,7 @@ Value ListReceived(const Array& params, bool fByAccounts) obj.push_back(Pair("account", strAccount)); obj.push_back(Pair("label", strAccount)); // deprecated obj.push_back(Pair("amount", ValueFromAmount(nAmount))); - obj.push_back(Pair("confirmations", (nConf == INT_MAX ? 0 : nConf))); + obj.push_back(Pair("confirmations", (nConf == std::numeric_limits::max() ? 0 : nConf))); ret.push_back(obj); } } @@ -962,7 +962,7 @@ Value ListReceived(const Array& params, bool fByAccounts) obj.push_back(Pair("account", (*it).first)); obj.push_back(Pair("label", (*it).first)); // deprecated obj.push_back(Pair("amount", ValueFromAmount(nAmount))); - obj.push_back(Pair("confirmations", (nConf == INT_MAX ? 0 : nConf))); + obj.push_back(Pair("confirmations", (nConf == std::numeric_limits::max() ? 0 : nConf))); ret.push_back(obj); } } diff --git a/src/serialize.h b/src/serialize.h index db3c9636..7b5aac24 100644 --- a/src/serialize.h +++ b/src/serialize.h @@ -201,8 +201,8 @@ template inline void Unserialize(Stream& s, bool& a, int, int=0 inline unsigned int GetSizeOfCompactSize(uint64 nSize) { if (nSize < 253) return sizeof(unsigned char); - else if (nSize <= USHRT_MAX) return sizeof(unsigned char) + sizeof(unsigned short); - else if (nSize <= UINT_MAX) return sizeof(unsigned char) + sizeof(unsigned int); + else if (nSize <= std::numeric_limits::max()) return sizeof(unsigned char) + sizeof(unsigned short); + else if (nSize <= std::numeric_limits::max()) return sizeof(unsigned char) + sizeof(unsigned int); else return sizeof(unsigned char) + sizeof(uint64); } @@ -214,14 +214,14 @@ void WriteCompactSize(Stream& os, uint64 nSize) unsigned char chSize = nSize; WRITEDATA(os, chSize); } - else if (nSize <= USHRT_MAX) + else if (nSize <= std::numeric_limits::max()) { unsigned char chSize = 253; unsigned short xSize = nSize; WRITEDATA(os, chSize); WRITEDATA(os, xSize); } - else if (nSize <= UINT_MAX) + else if (nSize <= std::numeric_limits::max()) { unsigned char chSize = 254; unsigned int xSize = nSize; diff --git a/src/util.cpp b/src/util.cpp index ccd39aa2..cae01dff 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -144,7 +144,7 @@ uint64 GetRand(uint64 nMax) // The range of the random source must be a multiple of the modulus // to give every possible output value an equal possibility - uint64 nRange = (UINT64_MAX / nMax) * nMax; + uint64 nRange = (std::numeric_limits::max() / nMax) * nMax; uint64 nRand = 0; do RAND_bytes((unsigned char*)&nRand, sizeof(nRand)); diff --git a/src/util.h b/src/util.h index 88cc1e79..284cf33c 100644 --- a/src/util.h +++ b/src/util.h @@ -84,11 +84,7 @@ T* alignup(T* p) #ifdef __WXMSW__ #define MSG_NOSIGNAL 0 #define MSG_DONTWAIT 0 -#ifndef UINT64_MAX -#define UINT64_MAX _UI64_MAX -#define INT64_MAX _I64_MAX -#define INT64_MIN _I64_MIN -#endif + #ifndef S_IRUSR #define S_IRUSR 0400 #define S_IWUSR 0200 diff --git a/src/wallet.cpp b/src/wallet.cpp index 973727b2..8fe77119 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -747,7 +747,7 @@ bool CWallet::SelectCoinsMinConf(int64 nTargetValue, int nConfMine, int nConfThe // List of values less than target pair > coinLowestLarger; - coinLowestLarger.first = INT64_MAX; + coinLowestLarger.first = std::numeric_limits::max(); coinLowestLarger.second.first = NULL; vector > > vValue; int64 nTotalLower = 0; From b0e508a0c095a4ff44bffecd9508dc27e76712cb Mon Sep 17 00:00:00 2001 From: Gavin Andresen Date: Tue, 20 Dec 2011 12:04:33 -0500 Subject: [PATCH 02/34] Include limits, not climints (using std::numeric_limits now) --- src/serialize.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/serialize.h b/src/serialize.h index 7b5aac24..8cdfb30b 100644 --- a/src/serialize.h +++ b/src/serialize.h @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include From 0ce74bfaa5f34351e5b23e19ee90e7367bd50245 Mon Sep 17 00:00:00 2001 From: Gavin Andresen Date: Mon, 19 Dec 2011 17:08:25 -0500 Subject: [PATCH 03/34] Use std::numeric_limits<> for typesafe INT_MAX/etc (this fixes a Mac OS X gitian build error for 0.5.x) --- src/bignum.h | 4 ++-- src/bitcoinrpc.cpp | 8 ++++---- src/headers.h | 4 ---- src/main.cpp | 2 +- src/main.h | 12 ++++++------ src/net.cpp | 6 +++--- src/protocol.cpp | 2 +- src/qt/optionsmodel.cpp | 2 +- src/qt/transactionrecord.cpp | 2 +- src/serialize.h | 8 ++++---- src/util.cpp | 2 +- src/util.h | 6 +----- src/wallet.cpp | 2 +- 13 files changed, 26 insertions(+), 34 deletions(-) diff --git a/src/bignum.h b/src/bignum.h index bd42f77c..4a3fb38b 100644 --- a/src/bignum.h +++ b/src/bignum.h @@ -116,9 +116,9 @@ public: { unsigned long n = BN_get_word(this); if (!BN_is_negative(this)) - return (n > INT_MAX ? INT_MAX : n); + return (n > std::numeric_limits::max() ? std::numeric_limits::max() : n); else - return (n > INT_MAX ? INT_MIN : -(int)n); + return (n > std::numeric_limits::max() ? std::numeric_limits::min() : -(int)n); } void setint64(int64 n) diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp index 38f102e1..55ad1198 100644 --- a/src/bitcoinrpc.cpp +++ b/src/bitcoinrpc.cpp @@ -944,7 +944,7 @@ struct tallyitem tallyitem() { nAmount = 0; - nConf = INT_MAX; + nConf = std::numeric_limits::max(); } }; @@ -996,7 +996,7 @@ Value ListReceived(const Array& params, bool fByAccounts) continue; int64 nAmount = 0; - int nConf = INT_MAX; + int nConf = std::numeric_limits::max(); if (it != mapTally.end()) { nAmount = (*it).second.nAmount; @@ -1015,7 +1015,7 @@ Value ListReceived(const Array& params, bool fByAccounts) obj.push_back(Pair("address", address.ToString())); obj.push_back(Pair("account", strAccount)); obj.push_back(Pair("amount", ValueFromAmount(nAmount))); - obj.push_back(Pair("confirmations", (nConf == INT_MAX ? 0 : nConf))); + obj.push_back(Pair("confirmations", (nConf == std::numeric_limits::max() ? 0 : nConf))); ret.push_back(obj); } } @@ -1029,7 +1029,7 @@ Value ListReceived(const Array& params, bool fByAccounts) Object obj; obj.push_back(Pair("account", (*it).first)); obj.push_back(Pair("amount", ValueFromAmount(nAmount))); - obj.push_back(Pair("confirmations", (nConf == INT_MAX ? 0 : nConf))); + obj.push_back(Pair("confirmations", (nConf == std::numeric_limits::max() ? 0 : nConf))); ret.push_back(obj); } } diff --git a/src/headers.h b/src/headers.h index cef2718c..83272d0a 100644 --- a/src/headers.h +++ b/src/headers.h @@ -21,9 +21,6 @@ // Include boost/foreach here as it defines __STDC_LIMIT_MACROS on some systems. #include -#ifndef __STDC_LIMIT_MACROS -#define __STDC_LIMIT_MACROS // to enable UINT64_MAX from stdint.h -#endif #if (defined(__unix__) || defined(unix)) && !defined(USG) #include // to get BSD define @@ -44,7 +41,6 @@ #include #include #include -#include #include #include #include diff --git a/src/main.cpp b/src/main.cpp index a28d2e80..387670ba 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -379,7 +379,7 @@ bool CTransaction::AcceptToMemoryPool(CTxDB& txdb, bool fCheckInputs, bool* pfMi return DoS(100, error("AcceptToMemoryPool() : coinbase as individual tx")); // To help v0.1.5 clients who would see it as a negative number - if ((int64)nLockTime > INT_MAX) + if ((int64)nLockTime > std::numeric_limits::max()) return error("AcceptToMemoryPool() : not accepting nLockTime beyond 2038 yet"); // Rather not work on nonstandard transactions (unless -testnet) diff --git a/src/main.h b/src/main.h index 74bbe294..5357413c 100644 --- a/src/main.h +++ b/src/main.h @@ -255,17 +255,17 @@ public: CTxIn() { - nSequence = UINT_MAX; + nSequence = std::numeric_limits::max(); } - explicit CTxIn(COutPoint prevoutIn, CScript scriptSigIn=CScript(), unsigned int nSequenceIn=UINT_MAX) + explicit CTxIn(COutPoint prevoutIn, CScript scriptSigIn=CScript(), unsigned int nSequenceIn=std::numeric_limits::max()) { prevout = prevoutIn; scriptSig = scriptSigIn; nSequence = nSequenceIn; } - CTxIn(uint256 hashPrevTx, unsigned int nOut, CScript scriptSigIn=CScript(), unsigned int nSequenceIn=UINT_MAX) + CTxIn(uint256 hashPrevTx, unsigned int nOut, CScript scriptSigIn=CScript(), unsigned int nSequenceIn=std::numeric_limits::max()) { prevout = COutPoint(hashPrevTx, nOut); scriptSig = scriptSigIn; @@ -281,7 +281,7 @@ public: bool IsFinal() const { - return (nSequence == UINT_MAX); + return (nSequence == std::numeric_limits::max()); } friend bool operator==(const CTxIn& a, const CTxIn& b) @@ -305,7 +305,7 @@ public: str += strprintf(", coinbase %s", HexStr(scriptSig).c_str()); else str += strprintf(", scriptSig=%s", scriptSig.ToString().substr(0,24).c_str()); - if (nSequence != UINT_MAX) + if (nSequence != std::numeric_limits::max()) str += strprintf(", nSequence=%u", nSequence); str += ")"; return str; @@ -466,7 +466,7 @@ public: return false; bool fNewer = false; - unsigned int nLowest = UINT_MAX; + unsigned int nLowest = std::numeric_limits::max(); for (unsigned int i = 0; i < vin.size(); i++) { if (vin[i].nSequence != old.vin[i].nSequence) diff --git a/src/net.cpp b/src/net.cpp index 83842510..0c98b8ee 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -251,8 +251,8 @@ bool Lookup(const char *pszName, vector& vaddr, int nServices, int nMa else pszColon[0] = 0; port = portParsed; - if (port < 0 || port > USHRT_MAX) - port = USHRT_MAX; + if (port < 0 || port > std::numeric_limits::max()) + port = std::numeric_limits::max(); } } @@ -1540,7 +1540,7 @@ void ThreadOpenConnections2(void* parg) // Choose an address to connect to based on most recently seen // CAddress addrConnect; - int64 nBest = INT64_MIN; + int64 nBest = std::numeric_limits::min(); // Only connect to one address per a.b.?.? range. // Do this here so we don't have to critsect vNodes inside mapAddresses critsect. diff --git a/src/protocol.cpp b/src/protocol.cpp index 3376c37e..410d0004 100644 --- a/src/protocol.cpp +++ b/src/protocol.cpp @@ -224,7 +224,7 @@ bool CAddress::IsValid() const if (memcmp(pchReserved, pchIPv4+3, sizeof(pchIPv4)-3) == 0) return false; - return (ip != 0 && ip != INADDR_NONE && port != htons(USHRT_MAX)); + return (ip != 0 && ip != INADDR_NONE && port != htons(std::numeric_limits::max())); } unsigned char CAddress::GetByte(int n) const diff --git a/src/qt/optionsmodel.cpp b/src/qt/optionsmodel.cpp index 02daef5e..883d7e4f 100644 --- a/src/qt/optionsmodel.cpp +++ b/src/qt/optionsmodel.cpp @@ -101,7 +101,7 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in case ProxyPort: { int nPort = atoi(value.toString().toAscii().data()); - if (nPort > 0 && nPort < USHRT_MAX) + if (nPort > 0 && nPort < std::numeric_limits::max()) { addrProxy.port = htons(nPort); walletdb.WriteSetting("addrProxy", addrProxy); diff --git a/src/qt/transactionrecord.cpp b/src/qt/transactionrecord.cpp index 4059207b..5ec463b2 100644 --- a/src/qt/transactionrecord.cpp +++ b/src/qt/transactionrecord.cpp @@ -172,7 +172,7 @@ void TransactionRecord::updateStatus(const CWalletTx &wtx) // Sort order, unrecorded transactions sort to the top status.sortKey = strprintf("%010d-%01d-%010u-%03d", - (pindex ? pindex->nHeight : INT_MAX), + (pindex ? pindex->nHeight : std::numeric_limits::max()), (wtx.IsCoinBase() ? 1 : 0), wtx.nTimeReceived, idx); diff --git a/src/serialize.h b/src/serialize.h index 61d80d70..2f4c55ae 100644 --- a/src/serialize.h +++ b/src/serialize.h @@ -202,8 +202,8 @@ template inline void Unserialize(Stream& s, bool& a, int, int=0 inline unsigned int GetSizeOfCompactSize(uint64 nSize) { if (nSize < 253) return sizeof(unsigned char); - else if (nSize <= USHRT_MAX) return sizeof(unsigned char) + sizeof(unsigned short); - else if (nSize <= UINT_MAX) return sizeof(unsigned char) + sizeof(unsigned int); + else if (nSize <= std::numeric_limits::max()) return sizeof(unsigned char) + sizeof(unsigned short); + else if (nSize <= std::numeric_limits::max()) return sizeof(unsigned char) + sizeof(unsigned int); else return sizeof(unsigned char) + sizeof(uint64); } @@ -215,14 +215,14 @@ void WriteCompactSize(Stream& os, uint64 nSize) unsigned char chSize = nSize; WRITEDATA(os, chSize); } - else if (nSize <= USHRT_MAX) + else if (nSize <= std::numeric_limits::max()) { unsigned char chSize = 253; unsigned short xSize = nSize; WRITEDATA(os, chSize); WRITEDATA(os, xSize); } - else if (nSize <= UINT_MAX) + else if (nSize <= std::numeric_limits::max()) { unsigned char chSize = 254; unsigned int xSize = nSize; diff --git a/src/util.cpp b/src/util.cpp index 6314b536..03112038 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -144,7 +144,7 @@ uint64 GetRand(uint64 nMax) // The range of the random source must be a multiple of the modulus // to give every possible output value an equal possibility - uint64 nRange = (UINT64_MAX / nMax) * nMax; + uint64 nRange = (std::numeric_limits::max() / nMax) * nMax; uint64 nRand = 0; do RAND_bytes((unsigned char*)&nRand, sizeof(nRand)); diff --git a/src/util.h b/src/util.h index da8e7630..69ac670f 100644 --- a/src/util.h +++ b/src/util.h @@ -84,11 +84,7 @@ T* alignup(T* p) #ifdef WIN32 #define MSG_NOSIGNAL 0 #define MSG_DONTWAIT 0 -#ifndef UINT64_MAX -#define UINT64_MAX _UI64_MAX -#define INT64_MAX _I64_MAX -#define INT64_MIN _I64_MIN -#endif + #ifndef S_IRUSR #define S_IRUSR 0400 #define S_IWUSR 0200 diff --git a/src/wallet.cpp b/src/wallet.cpp index 3ffad27e..68d7e5ac 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -767,7 +767,7 @@ bool CWallet::SelectCoinsMinConf(int64 nTargetValue, int nConfMine, int nConfThe // List of values less than target pair > coinLowestLarger; - coinLowestLarger.first = INT64_MAX; + coinLowestLarger.first = std::numeric_limits::max(); coinLowestLarger.second.first = NULL; vector > > vValue; int64 nTotalLower = 0; From fa57170187415bf939885fc71cea5bffc30a32f8 Mon Sep 17 00:00:00 2001 From: Gavin Andresen Date: Thu, 14 Jun 2012 20:44:04 -0400 Subject: [PATCH 04/34] Document how to build/run unit tests --- doc/unit-tests.txt | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 doc/unit-tests.txt diff --git a/doc/unit-tests.txt b/doc/unit-tests.txt new file mode 100644 index 00000000..1168de7b --- /dev/null +++ b/doc/unit-tests.txt @@ -0,0 +1,18 @@ +Compiling/runing bitcoind unit tests +------------------------------------ + +bitcoind unit tests are in the src/test/ directory; they +use the Boost::Test unit-testing framework. + +To compile and run the tests: +cd src +make -f makefile.unix test_bitcoin # Replace makefile.unix if you're not on unix +./test_bitcoin # Runs the unit tests + +If all tests succeed the last line of output will be: +*** No errors detected + +To add more tests, add BOOST_AUTO_TEST_CASE's to the existing +.cpp files in the test/ directory or add new .cpp files that +implement new BOOST_AUTO_TEST_SUITE's (and add them to the +list of includes in test_bitcoin.cpp). From 0969343320e4ccca5893a913afdc4ca1ffb0b5c4 Mon Sep 17 00:00:00 2001 From: Gavin Andresen Date: Thu, 14 Jun 2012 20:44:04 -0400 Subject: [PATCH 05/34] Document how to build/run unit tests --- doc/unit-tests.txt | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 doc/unit-tests.txt diff --git a/doc/unit-tests.txt b/doc/unit-tests.txt new file mode 100644 index 00000000..e7f21518 --- /dev/null +++ b/doc/unit-tests.txt @@ -0,0 +1,33 @@ +Compiling/runing bitcoind unit tests +------------------------------------ + +bitcoind unit tests are in the src/test/ directory; they +use the Boost::Test unit-testing framework. + +To compile and run the tests: +cd src +make -f makefile.unix test_bitcoin # Replace makefile.unix if you're not on unix +./test_bitcoin # Runs the unit tests + +If all tests succeed the last line of output will be: +*** No errors detected + +To add more tests, add BOOST_AUTO_TEST_CASE's to the existing +.cpp files in the test/ directory or add new .cpp files that +implement new BOOST_AUTO_TEST_SUITE's (the makefiles are +set up to add test/*.cpp to test_bitcoin automatically). + + +Compiling/running Bitcoin-Qt unit tests +--------------------------------------- + +Bitcoin-Qt unit tests are in the src/qt/test/ directory; they +use the Qt unit-testing framework. + +To compile and run the tests: +qmake bitcoin-qt.pro BITCOIN_QT_TEST=1 +make +./bitcoin-qt_test + +To add more tests, add them to the src/qt/test/ directory, +the src/qt/test/test_main.cpp file, and bitcoin-qt.pro. From 506bf85de57bdf079824a14e492c112338768c2a Mon Sep 17 00:00:00 2001 From: Philip Kaufmann Date: Sat, 9 Jun 2012 15:41:21 +0200 Subject: [PATCH 06/34] add the slot updateDisplayUnit() to overviewpage, sendcoinsdialog, sendcoinsentry and connect it to displayUnitChanged() - this ensures all fields in the GUI, who use a display unit are imediately updated, when the user changes this setting in the optionsdialog / ensure used fields init with the current set display unit --- src/qt/overviewpage.cpp | 32 +++++++++++++++++++------------- src/qt/overviewpage.h | 2 +- src/qt/sendcoinsdialog.cpp | 14 ++++++++++++-- src/qt/sendcoinsdialog.h | 2 +- src/qt/sendcoinsentry.cpp | 18 ++++++++++++++---- src/qt/sendcoinsentry.h | 1 + 6 files changed, 48 insertions(+), 21 deletions(-) diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index 5b5a8f52..2c3d8a49 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -143,7 +143,7 @@ void OverviewPage::setNumTransactions(int count) void OverviewPage::setModel(WalletModel *model) { this->model = model; - if(model) + if(model && model->getOptionsModel()) { // Set up transaction list TransactionFilterProxy *filter = new TransactionFilterProxy(); @@ -163,17 +163,23 @@ void OverviewPage::setModel(WalletModel *model) setNumTransactions(model->getNumTransactions()); connect(model, SIGNAL(numTransactionsChanged(int)), this, SLOT(setNumTransactions(int))); - connect(model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(displayUnitChanged())); + connect(model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit())); + } + + // update the display unit, to not use the default ("BTC") + updateDisplayUnit(); +} + +void OverviewPage::updateDisplayUnit() +{ + if(model && model->getOptionsModel()) + { + if(currentBalance != -1) + setBalance(currentBalance, currentUnconfirmedBalance); + + // Update txdelegate->unit with the current unit + txdelegate->unit = model->getOptionsModel()->getDisplayUnit(); + + ui->listTransactions->update(); } } - -void OverviewPage::displayUnitChanged() -{ - if(!model || !model->getOptionsModel()) - return; - if(currentBalance != -1) - setBalance(currentBalance, currentUnconfirmedBalance); - - txdelegate->unit = model->getOptionsModel()->getDisplayUnit(); - ui->listTransactions->update(); -} diff --git a/src/qt/overviewpage.h b/src/qt/overviewpage.h index 11992271..99fe4864 100644 --- a/src/qt/overviewpage.h +++ b/src/qt/overviewpage.h @@ -40,7 +40,7 @@ private: TxViewDelegate *txdelegate; private slots: - void displayUnitChanged(); + void updateDisplayUnit(); }; #endif // OVERVIEWPAGE_H diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp index 4c58b38b..ef2f1c31 100644 --- a/src/qt/sendcoinsdialog.cpp +++ b/src/qt/sendcoinsdialog.cpp @@ -44,10 +44,11 @@ void SendCoinsDialog::setModel(WalletModel *model) entry->setModel(model); } } - if(model) + if(model && model->getOptionsModel()) { setBalance(model->getBalance(), model->getUnconfirmedBalance()); connect(model, SIGNAL(balanceChanged(qint64, qint64)), this, SLOT(setBalance(qint64, qint64))); + connect(model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit())); } } @@ -195,7 +196,7 @@ SendCoinsEntry *SendCoinsDialog::addEntry() ui->scrollAreaWidgetContents->resize(ui->scrollAreaWidgetContents->sizeHint()); QCoreApplication::instance()->processEvents(); QScrollBar* bar = ui->scrollArea->verticalScrollBar(); - if (bar) + if(bar) bar->setSliderPosition(bar->maximum()); return entry; } @@ -286,3 +287,12 @@ void SendCoinsDialog::setBalance(qint64 balance, qint64 unconfirmedBalance) int unit = model->getOptionsModel()->getDisplayUnit(); ui->labelBalance->setText(BitcoinUnits::formatWithUnit(unit, balance)); } + +void SendCoinsDialog::updateDisplayUnit() +{ + if(model && model->getOptionsModel()) + { + // Update labelBalance with the current balance and the current unit + ui->labelBalance->setText(BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), model->getBalance())); + } +} diff --git a/src/qt/sendcoinsdialog.h b/src/qt/sendcoinsdialog.h index 79125766..ed562141 100644 --- a/src/qt/sendcoinsdialog.h +++ b/src/qt/sendcoinsdialog.h @@ -47,8 +47,8 @@ private: private slots: void on_sendButton_clicked(); - void removeEntry(SendCoinsEntry* entry); + void updateDisplayUnit(); }; #endif // SENDCOINSDIALOG_H diff --git a/src/qt/sendcoinsentry.cpp b/src/qt/sendcoinsentry.cpp index c8242d83..599a804c 100644 --- a/src/qt/sendcoinsentry.cpp +++ b/src/qt/sendcoinsentry.cpp @@ -68,6 +68,10 @@ void SendCoinsEntry::on_payTo_textChanged(const QString &address) void SendCoinsEntry::setModel(WalletModel *model) { this->model = model; + + if(model && model->getOptionsModel()) + connect(model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit())); + clear(); } @@ -82,10 +86,8 @@ void SendCoinsEntry::clear() ui->addAsLabel->clear(); ui->payAmount->clear(); ui->payTo->setFocus(); - if(model && model->getOptionsModel()) - { - ui->payAmount->setDisplayUnit(model->getOptionsModel()->getDisplayUnit()); - } + // update the display unit, to not use the default ("BTC") + updateDisplayUnit(); } void SendCoinsEntry::on_deleteButton_clicked() @@ -160,3 +162,11 @@ void SendCoinsEntry::setFocus() ui->payTo->setFocus(); } +void SendCoinsEntry::updateDisplayUnit() +{ + if(model && model->getOptionsModel()) + { + // Update payAmount with the current unit + ui->payAmount->setDisplayUnit(model->getOptionsModel()->getDisplayUnit()); + } +} diff --git a/src/qt/sendcoinsentry.h b/src/qt/sendcoinsentry.h index cdbf8932..db6cba0d 100644 --- a/src/qt/sendcoinsentry.h +++ b/src/qt/sendcoinsentry.h @@ -45,6 +45,7 @@ private slots: void on_payTo_textChanged(const QString &address); void on_addressBookButton_clicked(); void on_pasteButton_clicked(); + void updateDisplayUnit(); private: Ui::SendCoinsEntry *ui; From 7ff54e08aa42f10dae424711a0a3764a67eae295 Mon Sep 17 00:00:00 2001 From: "Ricardo M. Correia" Date: Mon, 14 May 2012 02:50:01 +0200 Subject: [PATCH 07/34] Don't overflow signed ints in CBigNum::setint64(). CBigNum::setint64() does 'n <<= 8', where n is of type "long long". This leads to shifting onto and past the sign bit, which is undefined behavior in C++11 and can cause problems in the future. --- src/bignum.h | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/bignum.h b/src/bignum.h index 4a3fb38b..e203b26a 100644 --- a/src/bignum.h +++ b/src/bignum.h @@ -121,16 +121,22 @@ public: return (n > std::numeric_limits::max() ? std::numeric_limits::min() : -(int)n); } - void setint64(int64 n) + void setint64(int64 sn) { - unsigned char pch[sizeof(n) + 6]; + unsigned char pch[sizeof(sn) + 6]; unsigned char* p = pch + 4; - bool fNegative = false; - if (n < (int64)0) + bool fNegative; + uint64 n; + + if (sn < (int64)0) { - n = -n; + n = -sn; fNegative = true; + } else { + n = sn; + fNegative = false; } + bool fLeadingZeroes = true; for (int i = 0; i < 8; i++) { From b0d9f41cd222de5d13d2b9cec27474009029d5ec Mon Sep 17 00:00:00 2001 From: "Ricardo M. Correia" Date: Thu, 7 Jun 2012 19:11:15 +0200 Subject: [PATCH 08/34] Don't overflow integer on 32-bit machines. This was causing test_bitcoin to abort on a 32-bit system likely due to -ftrapv. --- src/util.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util.h b/src/util.h index 284cf33c..dc729683 100644 --- a/src/util.h +++ b/src/util.h @@ -396,7 +396,7 @@ inline int64 GetPerformanceCounter() #else timeval t; gettimeofday(&t, NULL); - nCounter = t.tv_sec * 1000000 + t.tv_usec; + nCounter = (int64) t.tv_sec * 1000000 + t.tv_usec; #endif return nCounter; } From c3def40293a89307d296ff66653b5927165c3c18 Mon Sep 17 00:00:00 2001 From: Gavin Andresen Date: Tue, 15 May 2012 15:53:30 -0400 Subject: [PATCH 09/34] Optimize orphan transaction handling Changes suggested by Sergio Demian Lerner to help prevent potential DoS attacks. --- src/main.cpp | 46 ++++++++++++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 0f45b2e1..b7067b20 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -45,7 +45,7 @@ map mapOrphanBlocks; multimap mapOrphanBlocksByPrev; map mapOrphanTransactions; -multimap mapOrphanTransactionsByPrev; +map > mapOrphanTransactionsByPrev; double dHashesPerSec; @@ -160,17 +160,37 @@ void static ResendWalletTransactions() // mapOrphanTransactions // -void AddOrphanTx(const CDataStream& vMsg) +bool AddOrphanTx(const CDataStream& vMsg) { CTransaction tx; CDataStream(vMsg) >> tx; uint256 hash = tx.GetHash(); if (mapOrphanTransactions.count(hash)) - return; + return false; - CDataStream* pvMsg = mapOrphanTransactions[hash] = new CDataStream(vMsg); + CDataStream* pvMsg = new CDataStream(vMsg); + + // Ignore big transactions, to avoid a + // send-big-orphans memory exhaustion attack. If a peer has a legitimate + // large transaction with a missing parent then we assume + // it will rebroadcast it later, after the parent transaction(s) + // have been mined or received. + // 10,000 orphans, each of which is at most 5,000 bytes big is + // at most 500 megabytes of orphans: + if (pvMsg->size() > 5000) + { + delete pvMsg; + printf("ignoring large orphan tx (size: %u, hash: %s)\n", pvMsg->size(), hash.ToString().substr(0,10).c_str()); + return false; + } + + mapOrphanTransactions[hash] = pvMsg; BOOST_FOREACH(const CTxIn& txin, tx.vin) - mapOrphanTransactionsByPrev.insert(make_pair(txin.prevout.hash, pvMsg)); + mapOrphanTransactionsByPrev[txin.prevout.hash].insert(make_pair(hash, pvMsg)); + + printf("stored orphan tx %s (mapsz %u)\n", hash.ToString().substr(0,10).c_str(), + mapOrphanTransactions.size()); + return true; } void static EraseOrphanTx(uint256 hash) @@ -182,14 +202,9 @@ void static EraseOrphanTx(uint256 hash) CDataStream(*pvMsg) >> tx; BOOST_FOREACH(const CTxIn& txin, tx.vin) { - for (multimap::iterator mi = mapOrphanTransactionsByPrev.lower_bound(txin.prevout.hash); - mi != mapOrphanTransactionsByPrev.upper_bound(txin.prevout.hash);) - { - if ((*mi).second == pvMsg) - mapOrphanTransactionsByPrev.erase(mi++); - else - mi++; - } + mapOrphanTransactionsByPrev[txin.prevout.hash].erase(hash); + if (mapOrphanTransactionsByPrev[txin.prevout.hash].empty()) + mapOrphanTransactionsByPrev.erase(txin.prevout.hash); } delete pvMsg; mapOrphanTransactions.erase(hash); @@ -2371,8 +2386,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) for (unsigned int i = 0; i < vWorkQueue.size(); i++) { uint256 hashPrev = vWorkQueue[i]; - for (multimap::iterator mi = mapOrphanTransactionsByPrev.lower_bound(hashPrev); - mi != mapOrphanTransactionsByPrev.upper_bound(hashPrev); + for (map::iterator mi = mapOrphanTransactionsByPrev[hashPrev].begin(); + mi != mapOrphanTransactionsByPrev[hashPrev].end(); ++mi) { const CDataStream& vMsg = *((*mi).second); @@ -2396,7 +2411,6 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) } else if (fMissingInputs) { - printf("storing orphan tx %s\n", inv.hash.ToString().substr(0,10).c_str()); AddOrphanTx(vMsg); // DoS prevention: do not allow mapOrphanTransactions to grow unbounded From ce1a071f6d6d1548974796c4327399659415b489 Mon Sep 17 00:00:00 2001 From: Gavin Andresen Date: Wed, 16 May 2012 11:26:56 -0400 Subject: [PATCH 10/34] Further DoS prevention: Verify signatures last Loop over all inputs doing inexpensive validity checks first, and then loop over them a second time doing expensive signature checks. This helps prevent possible CPU exhaustion attacks where an attacker tries to make a victim waste time checking signatures for invalid transactions. --- src/main.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index b7067b20..00f06334 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1033,15 +1033,26 @@ bool CTransaction::ConnectInputs(MapPrevTx inputs, if (pindex->nBlockPos == txindex.pos.nBlockPos && pindex->nFile == txindex.pos.nFile) return error("ConnectInputs() : tried to spend coinbase at depth %d", pindexBlock->nHeight - pindex->nHeight); - // Check for conflicts (double-spend) - if (!txindex.vSpent[prevout.n].IsNull()) - return fMiner ? false : error("ConnectInputs() : %s prev tx already used at %s", GetHash().ToString().substr(0,10).c_str(), txindex.vSpent[prevout.n].ToString().c_str()); - // Check for negative or overflow input values nValueIn += txPrev.vout[prevout.n].nValue; if (!MoneyRange(txPrev.vout[prevout.n].nValue) || !MoneyRange(nValueIn)) return error("ConnectInputs() : txin values out of range"); + } + // The first loop above does all the inexpensive checks. + // Only if ALL inputs pass do we perform expensive ECDSA signature checks. + // Helps prevent CPU exhaustion attacks. + for (unsigned int i = 0; i < vin.size(); i++) + { + COutPoint prevout = vin[i].prevout; + assert(inputs.count(prevout.hash) > 0); + CTxIndex& txindex = inputs[prevout.hash].first; + CTransaction& txPrev = inputs[prevout.hash].second; + + // Check for conflicts (double-spend) + if (!txindex.vSpent[prevout.n].IsNull()) + return fMiner ? false : error("ConnectInputs() : %s prev tx already used at %s", GetHash().ToString().substr(0,10).c_str(), txindex.vSpent[prevout.n].ToString().c_str()); + // Verify signature if (!VerifySignature(txPrev, *this, i, fStrictPayToScriptHash, 0)) { From 01473c3f40cea8209186e737ae20289eebcb8898 Mon Sep 17 00:00:00 2001 From: Gavin Andresen Date: Thu, 17 May 2012 10:12:04 -0400 Subject: [PATCH 11/34] Remove invalid dependent orphans from memory Remove orphan transactions from memory once all of their parent transactions are received and they're still not valid. Thanks to Sergio Demian Lerner for suggesting this fix. --- src/main.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 00f06334..432ec871 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2378,6 +2378,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) else if (strCommand == "tx") { vector vWorkQueue; + vector vEraseQueue; CDataStream vMsg(vRecv); CTransaction tx; vRecv >> tx; @@ -2392,6 +2393,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) RelayMessage(inv, vMsg); mapAlreadyAskedFor.erase(inv); vWorkQueue.push_back(inv.hash); + vEraseQueue.push_back(inv.hash); // Recursively process any orphan transactions that depended on this one for (unsigned int i = 0; i < vWorkQueue.size(); i++) @@ -2405,19 +2407,27 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) CTransaction tx; CDataStream(vMsg) >> tx; CInv inv(MSG_TX, tx.GetHash()); + bool fMissingInputs2 = false; - if (tx.AcceptToMemoryPool(true)) + if (tx.AcceptToMemoryPool(true, &fMissingInputs2)) { printf(" accepted orphan tx %s\n", inv.hash.ToString().substr(0,10).c_str()); SyncWithWallets(tx, NULL, true); RelayMessage(inv, vMsg); mapAlreadyAskedFor.erase(inv); vWorkQueue.push_back(inv.hash); + vEraseQueue.push_back(inv.hash); + } + else if (!fMissingInputs2) + { + // invalid orphan + vEraseQueue.push_back(inv.hash); + printf(" removed invalid orphan tx %s\n", inv.hash.ToString().substr(0,10).c_str()); } } } - BOOST_FOREACH(uint256 hash, vWorkQueue) + BOOST_FOREACH(uint256 hash, vEraseQueue) EraseOrphanTx(hash); } else if (fMissingInputs) From b199f7547f357711873327347c0f368248e99032 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Wed, 20 Jun 2012 17:59:36 +0000 Subject: [PATCH 12/34] Bump VERSION so we can differentiate between 0.4.7rc2 and 0.4.7rc3 --- src/serialize.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/serialize.h b/src/serialize.h index 8cdfb30b..c7e64dac 100644 --- a/src/serialize.h +++ b/src/serialize.h @@ -59,7 +59,7 @@ class CDataStream; class CAutoFile; static const unsigned int MAX_SIZE = 0x02000000; -static const int VERSION = 40701; +static const int VERSION = 40703; static const char* pszSubVer = ""; static const bool VERSION_IS_BETA = true; From 3023e782bdaee3448e1543b482cf5cd022c9699f Mon Sep 17 00:00:00 2001 From: Gavin Andresen Date: Tue, 19 Jun 2012 15:50:12 -0400 Subject: [PATCH 13/34] print large orphan warning BEFORE deleting pvMsg --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 432ec871..7ce7c92e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -179,8 +179,8 @@ bool AddOrphanTx(const CDataStream& vMsg) // at most 500 megabytes of orphans: if (pvMsg->size() > 5000) { - delete pvMsg; printf("ignoring large orphan tx (size: %u, hash: %s)\n", pvMsg->size(), hash.ToString().substr(0,10).c_str()); + delete pvMsg; return false; } From 34709a786c3cefb11d5677bcad4bb764a0fba31d Mon Sep 17 00:00:00 2001 From: fanquake Date: Mon, 18 Jun 2012 21:58:20 +0800 Subject: [PATCH 14/34] build instructions: Qt is not uppercase (Upstream: 8b7b3be76529612ebe219e315a273d05066d2118) --- doc/build-msw.txt | 2 +- doc/build-osx.txt | 2 +- doc/build-unix.txt | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/build-msw.txt b/doc/build-msw.txt index 2e54b029..5d871e15 100644 --- a/doc/build-msw.txt +++ b/doc/build-msw.txt @@ -7,7 +7,7 @@ cryptographic software written by Eric Young (eay@cryptsoft.com) and UPnP software written by Thomas Bernard. -See readme-qt.rst for instructions on building Bitcoin QT, the +See readme-qt.rst for instructions on building Bitcoin-Qt, the graphical user interface. WINDOWS BUILD NOTES diff --git a/doc/build-osx.txt b/doc/build-osx.txt index 80024415..f06df50e 100644 --- a/doc/build-osx.txt +++ b/doc/build-osx.txt @@ -12,7 +12,7 @@ Laszlo Hanyecz Douglas Huff -See readme-qt.rst for instructions on building Bitcoin QT, the +See readme-qt.rst for instructions on building Bitcoin-Qt, the graphical user interface. Tested on 10.5 and 10.6 intel. PPC is not supported because it's big-endian. diff --git a/doc/build-unix.txt b/doc/build-unix.txt index 0d335dfa..565b191c 100644 --- a/doc/build-unix.txt +++ b/doc/build-unix.txt @@ -17,8 +17,8 @@ To Build cd src/ make -f makefile.unix # Headless bitcoin -See readme-qt.rst for instructions on building Bitcoin QT, -the graphical bitcoin. +See readme-qt.rst for instructions on building Bitcoin-Qt, +the graphical user interface. Dependencies ------------ From d2ee96d88f3db45b8b4f7a1ed97f7b62054f70b2 Mon Sep 17 00:00:00 2001 From: Philip Kaufmann Date: Mon, 18 Jun 2012 22:48:35 +0200 Subject: [PATCH 15/34] GUI: ensure a changed bitcoin unit immediately updates the tx list amounts --- src/qt/transactiontablemodel.cpp | 7 +++++++ src/qt/transactiontablemodel.h | 2 ++ 2 files changed, 9 insertions(+) diff --git a/src/qt/transactiontablemodel.cpp b/src/qt/transactiontablemodel.cpp index 28620bf3..a8ffe62e 100644 --- a/src/qt/transactiontablemodel.cpp +++ b/src/qt/transactiontablemodel.cpp @@ -218,6 +218,8 @@ TransactionTableModel::TransactionTableModel(CWallet* wallet, WalletModel *paren QTimer *timer = new QTimer(this); connect(timer, SIGNAL(timeout()), this, SLOT(update())); timer->start(MODEL_UPDATE_DELAY); + + connect(walletModel->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit())); } TransactionTableModel::~TransactionTableModel() @@ -619,3 +621,8 @@ QModelIndex TransactionTableModel::index(int row, int column, const QModelIndex } } +void TransactionTableModel::updateDisplayUnit() +{ + // emit dataChanged to update Amount column with the current unit + emit dataChanged(index(0, Amount), index(priv->size()-1, Amount)); +} diff --git a/src/qt/transactiontablemodel.h b/src/qt/transactiontablemodel.h index db88a060..3efeaa61 100644 --- a/src/qt/transactiontablemodel.h +++ b/src/qt/transactiontablemodel.h @@ -74,6 +74,8 @@ private: private slots: void update(); +public slots: + void updateDisplayUnit(); friend class TransactionTablePriv; }; From 6d6995bc83c3d97e5d99e45b40e76c34b772ebcc Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Wed, 20 Jun 2012 18:13:16 +0200 Subject: [PATCH 16/34] Update my GPG key --- contrib/gitian-downloader/sipa-key.pgp | Bin 108922 -> 109468 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/contrib/gitian-downloader/sipa-key.pgp b/contrib/gitian-downloader/sipa-key.pgp index a52a5deb1b6c4691bb7073fc819080f66df6d2f2..ffa09bb4ad276c2380686a7e1619d18dce71c8a1 100644 GIT binary patch delta 1670 zcmV;126_4V(gvK@2C!xVe;))e0RjLC1p-f?EfNA9AOH#p5V@oX=N+oabl{;6{0-$q zT-8kB9?A)MC$tf=*S8FrrO&5Zkls_REFE%X6y_`quYi+i4b!5P6>q=o#3|_6cj!3H zx&48~=8HhWJh~*d_4RCfIKzJjf*gB{4B-kF29kRr-|jxjA*{30f0KJ!Shm^VK*tGp zc%_?r9+kDbh)M5POh)miD^H><&ba`)Je|vdYrQ4D*7_Sb@yAhGRO!DXPe2PePsH%_OZY!1Q_Zp z`f^Tv1IED~-fCJ!)uA8S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+_G zi9gHyOQ?J1#(>KCKcrUR*nYk+P2Z2TXd}J2^~htRU^L>myw((DBYAL~RO^y2Nf__jzp5N*uAov>r%bEVh0B}60-!b~xjSHs26VT1k8n73 zS65E>RjleUAyblkDTl!Cdmp$~NI-#nUuNt~Z#F~? z3;3Vz5v!N4I}^79NH8B4teq&bM=YD3DT7EtHsHb4n;jS352iyEhhe4+wm@J}*QNo` zEqzPi=_-RANTQ8#3WjMe;|Ilx_{_{_#vLGmAt#vxN-o>ysf@Bm>LQ1(VLDBYzcD5C3{(f2HHBg>II+SUZ!0-}!u_H4z1z;BSH*=9bjwtrg+S_Y!!Tigp~4S$OVIItS` z@jUB5TT#D7rcHe=o<17l8H{eG9^Yt2$2(6oxKf86`hfDP3`@y`{r5zep9BVp3I}Xr zGJk2*vm?I8x8bvajX1BYsQu+j684a`g4HKw_#)tQQ3UK2L#D_W2^chkgAT{?#HWhElzr z9_o6xE09C$>ouZ&_sirVA??)$!6k3hOlJ)RKzMw!+JcLqkGwKhnXH~~A6nq`AbGeveku*4((bFPyRAk}x)@)~C zNRWB?E_A~eZx8=y2&B@SV<&<4H~PuE6l7d5fbs?yXLs+)ik>&x@Mg1tp*mETZmg?- i(}4_jyhx;GoaoaOI0*2l*5-Hua}$$qSsSz6`oFMgG8U-- From 90712378a73337f4ec5451da72d255f9f13664c0 Mon Sep 17 00:00:00 2001 From: xanatos Date: Thu, 21 Jun 2012 21:37:49 +0300 Subject: [PATCH 17/34] = instead of == in multisig_tests.cpp --- src/test/multisig_tests.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/multisig_tests.cpp b/src/test/multisig_tests.cpp index 8ae9290f..521b787d 100644 --- a/src/test/multisig_tests.cpp +++ b/src/test/multisig_tests.cpp @@ -235,7 +235,7 @@ BOOST_AUTO_TEST_CASE(multisig_Solver1) BOOST_CHECK(ExtractAddresses(s, whichType, addrs, nRequired)); BOOST_CHECK(addrs[0] == keyaddr[0]); BOOST_CHECK(addrs[1] == keyaddr[1]); - BOOST_CHECK(nRequired = 1); + BOOST_CHECK(nRequired == 1); BOOST_CHECK(IsMine(keystore, s)); BOOST_CHECK(!IsMine(emptykeystore, s)); BOOST_CHECK(!IsMine(partialkeystore, s)); From 3edb53eeed578fcccb13c4205c950f6938585240 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Wed, 20 Jun 2012 16:15:46 +0000 Subject: [PATCH 18/34] gitian-downloader: Update luke-jr's key --- contrib/gitian-downloader/luke-jr-key.pgp | Bin 5467 -> 7322 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/contrib/gitian-downloader/luke-jr-key.pgp b/contrib/gitian-downloader/luke-jr-key.pgp index c40917d78c512ac13414b0d9e92c59f57e6a9c77..275b041d2059ece19e1a4ade74b32654ab3a2c56 100644 GIT binary patch delta 5057 zcmaLaWml99qlRH(=#Wn7?(PtfA*Cgxk&u)g0fCzuy1ToP4r!HckP-$Mnvw1h5ccyv zpWeOpTKg|tAC7fiE1cO94TPW+Urf#vEf6JuLWzuqq6Nc@M#Dl;*|kE##v@A67t>i5 zIhs0N5SrV6Y-gT?Xl2V##wY#cu6j@L{&v6bci5@>H!f*ZCQNfSwcenXpZ89hsk~Ld zdAGmB^7(>~uu zp;X3G`46thr!#|GdGbAW7fdl0wirgKu3^S5F3axHR15nfM(M8ueB(5=Ji%FqN1!F- z;WF!_E-NuSyGxgdhx7H4rRTS-g1fJ>b{tqBO=j%v9?C`P9Tsb9XTbNh*Y2UnGqZK^ zOr;yRd+y4OdaiB*`ZpOqe>d%b*3db!Fv6Z0_4mzs@+6NcKiX@Y4R%U@9#Fr51CB1q zrS5_3E~5DuJ9u%}im^j+@rU?EM!2B7#yP8p+f=6SMuMT+IMB+}Ul^-$mK!6Rsh^xu z+C6G}A%YB?Xf?c#p;s6$0l$E)_6No{sn*sP)LX}8NtVt%MQhRG$F-$^BSYsK-@|Mo znndDRe|l}eLzt7+W3)H8>lRD&DZ9ej`NLmR#m3REXGJV2u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5LGcl#0asl$rBx1k*#!~LA|Q1 z0Em>AkR1+r^iv^^US>e~d_NICpn2!ZI)J19D4TD4gwkQ=ay+pHMCqbP>D>5aLR6G| zOE46xYJV?j3sku>xDcZv9XE&LR)yq_T$h0e2oaO~ihlxWP_KXNy~> zdEiYko0qbaw~&6xhA{}-7=WonwQ-Yw18)*;10}ZEd3?*j|(B(=StHFa_yZVrGDU^VCet(J-IXQpVQVt#aa}x}*RJLXTrZl`& zNK;SLQ2g=xYS9HcRnRU3!1piTiQoL)thbBN0-Ynx@W<&)uPc{+W=g05=e?jroH5zBk&=xm=qP!v0z8fYMgkjxf4C}~-(Y-TONa92 z=p(rphW*3jP2nJc9i`@}IjH5ic%%5_0e^UO z)d9xsybUKL8ar%oJ0?3S-JC z5t|DS%1&hwsEvlRkAy>PQe?gm*?+Z#dvrZ~e;jSS^HcyH^H;&(DYMjSzUZu{-aA$KO=jD<1Hqyb179wa=OsiYKi%;^OkAng% zvv;l5x|)BuEybhYln>)c3?KxI4^mgY92e`Gt(X|?Kh5v`mJg_pzJ1JC?I--jvT`lY k6rI(CigqmMUACW1IZH8tk+K&Gd567|?sHt)`vNl|#X!3u_5c6? From 04d4c0e444d9b02d5d9ba7893052f8c75cfdfed9 Mon Sep 17 00:00:00 2001 From: Philip Kaufmann Date: Thu, 21 Jun 2012 12:05:06 +0200 Subject: [PATCH 19/34] fix a memory leak in key.cpp - add EC_KEY_free() in CKey::Reset() when pkey != NULL - init pkey with NULL in CKey constructor --- src/key.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/key.h b/src/key.h index ba68f0dd..5986a534 100644 --- a/src/key.h +++ b/src/key.h @@ -73,6 +73,8 @@ public: void Reset() { fCompressedPubKey = false; + if (pkey != NULL) + EC_KEY_free(pkey); pkey = EC_KEY_new_by_curve_name(NID_secp256k1); if (pkey == NULL) throw key_error("CKey::CKey() : EC_KEY_new_by_curve_name failed"); @@ -81,6 +83,7 @@ public: CKey() { + pkey = NULL; Reset(); } From 971a6e53a155c5a78c5d273dccc7c0c51c670d07 Mon Sep 17 00:00:00 2001 From: Philip Kaufmann Date: Sun, 24 Jun 2012 18:08:27 +0200 Subject: [PATCH 20/34] fix a comment to correctly use -upgradewallet --- src/init.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/init.cpp b/src/init.cpp index 586e3dab..3ce32947 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -399,7 +399,7 @@ bool AppInit2(int argc, char* argv[]) if (GetBoolArg("-upgradewallet", fFirstRun)) { int nMaxVersion = GetArg("-upgradewallet", 0); - if (nMaxVersion == 0) // the -walletupgrade without argument case + if (nMaxVersion == 0) // the -upgradewallet without argument case { printf("Performing wallet upgrade to %i\n", FEATURE_LATEST); nMaxVersion = CLIENT_VERSION; From 04ae8e1a1b82ec59d7b4b720de0d5d1ebe0e12ba Mon Sep 17 00:00:00 2001 From: Michael Ford Date: Thu, 21 Jun 2012 09:36:20 +0800 Subject: [PATCH 21/34] Update master --- INSTALL | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/INSTALL b/INSTALL index 6989d890..fe7de512 100644 --- a/INSTALL +++ b/INSTALL @@ -1,9 +1,9 @@ Building Bitcoin -See doc/readme-qt.rst for instructions on building Bitcoin QT, +See doc/readme-qt.rst for instructions on building Bitcoin-Qt, the intended-for-end-users, nice-graphical-interface, reference implementation of Bitcoin. See doc/build-*.txt for instructions on building bitcoind, the intended-for-services, no-graphical-interface, reference -implementation of Bitcoin. +implementation of Bitcoin. \ No newline at end of file From ccf2e853a1f4039d008e758138e80fa09e4f6f12 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Thu, 5 Jul 2012 23:05:58 +0000 Subject: [PATCH 22/34] Update Debian "Use system json-spirit" patch to apply ("Fixed" upstream in 3563824c602cb2b42cc21970935f45ce646c3964) --- .../patches/1001_use_system_json-spirit.patch | 48 +++++++++++++++---- 1 file changed, 39 insertions(+), 9 deletions(-) diff --git a/contrib/debian/patches/1001_use_system_json-spirit.patch b/contrib/debian/patches/1001_use_system_json-spirit.patch index 56a20af3..307dfc8d 100644 --- a/contrib/debian/patches/1001_use_system_json-spirit.patch +++ b/contrib/debian/patches/1001_use_system_json-spirit.patch @@ -1,10 +1,10 @@ Description: Use system JSON Spirit library Author: Jonas Smedegaard -Last-Update: 2011-05-17 ---- a/src/rpc.cpp -+++ b/src/rpc.cpp -@@ -12,9 +12,7 @@ - #include +Last-Update: 2012-07-05 +--- a/src/bitcoinrpc.cpp ++++ b/src/bitcoinrpc.cpp +@@ -20,9 +20,7 @@ + #include typedef boost::asio::ssl::stream SSLStream; #endif -#include "json/json_spirit_reader_template.h" @@ -16,11 +16,41 @@ Last-Update: 2011-05-17 // precompiled in headers.h. The problem might be when the pch file goes over --- a/src/makefile.unix +++ b/src/makefile.unix -@@ -23,6 +23,7 @@ - -l boost_thread \ - -l db_cxx \ +@@ -29,6 +29,7 @@ LIBS += \ + -l boost_thread$(BOOST_LIB_SUFFIX) \ + -l db_cxx$(BDB_LIB_SUFFIX) \ -l ssl \ + -l json_spirit \ -l crypto - ifdef USE_UPNP + ifndef USE_UPNP +--- a/src/rpcdump.cpp ++++ b/src/rpcdump.cpp +@@ -15,9 +15,8 @@ + // typedef boost::asio::ssl::stream SSLStream; + // #endif + // #include +-#include "json/json_spirit_reader_template.h" +-#include "json/json_spirit_writer_template.h" +-#include "json/json_spirit_utils.h" ++ ++#include + + #define printf OutputDebugStringF + +--- a/src/test/rpc_tests.cpp ++++ b/src/test/rpc_tests.cpp +@@ -1,11 +1,10 @@ + #include + #include + ++#include ++ + #include "base58.h" + #include "util.h" +-#include "json/json_spirit_reader_template.h" +-#include "json/json_spirit_writer_template.h" +-#include "json/json_spirit_utils.h" + + using namespace std; + using namespace json_spirit; From a0cbcfd6ed9607e481211826c33cdd15e2cee579 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Thu, 5 Jul 2012 23:05:58 +0000 Subject: [PATCH 23/34] Update Debian "Use system json-spirit" patch to apply ("Fixed" upstream in 3563824c602cb2b42cc21970935f45ce646c3964) --- contrib/debian/patches/1001_use_system_json-spirit.patch | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/contrib/debian/patches/1001_use_system_json-spirit.patch b/contrib/debian/patches/1001_use_system_json-spirit.patch index 56a20af3..d471bded 100644 --- a/contrib/debian/patches/1001_use_system_json-spirit.patch +++ b/contrib/debian/patches/1001_use_system_json-spirit.patch @@ -1,8 +1,8 @@ Description: Use system JSON Spirit library Author: Jonas Smedegaard -Last-Update: 2011-05-17 ---- a/src/rpc.cpp -+++ b/src/rpc.cpp +Last-Update: 2012-07-05 +--- a/src/bitcoinrpc.cpp ++++ b/src/bitcoinrpc.cpp @@ -12,9 +12,7 @@ #include typedef boost::asio::ssl::stream SSLStream; From 46dbdebb5918b170963f1b5a14c5ef0148262e1e Mon Sep 17 00:00:00 2001 From: Philip Kaufmann Date: Sun, 24 Jun 2012 18:03:03 +0200 Subject: [PATCH 24/34] small updates to Bitcoin-Qt project file - re-word a comment and remove a space --- bitcoin-qt.pro | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bitcoin-qt.pro b/bitcoin-qt.pro index b5cee48e..d79e025f 100644 --- a/bitcoin-qt.pro +++ b/bitcoin-qt.pro @@ -5,15 +5,15 @@ INCLUDEPATH += src src/json src/qt DEFINES += QT_GUI BOOST_THREAD_USE_LIB CONFIG += no_include_pwd -# for boost 1.37, add -mt to the boost libraries +# for boost 1.37, add -mt to the boost libraries # use: qmake BOOST_LIB_SUFFIX=-mt # for boost thread win32 with _win32 sufix # use: BOOST_THREAD_LIB_SUFFIX=_win32-... # or when linking against a specific BerkelyDB version: BDB_LIB_SUFFIX=-4.8 -# Dependency library locations can be customized with BOOST_INCLUDE_PATH, -# BOOST_LIB_PATH, BDB_INCLUDE_PATH, BDB_LIB_PATH -# OPENSSL_INCLUDE_PATH and OPENSSL_LIB_PATH respectively +# Dependency library locations can be customized with: +# BOOST_INCLUDE_PATH, BOOST_LIB_PATH, BDB_INCLUDE_PATH, +# BDB_LIB_PATH, OPENSSL_INCLUDE_PATH and OPENSSL_LIB_PATH respectively OBJECTS_DIR = build MOC_DIR = build From 19920202cc73c72f7cf5df8eb0d158f6713ef6f5 Mon Sep 17 00:00:00 2001 From: xanatos Date: Fri, 22 Jun 2012 10:02:43 +0300 Subject: [PATCH 25/34] Small fix to rpc_tests --- src/test/rpc_tests.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/rpc_tests.cpp b/src/test/rpc_tests.cpp index 87462f76..45424163 100644 --- a/src/test/rpc_tests.cpp +++ b/src/test/rpc_tests.cpp @@ -39,9 +39,9 @@ BOOST_FIXTURE_TEST_CASE(rpc_addmultisig, TestNetFixture) rpcfn_type addmultisig = mapCallTable["addmultisigaddress"]; // old, 65-byte-long: - const char* address1Hex = "0434e3e09f49ea168c5bbf53f877ff4206923858aab7c7e1df25bc263978107c95e35065a27ef6f1b27222db0ec97e0e895eaca603d3ee0d4c060ce3d8a00286c8"; + const char address1Hex[] = "0434e3e09f49ea168c5bbf53f877ff4206923858aab7c7e1df25bc263978107c95e35065a27ef6f1b27222db0ec97e0e895eaca603d3ee0d4c060ce3d8a00286c8"; // new, compressed: - const char* address2Hex = "0388c2037017c62240b6b72ac1a2a5f94da790596ebd06177c8572752922165cb4"; + const char address2Hex[] = "0388c2037017c62240b6b72ac1a2a5f94da790596ebd06177c8572752922165cb4"; Value v; CBitcoinAddress address; @@ -67,7 +67,7 @@ BOOST_FIXTURE_TEST_CASE(rpc_addmultisig, TestNetFixture) string short1(address1Hex, address1Hex+sizeof(address1Hex)-2); // last byte missing BOOST_CHECK_THROW(addmultisig(createArgs(2, short1.c_str()), false), runtime_error); - string short2(address1Hex+2, address1Hex+sizeof(address1Hex)); // first byte missing + string short2(address1Hex+1, address1Hex+sizeof(address1Hex)); // first byte missing BOOST_CHECK_THROW(addmultisig(createArgs(2, short2.c_str()), false), runtime_error); } From ee29ad27b365be363fdbc7f4db99c306c090404c Mon Sep 17 00:00:00 2001 From: xanatos Date: Sat, 23 Jun 2012 17:29:34 +0300 Subject: [PATCH 26/34] Changed a comment about a QVariant type --- src/qt/optionsmodel.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/optionsmodel.h b/src/qt/optionsmodel.h index 775362d6..debd614e 100644 --- a/src/qt/optionsmodel.h +++ b/src/qt/optionsmodel.h @@ -24,7 +24,7 @@ public: MinimizeOnClose, // bool ConnectSOCKS4, // bool ProxyIP, // QString - ProxyPort, // QString + ProxyPort, // int Fee, // qint64 DisplayUnit, // BitcoinUnits::Unit DisplayAddresses, // bool From 26199789ed6b8ec8bebeee67df1df4b29d465a79 Mon Sep 17 00:00:00 2001 From: fanquake Date: Fri, 29 Jun 2012 17:26:45 +0800 Subject: [PATCH 27/34] Fix a few typos --- src/util.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/util.cpp b/src/util.cpp index cae01dff..6e31540f 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -852,7 +852,7 @@ void ShrinkDebugFile() // "Never go to sea with two chronometers; take one or three." // Our three time sources are: // - System clock -// - Median of other nodes's clocks +// - Median of other nodes clocks // - The user (asking the user to fix the system clock if the first two disagree) // int64 GetTime() @@ -958,7 +958,7 @@ string FormatFullVersion() // --> may result in deadlock between the two threads, depending on when they run. // Solution implemented here: // Keep track of pairs of locks: (A before B), (A before C), etc. -// Complain if any thread trys to lock in a different order. +// Complain if any thread tries to lock in a different order. // struct CLockLocation From 46761b339cd57c5de56c2ae5c7a6d8fa592567ce Mon Sep 17 00:00:00 2001 From: fanquake Date: Fri, 29 Jun 2012 17:26:45 +0800 Subject: [PATCH 28/34] Fix a few typos --- src/base58.h | 6 +++--- src/util.cpp | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/base58.h b/src/base58.h index d92054da..8ee05b07 100644 --- a/src/base58.h +++ b/src/base58.h @@ -117,7 +117,7 @@ inline bool DecodeBase58(const char* psz, std::vector& vchRet) } // Decode a base58-encoded string str into byte vector vchRet -// returns true if decoding is succesful +// returns true if decoding is successful inline bool DecodeBase58(const std::string& str, std::vector& vchRet) { return DecodeBase58(str.c_str(), vchRet); @@ -137,7 +137,7 @@ inline std::string EncodeBase58Check(const std::vector& vchIn) } // Decode a base58-encoded string psz that includes a checksum, into byte vector vchRet -// returns true if decoding is succesful +// returns true if decoding is successful inline bool DecodeBase58Check(const char* psz, std::vector& vchRet) { if (!DecodeBase58(psz, vchRet)) @@ -158,7 +158,7 @@ inline bool DecodeBase58Check(const char* psz, std::vector& vchRe } // Decode a base58-encoded string str that includes a checksum, into byte vector vchRet -// returns true if decoding is succesful +// returns true if decoding is successful inline bool DecodeBase58Check(const std::string& str, std::vector& vchRet) { return DecodeBase58Check(str.c_str(), vchRet); diff --git a/src/util.cpp b/src/util.cpp index 03112038..1f120e18 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -946,7 +946,7 @@ void ShrinkDebugFile() // "Never go to sea with two chronometers; take one or three." // Our three time sources are: // - System clock -// - Median of other nodes's clocks +// - Median of other nodes clocks // - The user (asking the user to fix the system clock if the first two disagree) // static int64 nMockTime = 0; // For unit testing @@ -1061,7 +1061,7 @@ string FormatFullVersion() // --> may result in deadlock between the two threads, depending on when they run. // Solution implemented here: // Keep track of pairs of locks: (A before B), (A before C), etc. -// Complain if any thread trys to lock in a different order. +// Complain if any thread tries to lock in a different order. // struct CLockLocation From d477028247a7de1f1e2acabe85d5d281bd8f62cf Mon Sep 17 00:00:00 2001 From: fanquake Date: Fri, 29 Jun 2012 17:26:45 +0800 Subject: [PATCH 29/34] Fix a few typos --- src/addrman.h | 4 ++-- src/base58.h | 6 +++--- src/util.cpp | 4 ++-- src/wallet.h | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/addrman.h b/src/addrman.h index 95079878..e89fbba9 100644 --- a/src/addrman.h +++ b/src/addrman.h @@ -22,13 +22,13 @@ private: // where knowledge about this address first came from CNetAddr source; - // last succesfull connection by us + // last successful connection by us int64 nLastSuccess; // last try whatsoever by us: // int64 CAddress::nLastTry - // connection attempts since last succesful attempt + // connection attempts since last successful attempt int nAttempts; // reference count in new sets (memory only) diff --git a/src/base58.h b/src/base58.h index bc681a08..201a9e24 100644 --- a/src/base58.h +++ b/src/base58.h @@ -118,7 +118,7 @@ inline bool DecodeBase58(const char* psz, std::vector& vchRet) } // Decode a base58-encoded string str into byte vector vchRet -// returns true if decoding is succesful +// returns true if decoding is successful inline bool DecodeBase58(const std::string& str, std::vector& vchRet) { return DecodeBase58(str.c_str(), vchRet); @@ -138,7 +138,7 @@ inline std::string EncodeBase58Check(const std::vector& vchIn) } // Decode a base58-encoded string psz that includes a checksum, into byte vector vchRet -// returns true if decoding is succesful +// returns true if decoding is successful inline bool DecodeBase58Check(const char* psz, std::vector& vchRet) { if (!DecodeBase58(psz, vchRet)) @@ -159,7 +159,7 @@ inline bool DecodeBase58Check(const char* psz, std::vector& vchRe } // Decode a base58-encoded string str that includes a checksum, into byte vector vchRet -// returns true if decoding is succesful +// returns true if decoding is successful inline bool DecodeBase58Check(const std::string& str, std::vector& vchRet) { return DecodeBase58Check(str.c_str(), vchRet); diff --git a/src/util.cpp b/src/util.cpp index 94bdba6f..a4424a46 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -991,7 +991,7 @@ void ShrinkDebugFile() // "Never go to sea with two chronometers; take one or three." // Our three time sources are: // - System clock -// - Median of other nodes's clocks +// - Median of other nodes clocks // - The user (asking the user to fix the system clock if the first two disagree) // static int64 nMockTime = 0; // For unit testing @@ -1116,7 +1116,7 @@ std::string FormatSubVersion(const std::string& name, int nClientVersion, const // --> may result in deadlock between the two threads, depending on when they run. // Solution implemented here: // Keep track of pairs of locks: (A before B), (A before C), etc. -// Complain if any thread trys to lock in a different order. +// Complain if any thread tries to lock in a different order. // struct CLockLocation diff --git a/src/wallet.h b/src/wallet.h index 1b17dea9..6fe3ca67 100644 --- a/src/wallet.h +++ b/src/wallet.h @@ -39,7 +39,7 @@ private: // the current wallet version: clients below this version are not able to load the wallet int nWalletVersion; - // the maxmimum wallet format version: memory-only variable that specifies to what version this wallet may be upgraded + // the maximum wallet format version: memory-only variable that specifies to what version this wallet may be upgraded int nWalletMaxVersion; public: From a1816267e6bf6d7fe017f089c5720da1a693a868 Mon Sep 17 00:00:00 2001 From: Philip Kaufmann Date: Sat, 30 Jun 2012 01:16:22 +0200 Subject: [PATCH 30/34] fix a typo in OptionsDialog --- src/qt/optionsdialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/optionsdialog.cpp b/src/qt/optionsdialog.cpp index bac01829..6018419f 100644 --- a/src/qt/optionsdialog.cpp +++ b/src/qt/optionsdialog.cpp @@ -188,7 +188,7 @@ MainOptionsPage::MainOptionsPage(QWidget *parent): #endif connect_socks4 = new QCheckBox(tr("&Connect through SOCKS4 proxy:")); - connect_socks4->setToolTip(tr("Connect to the Bitcon network through a SOCKS4 proxy (e.g. when connecting through Tor)")); + connect_socks4->setToolTip(tr("Connect to the Bitcoin network through a SOCKS4 proxy (e.g. when connecting through Tor)")); layout->addWidget(connect_socks4); QHBoxLayout *proxy_hbox = new QHBoxLayout(); From cf6ab20d8b53503a4727bd86d1747efbe013a417 Mon Sep 17 00:00:00 2001 From: fanquake Date: Sat, 30 Jun 2012 17:05:28 +0800 Subject: [PATCH 31/34] Fix a couple more typos --- src/base58.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/base58.h b/src/base58.h index 8ee05b07..9bd078ca 100644 --- a/src/base58.h +++ b/src/base58.h @@ -69,7 +69,7 @@ inline std::string EncodeBase58(const std::vector& vch) } // Decode a base58-encoded string psz into byte vector vchRet -// returns true if decoding is succesful +// returns true if decoding is successful inline bool DecodeBase58(const char* psz, std::vector& vchRet) { CAutoBN_CTX pctx; From fb7ca331781c2ddc3118762bcb21229c8a9a409e Mon Sep 17 00:00:00 2001 From: fanquake Date: Sat, 30 Jun 2012 17:05:28 +0800 Subject: [PATCH 32/34] Fix a couple more typos --- src/base58.h | 2 +- src/qt/test/uritests.cpp | 2 +- src/test/mruset_tests.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/base58.h b/src/base58.h index 201a9e24..dff475a7 100644 --- a/src/base58.h +++ b/src/base58.h @@ -70,7 +70,7 @@ inline std::string EncodeBase58(const std::vector& vch) } // Decode a base58-encoded string psz into byte vector vchRet -// returns true if decoding is succesful +// returns true if decoding is successful inline bool DecodeBase58(const char* psz, std::vector& vchRet) { CAutoBN_CTX pctx; diff --git a/src/qt/test/uritests.cpp b/src/qt/test/uritests.cpp index 70c20be0..a281c39c 100644 --- a/src/qt/test/uritests.cpp +++ b/src/qt/test/uritests.cpp @@ -59,7 +59,7 @@ void URITests::uriTests() QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W")); QVERIFY(rv.label == QString()); - // We currently dont implement the message paramenter (ok, yea, we break spec...) + // We currently don't implement the message parameter (ok, yea, we break spec...) uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?req-message=Wikipedia Example Address")); QVERIFY(!GUIUtil::parseBitcoinURI(uri, &rv)); diff --git a/src/test/mruset_tests.cpp b/src/test/mruset_tests.cpp index ca5a1f1b..64a6678a 100644 --- a/src/test/mruset_tests.cpp +++ b/src/test/mruset_tests.cpp @@ -71,7 +71,7 @@ int static permute(int n) return ret; } -// Test that an mruset acts like a moving window, if no duplcate elements are added +// Test that an mruset acts like a moving window, if no duplicate elements are added BOOST_AUTO_TEST_CASE(mruset_window) { mruset mru(MAX_SIZE); From 580f7cd73189c6840b354c9ed6a0227161150fcc Mon Sep 17 00:00:00 2001 From: Gregory Maxwell Date: Sun, 1 Jul 2012 20:23:26 -0400 Subject: [PATCH 33/34] Do not consider inbound peers for outbound network group exclusion. Bitcoin will not make an outbound connection to a network group (/16 for IPv4) that it is already connected to. This means that if an attacker wants good odds of capturing all a nodes outbound connections he must have hosts on a a large number of distinct groups. Previously both inbound and outbound connections were used to feed this exclusion. The use of inbound connections, which can be controlled by the attacker, actually has the potential of making sibyl attacks _easier_: An attacker can start up hosts in groups which house many honest nodes and make outbound connections to the victim to exclude big swaths of honest nodes. Because the attacker chooses to make the outbound connection he can always beat out honest nodes for the consumption of inbound slots. At _best_ the old behavior increases attacker costs by a single group (e.g. one distinct group to use to fill up all your inbound slots), but at worst it allows the attacker to select whole networks you won't connect to. This commit makes the nodes use only outbound links to exclude network groups for outbound connections. Fancier things could be done, like weaker exclusion for inbound groups... but simplicity is good and I don't believe more complexity is currently needed. --- src/net.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/net.cpp b/src/net.cpp index 2ff539a1..7637f885 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1491,12 +1491,14 @@ void ThreadOpenConnections2(void* parg) CAddress addrConnect; int64 nBest = std::numeric_limits::min(); - // Only connect to one address per a.b.?.? range. + // Only connect out to one peer per network group (/16 for IPv4). // Do this here so we don't have to critsect vNodes inside mapAddresses critsect. set setConnected; CRITICAL_BLOCK(cs_vNodes) BOOST_FOREACH(CNode* pnode, vNodes) - setConnected.insert(pnode->addr.ip & 0x0000ffff); + if (!pnode->fInbound) { + setConnected.insert(pnode->addr.ip & 0x0000ffff); + } CRITICAL_BLOCK(cs_mapAddresses) { From 927c00255b62171b75c0733fd90de9f76ce59613 Mon Sep 17 00:00:00 2001 From: Gregory Maxwell Date: Sun, 1 Jul 2012 20:23:26 -0400 Subject: [PATCH 34/34] Do not consider inbound peers for outbound network group exclusion. Bitcoin will not make an outbound connection to a network group (/16 for IPv4) that it is already connected to. This means that if an attacker wants good odds of capturing all a nodes outbound connections he must have hosts on a a large number of distinct groups. Previously both inbound and outbound connections were used to feed this exclusion. The use of inbound connections, which can be controlled by the attacker, actually has the potential of making sibyl attacks _easier_: An attacker can start up hosts in groups which house many honest nodes and make outbound connections to the victim to exclude big swaths of honest nodes. Because the attacker chooses to make the outbound connection he can always beat out honest nodes for the consumption of inbound slots. At _best_ the old behavior increases attacker costs by a single group (e.g. one distinct group to use to fill up all your inbound slots), but at worst it allows the attacker to select whole networks you won't connect to. This commit makes the nodes use only outbound links to exclude network groups for outbound connections. Fancier things could be done, like weaker exclusion for inbound groups... but simplicity is good and I don't believe more complexity is currently needed. --- src/net.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/net.cpp b/src/net.cpp index d927c505..7f2f48a6 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1333,12 +1333,14 @@ void ThreadOpenConnections2(void* parg) // CAddress addrConnect; - // Only connect to one address per a.b.?.? range. + // Only connect out to one peer per network group (/16 for IPv4). // Do this here so we don't have to critsect vNodes inside mapAddresses critsect. set > setConnected; CRITICAL_BLOCK(cs_vNodes) BOOST_FOREACH(CNode* pnode, vNodes) - setConnected.insert(pnode->addr.GetGroup()); + if (!pnode->fInbound) { + setConnected.insert(pnode->addr.GetGroup()); + } int64 nANow = GetAdjustedTime();