From 20cff2ade4d686fb4f10c106dbc99b76c173102a Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Sat, 1 Oct 2011 02:47:47 +0200 Subject: [PATCH 01/41] remove possibility of 63 bit overflow in ParseMoney --- src/util.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util.cpp b/src/util.cpp index 76a27002719..d6a113095da 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -389,7 +389,7 @@ bool ParseMoney(const char* pszIn, int64& nRet) for (; *p; p++) if (!isspace(*p)) return false; - if (strWhole.size() > 14) + if (strWhole.size() > 10) // guard against 63 bit overflow return false; if (nUnits < 0 || nUnits > COIN) return false; From 600dc6255971bfe152767c67e7ca6866fb1541ea Mon Sep 17 00:00:00 2001 From: Victor Leschuk Date: Thu, 6 Oct 2011 19:53:42 +0400 Subject: [PATCH 02/41] Fix for 64bit build --- src/util.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/util.h b/src/util.h index 3d7ef108b47..6ecc92b2b6d 100644 --- a/src/util.h +++ b/src/util.h @@ -662,8 +662,8 @@ inline bool AffinityBugWorkaround(void(*pfn)(void*)) { #ifdef __WXMSW__ // Sometimes after a few hours affinity gets stuck on one processor - DWORD dwProcessAffinityMask = -1; - DWORD dwSystemAffinityMask = -1; + DWORD_PTR dwProcessAffinityMask = -1; + DWORD_PTR dwSystemAffinityMask = -1; GetProcessAffinityMask(GetCurrentProcess(), &dwProcessAffinityMask, &dwSystemAffinityMask); DWORD dwPrev1 = SetThreadAffinityMask(GetCurrentThread(), dwProcessAffinityMask); DWORD dwPrev2 = SetThreadAffinityMask(GetCurrentThread(), dwProcessAffinityMask); From aec5c5fe26293452d3fe7acf1e4c20830613812c Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Mon, 10 Oct 2011 14:22:31 -0400 Subject: [PATCH 03/41] Bump version to 0.4.1 --- contrib/Bitcoin.app/Contents/Info.plist | 2 +- doc/README | 2 +- doc/README_windows.txt | 2 +- share/setup.nsi | 6 +++--- src/serialize.h | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/contrib/Bitcoin.app/Contents/Info.plist b/contrib/Bitcoin.app/Contents/Info.plist index a5c7da1c8f4..d5a278a570c 100644 --- a/contrib/Bitcoin.app/Contents/Info.plist +++ b/contrib/Bitcoin.app/Contents/Info.plist @@ -17,7 +17,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 0.4.00 + 0.4.1 CFBundleSignature ???? CFBundleVersion diff --git a/doc/README b/doc/README index 772fd7f31ec..789cc9fb870 100644 --- a/doc/README +++ b/doc/README @@ -1,4 +1,4 @@ -Bitcoin 0.4.0rc1 BETA +Bitcoin 0.4.1 BETA Copyright (c) 2009-2011 Bitcoin Developers Distributed under the MIT/X11 software license, see the accompanying diff --git a/doc/README_windows.txt b/doc/README_windows.txt index 8378ae50d81..7ff8834920b 100644 --- a/doc/README_windows.txt +++ b/doc/README_windows.txt @@ -1,4 +1,4 @@ -Bitcoin 0.4.00rc1 BETA +Bitcoin 0.4.1 BETA Copyright (c) 2009-2011 Bitcoin Developers Distributed under the MIT/X11 software license, see the accompanying diff --git a/share/setup.nsi b/share/setup.nsi index 6cf477747c8..4c837c974bf 100644 --- a/share/setup.nsi +++ b/share/setup.nsi @@ -5,7 +5,7 @@ SetCompressor /SOLID lzma # General Symbol Definitions !define REGKEY "SOFTWARE\$(^Name)" -!define VERSION 0.4.00 +!define VERSION 0.4.1 !define COMPANY "Bitcoin project" !define URL http://www.bitcoin.org/ @@ -45,13 +45,13 @@ Var StartMenuGroup !insertmacro MUI_LANGUAGE English # Installer attributes -OutFile bitcoin-0.4.00-win32-setup.exe +OutFile bitcoin-0.4.1-win32-setup.exe InstallDir $PROGRAMFILES\Bitcoin CRCCheck on XPStyle on BrandingText " " ShowInstDetails show -VIProductVersion 0.4.00.0 +VIProductVersion 0.4.1.0 VIAddVersionKey ProductName Bitcoin VIAddVersionKey ProductVersion "${VERSION}" VIAddVersionKey CompanyName "${COMPANY}" diff --git a/src/serialize.h b/src/serialize.h index 698bdfe6a9d..320ce9d2ae0 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 = 40000; +static const int VERSION = 40100; static const char* pszSubVer = ""; static const bool VERSION_IS_BETA = true; From b526cbaa718a6c66bc6b5bc224d2717e0066ddb6 Mon Sep 17 00:00:00 2001 From: Gavin Andresen Date: Mon, 10 Oct 2011 16:03:14 -0400 Subject: [PATCH 04/41] bitcoind does not need to link with gthread-2.0 --- src/makefile.unix | 1 - 1 file changed, 1 deletion(-) diff --git a/src/makefile.unix b/src/makefile.unix index 43c3ea7f500..98c40771d29 100644 --- a/src/makefile.unix +++ b/src/makefile.unix @@ -30,7 +30,6 @@ endif LIBS+= \ -Wl,-Bdynamic \ - -l gthread-2.0 \ -l z \ -l dl \ -l pthread From 38a976d5bbfb1bdb304ae64aa3ca992d13ad3cde Mon Sep 17 00:00:00 2001 From: cjdelisle Date: Sun, 16 Oct 2011 20:38:23 -0400 Subject: [PATCH 05/41] Added a workaround for an Ubuntu bug which causes -fstack-protector-all to be disregarded. --- src/makefile.unix | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/makefile.unix b/src/makefile.unix index 98c40771d29..9e0b3263d7a 100644 --- a/src/makefile.unix +++ b/src/makefile.unix @@ -38,12 +38,17 @@ LIBS+= \ # Hardening # Make some classes of vulnerabilities unexploitable in case one is discovered. # + # This is a workaround for Ubuntu bug #691722, the default -fstack-protector causes + # -fstack-protector-all to be ignored unless -fno-stack-protector is used first. + # see: https://bugs.launchpad.net/ubuntu/+source/gcc-4.5/+bug/691722 + HARDENING=-fno-stack-protector + # Stack Canaries # Put numbers at the beginning of each stack frame and check that they are the same. # If a stack buffer if overflowed, it writes over the canary number and then on return # when that number is checked, it won't be the same and the program will exit with # a "Stack smashing detected" error instead of being exploited. - HARDENING=-fstack-protector-all -Wstack-protector + HARDENING+=-fstack-protector-all -Wstack-protector # Make some important things such as the global offset table read only as soon as # the dynamic linker is finished building it. This will prevent overwriting of addresses From ed176ba584ed9f05f5311743059e108ddbbb5d5b Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Mon, 10 Oct 2011 12:08:05 -0400 Subject: [PATCH 06/41] Only define __STDC_LIMIT_MACROS if not already defined. --- src/headers.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/headers.h b/src/headers.h index d0c74348202..ab318cbb436 100644 --- a/src/headers.h +++ b/src/headers.h @@ -18,7 +18,13 @@ #endif #define _WIN32_IE 0x0400 #define WIN32_LEAN_AND_MEAN 1 + +// 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 #endif @@ -57,8 +63,6 @@ #include #include -#include - #ifdef __WXMSW__ #include #include From ef4280e08b217bf2512bb1878e1dd2a926e557c9 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Mon, 10 Oct 2011 15:51:07 -0400 Subject: [PATCH 07/41] Add returns to avoid annoying compile-time warnings. --- src/keystore.h | 1 + src/wallet.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/src/keystore.h b/src/keystore.h index bbfac83d1f1..1f2c6aea3ea 100644 --- a/src/keystore.h +++ b/src/keystore.h @@ -114,6 +114,7 @@ public: return CBasicKeyStore::HaveKey(address); return mapCryptedKeys.count(address) > 0; } + return false; } bool GetKey(const CBitcoinAddress &address, CKey& keyOut) const; bool GetPubKey(const CBitcoinAddress &address, std::vector& vchPubKeyOut) const; diff --git a/src/wallet.cpp b/src/wallet.cpp index 8bbb80cf254..298a2c64288 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -40,6 +40,7 @@ bool CWallet::AddCryptedKey(const vector &vchPubKey, const vector else return CWalletDB(strWalletFile).WriteCryptedKey(vchPubKey, vchCryptedSecret); } + return false; } bool CWallet::Unlock(const string& strWalletPassphrase) From 00eae584a26295dbf7b1aebf99c1b8a4c9a86c37 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Thu, 10 Nov 2011 21:29:23 +0100 Subject: [PATCH 08/41] Resilvering --- src/db.cpp | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/db.h | 5 ++- src/wallet.cpp | 10 ++++++ 3 files changed, 104 insertions(+), 1 deletion(-) diff --git a/src/db.cpp b/src/db.cpp index a22b17e34c2..d41da68abad 100644 --- a/src/db.cpp +++ b/src/db.cpp @@ -165,6 +165,90 @@ void static CloseDb(const string& strFile) } } +bool Resilver(const string& strFile) +{ + while (!fShutdown) + { + CRITICAL_BLOCK(cs_db) + { + if (!mapFileUseCount.count(strFile) || mapFileUseCount[strFile] == 0) + { + // Flush log data to the dat file + CloseDb(strFile); + dbenv.txn_checkpoint(0, 0, 0); + dbenv.lsn_reset(strFile.c_str(), 0); + mapFileUseCount.erase(strFile); + + bool fSuccess = true; + printf("Resilvering %s...\n", strFile.c_str()); + string strFileRes = strFile + ".resilver"; + CDB db(strFile.c_str(), "r"); + Db* pdbCopy = new Db(&dbenv, 0); + + int ret = pdbCopy->open(NULL, // Txn pointer + strFileRes.c_str(), // Filename + "main", // Logical db name + DB_BTREE, // Database type + DB_CREATE, // Flags + 0); + if (ret > 0) + { + printf("Cannot create database file %s\n", strFileRes.c_str()); + fSuccess = false; + } + + Dbc* pcursor = db.GetCursor(); + if (pcursor) + while (fSuccess) + { + CDataStream ssKey; + CDataStream ssValue; + int ret = db.ReadAtCursor(pcursor, ssKey, ssValue, DB_NEXT); + if (ret == DB_NOTFOUND) + break; + else if (ret != 0) + { + pcursor->close(); + fSuccess = false; + break; + } + Dbt datKey(&ssKey[0], ssKey.size()); + Dbt datValue(&ssValue[0], ssValue.size()); + int ret2 = pdbCopy->put(NULL, &datKey, &datValue, DB_NOOVERWRITE); + if (ret2 > 0) + fSuccess = false; + } + if (fSuccess) + { + Db* pdb = mapDb[strFile]; + if (pdb->close(0)) + fSuccess = false; + if (pdbCopy->close(0)) + fSuccess = false; + delete pdb; + delete pdbCopy; + mapDb[strFile] = NULL; + } + if (fSuccess) + { + Db dbA(&dbenv, 0); + if (dbA.remove(strFile.c_str(), NULL, 0)) + fSuccess = false; + Db dbB(&dbenv, 0); + if (dbB.rename(strFileRes.c_str(), NULL, strFile.c_str(), 0)) + fSuccess = false; + } + if (!fSuccess) + printf("Resilvering of %s FAILED!\n", strFileRes.c_str()); + return fSuccess; + } + } + Sleep(100); + } + return false; +} + + void DBFlush(bool fShutdown) { // Flush log data to the actual data file @@ -674,6 +758,8 @@ int CWalletDB::LoadWallet(CWallet* pwallet) pwallet->vchDefaultKey.clear(); int nFileVersion = 0; vector vWalletUpgrade; + bool fIsResilvered = false; + bool fIsEncrypted = false; // Modify defaults #ifndef __WXMSW__ @@ -799,6 +885,7 @@ int CWalletDB::LoadWallet(CWallet* pwallet) ssValue >> vchPrivKey; if (!pwallet->LoadCryptedKey(vchPubKey, vchPrivKey)) return DB_CORRUPT; + fIsEncrypted = true; } else if (strType == "defaultkey") { @@ -832,6 +919,7 @@ int CWalletDB::LoadWallet(CWallet* pwallet) if (strKey == "fMinimizeOnClose") ssValue >> fMinimizeOnClose; if (strKey == "fUseProxy") ssValue >> fUseProxy; if (strKey == "addrProxy") ssValue >> addrProxy; + if (strKey == "fIsResilvered") ssValue >> fIsResilvered; if (fHaveUPnP && strKey == "fUseUPnP") ssValue >> fUseUPnP; } else if (strType == "minversion") @@ -869,6 +957,8 @@ int CWalletDB::LoadWallet(CWallet* pwallet) WriteVersion(VERSION); } + if (fIsEncrypted && !fIsResilvered) + return DB_NEED_RESILVER; return DB_LOAD_OK; } diff --git a/src/db.h b/src/db.h index 73ea1902ccf..75748ace01b 100644 --- a/src/db.h +++ b/src/db.h @@ -32,7 +32,7 @@ extern DbEnv dbenv; extern void DBFlush(bool fShutdown); void ThreadFlushWalletDB(void* parg); bool BackupWallet(const CWallet& wallet, const std::string& strDest); - +extern bool Resilver(const std::string& strFile); @@ -257,6 +257,8 @@ public: { return Write(std::string("version"), nVersion); } + + friend bool Resilver(const std::string&); }; @@ -349,6 +351,7 @@ enum DBErrors DB_CORRUPT, DB_TOO_NEW, DB_LOAD_FAIL, + DB_NEED_RESILVER }; class CWalletDB : public CDB diff --git a/src/wallet.cpp b/src/wallet.cpp index 298a2c64288..924700d0276 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -190,6 +190,9 @@ bool CWallet::EncryptWallet(const string& strWalletPassphrase) Lock(); } + if (Resilver(strWalletFile)) + CWalletDB(strWalletFile, "r+").WriteSetting("fIsResilvered", true); + return true; } @@ -1122,6 +1125,13 @@ int CWallet::LoadWallet(bool& fFirstRunRet) return false; fFirstRunRet = false; int nLoadWalletRet = CWalletDB(strWalletFile,"cr+").LoadWallet(this); + if (nLoadWalletRet == DB_NEED_RESILVER) + { + if (Resilver(strWalletFile)) + CWalletDB(strWalletFile, "r+").WriteSetting("fIsResilvered", true); + nLoadWalletRet = DB_LOAD_OK; + } + if (nLoadWalletRet != DB_LOAD_OK) return nLoadWalletRet; fFirstRunRet = vchDefaultKey.empty(); From 2744ea8c1fbc2e1ef6b1824a21fd2a75e2b6dbc4 Mon Sep 17 00:00:00 2001 From: Gavin Andresen Date: Thu, 10 Nov 2011 21:12:46 -0500 Subject: [PATCH 09/41] Obsolete keypool and make sure database removes log files on shutdown. --- src/db.cpp | 70 +++++++++++++++++++++++++++++++++++-------------- src/db.h | 7 +++-- src/init.cpp | 14 +++++++--- src/rpc.cpp | 11 +++++++- src/serialize.h | 2 +- src/wallet.cpp | 21 ++++++++++----- 6 files changed, 89 insertions(+), 36 deletions(-) diff --git a/src/db.cpp b/src/db.cpp index d41da68abad..1a1289f8d10 100644 --- a/src/db.cpp +++ b/src/db.cpp @@ -28,6 +28,34 @@ DbEnv dbenv(0); static map mapFileUseCount; static map mapDb; +static void EnvShutdown(bool fRemoveLogFiles) +{ + if (!fDbEnvInit) + return; + + fDbEnvInit = false; + dbenv.close(0); + DbEnv(0).remove(GetDataDir().c_str(), 0); + + if (fRemoveLogFiles) + { + filesystem::path datadir(GetDataDir()); + filesystem::directory_iterator it(datadir / "database"); + while (it != filesystem::directory_iterator()) + { + const filesystem::path& p = it->path(); +#if BOOST_FILESYSTEM_VERSION == 2 + std::string f = p.filename(); +#else + std::string f = p.filename().generic_string(); +#endif + if (f.find("log.") == 0) + filesystem::remove(p); + ++it; + } + } +} + class CDBInit { public: @@ -36,11 +64,7 @@ public: } ~CDBInit() { - if (fDbEnvInit) - { - dbenv.close(0); - fDbEnvInit = false; - } + EnvShutdown(false); } } instance_of_cdbinit; @@ -165,7 +189,7 @@ void static CloseDb(const string& strFile) } } -bool Resilver(const string& strFile) +bool CDB::Rewrite(const string& strFile, const char* pszSkip) { while (!fShutdown) { @@ -180,8 +204,8 @@ bool Resilver(const string& strFile) mapFileUseCount.erase(strFile); bool fSuccess = true; - printf("Resilvering %s...\n", strFile.c_str()); - string strFileRes = strFile + ".resilver"; + printf("Rewriting %s...\n", strFile.c_str()); + string strFileRes = strFile + ".rewrite"; CDB db(strFile.c_str(), "r"); Db* pdbCopy = new Db(&dbenv, 0); @@ -212,6 +236,15 @@ bool Resilver(const string& strFile) fSuccess = false; break; } + if (pszSkip && + strncmp(&ssKey[0], pszSkip, std::min(ssKey.size(), strlen(pszSkip))) == 0) + continue; + if (strncmp(&ssKey[0], "\x07version", 8) == 0) + { + // Update version: + ssValue.clear(); + ssValue << VERSION; + } Dbt datKey(&ssKey[0], ssKey.size()); Dbt datValue(&ssValue[0], ssValue.size()); int ret2 = pdbCopy->put(NULL, &datKey, &datValue, DB_NOOVERWRITE); @@ -239,7 +272,7 @@ bool Resilver(const string& strFile) fSuccess = false; } if (!fSuccess) - printf("Resilvering of %s FAILED!\n", strFileRes.c_str()); + printf("Rewriting of %s FAILED!\n", strFileRes.c_str()); return fSuccess; } } @@ -249,7 +282,7 @@ bool Resilver(const string& strFile) } -void DBFlush(bool fShutdown) +void DBFlush(bool fShutdown, bool fRemoveLogFiles) { // Flush log data to the actual data file // on all files that are not in use @@ -280,9 +313,10 @@ void DBFlush(bool fShutdown) { char** listp; if (mapFileUseCount.empty()) + { dbenv.log_archive(&listp, DB_ARCH_REMOVE); - dbenv.close(0); - fDbEnvInit = false; + EnvShutdown(fRemoveLogFiles); + } } } } @@ -758,7 +792,6 @@ int CWalletDB::LoadWallet(CWallet* pwallet) pwallet->vchDefaultKey.clear(); int nFileVersion = 0; vector vWalletUpgrade; - bool fIsResilvered = false; bool fIsEncrypted = false; // Modify defaults @@ -919,7 +952,6 @@ int CWalletDB::LoadWallet(CWallet* pwallet) if (strKey == "fMinimizeOnClose") ssValue >> fMinimizeOnClose; if (strKey == "fUseProxy") ssValue >> fUseProxy; if (strKey == "addrProxy") ssValue >> addrProxy; - if (strKey == "fIsResilvered") ssValue >> fIsResilvered; if (fHaveUPnP && strKey == "fUseUPnP") ssValue >> fUseUPnP; } else if (strType == "minversion") @@ -947,8 +979,11 @@ int CWalletDB::LoadWallet(CWallet* pwallet) printf("fUseUPnP = %d\n", fUseUPnP); - // Upgrade - if (nFileVersion < VERSION) + // Rewrite encrypted wallets of versions 0.4.0 and 0.5.0rc: + if (fIsEncrypted && (nFileVersion == 40000 || nFileVersion == 50000)) + return DB_NEED_REWRITE; + + if (nFileVersion < VERSION) // Update { // Get rid of old debug.log file in current directory if (nFileVersion <= 105 && !pszSetDataDir[0]) @@ -957,9 +992,6 @@ int CWalletDB::LoadWallet(CWallet* pwallet) WriteVersion(VERSION); } - if (fIsEncrypted && !fIsResilvered) - return DB_NEED_RESILVER; - return DB_LOAD_OK; } diff --git a/src/db.h b/src/db.h index 75748ace01b..98af4be9a0e 100644 --- a/src/db.h +++ b/src/db.h @@ -29,10 +29,9 @@ extern unsigned int nWalletDBUpdated; extern DbEnv dbenv; -extern void DBFlush(bool fShutdown); +extern void DBFlush(bool fShutdown, bool fRemoveLogFiles); void ThreadFlushWalletDB(void* parg); bool BackupWallet(const CWallet& wallet, const std::string& strDest); -extern bool Resilver(const std::string& strFile); @@ -258,7 +257,7 @@ public: return Write(std::string("version"), nVersion); } - friend bool Resilver(const std::string&); + bool static Rewrite(const std::string& strFile, const char* pszSkip = NULL); }; @@ -351,7 +350,7 @@ enum DBErrors DB_CORRUPT, DB_TOO_NEW, DB_LOAD_FAIL, - DB_NEED_RESILVER + DB_NEED_REWRITE }; class CWalletDB : public CDB diff --git a/src/init.cpp b/src/init.cpp index dbc2c413322..4a149b31bf3 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -34,8 +34,8 @@ void Shutdown(void* parg) { static CCriticalSection cs_Shutdown; static bool fTaken; - bool fFirstThread; - CRITICAL_BLOCK(cs_Shutdown) + bool fFirstThread = false; + TRY_CRITICAL_BLOCK(cs_Shutdown) { fFirstThread = !fTaken; fTaken = true; @@ -45,9 +45,9 @@ void Shutdown(void* parg) { fShutdown = true; nTransactionsUpdated++; - DBFlush(false); + DBFlush(false, false); StopNode(); - DBFlush(true); + DBFlush(true, true); boost::filesystem::remove(GetPidFile()); UnregisterWallet(pwalletMain); delete pwalletMain; @@ -396,6 +396,12 @@ bool AppInit2(int argc, char* argv[]) strErrors += _("Error loading wallet.dat: Wallet corrupted \n"); else if (nLoadWalletRet == DB_TOO_NEW) strErrors += _("Error loading wallet.dat: Wallet requires newer version of Bitcoin \n"); + else if (nLoadWalletRet == DB_NEED_REWRITE) + { + strErrors += _("Wallet needed to be rewritten: restart Bitcoin to complete \n"); + wxMessageBox(strErrors, "Bitcoin", wxOK | wxICON_ERROR); + return false; + } else strErrors += _("Error loading wallet.dat \n"); } diff --git a/src/rpc.cpp b/src/rpc.cpp index 885ffd1f2b7..a936edbbe47 100644 --- a/src/rpc.cpp +++ b/src/rpc.cpp @@ -1431,6 +1431,11 @@ Value encryptwallet(const Array& params, bool fHelp) if (pwalletMain->IsCrypted()) throw JSONRPCError(-15, "Error: running with an encrypted wallet, but encryptwallet was called."); +#ifdef GUI + // shutting down via RPC while the GUI is running does not work (yet): + throw runtime_error("Not Yet Implemented: use GUI to encrypt wallet, not RPC command"); +#endif + string strWalletPass; strWalletPass.reserve(100); mlock(&strWalletPass[0], strWalletPass.capacity()); @@ -1450,7 +1455,11 @@ Value encryptwallet(const Array& params, bool fHelp) fill(strWalletPass.begin(), strWalletPass.end(), '\0'); munlock(&strWalletPass[0], strWalletPass.capacity()); - return Value::null; + // BDB seems to have a bad habit of writing old data into + // slack space in .dat files; that is bad if the old data is + // unencrypted private keys. So: + CreateThread(Shutdown, NULL); + return "wallet encrypted; bitcoin server stopping, restart to run with encrypted wallet"; } diff --git a/src/serialize.h b/src/serialize.h index 320ce9d2ae0..c531d2a198e 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 = 40100; +static const int VERSION = 40101; static const char* pszSubVer = ""; static const bool VERSION_IS_BETA = true; diff --git a/src/wallet.cpp b/src/wallet.cpp index 924700d0276..c004d183604 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -188,10 +188,12 @@ bool CWallet::EncryptWallet(const string& strWalletPassphrase) } Lock(); - } - if (Resilver(strWalletFile)) - CWalletDB(strWalletFile, "r+").WriteSetting("fIsResilvered", true); + // Need to completely rewrite the wallet file; if we don't, bdb might keep + // bits of the unencrypted private key in slack space in the database file. + setKeyPool.clear(); + CDB::Rewrite(strWalletFile, "\x04pool"); + } return true; } @@ -1125,11 +1127,16 @@ int CWallet::LoadWallet(bool& fFirstRunRet) return false; fFirstRunRet = false; int nLoadWalletRet = CWalletDB(strWalletFile,"cr+").LoadWallet(this); - if (nLoadWalletRet == DB_NEED_RESILVER) + if (nLoadWalletRet == DB_NEED_REWRITE) { - if (Resilver(strWalletFile)) - CWalletDB(strWalletFile, "r+").WriteSetting("fIsResilvered", true); - nLoadWalletRet = DB_LOAD_OK; + if (CDB::Rewrite(strWalletFile, "\x04pool")) + { + setKeyPool.clear(); + // Note: can't top-up keypool here, because wallet is locked. + // User will be prompted to unlock wallet the next operation + // the requires a new key. + } + nLoadWalletRet = DB_NEED_REWRITE; } if (nLoadWalletRet != DB_LOAD_OK) From 0143c024af1e5b93dfc3a89e4e40be59a0f40f58 Mon Sep 17 00:00:00 2001 From: Gavin Andresen Date: Tue, 15 Nov 2011 09:47:29 -0500 Subject: [PATCH 10/41] Fix boost filesystem incompatibility problem --- src/db.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/db.cpp b/src/db.cpp index 1a1289f8d10..b2bd7e2899c 100644 --- a/src/db.cpp +++ b/src/db.cpp @@ -44,10 +44,10 @@ static void EnvShutdown(bool fRemoveLogFiles) while (it != filesystem::directory_iterator()) { const filesystem::path& p = it->path(); -#if BOOST_FILESYSTEM_VERSION == 2 - std::string f = p.filename(); -#else +#if BOOST_FILESYSTEM_VERSION == 3 std::string f = p.filename().generic_string(); +#else + std::string f = p.filename(); #endif if (f.find("log.") == 0) filesystem::remove(p); From 1179f6373dfffdcb091576215cabe73c932df925 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Tue, 15 Nov 2011 10:33:26 -0500 Subject: [PATCH 11/41] Update gitian descriptors to point at stable git repo --- contrib/gitian-descriptors/gitian-win32.yml | 2 +- contrib/gitian-descriptors/gitian.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/gitian-descriptors/gitian-win32.yml b/contrib/gitian-descriptors/gitian-win32.yml index 52b10bc33fc..252e62e2369 100644 --- a/contrib/gitian-descriptors/gitian-win32.yml +++ b/contrib/gitian-descriptors/gitian-win32.yml @@ -13,7 +13,7 @@ packages: - "wine" reference_datetime: "2011-01-30 00:00:00" remotes: -- "url": "https://github.com/bitcoin/bitcoin.git" +- "url": "https://git.gitorious.org/+bitcoin-stable-developers/bitcoin/bitcoind-stable.git" "dir": "bitcoin" files: - "wxwidgets-win32-2.9.2-gitian.zip" diff --git a/contrib/gitian-descriptors/gitian.yml b/contrib/gitian-descriptors/gitian.yml index efa9cb8c109..c29224402a7 100644 --- a/contrib/gitian-descriptors/gitian.yml +++ b/contrib/gitian-descriptors/gitian.yml @@ -15,7 +15,7 @@ packages: - "unzip" reference_datetime: "2011-01-30 00:00:00" remotes: -- "url": "https://github.com/bitcoin/bitcoin.git" +- "url": "https://git.gitorious.org/+bitcoin-stable-developers/bitcoin/bitcoind-stable.git" "dir": "bitcoin" files: - "wxWidgets-2.9.2-x64-gitian.zip" From 586ea168c2e29b9f96b07a3a5145356af11b4dce Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Tue, 15 Nov 2011 10:21:02 -0500 Subject: [PATCH 12/41] add message about restarting bitcoin after encrypting wallet succesfully --- src/ui.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/ui.cpp b/src/ui.cpp index 6b7ecdbc8d4..bfb708b3e90 100644 --- a/src/ui.cpp +++ b/src/ui.cpp @@ -1222,10 +1222,9 @@ void CMainFrame::OnMenuOptionsEncryptWallet(wxCommandEvent& event) fill(strWalletPassTest.begin(), strWalletPassTest.end(), '\0'); munlock(&strWalletPass[0], strWalletPass.capacity()); munlock(&strWalletPassTest[0], strWalletPassTest.capacity()); - wxMessageBox(_("Wallet Encrypted.\nRemember that encrypting your wallet cannot fully protect your bitcoins from being stolen by malware infecting your computer."), "Bitcoin"); + wxMessageBox(_("Wallet Encrypted.\nBitcoin will close now to finish the encryption process. Remember that encrypting your wallet cannot fully protect your bitcoins from being stolen by malware infecting your computer."), "Bitcoin"); - m_menuOptions->Remove(m_menuOptionsEncryptWallet); - m_menuOptions->Insert(m_menuOptions->GetMenuItemCount() - 1, m_menuOptionsChangeWalletPassphrase); + Close(true); } void CMainFrame::OnMenuOptionsChangeWalletPassphrase(wxCommandEvent& event) From 1aafd7464f67e0ba42b18a08070a86a427e28c72 Mon Sep 17 00:00:00 2001 From: Gavin Andresen Date: Tue, 15 Nov 2011 14:30:15 -0500 Subject: [PATCH 13/41] Fix crash-on-osx-on-shutdown bug. And cleanup CDB handling in Rewrite. --- src/db.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/db.cpp b/src/db.cpp index b2bd7e2899c..023dc5947a2 100644 --- a/src/db.cpp +++ b/src/db.cpp @@ -34,7 +34,14 @@ static void EnvShutdown(bool fRemoveLogFiles) return; fDbEnvInit = false; - dbenv.close(0); + try + { + dbenv.close(0); + } + catch (const DbException& e) + { + printf("EnvShutdown exception: %s (%d)\n", e.what(), e.get_errno()); + } DbEnv(0).remove(GetDataDir().c_str(), 0); if (fRemoveLogFiles) @@ -229,7 +236,10 @@ bool CDB::Rewrite(const string& strFile, const char* pszSkip) CDataStream ssValue; int ret = db.ReadAtCursor(pcursor, ssKey, ssValue, DB_NEXT); if (ret == DB_NOTFOUND) + { + pcursor->close(); break; + } else if (ret != 0) { pcursor->close(); @@ -253,14 +263,11 @@ bool CDB::Rewrite(const string& strFile, const char* pszSkip) } if (fSuccess) { - Db* pdb = mapDb[strFile]; - if (pdb->close(0)) - fSuccess = false; + db.Close(); + CloseDb(strFile); if (pdbCopy->close(0)) fSuccess = false; - delete pdb; delete pdbCopy; - mapDb[strFile] = NULL; } if (fSuccess) { From 831d24a19d6687edfcce54bc0be0dcad8899fc30 Mon Sep 17 00:00:00 2001 From: Gavin Andresen Date: Tue, 15 Nov 2011 14:28:51 -0500 Subject: [PATCH 14/41] Tweak handling of boost filesystem versions (partial cherry pick) --- src/db.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/db.cpp b/src/db.cpp index 023dc5947a2..b48be7ab75c 100644 --- a/src/db.cpp +++ b/src/db.cpp @@ -51,7 +51,7 @@ static void EnvShutdown(bool fRemoveLogFiles) while (it != filesystem::directory_iterator()) { const filesystem::path& p = it->path(); -#if BOOST_FILESYSTEM_VERSION == 3 +#if BOOST_FILESYSTEM_VERSION >= 3 std::string f = p.filename().generic_string(); #else std::string f = p.filename(); From 2bf36b4e7dd06d44ee3c81391338ccb708edbbaa Mon Sep 17 00:00:00 2001 From: Jeff Garzik Date: Mon, 31 Oct 2011 12:42:01 -0400 Subject: [PATCH 15/41] Remove vladimir's DNS seed, at his request. --- src/net.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/net.cpp b/src/net.cpp index f5e8b71c03a..f8f6afde543 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1159,7 +1159,6 @@ void MapPort(bool /* unused fMapPort */) static const char *strDNSSeed[] = { "bitseed.xf2.org", - "bitseed.bitcoin.org.uk", "dnsseed.bluematt.me", }; From 90de05e88ecc879b75315eebacb488b44353f5d9 Mon Sep 17 00:00:00 2001 From: Gavin Andresen Date: Thu, 17 Nov 2011 14:01:25 -0500 Subject: [PATCH 16/41] Create new keypool for newly encrypted wallets. --- src/wallet.cpp | 33 ++++++++++++++++++++++++++++++++- src/wallet.h | 1 + 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/wallet.cpp b/src/wallet.cpp index c004d183604..9b9586face2 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -187,12 +187,15 @@ bool CWallet::EncryptWallet(const string& strWalletPassphrase) pwalletdbEncryption = NULL; } + Lock(); + Unlock(strWalletPassphrase); + NewKeyPool(); Lock(); // Need to completely rewrite the wallet file; if we don't, bdb might keep // bits of the unencrypted private key in slack space in the database file. setKeyPool.clear(); - CDB::Rewrite(strWalletFile, "\x04pool"); + CDB::Rewrite(strWalletFile); } return true; @@ -1224,6 +1227,34 @@ bool GetWalletFile(CWallet* pwallet, string &strWalletFileOut) return true; } +// +// Mark old keypool keys as used, +// and generate all new keys +// +bool CWallet::NewKeyPool() +{ + CRITICAL_BLOCK(cs_wallet) + { + CWalletDB walletdb(strWalletFile); + BOOST_FOREACH(int64 nIndex, setKeyPool) + walletdb.ErasePool(nIndex); + setKeyPool.clear(); + + if (IsLocked()) + return false; + + int64 nKeys = max(GetArg("-keypool", 100), (int64)0); + for (int i = 0; i < nKeys; i++) + { + int64 nIndex = i+1; + walletdb.WritePool(nIndex, CKeyPool(GenerateNewKey())); + setKeyPool.insert(nIndex); + } + printf("CWallet::NewKeyPool wrote %"PRI64d" new keys\n", nKeys); + } + return true; +} + bool CWallet::TopUpKeyPool() { CRITICAL_BLOCK(cs_wallet) diff --git a/src/wallet.h b/src/wallet.h index 1dd2e512602..794139233d0 100644 --- a/src/wallet.h +++ b/src/wallet.h @@ -81,6 +81,7 @@ public: std::string SendMoney(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew, bool fAskFee=false); std::string SendMoneyToBitcoinAddress(const CBitcoinAddress& address, int64 nValue, CWalletTx& wtxNew, bool fAskFee=false); + bool NewKeyPool(); bool TopUpKeyPool(); void ReserveKeyFromKeyPool(int64& nIndex, CKeyPool& keypool); void KeepKey(int64 nIndex); From c4a3bf9e552f25a5ad0efb8cf62d344a7dad53ed Mon Sep 17 00:00:00 2001 From: Gavin Andresen Date: Thu, 17 Nov 2011 14:21:32 -0500 Subject: [PATCH 17/41] Only remove database log files on shutdown after wallet encryption/rewrite --- src/db.cpp | 13 +++++++++---- src/db.h | 3 ++- src/init.cpp | 4 ++-- src/wallet.cpp | 5 +++-- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/db.cpp b/src/db.cpp index b48be7ab75c..77000ab00eb 100644 --- a/src/db.cpp +++ b/src/db.cpp @@ -28,7 +28,12 @@ DbEnv dbenv(0); static map mapFileUseCount; static map mapDb; -static void EnvShutdown(bool fRemoveLogFiles) +static bool fRemoveLogFiles = false; +void RemoveLogFilesOnShutdown(bool fIn) +{ + fRemoveLogFiles = fIn; +} +static void EnvShutdown() { if (!fDbEnvInit) return; @@ -71,7 +76,7 @@ public: } ~CDBInit() { - EnvShutdown(false); + EnvShutdown(); } } instance_of_cdbinit; @@ -289,7 +294,7 @@ bool CDB::Rewrite(const string& strFile, const char* pszSkip) } -void DBFlush(bool fShutdown, bool fRemoveLogFiles) +void DBFlush(bool fShutdown) { // Flush log data to the actual data file // on all files that are not in use @@ -322,7 +327,7 @@ void DBFlush(bool fShutdown, bool fRemoveLogFiles) if (mapFileUseCount.empty()) { dbenv.log_archive(&listp, DB_ARCH_REMOVE); - EnvShutdown(fRemoveLogFiles); + EnvShutdown(); } } } diff --git a/src/db.h b/src/db.h index 98af4be9a0e..425dc2e57b8 100644 --- a/src/db.h +++ b/src/db.h @@ -29,7 +29,8 @@ extern unsigned int nWalletDBUpdated; extern DbEnv dbenv; -extern void DBFlush(bool fShutdown, bool fRemoveLogFiles); +extern void RemoveLogFilesOnShutdown(bool fRemoveLogFiles); +extern void DBFlush(bool fShutdown); void ThreadFlushWalletDB(void* parg); bool BackupWallet(const CWallet& wallet, const std::string& strDest); diff --git a/src/init.cpp b/src/init.cpp index 4a149b31bf3..2d21a261437 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -45,9 +45,9 @@ void Shutdown(void* parg) { fShutdown = true; nTransactionsUpdated++; - DBFlush(false, false); + DBFlush(false); StopNode(); - DBFlush(true, true); + DBFlush(true); boost::filesystem::remove(GetPidFile()); UnregisterWallet(pwalletMain); delete pwalletMain; diff --git a/src/wallet.cpp b/src/wallet.cpp index 9b9586face2..737f0e6238c 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -194,8 +194,8 @@ bool CWallet::EncryptWallet(const string& strWalletPassphrase) // Need to completely rewrite the wallet file; if we don't, bdb might keep // bits of the unencrypted private key in slack space in the database file. - setKeyPool.clear(); - CDB::Rewrite(strWalletFile); + if (CDB::Rewrite(strWalletFile)) + RemoveLogFilesOnShutdown(true); } return true; @@ -1134,6 +1134,7 @@ int CWallet::LoadWallet(bool& fFirstRunRet) { if (CDB::Rewrite(strWalletFile, "\x04pool")) { + RemoveLogFilesOnShutdown(true); setKeyPool.clear(); // Note: can't top-up keypool here, because wallet is locked. // User will be prompted to unlock wallet the next operation From 76ef6d89b98b57d2ee5c6db993cd1cc375dd3726 Mon Sep 17 00:00:00 2001 From: Gavin Andresen Date: Sun, 20 Nov 2011 10:39:01 -0500 Subject: [PATCH 18/41] Never remove database files on shutdown, it caused unreadable wallets on some testers' machines. --- src/db.cpp | 23 ----------------------- src/db.h | 2 -- src/wallet.cpp | 4 +--- 3 files changed, 1 insertion(+), 28 deletions(-) diff --git a/src/db.cpp b/src/db.cpp index 77000ab00eb..5cacf196920 100644 --- a/src/db.cpp +++ b/src/db.cpp @@ -28,11 +28,6 @@ DbEnv dbenv(0); static map mapFileUseCount; static map mapDb; -static bool fRemoveLogFiles = false; -void RemoveLogFilesOnShutdown(bool fIn) -{ - fRemoveLogFiles = fIn; -} static void EnvShutdown() { if (!fDbEnvInit) @@ -48,24 +43,6 @@ static void EnvShutdown() printf("EnvShutdown exception: %s (%d)\n", e.what(), e.get_errno()); } DbEnv(0).remove(GetDataDir().c_str(), 0); - - if (fRemoveLogFiles) - { - filesystem::path datadir(GetDataDir()); - filesystem::directory_iterator it(datadir / "database"); - while (it != filesystem::directory_iterator()) - { - const filesystem::path& p = it->path(); -#if BOOST_FILESYSTEM_VERSION >= 3 - std::string f = p.filename().generic_string(); -#else - std::string f = p.filename(); -#endif - if (f.find("log.") == 0) - filesystem::remove(p); - ++it; - } - } } class CDBInit diff --git a/src/db.h b/src/db.h index 425dc2e57b8..15bfb29c8e9 100644 --- a/src/db.h +++ b/src/db.h @@ -28,8 +28,6 @@ class CBlockLocator; extern unsigned int nWalletDBUpdated; extern DbEnv dbenv; - -extern void RemoveLogFilesOnShutdown(bool fRemoveLogFiles); extern void DBFlush(bool fShutdown); void ThreadFlushWalletDB(void* parg); bool BackupWallet(const CWallet& wallet, const std::string& strDest); diff --git a/src/wallet.cpp b/src/wallet.cpp index 737f0e6238c..43fb6b6da39 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -194,8 +194,7 @@ bool CWallet::EncryptWallet(const string& strWalletPassphrase) // Need to completely rewrite the wallet file; if we don't, bdb might keep // bits of the unencrypted private key in slack space in the database file. - if (CDB::Rewrite(strWalletFile)) - RemoveLogFilesOnShutdown(true); + CDB::Rewrite(strWalletFile); } return true; @@ -1134,7 +1133,6 @@ int CWallet::LoadWallet(bool& fFirstRunRet) { if (CDB::Rewrite(strWalletFile, "\x04pool")) { - RemoveLogFilesOnShutdown(true); setKeyPool.clear(); // Note: can't top-up keypool here, because wallet is locked. // User will be prompted to unlock wallet the next operation From 36b1eb763101299a4c4d4dad9d40b8ff70011d11 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Sun, 20 Nov 2011 17:12:00 +0100 Subject: [PATCH 19/41] close old db when rewriting --- src/db.cpp | 108 +++++++++++++++++++++++++++-------------------------- 1 file changed, 55 insertions(+), 53 deletions(-) diff --git a/src/db.cpp b/src/db.cpp index 5cacf196920..f9a7d6c90a5 100644 --- a/src/db.cpp +++ b/src/db.cpp @@ -195,61 +195,63 @@ bool CDB::Rewrite(const string& strFile, const char* pszSkip) bool fSuccess = true; printf("Rewriting %s...\n", strFile.c_str()); string strFileRes = strFile + ".rewrite"; - CDB db(strFile.c_str(), "r"); - Db* pdbCopy = new Db(&dbenv, 0); - - int ret = pdbCopy->open(NULL, // Txn pointer - strFileRes.c_str(), // Filename - "main", // Logical db name - DB_BTREE, // Database type - DB_CREATE, // Flags - 0); - if (ret > 0) - { - printf("Cannot create database file %s\n", strFileRes.c_str()); - fSuccess = false; - } - - Dbc* pcursor = db.GetCursor(); - if (pcursor) - while (fSuccess) + { // surround usage of db with extra {} + CDB db(strFile.c_str(), "r"); + Db* pdbCopy = new Db(&dbenv, 0); + + int ret = pdbCopy->open(NULL, // Txn pointer + strFileRes.c_str(), // Filename + "main", // Logical db name + DB_BTREE, // Database type + DB_CREATE, // Flags + 0); + if (ret > 0) { - CDataStream ssKey; - CDataStream ssValue; - int ret = db.ReadAtCursor(pcursor, ssKey, ssValue, DB_NEXT); - if (ret == DB_NOTFOUND) - { - pcursor->close(); - break; - } - else if (ret != 0) - { - pcursor->close(); - fSuccess = false; - break; - } - if (pszSkip && - strncmp(&ssKey[0], pszSkip, std::min(ssKey.size(), strlen(pszSkip))) == 0) - continue; - if (strncmp(&ssKey[0], "\x07version", 8) == 0) - { - // Update version: - ssValue.clear(); - ssValue << VERSION; - } - Dbt datKey(&ssKey[0], ssKey.size()); - Dbt datValue(&ssValue[0], ssValue.size()); - int ret2 = pdbCopy->put(NULL, &datKey, &datValue, DB_NOOVERWRITE); - if (ret2 > 0) - fSuccess = false; - } - if (fSuccess) - { - db.Close(); - CloseDb(strFile); - if (pdbCopy->close(0)) + printf("Cannot create database file %s\n", strFileRes.c_str()); fSuccess = false; - delete pdbCopy; + } + + Dbc* pcursor = db.GetCursor(); + if (pcursor) + while (fSuccess) + { + CDataStream ssKey; + CDataStream ssValue; + int ret = db.ReadAtCursor(pcursor, ssKey, ssValue, DB_NEXT); + if (ret == DB_NOTFOUND) + { + pcursor->close(); + break; + } + else if (ret != 0) + { + pcursor->close(); + fSuccess = false; + break; + } + if (pszSkip && + strncmp(&ssKey[0], pszSkip, std::min(ssKey.size(), strlen(pszSkip))) == 0) + continue; + if (strncmp(&ssKey[0], "\x07version", 8) == 0) + { + // Update version: + ssValue.clear(); + ssValue << VERSION; + } + Dbt datKey(&ssKey[0], ssKey.size()); + Dbt datValue(&ssValue[0], ssValue.size()); + int ret2 = pdbCopy->put(NULL, &datKey, &datValue, DB_NOOVERWRITE); + if (ret2 > 0) + fSuccess = false; + } + if (fSuccess) + { + db.Close(); + CloseDb(strFile); + if (pdbCopy->close(0)) + fSuccess = false; + delete pdbCopy; + } } if (fSuccess) { From d885aba347c2c53f71fdd5aef588b7115d689183 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Mon, 21 Nov 2011 13:38:09 -0500 Subject: [PATCH 20/41] Bump version to 0.4.2 --- contrib/Bitcoin.app/Contents/Info.plist | 2 +- doc/README | 2 +- doc/README_windows.txt | 2 +- share/setup.nsi | 6 +++--- src/serialize.h | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/contrib/Bitcoin.app/Contents/Info.plist b/contrib/Bitcoin.app/Contents/Info.plist index d5a278a570c..9145db10f15 100644 --- a/contrib/Bitcoin.app/Contents/Info.plist +++ b/contrib/Bitcoin.app/Contents/Info.plist @@ -17,7 +17,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 0.4.1 + 0.4.2 CFBundleSignature ???? CFBundleVersion diff --git a/doc/README b/doc/README index 789cc9fb870..9c28f4c6929 100644 --- a/doc/README +++ b/doc/README @@ -1,4 +1,4 @@ -Bitcoin 0.4.1 BETA +Bitcoin 0.4.2 BETA Copyright (c) 2009-2011 Bitcoin Developers Distributed under the MIT/X11 software license, see the accompanying diff --git a/doc/README_windows.txt b/doc/README_windows.txt index 7ff8834920b..7a406d65a37 100644 --- a/doc/README_windows.txt +++ b/doc/README_windows.txt @@ -1,4 +1,4 @@ -Bitcoin 0.4.1 BETA +Bitcoin 0.4.2 BETA Copyright (c) 2009-2011 Bitcoin Developers Distributed under the MIT/X11 software license, see the accompanying diff --git a/share/setup.nsi b/share/setup.nsi index 4c837c974bf..4500dc48e1b 100644 --- a/share/setup.nsi +++ b/share/setup.nsi @@ -5,7 +5,7 @@ SetCompressor /SOLID lzma # General Symbol Definitions !define REGKEY "SOFTWARE\$(^Name)" -!define VERSION 0.4.1 +!define VERSION 0.4.2 !define COMPANY "Bitcoin project" !define URL http://www.bitcoin.org/ @@ -45,13 +45,13 @@ Var StartMenuGroup !insertmacro MUI_LANGUAGE English # Installer attributes -OutFile bitcoin-0.4.1-win32-setup.exe +OutFile bitcoin-0.4.2-win32-setup.exe InstallDir $PROGRAMFILES\Bitcoin CRCCheck on XPStyle on BrandingText " " ShowInstDetails show -VIProductVersion 0.4.1.0 +VIProductVersion 0.4.2.0 VIAddVersionKey ProductName Bitcoin VIAddVersionKey ProductVersion "${VERSION}" VIAddVersionKey CompanyName "${COMPANY}" diff --git a/src/serialize.h b/src/serialize.h index c531d2a198e..64fae0367ea 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 = 40101; +static const int VERSION = 40200; static const char* pszSubVer = ""; static const bool VERSION_IS_BETA = true; From 45593c271a5a039d75fc136e46fac71fcb52e779 Mon Sep 17 00:00:00 2001 From: Gavin Andresen Date: Mon, 21 Nov 2011 14:38:47 -0500 Subject: [PATCH 21/41] Don't forget to bump release numbers in READMEs next time --- doc/release-process.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/release-process.txt b/doc/release-process.txt index bcda64dbed5..953761b4a95 100644 --- a/doc/release-process.txt +++ b/doc/release-process.txt @@ -1,6 +1,7 @@ * update (commit) version in sources src/serialize.h share/setup.nsi + doc/README* * update (commit) version in OSX app bundle contrib/Bitcoin.app/Contents/Info.plist From 99fe0af2feaea626541fc14f479e6890202fb617 Mon Sep 17 00:00:00 2001 From: Gavin Andresen Date: Mon, 21 Nov 2011 14:37:59 -0500 Subject: [PATCH 22/41] Bump version numbers to 0.5.1 --- doc/README | 2 +- doc/README_windows.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/README b/doc/README index f45bf0c1520..5e0f8ee1ed7 100644 --- a/doc/README +++ b/doc/README @@ -1,4 +1,4 @@ -Bitcoin 0.5.0 BETA +Bitcoin 0.5.1 BETA Copyright (c) 2009-2011 Bitcoin Developers Distributed under the MIT/X11 software license, see the accompanying diff --git a/doc/README_windows.txt b/doc/README_windows.txt index ea2f14c42a0..d237615f57c 100644 --- a/doc/README_windows.txt +++ b/doc/README_windows.txt @@ -1,4 +1,4 @@ -Bitcoin 0.5.0 BETA +Bitcoin 0.5.1 BETA Copyright (c) 2009-2011 Bitcoin Developers Distributed under the MIT/X11 software license, see the accompanying From adb9f7ddde0d31c7b70d37cd30ee8e5bd8a3b2f8 Mon Sep 17 00:00:00 2001 From: Gavin Andresen Date: Mon, 21 Nov 2011 14:38:47 -0500 Subject: [PATCH 23/41] Don't forget to bump release numbers in READMEs next time --- doc/release-process.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/release-process.txt b/doc/release-process.txt index ac388847c20..14d8efeb32d 100644 --- a/doc/release-process.txt +++ b/doc/release-process.txt @@ -2,6 +2,7 @@ bitcoin-qt.pro src/serialize.h share/setup.nsi + doc/README* * tag version in git From 7597fcd92feb63f4ff2abf074ae70b3f575737e4 Mon Sep 17 00:00:00 2001 From: Alex B Date: Thu, 24 Nov 2011 12:32:19 +0100 Subject: [PATCH 24/41] Small fixes in both spanish translations --- src/qt/locale/bitcoin_es.ts | 63 +++++++++++++++++++++++----------- src/qt/locale/bitcoin_es_CL.ts | 63 +++++++++++++++++++++++----------- 2 files changed, 86 insertions(+), 40 deletions(-) diff --git a/src/qt/locale/bitcoin_es.ts b/src/qt/locale/bitcoin_es.ts index e2ec6bff542..49e0f0a2c7f 100644 --- a/src/qt/locale/bitcoin_es.ts +++ b/src/qt/locale/bitcoin_es.ts @@ -1,4 +1,6 @@ - + + + UTF-8 AboutDialog @@ -321,7 +323,7 @@ Are you sure you wish to encrypt your wallet? E&xit - + &Salir @@ -331,7 +333,7 @@ Are you sure you wish to encrypt your wallet? &About %1 - + S&obre %1 @@ -426,7 +428,10 @@ Are you sure you wish to encrypt your wallet? %n active connection(s) to Bitcoin network - %n conexión activa hacia la red Bitcoin%n conexiones activas hacia la red Bitcoin + + %n conexión activa hacia la red Bitcoin + %n conexiones activas hacia la red Bitcoin + @@ -441,22 +446,34 @@ Are you sure you wish to encrypt your wallet? %n second(s) ago - Hace %n segundoHace %n segundos + + Hace %n segundo + Hace %n segundos + %n minute(s) ago - Hace %n minutoHace %n minutos + + Hace %n minuto + Hace %n minutos + %n hour(s) ago - Hace %n horaHace %n horas + + Hace %n hora + Hace %n horas + %n day(s) ago - Hace %n díaHace %n días + + Hace %n día + Hace %n días + @@ -750,12 +767,12 @@ Dirección: %4 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;"> +</style></head><body style=" font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;"> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">Wallet</span></p></body></html> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;"> +</style></head><body style=" font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;"> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">Cartera</span></p></body></html> @@ -988,12 +1005,12 @@ p, li { white-space: pre-wrap; } , broadcast through %1 node - , emitido mediante %d nodo + , emitido mediante %1 nodo , broadcast through %1 nodes - , emitido mediante %d nodos + , emitido mediante %1 nodos @@ -1044,7 +1061,7 @@ p, li { white-space: pre-wrap; } (%1 matures in %2 more blocks) - (%s madura en %d bloques mas) + (%1 madura en %1 bloques mas) @@ -1122,7 +1139,10 @@ p, li { white-space: pre-wrap; } Open for %n block(s) - Abierto por %n bloqueAbierto por %n bloques + + Abierto por %n bloque + Abierto por %n bloques + @@ -1147,7 +1167,10 @@ p, li { white-space: pre-wrap; } Mined balance will be available in %n more blocks - El balance minado estará disponible en %n bloque masEl balance minado estará disponible en %n bloques mas + + El balance minado estará disponible en %n bloque mas + El balance minado estará disponible en %n bloques mas + @@ -1450,7 +1473,7 @@ p, li { white-space: pre-wrap; } - Don't generate coins + Don't generate coins No generar monedas @@ -1506,14 +1529,14 @@ p, li { white-space: pre-wrap; } - Don't accept connections from outside + Don't accept connections from outside No aceptar conexiones desde el exterior - Don't attempt to use UPnP to map the listening port + Don't attempt to use UPnP to map the listening port No intentar usar UPnP para mapear el puerto de entrada @@ -2336,7 +2359,7 @@ pero la información de los comentarios quedará en blanco. Bitcoin Qt - + Bitcoin Qt - \ No newline at end of file + diff --git a/src/qt/locale/bitcoin_es_CL.ts b/src/qt/locale/bitcoin_es_CL.ts index b44c1434460..bb9d299790f 100644 --- a/src/qt/locale/bitcoin_es_CL.ts +++ b/src/qt/locale/bitcoin_es_CL.ts @@ -1,4 +1,6 @@ - + + + UTF-8 AboutDialog @@ -321,7 +323,7 @@ Are you sure you wish to encrypt your wallet? E&xit - + &Salir @@ -331,7 +333,7 @@ Are you sure you wish to encrypt your wallet? &About %1 - + S&obre %1 @@ -426,7 +428,10 @@ Are you sure you wish to encrypt your wallet? %n active connection(s) to Bitcoin network - %n conexión activa hacia la red Bitcoin%n conexiones activas hacia la red Bitcoin + + %n conexión activa hacia la red Bitcoin + %n conexiones activas hacia la red Bitcoin + @@ -441,22 +446,34 @@ Are you sure you wish to encrypt your wallet? %n second(s) ago - Hace %n segundoHace %n segundos + + Hace %n segundo + Hace %n segundos + %n minute(s) ago - Hace %n minutoHace %n minutos + + Hace %n minuto + Hace %n minutos + %n hour(s) ago - Hace %n horaHace %n horas + + Hace %n hora + Hace %n horas + %n day(s) ago - Hace %n díaHace %n días + + Hace %n día + Hace %n días + @@ -750,12 +767,12 @@ Dirección: %4 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;"> +</style></head><body style=" font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;"> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">Wallet</span></p></body></html> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;"> +</style></head><body style=" font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;"> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">Cartera</span></p></body></html> @@ -988,12 +1005,12 @@ p, li { white-space: pre-wrap; } , broadcast through %1 node - , emitido mediante %d nodo + , emitido mediante %1 nodo , broadcast through %1 nodes - , emitido mediante %d nodos + , emitido mediante %1 nodos @@ -1044,7 +1061,7 @@ p, li { white-space: pre-wrap; } (%1 matures in %2 more blocks) - (%s madura en %d bloques mas) + (%1 madura en %2 bloques mas) @@ -1122,7 +1139,10 @@ p, li { white-space: pre-wrap; } Open for %n block(s) - Abierto por %n bloqueAbierto por %n bloques + + Abierto por %n bloque + Abierto por %n bloques + @@ -1147,7 +1167,10 @@ p, li { white-space: pre-wrap; } Mined balance will be available in %n more blocks - El balance minado estará disponible en %n bloque masEl balance minado estará disponible en %n bloques mas + + El balance minado estará disponible en %n bloque mas + El balance minado estará disponible en %n bloques mas + @@ -1450,7 +1473,7 @@ p, li { white-space: pre-wrap; } - Don't generate coins + Don't generate coins No generar monedas @@ -1506,14 +1529,14 @@ p, li { white-space: pre-wrap; } - Don't accept connections from outside + Don't accept connections from outside No aceptar conexiones desde el exterior - Don't attempt to use UPnP to map the listening port + Don't attempt to use UPnP to map the listening port No intentar usar UPnP para mapear el puerto de entrada @@ -2336,7 +2359,7 @@ pero la información de los comentarios quedará en blanco. Bitcoin Qt - + Bitcoin Qt - \ No newline at end of file + From 1c4be55a993bf77a5d44b9f468c12506e5b051ba Mon Sep 17 00:00:00 2001 From: Nils Schneider Date: Thu, 24 Nov 2011 13:40:32 +0100 Subject: [PATCH 25/41] update translation: de --- src/qt/locale/bitcoin_de.ts | 64 ++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/src/qt/locale/bitcoin_de.ts b/src/qt/locale/bitcoin_de.ts index 97eb5cb6423..f7b134a75d8 100644 --- a/src/qt/locale/bitcoin_de.ts +++ b/src/qt/locale/bitcoin_de.ts @@ -328,7 +328,7 @@ Sind Sie sich sicher, dass Sie Ihre Brieftasche verschlüsseln möchten? &About %1 - + &Über %1 @@ -1885,7 +1885,7 @@ Are you sure you wish to encrypt your wallet? Wallet encryption failed. - + Verschlüsselung der Brieftasche fehlgeschlagen. @@ -1896,22 +1896,22 @@ Remember that encrypting your wallet cannot fully protect your bitcoins from bei Wallet is unencrypted, please encrypt it first. - + Brieftasche nicht verschlüsselt, bitte zuerst verschlüsseln. Enter the new passphrase for the wallet. - + Gib eine neue Passphrase für die Brieftasche eine. Re-enter the new passphrase for the wallet. - + Gib die neue Passphrase erneut ein. Wallet Passphrase Changed. - + Passphrase geändert. @@ -1948,7 +1948,7 @@ Label <b>Date:</b> - + <b>Datum:</b> @@ -1958,7 +1958,7 @@ Label <b>From:</b> - + <b>Von:</b> @@ -2003,7 +2003,7 @@ Label <b>Transaction fee:</b> - + <b>Transaktionsgebühr:</b> @@ -2048,7 +2048,7 @@ Label version %s - + Version %s @@ -2063,7 +2063,7 @@ Label Amount exceeds your balance - + Betrag übersteigt Ihr Guthaben @@ -2078,7 +2078,7 @@ Label Payment sent - + Zahlung gesendet @@ -2088,22 +2088,22 @@ Label Invalid address - + ungültige Adresse Sending %s to %s - + Sende %s an %s CANCELLED - + ABGEBROCHEN Cancelled - + Abgebrochen @@ -2113,7 +2113,7 @@ Label Error: - + Fehler: @@ -2123,12 +2123,12 @@ Label Connecting... - + Verbinde... Unable to connect - + Kann nicht verbinden @@ -2173,7 +2173,7 @@ Label Transaction aborted - + Transaktion abgebrochen @@ -2183,17 +2183,17 @@ Label Sending payment... - + Sende Zahlung... The transaction was rejected. This might happen if some of the coins in your wallet were already spent, such as if you used a copy of wallet.dat and coins were spent in the copy but not marked as spent here. - + Fehler: Die Transaktion wurde abgelehnt. Dies kann passieren, wenn einige Ihrer Bitcoins aus Ihrer Brieftasche bereits ausgegeben wurden (z.B. aus einer Sicherungskopie Ihrer wallet.dat). Waiting for confirmation... - + Warte auf Bestätigung... @@ -2210,12 +2210,12 @@ but the comment information will be blank. Payment completed - + Die Zahlung wurde abgeschlossen Name - + Name @@ -2230,7 +2230,7 @@ but the comment information will be blank. Bitcoin Address - + Bitcoin Adresse @@ -2250,22 +2250,22 @@ but the comment information will be blank. Add Address - + Adresse hinzufügen Bitcoin - + Bitcoin Bitcoin - Generating - + Bitcoin - Generiere Bitcoin - (not connected) - + Bitcoin - (nicht verbunden) @@ -2300,7 +2300,7 @@ but the comment information will be blank. beta - + Beta @@ -2308,7 +2308,7 @@ but the comment information will be blank. Bitcoin Qt - + Bitcoin Qt \ No newline at end of file From 094c35cffc74cd6843cd858ca9afba7056db1ff3 Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Thu, 24 Nov 2011 20:20:01 +0100 Subject: [PATCH 26/41] allow for filtering addresses and labels by searching for the typed string anywhere, not just at the beginning (#641) --- src/qt/transactionfilterproxy.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/transactionfilterproxy.cpp b/src/qt/transactionfilterproxy.cpp index a4c5b371714..16fb4dab925 100644 --- a/src/qt/transactionfilterproxy.cpp +++ b/src/qt/transactionfilterproxy.cpp @@ -35,7 +35,7 @@ bool TransactionFilterProxy::filterAcceptsRow(int sourceRow, const QModelIndex & return false; if(datetime < dateFrom || datetime > dateTo) return false; - if(!address.startsWith(addrPrefix) && !label.startsWith(addrPrefix)) + if (!address.contains(addrPrefix, Qt::CaseInsensitive) && !label.contains(addrPrefix, Qt::CaseInsensitive)) return false; if(amount < minAmount) return false; From a7d735dcc25c85ad883e6d619848ce0478ebe299 Mon Sep 17 00:00:00 2001 From: Gavin Andresen Date: Sun, 27 Nov 2011 14:53:30 -0500 Subject: [PATCH 27/41] Add missing command-line arguments to --help/-? output --- src/init.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index 2d21a261437..68303c19fad 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -162,10 +162,10 @@ bool AppInit2(int argc, char* argv[]) string strUsage = string() + _("Bitcoin version") + " " + FormatFullVersion() + "\n\n" + _("Usage:") + "\t\t\t\t\t\t\t\t\t\t\n" + - " bitcoin [options] \t " + "\n" + - " bitcoin [options] [params]\t " + _("Send command to -server or bitcoind\n") + - " bitcoin [options] help \t\t " + _("List commands\n") + - " bitcoin [options] help \t\t " + _("Get help for a command\n") + + " bitcoind [options] \t " + "\n" + + " bitcoind [options] [params]\t " + _("Send command to -server or bitcoind\n") + + " bitcoind [options] help \t\t " + _("List commands\n") + + " bitcoind [options] help \t\t " + _("Get help for a command\n") + _("Options:\n") + " -conf= \t\t " + _("Specify configuration file (default: bitcoin.conf)\n") + " -pid= \t\t " + _("Specify pid file (default: bitcoind.pid)\n") + @@ -176,9 +176,14 @@ bool AppInit2(int argc, char* argv[]) " -timeout= \t " + _("Specify connection timeout (in milliseconds)\n") + " -proxy= \t " + _("Connect through socks4 proxy\n") + " -dns \t " + _("Allow DNS lookups for addnode and connect\n") + + " -port= \t\t " + _("Listen for connections on (default: 8333 or testnet: 18333)\n") + + " -maxconnections=\t " + _("Maintain at most connections to peers (default: 125)\n") + " -addnode= \t " + _("Add a node to connect to\n") + " -connect= \t\t " + _("Connect only to the specified node\n") + " -nolisten \t " + _("Don't accept connections from outside\n") + + " -nodnsseed \t " + _("Don't bootstrap list of peers using DNS\n") + + " -maxreceivebuffer=\t " + _("Maximum per-connection receive buffer, *1000 bytes (default: 10000)\n") + + " -maxsendbuffer=\t " + _("Maximum per-connection send buffer, *1000 bytes (default: 10000)\n") + #ifdef USE_UPNP #if USE_UPNP " -noupnp \t " + _("Don't attempt to use UPnP to map the listening port\n") + @@ -194,6 +199,12 @@ bool AppInit2(int argc, char* argv[]) " -daemon \t\t " + _("Run in the background as a daemon and accept commands\n") + #endif " -testnet \t\t " + _("Use the test network\n") + + " -debug \t\t " + _("Output extra debugging information\n") + + " -logtimestamps \t " + _("Prepend debug output with timestamp\n") + + " -printtoconsole \t " + _("Send trace/debug info to console instead of debug.log file\n") + +#ifdef WIN32 + " -printtodebugger \t " + _("Send trace/debug info to debugger\n") + +#endif " -rpcuser= \t " + _("Username for JSON-RPC connections\n") + " -rpcpassword=\t " + _("Password for JSON-RPC connections\n") + " -rpcport= \t\t " + _("Listen for JSON-RPC connections on (default: 8332)\n") + From cba18514c0d5b364ee96a984c255dc9e29a00d68 Mon Sep 17 00:00:00 2001 From: Gavin Andresen Date: Sun, 27 Nov 2011 14:53:30 -0500 Subject: [PATCH 28/41] Add missing command-line arguments to --help/-? output --- src/init.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index a6d0ab56e3e..367e75f39bc 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -172,10 +172,10 @@ bool AppInit2(int argc, char* argv[]) string strUsage = string() + _("Bitcoin version") + " " + FormatFullVersion() + "\n\n" + _("Usage:") + "\t\t\t\t\t\t\t\t\t\t\n" + - " bitcoin [options] \t " + "\n" + - " bitcoin [options] [params]\t " + _("Send command to -server or bitcoind\n") + - " bitcoin [options] help \t\t " + _("List commands\n") + - " bitcoin [options] help \t\t " + _("Get help for a command\n") + + " bitcoind [options] \t " + "\n" + + " bitcoind [options] [params]\t " + _("Send command to -server or bitcoind\n") + + " bitcoind [options] help \t\t " + _("List commands\n") + + " bitcoind [options] help \t\t " + _("Get help for a command\n") + _("Options:\n") + " -conf= \t\t " + _("Specify configuration file (default: bitcoin.conf)\n") + " -pid= \t\t " + _("Specify pid file (default: bitcoind.pid)\n") + @@ -186,11 +186,16 @@ bool AppInit2(int argc, char* argv[]) " -timeout= \t " + _("Specify connection timeout (in milliseconds)\n") + " -proxy= \t " + _("Connect through socks4 proxy\n") + " -dns \t " + _("Allow DNS lookups for addnode and connect\n") + + " -port= \t\t " + _("Listen for connections on (default: 8333 or testnet: 18333)\n") + + " -maxconnections=\t " + _("Maintain at most connections to peers (default: 125)\n") + " -addnode= \t " + _("Add a node to connect to\n") + " -connect= \t\t " + _("Connect only to the specified node\n") + " -nolisten \t " + _("Don't accept connections from outside\n") + + " -nodnsseed \t " + _("Don't bootstrap list of peers using DNS\n") + " -banscore= \t " + _("Threshold for disconnecting misbehaving peers (default: 100)\n") + " -bantime= \t " + _("Number of seconds to keep misbehaving peers from reconnecting (default: 86400)\n") + + " -maxreceivebuffer=\t " + _("Maximum per-connection receive buffer, *1000 bytes (default: 10000)\n") + + " -maxsendbuffer=\t " + _("Maximum per-connection send buffer, *1000 bytes (default: 10000)\n") + #ifdef USE_UPNP #if USE_UPNP " -noupnp \t " + _("Don't attempt to use UPnP to map the listening port\n") + @@ -206,6 +211,12 @@ bool AppInit2(int argc, char* argv[]) " -daemon \t\t " + _("Run in the background as a daemon and accept commands\n") + #endif " -testnet \t\t " + _("Use the test network\n") + + " -debug \t\t " + _("Output extra debugging information\n") + + " -logtimestamps \t " + _("Prepend debug output with timestamp\n") + + " -printtoconsole \t " + _("Send trace/debug info to console instead of debug.log file\n") + +#ifdef WIN32 + " -printtodebugger \t " + _("Send trace/debug info to debugger\n") + +#endif " -rpcuser= \t " + _("Username for JSON-RPC connections\n") + " -rpcpassword=\t " + _("Password for JSON-RPC connections\n") + " -rpcport= \t\t " + _("Listen for JSON-RPC connections on (default: 8332)\n") + From 3741185a51cada1adb17b1578a086544101ce7c7 Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Sat, 26 Nov 2011 09:55:12 +0100 Subject: [PATCH 29/41] Make home and addressbook icon more consistent with other toolbar icons (make it blue and flip light source direction) --- src/qt/res/icons/address-book.png | Bin 1851 -> 1916 bytes src/qt/res/icons/overview.png | Bin 7936 -> 7455 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/src/qt/res/icons/address-book.png b/src/qt/res/icons/address-book.png index dbfc28ab3d8c6d2eb0f93b0e4495eec606dbd1b4..d41dbe6539f64829c004d0f7fc9bf0ba1aa4d7df 100644 GIT binary patch delta 1901 zcmV-z2a@=^4*U*~B!2;OQb$4nuFf3k00006VoOIv0RI600RN!9r;`8x010qNS#tmY z3ljhU3ljkVnw%H_000McNliru+Y1^A1|7!KFm?a{2K-4xK~z}7<(F%4ROKDUf9JA$ zb~l&ZB#;mwA(9&q1F4u0n5tk(xM&q?$4VJ&8Syeyi%dxe$A69&deQp9_CvK_TC3Ay z5!y}yBgmkcA_~PJB#@Ah3rQAoCCTn4+3eZfbIyDEf!Im~DT?Jo|1kgci>2gV~uNAaRsESPnxkm zJu!1e@f*RR_J3i2c+WN<^uJReCQy8HUReD4_WLU~J^olSv!4c>*8#u+*#uhxo68SF zFzx-qdmecDyHAY|j^n&%CG&58VzZOvbzi*#Hl*#FK6Awr54`fLr*4s#1Uu<$=%jG- zdadxLwa+W4<<}3uvOha?o%G^GKYQl6id=B;&_ksx2!HwM4n|n;gU7Nn6Yh8k$ogs& zFl|ylShV5US2uny-;|l1jZt)TUW-KnI6t{oMXoQcV(m}uYOTR z%KdTxx=HfEqRJ<$*8Z@hY#JTCI=XHVjR`Ev#(y+zkR&3yNibqiRkf5dM;!l9klAb2 zmbo+YwgQRrHOX!R26(G;QrxvOmoK|_)oW|k&-ZlnS%iWy;)YG!lrV&hVS!=zn+fDDW9bFR))Bqm> z`o93O_vFtpeaRcW-jH~ok&#B6PiHRV`y#%E|)?iVxnmZwqz3;8OKUbB`bR_t?efn4fc}Y zn@Knp!RuC$lU#%bNBQ%6=jf?5wA;&QEv4 z>rGKY)xfcfC+t4}hGR#6)4KC_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jQ3 aj{gp$T0HKdgX+ux0000OnP?! diff --git a/src/qt/res/icons/overview.png b/src/qt/res/icons/overview.png index 3b90fe5569b74b2364c44eeff742e802690d18b5..ee2511f01d0d76a60cd9e7febc4c9218f38e3683 100644 GIT binary patch literal 7455 zcmZu$cQoA3*Z%BUcJ?wvUkrT6$DISDff0087#nrcsPHR^u?Bf6ct6l?}= z70B!9LlvNUh;{Q85ZUTHR0D4QH!y7_$+s3_cTH0-0HFB(KLMo(P_Wz@p>MPvsY7Q; znPKyg#H1RwD9w?@|nR zy0FrzD5(QAQ|6AX#LJM#RB6yM*JG4#6b-`i|AAJ@ zAA;jj6jE0yod8$Boe1E?T_ZNi1OJv;bTl?1I*Myi)%Fo30_8bRLpl!jDjr27DhJlW z()0#%s$*!D7>tHE2xWpww?Sl5;Kj3+T3#Fv*@5B3ucUlmGCV0Cfu^#e;<&|KydlM9 zu_wK%`)PWiwRINIff7$!O-RfOf?=d6gSN{4q;>cS(zl=R*ymUl9S6bnG%-Aqfb72{ zw7v%eyz2#`UnCL51t8m}PTQvA9E^rlo&CgtC0}oH?)c1@;l(n_!22VAnTmtEa-P%j zD3PU*_DPqKq{o1C?`K?6(fHYQj($aGCGAR-moEqJnnio-P^ySQBL}=Z91k8hDlqaW zK}AZEh|98-tU&HEl=(<1-GHOh=ACNAUqRPjN+xag=VzBFMJ*CF^V*Gx{Vb@=pHkiW z2(5p(v~0j>2z5;1p8SBUwY$p;Gt01sCDtr{KF*$RJ}ssz75w1M1V$0?Z=@*J^>!rC zU{(nI*TE)~h*YWb>g4#}=W&z;Za2x90`qF%osLrS_Fp$NuFVGuA8$TZ_*;Rri8mx~ z9Tgq>z1EWag&hOh`y{1>R6hJ(Fz;M5{!To?`qyF)oMR9IVY{q$xY(a-3GdsaqCe!K7Opw{1JnzLGaeR82(7@mY|Gqu#VkSV)zn~HTR}+whqQ{BQu3y)^7s0j%4bZD`lP0 zs#1kuA3&_4wt=`JiS!K7v{ft^j}jZbIjoe}KN9dtO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uJWZNn4CJ;a4(t z=q89z>xlx(Ra04+-gS44ewKpKZqe|Jm$&ut%4-m-Gs4WCs7pPlduRDUPj}6pD$R!) zhn@NdnRq{u?Fo8+2RQ;*&M5$c3dkSzKhrkURu71QfZ%#mUys?Yk`(X^N1fA$GZpn| zdhaA1Z@aGP?8FW2$J(ZIbS_jki%6>k0l*DqMUj&G6JkqA+=bxbKFIRfR6z;)&l+?I zErKPEkMj^b-LUQO2(APBq?I{t5j+A^!V@cBb6{e9_ikfCiW$V`q2fI2U-mbyi|B)9 xfIalw&j@_9!j8NIq{gL25Jj)>e+W0yUv-0AMl6w+_akgTNnTB^T-Gf3{{fFb<^})& From d27be1f55777bd502beb6b89513f1a03ed988f1a Mon Sep 17 00:00:00 2001 From: Gavin Andresen Date: Thu, 8 Sep 2011 16:50:58 -0400 Subject: [PATCH 30/41] Moved checkpoints out of main, to prep for using them to help prevent DoS attacks --- bitcoin-qt.pro | 2 ++ src/checkpoints.cpp | 43 ++++++++++++++++++++++++++++++++++ src/checkpoints.h | 22 +++++++++++++++++ src/main.cpp | 32 ++++--------------------- src/main.h | 1 - src/makefile.linux-mingw | 2 ++ src/makefile.mingw | 2 ++ src/makefile.osx | 2 ++ src/makefile.unix | 2 ++ src/makefile.vc | 6 +++++ src/test/Checkpoints_tests.cpp | 34 +++++++++++++++++++++++++++ src/test/DoS_tests.cpp | 1 - src/test/test_bitcoin.cpp | 1 + 13 files changed, 121 insertions(+), 29 deletions(-) create mode 100644 src/checkpoints.cpp create mode 100644 src/checkpoints.h create mode 100644 src/test/Checkpoints_tests.cpp diff --git a/bitcoin-qt.pro b/bitcoin-qt.pro index 7444ff4ac16..8fc177f7f48 100644 --- a/bitcoin-qt.pro +++ b/bitcoin-qt.pro @@ -88,6 +88,7 @@ HEADERS += src/qt/bitcoingui.h \ src/qt/bitcoinaddressvalidator.h \ src/base58.h \ src/bignum.h \ + src/checkpoints.h \ src/util.h \ src/uint256.h \ src/serialize.h \ @@ -152,6 +153,7 @@ SOURCES += src/qt/bitcoin.cpp src/qt/bitcoingui.cpp \ src/init.cpp \ src/net.cpp \ src/irc.cpp \ + src/checkpoints.cpp \ src/db.cpp \ src/json/json_spirit_writer.cpp \ src/json/json_spirit_value.cpp \ diff --git a/src/checkpoints.cpp b/src/checkpoints.cpp new file mode 100644 index 00000000000..4419a06c830 --- /dev/null +++ b/src/checkpoints.cpp @@ -0,0 +1,43 @@ +// Copyright (c) 2011 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file license.txt or http://www.opensource.org/licenses/mit-license.php. + +#include "checkpoints.h" +#include "uint256.h" +#include "util.h" + +#include // for 'map_list_of()' + +namespace Checkpoints +{ + typedef std::map MapCheckpoints; + + static MapCheckpoints mapCheckpoints = + boost::assign::map_list_of + ( 11111, uint256("0x0000000069e244f73d78e8fd29ba2fd2ed618bd6fa2ee92559f542fdb26e7c1d")) + ( 33333, uint256("0x000000002dd5588a74784eaa7ab0507a18ad16a236e7b1ce69f00d7ddfb5d0a6")) + ( 68555, uint256("0x00000000001e1b4903550a0b96e9a9405c8a95f387162e4944e8d9fbe501cd6a")) + ( 70567, uint256("0x00000000006a49b14bcf27462068f1264c961f11fa2e0eddd2be0791e1d4124a")) + ( 74000, uint256("0x0000000000573993a3c9e41ce34471c079dcf5f52a0e824a81e7f953b8661a20")) + (105000, uint256("0x00000000000291ce28027faea320c8d2b054b2e0fe44a773f3eefb151d6bdc97")) + (118000, uint256("0x000000000000774a7f8a7a12dc906ddb9e17e75d684f15e00f8767f9e8f36553")) + (134444, uint256("0x00000000000005b12ffd4cd315cd34ffd4a594f430ac814c91184a0d42d2b0fe")) + (140700, uint256("0x000000000000033b512028abb90e1626d8b346fd0ed598ac0a3c371138dce2bd")) + ; + + bool CheckBlock(int nHeight, const uint256& hash) + { + if (fTestNet) return true; // Testnet has no checkpoints + + MapCheckpoints::const_iterator i = mapCheckpoints.find(nHeight); + if (i == mapCheckpoints.end()) return true; + return hash == i->second; + } + + int GetTotalBlocksEstimate() + { + if (fTestNet) return 0; // Testnet has no checkpoints + + return mapCheckpoints.rbegin()->first; + } +} diff --git a/src/checkpoints.h b/src/checkpoints.h new file mode 100644 index 00000000000..32094fdde62 --- /dev/null +++ b/src/checkpoints.h @@ -0,0 +1,22 @@ +// Copyright (c) 2011 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file license.txt or http://www.opensource.org/licenses/mit-license.php. +#ifndef BITCOIN_CHECKPOINT_H +#define BITCOIN_CHECKPOINT_H + +class uint256; + +// +// Block-chain checkpoints are compiled-in sanity checks. +// They are updated every release or three. +// +namespace Checkpoints +{ + // Returns true if block passes checkpoint checks + bool CheckBlock(int nHeight, const uint256& hash); + + // Return conservative estimate of total number of blocks, 0 if unknown + int GetTotalBlocksEstimate(); +} + +#endif diff --git a/src/main.cpp b/src/main.cpp index 47f1090727f..832a0f92402 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3,6 +3,7 @@ // Distributed under the MIT/X11 software license, see the accompanying // file license.txt or http://www.opensource.org/licenses/mit-license.php. #include "headers.h" +#include "checkpoints.h" #include "db.h" #include "net.h" #include "init.h" @@ -29,7 +30,6 @@ map mapNextTx; map mapBlockIndex; uint256 hashGenesisBlock("0x000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"); static CBigNum bnProofOfWorkLimit(~uint256(0) >> 32); -const int nTotalBlocksEstimate = 140700; // Conservative estimate of total nr of blocks on main chain const int nInitialBlockThreshold = 120; // Regard blocks up until N-threshold as "initial download" CBlockIndex* pindexGenesisBlock = NULL; int nBestHeight = -1; @@ -721,28 +721,15 @@ bool CheckProofOfWork(uint256 hash, unsigned int nBits) return true; } -// Return conservative estimate of total number of blocks, 0 if unknown -int GetTotalBlocksEstimate() -{ - if(fTestNet) - { - return 0; - } - else - { - return nTotalBlocksEstimate; - } -} - // Return maximum amount of blocks that other nodes claim to have int GetNumBlocksOfPeers() { - return std::max(cPeerBlockCounts.median(), GetTotalBlocksEstimate()); + return std::max(cPeerBlockCounts.median(), Checkpoints::GetTotalBlocksEstimate()); } bool IsInitialBlockDownload() { - if (pindexBest == NULL || nBestHeight < (GetTotalBlocksEstimate()-nInitialBlockThreshold)) + if (pindexBest == NULL || nBestHeight < (Checkpoints::GetTotalBlocksEstimate()-nInitialBlockThreshold)) return true; static int64 nLastUpdate; static CBlockIndex* pindexLastBest; @@ -1317,17 +1304,8 @@ bool CBlock::AcceptBlock() return DoS(10, error("AcceptBlock() : contains a non-final transaction")); // Check that the block chain matches the known block chain up to a checkpoint - if (!fTestNet) - if ((nHeight == 11111 && hash != uint256("0x0000000069e244f73d78e8fd29ba2fd2ed618bd6fa2ee92559f542fdb26e7c1d")) || - (nHeight == 33333 && hash != uint256("0x000000002dd5588a74784eaa7ab0507a18ad16a236e7b1ce69f00d7ddfb5d0a6")) || - (nHeight == 68555 && hash != uint256("0x00000000001e1b4903550a0b96e9a9405c8a95f387162e4944e8d9fbe501cd6a")) || - (nHeight == 70567 && hash != uint256("0x00000000006a49b14bcf27462068f1264c961f11fa2e0eddd2be0791e1d4124a")) || - (nHeight == 74000 && hash != uint256("0x0000000000573993a3c9e41ce34471c079dcf5f52a0e824a81e7f953b8661a20")) || - (nHeight == 105000 && hash != uint256("0x00000000000291ce28027faea320c8d2b054b2e0fe44a773f3eefb151d6bdc97")) || - (nHeight == 118000 && hash != uint256("0x000000000000774a7f8a7a12dc906ddb9e17e75d684f15e00f8767f9e8f36553")) || - (nHeight == 134444 && hash != uint256("0x00000000000005b12ffd4cd315cd34ffd4a594f430ac814c91184a0d42d2b0fe")) || - (nHeight == 140700 && hash != uint256("0x000000000000033b512028abb90e1626d8b346fd0ed598ac0a3c371138dce2bd"))) - return DoS(100, error("AcceptBlock() : rejected by checkpoint lockin at %d", nHeight)); + if (!Checkpoints::CheckBlock(nHeight, hash)) + return DoS(100, error("AcceptBlock() : rejected by checkpoint lockin at %d", nHeight)); // Write block to history file if (!CheckDiskSpace(::GetSerializeSize(*this, SER_DISK))) diff --git a/src/main.h b/src/main.h index 60ca3183810..f459d050ce9 100644 --- a/src/main.h +++ b/src/main.h @@ -99,7 +99,6 @@ void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int& void FormatHashBuffers(CBlock* pblock, char* pmidstate, char* pdata, char* phash1); bool CheckWork(CBlock* pblock, CWallet& wallet, CReserveKey& reservekey); bool CheckProofOfWork(uint256 hash, unsigned int nBits); -int GetTotalBlocksEstimate(); int GetNumBlocksOfPeers(); bool IsInitialBlockDownload(); std::string GetWarnings(std::string strFor); diff --git a/src/makefile.linux-mingw b/src/makefile.linux-mingw index 29b433f851a..61f8d4881f0 100644 --- a/src/makefile.linux-mingw +++ b/src/makefile.linux-mingw @@ -32,6 +32,7 @@ CFLAGS=-O2 -w -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATH HEADERS = \ base58.h \ bignum.h \ + checkpoints.h \ crypter.h \ db.h \ headers.h \ @@ -61,6 +62,7 @@ endif LIBS += -l mingwthrd -l kernel32 -l user32 -l gdi32 -l comdlg32 -l winspool -l winmm -l shell32 -l comctl32 -l ole32 -l oleaut32 -l uuid -l rpcrt4 -l advapi32 -l ws2_32 -l shlwapi OBJS= \ + obj/checkpoints.o \ obj/crypter.o \ obj/db.o \ obj/init.o \ diff --git a/src/makefile.mingw b/src/makefile.mingw index 95d09f8770d..2cb78d97e6a 100644 --- a/src/makefile.mingw +++ b/src/makefile.mingw @@ -29,6 +29,7 @@ CFLAGS=-mthreads -O2 -w -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(DEFS) $(I HEADERS = \ base58.h \ bignum.h \ + checkpoints.h \ crypter.h \ db.h \ headers.h \ @@ -58,6 +59,7 @@ endif LIBS += -l kernel32 -l user32 -l gdi32 -l comdlg32 -l winspool -l winmm -l shell32 -l comctl32 -l ole32 -l oleaut32 -l uuid -l rpcrt4 -l advapi32 -l ws2_32 -l shlwapi OBJS= \ + obj/checkpoints.o \ obj/crypter.o \ obj/db.o \ obj/init.o \ diff --git a/src/makefile.osx b/src/makefile.osx index 7830f3bad5f..de718879356 100644 --- a/src/makefile.osx +++ b/src/makefile.osx @@ -49,6 +49,7 @@ CFLAGS=-mmacosx-version-min=10.5 -arch i386 -O3 -Wno-invalid-offsetof -Wformat $ HEADERS = \ base58.h \ bignum.h \ + checkpoints.h \ crypter.h \ db.h \ headers.h \ @@ -69,6 +70,7 @@ HEADERS = \ wallet.h OBJS= \ + obj/checkpoints.o \ obj/crypter.o \ obj/db.o \ obj/init.o \ diff --git a/src/makefile.unix b/src/makefile.unix index 5f841ea0fea..6c48199546d 100644 --- a/src/makefile.unix +++ b/src/makefile.unix @@ -87,6 +87,7 @@ xCXXFLAGS=-pthread -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(DEFS) $(HARDEN HEADERS = \ base58.h \ bignum.h \ + checkpoints.h \ crypter.h \ db.h \ headers.h \ @@ -107,6 +108,7 @@ HEADERS = \ wallet.h OBJS= \ + obj/checkpoints.o \ obj/crypter.o \ obj/db.o \ obj/init.o \ diff --git a/src/makefile.vc b/src/makefile.vc index c7e8578a95e..60f1e096338 100644 --- a/src/makefile.vc +++ b/src/makefile.vc @@ -43,6 +43,7 @@ CFLAGS=/MD /c /nologo /EHsc /GR /Zm300 $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS) HEADERS = \ base58.h \ bignum.h \ + checkpoints.h \ crypter.h \ db.h \ headers.h \ @@ -65,6 +66,7 @@ HEADERS = \ wallet.h OBJS= \ + obj\checkpoints.o \ obj\crypter.o \ obj\db.o \ obj\init.o \ @@ -87,6 +89,8 @@ all: bitcoind.exe .cpp{obj}.obj: cl $(CFLAGS) /DGUI /Fo$@ %s +obj\checkpoints.obj: $(HEADERS) + obj\util.obj: $(HEADERS) obj\script.obj: $(HEADERS) @@ -116,6 +120,8 @@ obj\uibase.obj: $(HEADERS) .cpp{obj\nogui}.obj: cl $(CFLAGS) /Fo$@ %s +obj\nogui\checkpoints.obj: $(HEADERS) + obj\nogui\util.obj: $(HEADERS) obj\nogui\script.obj: $(HEADERS) diff --git a/src/test/Checkpoints_tests.cpp b/src/test/Checkpoints_tests.cpp new file mode 100644 index 00000000000..0d8a366d7ac --- /dev/null +++ b/src/test/Checkpoints_tests.cpp @@ -0,0 +1,34 @@ +// +// Unit tests for block-chain checkpoints +// +#include // for 'map_list_of()' +#include +#include + +#include "../checkpoints.h" +#include "../util.h" + +using namespace std; + +BOOST_AUTO_TEST_SUITE(Checkpoints_tests) + +BOOST_AUTO_TEST_CASE(sanity) +{ + uint256 p11111 = uint256("0x0000000069e244f73d78e8fd29ba2fd2ed618bd6fa2ee92559f542fdb26e7c1d"); + uint256 p140700 = uint256("0x000000000000033b512028abb90e1626d8b346fd0ed598ac0a3c371138dce2bd"); + BOOST_CHECK(Checkpoints::CheckBlock(11111, p11111)); + BOOST_CHECK(Checkpoints::CheckBlock(140700, p140700)); + + + // Wrong hashes at checkpoints should fail: + BOOST_CHECK(!Checkpoints::CheckBlock(11111, p140700)); + BOOST_CHECK(!Checkpoints::CheckBlock(140700, p11111)); + + // ... but any hash not at a checkpoint should succeed: + BOOST_CHECK(Checkpoints::CheckBlock(11111+1, p140700)); + BOOST_CHECK(Checkpoints::CheckBlock(140700+1, p11111)); + + BOOST_CHECK(Checkpoints::GetTotalBlocksEstimate() >= 140700); +} + +BOOST_AUTO_TEST_SUITE_END() diff --git a/src/test/DoS_tests.cpp b/src/test/DoS_tests.cpp index e60bb742dd3..1093b73d80e 100644 --- a/src/test/DoS_tests.cpp +++ b/src/test/DoS_tests.cpp @@ -64,5 +64,4 @@ BOOST_AUTO_TEST_CASE(DoS_bantime) BOOST_CHECK(!CNode::IsBanned(addr.ip)); } - BOOST_AUTO_TEST_SUITE_END() diff --git a/src/test/test_bitcoin.cpp b/src/test/test_bitcoin.cpp index 8863aad4780..39a7c88e135 100644 --- a/src/test/test_bitcoin.cpp +++ b/src/test/test_bitcoin.cpp @@ -13,6 +13,7 @@ #include "util_tests.cpp" #include "base58_tests.cpp" #include "miner_tests.cpp" +#include "Checkpoints_tests.cpp" CWallet* pwalletMain; From f8c3eb9568fcaff41afb257f6058d1f33ae14358 Mon Sep 17 00:00:00 2001 From: Gavin Andresen Date: Thu, 8 Sep 2011 12:51:43 -0400 Subject: [PATCH 31/41] Orphan block fill-up-memory attack prevention --- src/checkpoints.cpp | 32 +++++++++++++++++++++----- src/checkpoints.h | 7 ++++++ src/main.cpp | 49 +++++++++++++++++++++++++++++++++++++--- src/main.h | 1 + src/test/DoS_tests.cpp | 51 ++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 132 insertions(+), 8 deletions(-) diff --git a/src/checkpoints.cpp b/src/checkpoints.cpp index 4419a06c830..c7e054df378 100644 --- a/src/checkpoints.cpp +++ b/src/checkpoints.cpp @@ -2,16 +2,23 @@ // Distributed under the MIT/X11 software license, see the accompanying // file license.txt or http://www.opensource.org/licenses/mit-license.php. -#include "checkpoints.h" -#include "uint256.h" -#include "util.h" - #include // for 'map_list_of()' +#include + +#include "headers.h" +#include "checkpoints.h" namespace Checkpoints { typedef std::map MapCheckpoints; + // + // What makes a good checkpoint block? + // + Is surrounded by blocks with reasonable timestamps + // (no blocks before with a timestamp after, none after with + // timestamp before) + // + Contains no strange transactions + // static MapCheckpoints mapCheckpoints = boost::assign::map_list_of ( 11111, uint256("0x0000000069e244f73d78e8fd29ba2fd2ed618bd6fa2ee92559f542fdb26e7c1d")) @@ -36,8 +43,23 @@ namespace Checkpoints int GetTotalBlocksEstimate() { - if (fTestNet) return 0; // Testnet has no checkpoints + if (fTestNet) return 0; return mapCheckpoints.rbegin()->first; } + + CBlockIndex* GetLastCheckpoint(const std::map& mapBlockIndex) + { + if (fTestNet) return NULL; + + int64 nResult; + BOOST_REVERSE_FOREACH(const MapCheckpoints::value_type& i, mapCheckpoints) + { + const uint256& hash = i.second; + std::map::const_iterator t = mapBlockIndex.find(hash); + if (t != mapBlockIndex.end()) + return t->second; + } + return NULL; + } } diff --git a/src/checkpoints.h b/src/checkpoints.h index 32094fdde62..9d52da404fb 100644 --- a/src/checkpoints.h +++ b/src/checkpoints.h @@ -4,7 +4,11 @@ #ifndef BITCOIN_CHECKPOINT_H #define BITCOIN_CHECKPOINT_H +#include +#include "util.h" + class uint256; +class CBlockIndex; // // Block-chain checkpoints are compiled-in sanity checks. @@ -17,6 +21,9 @@ namespace Checkpoints // Return conservative estimate of total number of blocks, 0 if unknown int GetTotalBlocksEstimate(); + + // Returns last CBlockIndex* in mapBlockIndex that is a checkpoint + CBlockIndex* GetLastCheckpoint(const std::map& mapBlockIndex); } #endif diff --git a/src/main.cpp b/src/main.cpp index 832a0f92402..a7871fcc168 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -659,11 +659,32 @@ int64 static GetBlockValue(int nHeight, int64 nFees) return nSubsidy + nFees; } +static const int64 nTargetTimespan = 14 * 24 * 60 * 60; // two weeks +static const int64 nTargetSpacing = 10 * 60; +static const int64 nInterval = nTargetTimespan / nTargetSpacing; + +// +// minimum amount of work that could possibly be required nTime after +// minimum work required was nBase +// +unsigned int ComputeMinWork(unsigned int nBase, int64 nTime) +{ + CBigNum bnResult; + bnResult.SetCompact(nBase); + while (nTime > 0 && bnResult < bnProofOfWorkLimit) + { + // Maximum 400% adjustment... + bnResult *= 4; + // ... in best-case exactly 4-times-normal target time + nTime -= nTargetTimespan*4; + } + if (bnResult > bnProofOfWorkLimit) + bnResult = bnProofOfWorkLimit; + return bnResult.GetCompact(); +} + unsigned int static GetNextWorkRequired(const CBlockIndex* pindexLast) { - const int64 nTargetTimespan = 14 * 24 * 60 * 60; // two weeks - const int64 nTargetSpacing = 10 * 60; - const int64 nInterval = nTargetTimespan / nTargetSpacing; // Genesis block if (pindexLast == NULL) @@ -1340,6 +1361,28 @@ bool ProcessBlock(CNode* pfrom, CBlock* pblock) if (!pblock->CheckBlock()) return error("ProcessBlock() : CheckBlock FAILED"); + CBlockIndex* pcheckpoint = Checkpoints::GetLastCheckpoint(mapBlockIndex); + if (pcheckpoint && pblock->hashPrevBlock != hashBestChain) + { + // Extra checks to prevent "fill up memory by spamming with bogus blocks" + int64 deltaTime = pblock->GetBlockTime() - pcheckpoint->nTime; + if (deltaTime < 0) + { + pfrom->Misbehaving(100); + return error("ProcessBlock() : block with timestamp before last checkpoint"); + } + CBigNum bnNewBlock; + bnNewBlock.SetCompact(pblock->nBits); + CBigNum bnRequired; + bnRequired.SetCompact(ComputeMinWork(pcheckpoint->nBits, deltaTime)); + if (bnNewBlock > bnRequired) + { + pfrom->Misbehaving(100); + return error("ProcessBlock() : block with too little proof-of-work"); + } + } + + // If don't already have its previous block, shunt it off to holding area until we get it if (!mapBlockIndex.count(pblock->hashPrevBlock)) { diff --git a/src/main.h b/src/main.h index f459d050ce9..3870cee864b 100644 --- a/src/main.h +++ b/src/main.h @@ -99,6 +99,7 @@ void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int& void FormatHashBuffers(CBlock* pblock, char* pmidstate, char* pdata, char* phash1); bool CheckWork(CBlock* pblock, CWallet& wallet, CReserveKey& reservekey); bool CheckProofOfWork(uint256 hash, unsigned int nBits); +unsigned int ComputeMinWork(unsigned int nBase, int64 nTime); int GetNumBlocksOfPeers(); bool IsInitialBlockDownload(); std::string GetWarnings(std::string strFor); diff --git a/src/test/DoS_tests.cpp b/src/test/DoS_tests.cpp index 1093b73d80e..01e6691254a 100644 --- a/src/test/DoS_tests.cpp +++ b/src/test/DoS_tests.cpp @@ -1,6 +1,7 @@ // // Unit tests for denial-of-service detection/prevention code // +#include // for 'map_list_of()' #include #include @@ -64,4 +65,54 @@ BOOST_AUTO_TEST_CASE(DoS_bantime) BOOST_CHECK(!CNode::IsBanned(addr.ip)); } +static bool CheckNBits(unsigned int nbits1, int64 time1, unsigned int nbits2, int64 time2) +{ + if (time1 > time2) + return CheckNBits(nbits2, time2, nbits1, time1); + int64 deltaTime = time2-time1; + + CBigNum required; + required.SetCompact(ComputeMinWork(nbits1, deltaTime)); + CBigNum have; + have.SetCompact(nbits2); + return (have <= required); +} + +BOOST_AUTO_TEST_CASE(DoS_checknbits) +{ + using namespace boost::assign; // for 'map_list_of()' + + // Timestamps,nBits from the bitcoin blockchain. + // These are the block-chain checkpoint blocks + typedef std::map BlockData; + BlockData chainData = + map_list_of(1239852051,486604799)(1262749024,486594666) + (1279305360,469854461)(1280200847,469830746)(1281678674,469809688) + (1296207707,453179945)(1302624061,453036989)(1309640330,437004818) + (1313172719,436789733); + + // Make sure CheckNBits considers every combination of block-chain-lock-in-points + // "sane": + BOOST_FOREACH(const BlockData::value_type& i, chainData) + { + BOOST_FOREACH(const BlockData::value_type& j, chainData) + { + BOOST_CHECK(CheckNBits(i.second, i.first, j.second, j.first)); + } + } + + // Test a couple of insane combinations: + BlockData::value_type firstcheck = *(chainData.begin()); + BlockData::value_type lastcheck = *(chainData.rbegin()); + + // First checkpoint difficulty at or a while after the last checkpoint time should fail when + // compared to last checkpoint + BOOST_CHECK(!CheckNBits(firstcheck.second, lastcheck.first+60*10, lastcheck.second, lastcheck.first)); + BOOST_CHECK(!CheckNBits(firstcheck.second, lastcheck.first+60*60*24*14, lastcheck.second, lastcheck.first)); + + // ... but OK if enough time passed for difficulty to adjust downward: + BOOST_CHECK(CheckNBits(firstcheck.second, lastcheck.first+60*60*24*365*4, lastcheck.second, lastcheck.first)); + +} + BOOST_AUTO_TEST_SUITE_END() From 0e6425da4a29d6944e7edce85535725e1f963e2c Mon Sep 17 00:00:00 2001 From: Gavin Andresen Date: Thu, 8 Sep 2011 16:50:58 -0400 Subject: [PATCH 32/41] Moved checkpoints out of main, to prep for using them to help prevent DoS attacks --- src/checkpoints.cpp | 43 ++++++++++++++++++++++++++++++++++ src/checkpoints.h | 22 +++++++++++++++++ src/main.cpp | 30 ++++-------------------- src/main.h | 1 - src/makefile.linux-mingw | 2 ++ src/makefile.mingw | 2 ++ src/makefile.osx | 2 ++ src/makefile.unix | 2 ++ src/makefile.vc | 6 +++++ src/test/Checkpoints_tests.cpp | 34 +++++++++++++++++++++++++++ src/test/test_bitcoin.cpp | 1 + 11 files changed, 118 insertions(+), 27 deletions(-) create mode 100644 src/checkpoints.cpp create mode 100644 src/checkpoints.h create mode 100644 src/test/Checkpoints_tests.cpp diff --git a/src/checkpoints.cpp b/src/checkpoints.cpp new file mode 100644 index 00000000000..4419a06c830 --- /dev/null +++ b/src/checkpoints.cpp @@ -0,0 +1,43 @@ +// Copyright (c) 2011 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file license.txt or http://www.opensource.org/licenses/mit-license.php. + +#include "checkpoints.h" +#include "uint256.h" +#include "util.h" + +#include // for 'map_list_of()' + +namespace Checkpoints +{ + typedef std::map MapCheckpoints; + + static MapCheckpoints mapCheckpoints = + boost::assign::map_list_of + ( 11111, uint256("0x0000000069e244f73d78e8fd29ba2fd2ed618bd6fa2ee92559f542fdb26e7c1d")) + ( 33333, uint256("0x000000002dd5588a74784eaa7ab0507a18ad16a236e7b1ce69f00d7ddfb5d0a6")) + ( 68555, uint256("0x00000000001e1b4903550a0b96e9a9405c8a95f387162e4944e8d9fbe501cd6a")) + ( 70567, uint256("0x00000000006a49b14bcf27462068f1264c961f11fa2e0eddd2be0791e1d4124a")) + ( 74000, uint256("0x0000000000573993a3c9e41ce34471c079dcf5f52a0e824a81e7f953b8661a20")) + (105000, uint256("0x00000000000291ce28027faea320c8d2b054b2e0fe44a773f3eefb151d6bdc97")) + (118000, uint256("0x000000000000774a7f8a7a12dc906ddb9e17e75d684f15e00f8767f9e8f36553")) + (134444, uint256("0x00000000000005b12ffd4cd315cd34ffd4a594f430ac814c91184a0d42d2b0fe")) + (140700, uint256("0x000000000000033b512028abb90e1626d8b346fd0ed598ac0a3c371138dce2bd")) + ; + + bool CheckBlock(int nHeight, const uint256& hash) + { + if (fTestNet) return true; // Testnet has no checkpoints + + MapCheckpoints::const_iterator i = mapCheckpoints.find(nHeight); + if (i == mapCheckpoints.end()) return true; + return hash == i->second; + } + + int GetTotalBlocksEstimate() + { + if (fTestNet) return 0; // Testnet has no checkpoints + + return mapCheckpoints.rbegin()->first; + } +} diff --git a/src/checkpoints.h b/src/checkpoints.h new file mode 100644 index 00000000000..32094fdde62 --- /dev/null +++ b/src/checkpoints.h @@ -0,0 +1,22 @@ +// Copyright (c) 2011 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file license.txt or http://www.opensource.org/licenses/mit-license.php. +#ifndef BITCOIN_CHECKPOINT_H +#define BITCOIN_CHECKPOINT_H + +class uint256; + +// +// Block-chain checkpoints are compiled-in sanity checks. +// They are updated every release or three. +// +namespace Checkpoints +{ + // Returns true if block passes checkpoint checks + bool CheckBlock(int nHeight, const uint256& hash); + + // Return conservative estimate of total number of blocks, 0 if unknown + int GetTotalBlocksEstimate(); +} + +#endif diff --git a/src/main.cpp b/src/main.cpp index 6a3bacc78e9..dad7d144e7d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3,6 +3,7 @@ // Distributed under the MIT/X11 software license, see the accompanying // file license.txt or http://www.opensource.org/licenses/mit-license.php. #include "headers.h" +#include "checkpoints.h" #include "db.h" #include "net.h" #include "init.h" @@ -30,7 +31,6 @@ map mapNextTx; map mapBlockIndex; uint256 hashGenesisBlock("0x000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"); static CBigNum bnProofOfWorkLimit(~uint256(0) >> 32); -const int nTotalBlocksEstimate = 140700; // Conservative estimate of total nr of blocks on main chain const int nInitialBlockThreshold = 120; // Regard blocks up until N-threshold as "initial download" CBlockIndex* pindexGenesisBlock = NULL; int nBestHeight = -1; @@ -713,22 +713,9 @@ bool CheckProofOfWork(uint256 hash, unsigned int nBits) return true; } -// Return conservative estimate of total number of blocks, 0 if unknown -int GetTotalBlocksEstimate() -{ - if(fTestNet) - { - return 0; - } - else - { - return nTotalBlocksEstimate; - } -} - bool IsInitialBlockDownload() { - if (pindexBest == NULL || nBestHeight < (GetTotalBlocksEstimate()-nInitialBlockThreshold)) + if (pindexBest == NULL || nBestHeight < (Checkpoints::GetTotalBlocksEstimate()-nInitialBlockThreshold)) return true; static int64 nLastUpdate; static CBlockIndex* pindexLastBest; @@ -1294,17 +1281,8 @@ bool CBlock::AcceptBlock() return error("AcceptBlock() : contains a non-final transaction"); // Check that the block chain matches the known block chain up to a checkpoint - if (!fTestNet) - if ((nHeight == 11111 && hash != uint256("0x0000000069e244f73d78e8fd29ba2fd2ed618bd6fa2ee92559f542fdb26e7c1d")) || - (nHeight == 33333 && hash != uint256("0x000000002dd5588a74784eaa7ab0507a18ad16a236e7b1ce69f00d7ddfb5d0a6")) || - (nHeight == 68555 && hash != uint256("0x00000000001e1b4903550a0b96e9a9405c8a95f387162e4944e8d9fbe501cd6a")) || - (nHeight == 70567 && hash != uint256("0x00000000006a49b14bcf27462068f1264c961f11fa2e0eddd2be0791e1d4124a")) || - (nHeight == 74000 && hash != uint256("0x0000000000573993a3c9e41ce34471c079dcf5f52a0e824a81e7f953b8661a20")) || - (nHeight == 105000 && hash != uint256("0x00000000000291ce28027faea320c8d2b054b2e0fe44a773f3eefb151d6bdc97")) || - (nHeight == 118000 && hash != uint256("0x000000000000774a7f8a7a12dc906ddb9e17e75d684f15e00f8767f9e8f36553")) || - (nHeight == 134444 && hash != uint256("0x00000000000005b12ffd4cd315cd34ffd4a594f430ac814c91184a0d42d2b0fe")) || - (nHeight == 140700 && hash != uint256("0x000000000000033b512028abb90e1626d8b346fd0ed598ac0a3c371138dce2bd"))) - return error("AcceptBlock() : rejected by checkpoint lockin at %d", nHeight); + if (!Checkpoints::CheckBlock(nHeight, hash)) + return error("AcceptBlock() : rejected by checkpoint lockin at %d", nHeight); // Write block to history file if (!CheckDiskSpace(::GetSerializeSize(*this, SER_DISK))) diff --git a/src/main.h b/src/main.h index c400145d015..f5e7f6c3e37 100644 --- a/src/main.h +++ b/src/main.h @@ -98,7 +98,6 @@ void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int& void FormatHashBuffers(CBlock* pblock, char* pmidstate, char* pdata, char* phash1); bool CheckWork(CBlock* pblock, CWallet& wallet, CReserveKey& reservekey); bool CheckProofOfWork(uint256 hash, unsigned int nBits); -int GetTotalBlocksEstimate(); bool IsInitialBlockDownload(); std::string GetWarnings(std::string strFor); diff --git a/src/makefile.linux-mingw b/src/makefile.linux-mingw index 24cc127c2d8..23b417cad18 100644 --- a/src/makefile.linux-mingw +++ b/src/makefile.linux-mingw @@ -38,6 +38,7 @@ CFLAGS=-O2 -w -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATH HEADERS = \ base58.h \ bignum.h \ + checkpoints.h \ crypter.h \ db.h \ headers.h \ @@ -68,6 +69,7 @@ endif LIBS += -l mingwthrd -l kernel32 -l user32 -l gdi32 -l comdlg32 -l winspool -l winmm -l shell32 -l comctl32 -l ole32 -l oleaut32 -l uuid -l rpcrt4 -l advapi32 -l ws2_32 -l shlwapi OBJS= \ + obj/checkpoints.o \ obj/crypter.o \ obj/db.o \ obj/init.o \ diff --git a/src/makefile.mingw b/src/makefile.mingw index 1ca1a7bbe25..ef7eebf4306 100644 --- a/src/makefile.mingw +++ b/src/makefile.mingw @@ -35,6 +35,7 @@ CFLAGS=-mthreads -O2 -w -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(DEFS) $(I HEADERS = \ base58.h \ bignum.h \ + checkpoints.h \ crypter.h \ db.h \ headers.h \ @@ -66,6 +67,7 @@ endif LIBS += -l kernel32 -l user32 -l gdi32 -l comdlg32 -l winspool -l winmm -l shell32 -l comctl32 -l ole32 -l oleaut32 -l uuid -l rpcrt4 -l advapi32 -l ws2_32 -l shlwapi OBJS= \ + obj/checkpoints.o \ obj/crypter.o \ obj/db.o \ obj/init.o \ diff --git a/src/makefile.osx b/src/makefile.osx index 97264c7eb4c..af526369191 100644 --- a/src/makefile.osx +++ b/src/makefile.osx @@ -35,6 +35,7 @@ CFLAGS=-mmacosx-version-min=10.5 -arch i386 -arch x86_64 -O3 -Wno-invalid-offset HEADERS = \ base58.h \ bignum.h \ + checkpoints.h \ crypter.h \ db.h \ headers.h \ @@ -57,6 +58,7 @@ HEADERS = \ wallet.h OBJS= \ + obj/checkpoints.o \ obj/crypter.o \ obj/db.o \ obj/init.o \ diff --git a/src/makefile.unix b/src/makefile.unix index 9e0b3263d7a..a2cbc7c77e1 100644 --- a/src/makefile.unix +++ b/src/makefile.unix @@ -73,6 +73,7 @@ CXXFLAGS=-O2 -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(DEFS) $(HARDENING) HEADERS = \ base58.h \ bignum.h \ + checkpoints.h \ crypter.h \ db.h \ headers.h \ @@ -95,6 +96,7 @@ HEADERS = \ wallet.h OBJS= \ + obj/checkpoints.o \ obj/crypter.o \ obj/db.o \ obj/init.o \ diff --git a/src/makefile.vc b/src/makefile.vc index a5437bcf5cd..4c81cc400fc 100644 --- a/src/makefile.vc +++ b/src/makefile.vc @@ -48,6 +48,7 @@ CFLAGS=/MD /c /nologo /EHsc /GR /Zm300 $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS) HEADERS = \ base58.h \ bignum.h \ + checkpoints.h \ crypter.h \ db.h \ headers.h \ @@ -70,6 +71,7 @@ HEADERS = \ wallet.h OBJS= \ + obj\checkpoints.o \ obj\crypter.o \ obj\db.o \ obj\init.o \ @@ -98,6 +100,8 @@ all: bitcoin.exe .cpp{obj}.obj: cl $(CFLAGS) /DGUI /Fo$@ %s +obj\checkpoints.obj: $(HEADERS) + obj\util.obj: $(HEADERS) obj\script.obj: $(HEADERS) @@ -140,6 +144,8 @@ bitcoin.exe: $(OBJS) $(CRYPTOPP_OBJS) obj\ui.obj obj\uibase.obj obj\ui.res .cpp{obj\nogui}.obj: cl $(CFLAGS) /Fo$@ %s +obj\nogui\checkpoints.obj: $(HEADERS) + obj\nogui\util.obj: $(HEADERS) obj\nogui\script.obj: $(HEADERS) diff --git a/src/test/Checkpoints_tests.cpp b/src/test/Checkpoints_tests.cpp new file mode 100644 index 00000000000..0d8a366d7ac --- /dev/null +++ b/src/test/Checkpoints_tests.cpp @@ -0,0 +1,34 @@ +// +// Unit tests for block-chain checkpoints +// +#include // for 'map_list_of()' +#include +#include + +#include "../checkpoints.h" +#include "../util.h" + +using namespace std; + +BOOST_AUTO_TEST_SUITE(Checkpoints_tests) + +BOOST_AUTO_TEST_CASE(sanity) +{ + uint256 p11111 = uint256("0x0000000069e244f73d78e8fd29ba2fd2ed618bd6fa2ee92559f542fdb26e7c1d"); + uint256 p140700 = uint256("0x000000000000033b512028abb90e1626d8b346fd0ed598ac0a3c371138dce2bd"); + BOOST_CHECK(Checkpoints::CheckBlock(11111, p11111)); + BOOST_CHECK(Checkpoints::CheckBlock(140700, p140700)); + + + // Wrong hashes at checkpoints should fail: + BOOST_CHECK(!Checkpoints::CheckBlock(11111, p140700)); + BOOST_CHECK(!Checkpoints::CheckBlock(140700, p11111)); + + // ... but any hash not at a checkpoint should succeed: + BOOST_CHECK(Checkpoints::CheckBlock(11111+1, p140700)); + BOOST_CHECK(Checkpoints::CheckBlock(140700+1, p11111)); + + BOOST_CHECK(Checkpoints::GetTotalBlocksEstimate() >= 140700); +} + +BOOST_AUTO_TEST_SUITE_END() diff --git a/src/test/test_bitcoin.cpp b/src/test/test_bitcoin.cpp index 0230bb6ecad..645d8a2bdfe 100644 --- a/src/test/test_bitcoin.cpp +++ b/src/test/test_bitcoin.cpp @@ -8,6 +8,7 @@ #include "uint256_tests.cpp" #include "script_tests.cpp" #include "transaction_tests.cpp" +#include "Checkpoints_tests.cpp" CWallet* pwalletMain; From 5d901f1ba0b2f4444e484b9cb3db8d86c428af3f Mon Sep 17 00:00:00 2001 From: Gavin Andresen Date: Thu, 8 Sep 2011 12:51:43 -0400 Subject: [PATCH 33/41] Orphan block fill-up-memory attack prevention --- src/checkpoints.cpp | 32 +++++++++++++++++++++++++----- src/checkpoints.h | 7 +++++++ src/main.cpp | 47 ++++++++++++++++++++++++++++++++++++++++++--- src/main.h | 1 + 4 files changed, 79 insertions(+), 8 deletions(-) diff --git a/src/checkpoints.cpp b/src/checkpoints.cpp index 4419a06c830..c7e054df378 100644 --- a/src/checkpoints.cpp +++ b/src/checkpoints.cpp @@ -2,16 +2,23 @@ // Distributed under the MIT/X11 software license, see the accompanying // file license.txt or http://www.opensource.org/licenses/mit-license.php. -#include "checkpoints.h" -#include "uint256.h" -#include "util.h" - #include // for 'map_list_of()' +#include + +#include "headers.h" +#include "checkpoints.h" namespace Checkpoints { typedef std::map MapCheckpoints; + // + // What makes a good checkpoint block? + // + Is surrounded by blocks with reasonable timestamps + // (no blocks before with a timestamp after, none after with + // timestamp before) + // + Contains no strange transactions + // static MapCheckpoints mapCheckpoints = boost::assign::map_list_of ( 11111, uint256("0x0000000069e244f73d78e8fd29ba2fd2ed618bd6fa2ee92559f542fdb26e7c1d")) @@ -36,8 +43,23 @@ namespace Checkpoints int GetTotalBlocksEstimate() { - if (fTestNet) return 0; // Testnet has no checkpoints + if (fTestNet) return 0; return mapCheckpoints.rbegin()->first; } + + CBlockIndex* GetLastCheckpoint(const std::map& mapBlockIndex) + { + if (fTestNet) return NULL; + + int64 nResult; + BOOST_REVERSE_FOREACH(const MapCheckpoints::value_type& i, mapCheckpoints) + { + const uint256& hash = i.second; + std::map::const_iterator t = mapBlockIndex.find(hash); + if (t != mapBlockIndex.end()) + return t->second; + } + return NULL; + } } diff --git a/src/checkpoints.h b/src/checkpoints.h index 32094fdde62..9d52da404fb 100644 --- a/src/checkpoints.h +++ b/src/checkpoints.h @@ -4,7 +4,11 @@ #ifndef BITCOIN_CHECKPOINT_H #define BITCOIN_CHECKPOINT_H +#include +#include "util.h" + class uint256; +class CBlockIndex; // // Block-chain checkpoints are compiled-in sanity checks. @@ -17,6 +21,9 @@ namespace Checkpoints // Return conservative estimate of total number of blocks, 0 if unknown int GetTotalBlocksEstimate(); + + // Returns last CBlockIndex* in mapBlockIndex that is a checkpoint + CBlockIndex* GetLastCheckpoint(const std::map& mapBlockIndex); } #endif diff --git a/src/main.cpp b/src/main.cpp index dad7d144e7d..af00069d663 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -651,11 +651,32 @@ int64 static GetBlockValue(int nHeight, int64 nFees) return nSubsidy + nFees; } +static const int64 nTargetTimespan = 14 * 24 * 60 * 60; // two weeks +static const int64 nTargetSpacing = 10 * 60; +static const int64 nInterval = nTargetTimespan / nTargetSpacing; + +// +// minimum amount of work that could possibly be required nTime after +// minimum work required was nBase +// +unsigned int ComputeMinWork(unsigned int nBase, int64 nTime) +{ + CBigNum bnResult; + bnResult.SetCompact(nBase); + while (nTime > 0 && bnResult < bnProofOfWorkLimit) + { + // Maximum 400% adjustment... + bnResult *= 4; + // ... in best-case exactly 4-times-normal target time + nTime -= nTargetTimespan*4; + } + if (bnResult > bnProofOfWorkLimit) + bnResult = bnProofOfWorkLimit; + return bnResult.GetCompact(); +} + unsigned int static GetNextWorkRequired(const CBlockIndex* pindexLast) { - const int64 nTargetTimespan = 14 * 24 * 60 * 60; // two weeks - const int64 nTargetSpacing = 10 * 60; - const int64 nInterval = nTargetTimespan / nTargetSpacing; // Genesis block if (pindexLast == NULL) @@ -1317,6 +1338,26 @@ bool static ProcessBlock(CNode* pfrom, CBlock* pblock) if (!pblock->CheckBlock()) return error("ProcessBlock() : CheckBlock FAILED"); + CBlockIndex* pcheckpoint = Checkpoints::GetLastCheckpoint(mapBlockIndex); + if (pcheckpoint && pblock->hashPrevBlock != hashBestChain) + { + // Extra checks to prevent "fill up memory by spamming with bogus blocks" + int64 deltaTime = pblock->GetBlockTime() - pcheckpoint->nTime; + if (deltaTime < 0) + { + return error("ProcessBlock() : block with timestamp before last checkpoint"); + } + CBigNum bnNewBlock; + bnNewBlock.SetCompact(pblock->nBits); + CBigNum bnRequired; + bnRequired.SetCompact(ComputeMinWork(pcheckpoint->nBits, deltaTime)); + if (bnNewBlock > bnRequired) + { + return error("ProcessBlock() : block with too little proof-of-work"); + } + } + + // If don't already have its previous block, shunt it off to holding area until we get it if (!mapBlockIndex.count(pblock->hashPrevBlock)) { diff --git a/src/main.h b/src/main.h index f5e7f6c3e37..876a35d9cc3 100644 --- a/src/main.h +++ b/src/main.h @@ -98,6 +98,7 @@ void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int& void FormatHashBuffers(CBlock* pblock, char* pmidstate, char* pdata, char* phash1); bool CheckWork(CBlock* pblock, CWallet& wallet, CReserveKey& reservekey); bool CheckProofOfWork(uint256 hash, unsigned int nBits); +unsigned int ComputeMinWork(unsigned int nBase, int64 nTime); bool IsInitialBlockDownload(); std::string GetWarnings(std::string strFor); From ba56a88ca5fae52ce5690553d97e4e8ac1338dfd Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Mon, 21 Nov 2011 12:25:00 -0500 Subject: [PATCH 34/41] Move DNS Seed lookup to a new thread. --- src/init.cpp | 5 ----- src/net.cpp | 39 ++++++++++++++++++++++++++++++++++++++- src/net.h | 1 - 3 files changed, 38 insertions(+), 7 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index 68303c19fad..75ecfc574e0 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -519,11 +519,6 @@ bool AppInit2(int argc, char* argv[]) } } - if (GetBoolArg("-nodnsseed")) - printf("DNS seeding disabled\n"); - else - DNSAddressSeed(); - if (mapArgs.count("-paytxfee")) { if (!ParseMoney(mapArgs["-paytxfee"], nTransactionFee)) diff --git a/src/net.cpp b/src/net.cpp index f8f6afde543..1907397fada 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -32,6 +32,7 @@ void ThreadOpenConnections2(void* parg); #ifdef USE_UPNP void ThreadMapPort2(void* parg); #endif +void ThreadDNSAddressSeed2(void* parg); bool OpenNetworkConnection(const CAddress& addrConnect); @@ -1162,8 +1163,28 @@ static const char *strDNSSeed[] = { "dnsseed.bluematt.me", }; -void DNSAddressSeed() +void ThreadDNSAddressSeed(void* parg) { + IMPLEMENT_RANDOMIZE_STACK(ThreadDNSAddressSeed(parg)); + try + { + vnThreadsRunning[6]++; + ThreadDNSAddressSeed2(parg); + vnThreadsRunning[6]--; + } + catch (std::exception& e) { + vnThreadsRunning[6]--; + PrintException(&e, "ThreadDNSAddressSeed()"); + } catch (...) { + vnThreadsRunning[6]--; + throw; // support pthread_cancel() + } + printf("ThreadDNSAddressSeed exiting\n"); +} + +void ThreadDNSAddressSeed2(void* parg) +{ + printf("ThreadDNSAddressSeed started\n"); int found = 0; if (!fTestNet) @@ -1196,6 +1217,15 @@ void DNSAddressSeed() + + + + + + + + + unsigned int pnSeed[] = { 0x6884ac63, 0x3ffecead, 0x2919b953, 0x0942fe50, 0x7a1d922e, 0xcdd6734a, 0x953a5bb6, 0x2c46922e, @@ -1703,6 +1733,12 @@ void StartNode(void* parg) // Start threads // + if (GetBoolArg("-nodnsseed")) + printf("DNS seeding disabled\n"); + else + if (!CreateThread(ThreadDNSAddressSeed, NULL)) + printf("Error: CreateThread(ThreadDNSAddressSeed) failed\n"); + // Map ports with UPnP if (fHaveUPnP) MapPort(fUseUPnP); @@ -1749,6 +1785,7 @@ bool StopNode() if (vnThreadsRunning[3] > 0) printf("ThreadBitcoinMiner still running\n"); if (vnThreadsRunning[4] > 0) printf("ThreadRPCServer still running\n"); if (fHaveUPnP && vnThreadsRunning[5] > 0) printf("ThreadMapPort still running\n"); + if (vnThreadsRunning[6] > 0) printf("ThreadDNSAddressSeed still running\n"); while (vnThreadsRunning[2] > 0 || vnThreadsRunning[4] > 0) Sleep(20); Sleep(50); diff --git a/src/net.h b/src/net.h index 0026e402c2c..741e2a812ec 100644 --- a/src/net.h +++ b/src/net.h @@ -40,7 +40,6 @@ CNode* ConnectNode(CAddress addrConnect, int64 nTimeout=0); void AbandonRequests(void (*fn)(void*, CDataStream&), void* param1); bool AnySubscribed(unsigned int nChannel); void MapPort(bool fMapPort); -void DNSAddressSeed(); bool BindListenPort(std::string& strError=REF(std::string())); void StartNode(void* parg); bool StopNode(); From 16e7c05de71a2c215e3b74522bf34d8e0da3381e Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Sat, 3 Dec 2011 21:48:32 -0500 Subject: [PATCH 35/41] Move -lgdi32 after -lcrypto (fixes #681). --- bitcoin-qt.pro | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bitcoin-qt.pro b/bitcoin-qt.pro index 8fc177f7f48..66b53c23677 100644 --- a/bitcoin-qt.pro +++ b/bitcoin-qt.pro @@ -251,7 +251,7 @@ isEmpty(BOOST_INCLUDE_PATH) { macx:BOOST_INCLUDE_PATH = /opt/local/include } -windows:LIBS += -lws2_32 -lgdi32 +windows:LIBS += -lws2_32 windows:DEFINES += WIN32 windows:RC_FILE = src/qt/res/bitcoin-qt.rc @@ -266,6 +266,8 @@ macx:TARGET = "Bitcoin-Qt" INCLUDEPATH += $$BOOST_INCLUDE_PATH $$BDB_INCLUDE_PATH $$OPENSSL_INCLUDE_PATH LIBS += $$join(BOOST_LIB_PATH,,-L,) $$join(BDB_LIB_PATH,,-L,) $$join(OPENSSL_LIB_PATH,,-L,) LIBS += -lssl -lcrypto -ldb_cxx$$BDB_LIB_SUFFIX +# -lgdi32 has to happen after -lcrypto (see #681) +windows:LIBS += -lgdi32 LIBS += -lboost_system$$BOOST_LIB_SUFFIX -lboost_filesystem$$BOOST_LIB_SUFFIX -lboost_program_options$$BOOST_LIB_SUFFIX -lboost_thread$$BOOST_THREAD_LIB_SUFFIX contains(RELEASE, 1) { From 9a7f4948c6e63e9470b14b0f8b61c8ecbf21f00f Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Wed, 7 Dec 2011 10:26:55 -0500 Subject: [PATCH 36/41] Re-enable RPCSSL in gitian builds. --- contrib/gitian-descriptors/gitian-win32.yml | 4 ++-- contrib/gitian-descriptors/gitian.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/contrib/gitian-descriptors/gitian-win32.yml b/contrib/gitian-descriptors/gitian-win32.yml index 37dcb8d0b5f..0f4670979ef 100644 --- a/contrib/gitian-descriptors/gitian-win32.yml +++ b/contrib/gitian-descriptors/gitian-win32.yml @@ -71,7 +71,7 @@ script: | export LD_PRELOAD=/usr/lib/faketime/libfaketime.so.1 export FAKETIME=$REFERENCE_DATETIME export TZ=UTC - $HOME/qt/src/bin/qmake -spec unsupported/win32-g++-cross MINIUPNPC_LIB_PATH=$HOME/build/miniupnpc MINIUPNPC_INCLUDE_PATH=$HOME/build/ BDB_LIB_PATH=$HOME/build/db-4.8.30.NC/build_unix BDB_INCLUDE_PATH=$HOME/build/db-4.8.30.NC/build_unix BOOST_LIB_PATH=$HOME/build/boost_1_47_0/stage/lib BOOST_INCLUDE_PATH=$HOME/build/boost_1_47_0 BOOST_LIB_SUFFIX=-mt-s BOOST_THREAD_LIB_SUFFIX=_win32-mt-s OPENSSL_LIB_PATH=$HOME/build/openssl-1.0.0e OPENSSL_INCLUDE_PATH=$HOME/build/openssl-1.0.0e/include INCLUDEPATH=$HOME/build DEFINES=BOOST_THREAD_USE_LIB BITCOIN_NEED_QT_PLUGINS=1 QMAKE_LRELEASE=lrelease QMAKE_CXXFLAGS=-frandom-seed=bitcoin QMAKE_LFLAGS=-frandom-seed=bitcoin + $HOME/qt/src/bin/qmake -spec unsupported/win32-g++-cross USE_SSL=1 MINIUPNPC_LIB_PATH=$HOME/build/miniupnpc MINIUPNPC_INCLUDE_PATH=$HOME/build/ BDB_LIB_PATH=$HOME/build/db-4.8.30.NC/build_unix BDB_INCLUDE_PATH=$HOME/build/db-4.8.30.NC/build_unix BOOST_LIB_PATH=$HOME/build/boost_1_47_0/stage/lib BOOST_INCLUDE_PATH=$HOME/build/boost_1_47_0 BOOST_LIB_SUFFIX=-mt-s BOOST_THREAD_LIB_SUFFIX=_win32-mt-s OPENSSL_LIB_PATH=$HOME/build/openssl-1.0.0e OPENSSL_INCLUDE_PATH=$HOME/build/openssl-1.0.0e/include INCLUDEPATH=$HOME/build DEFINES=BOOST_THREAD_USE_LIB BITCOIN_NEED_QT_PLUGINS=1 QMAKE_LRELEASE=lrelease QMAKE_CXXFLAGS=-frandom-seed=bitcoin QMAKE_LFLAGS=-frandom-seed=bitcoin make $MAKEOPTS cp release/bitcoin-qt.exe $OUTDIR/ # @@ -80,7 +80,7 @@ script: | export LD_PRELOAD=/usr/lib/faketime/libfaketime.so.1 export FAKETIME=$REFERENCE_DATETIME export TZ=UTC - make -f makefile.linux-mingw $MAKEOPTS DEPSDIR=$HOME/build bitcoind.exe USE_UPNP=0 + make -f makefile.linux-mingw $MAKEOPTS DEPSDIR=$HOME/build bitcoind.exe USE_SSL=1 USE_UPNP=0 i586-mingw32msvc-strip bitcoind.exe makensis ../share/setup.nsi cp ../share/bitcoin-*-win32-setup.exe $OUTDIR/ diff --git a/contrib/gitian-descriptors/gitian.yml b/contrib/gitian-descriptors/gitian.yml index 84ecac6ff49..47164b0afd4 100644 --- a/contrib/gitian-descriptors/gitian.yml +++ b/contrib/gitian-descriptors/gitian.yml @@ -39,10 +39,10 @@ script: | cp $OUTDIR/src/COPYING $OUTDIR cd src sed 's/$(DEBUGFLAGS)//' -i makefile.unix - make -f makefile.unix STATIC=1 DEFS="-I$INSTDIR/include -L$INSTDIR/lib" $MAKEOPTS bitcoind USE_UPNP=0 + make -f makefile.unix STATIC=1 DEFS="-I$INSTDIR/include -L$INSTDIR/lib" $MAKEOPTS bitcoind USE_UPNP=0 USE_SSL=1 mkdir -p $OUTDIR/bin/$GBUILD_BITS install -s bitcoind $OUTDIR/bin/$GBUILD_BITS cd .. - qmake INCLUDEPATH="$INSTDIR/include" LIBS="-L$INSTDIR/lib" RELEASE=1 + qmake INCLUDEPATH="$INSTDIR/include" LIBS="-L$INSTDIR/lib" RELEASE=1 USE_SSL=1 make $MAKEOPTS install bitcoin-qt $OUTDIR/bin/$GBUILD_BITS From 142e5056cd8a62df838e9a3afee0f718faffd72b Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Tue, 13 Dec 2011 16:28:56 +0100 Subject: [PATCH 37/41] Enable wordwrap for long message in passphrase dialog - Remove explicit resizing from constructor to prevent potential hang --- src/qt/askpassphrasedialog.cpp | 1 - src/qt/forms/askpassphrasedialog.ui | 20 +++++--------------- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/src/qt/askpassphrasedialog.cpp b/src/qt/askpassphrasedialog.cpp index a574ef925b0..b52acf4545e 100644 --- a/src/qt/askpassphrasedialog.cpp +++ b/src/qt/askpassphrasedialog.cpp @@ -47,7 +47,6 @@ AskPassphraseDialog::AskPassphraseDialog(Mode mode, QWidget *parent) : ui->warningLabel->setText(tr("Enter the old and new passphrase to the wallet.")); break; } - resize(minimumSize()); // Get rid of extra space in dialog textChanged(); connect(ui->passEdit1, SIGNAL(textChanged(QString)), this, SLOT(textChanged())); diff --git a/src/qt/forms/askpassphrasedialog.ui b/src/qt/forms/askpassphrasedialog.ui index 70d9180e752..3c7dac5f8dd 100644 --- a/src/qt/forms/askpassphrasedialog.ui +++ b/src/qt/forms/askpassphrasedialog.ui @@ -6,8 +6,8 @@ 0 0 - 589 - 228 + 598 + 187 @@ -34,6 +34,9 @@ Qt::RichText + + true + @@ -85,19 +88,6 @@ - - - - Qt::Vertical - - - - 20 - 40 - - - - From 181b863d224b5236b53309e7cb12b3927b240d70 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Tue, 13 Dec 2011 14:00:21 -0500 Subject: [PATCH 38/41] Fix status bar not displaying Alerts. --- src/qt/bitcoin.cpp | 2 ++ src/qt/bitcoingui.cpp | 40 +++++++++++++++++++++++++++++++++++----- src/qt/bitcoingui.h | 2 ++ src/qt/clientmodel.cpp | 5 +++++ src/qt/clientmodel.h | 2 ++ 5 files changed, 46 insertions(+), 5 deletions(-) diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp index 6afa9671d0b..2142db5a364 100644 --- a/src/qt/bitcoin.cpp +++ b/src/qt/bitcoin.cpp @@ -91,6 +91,8 @@ void UIThreadCall(boost::function0 fn) void MainFrameRepaint() { + if(guiref) + QMetaObject::invokeMethod(guiref, "refreshStatusBar", Qt::QueuedConnection); } void InitMessage(const std::string &message) diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index 8641c723b0a..5968aab6c41 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -2,6 +2,7 @@ * Qt4 bitcoin GUI. * * W.J. van der Laan 2011 + * The Bitcoin Developers 2011 */ #include "bitcoingui.h" #include "transactiontablemodel.h" @@ -412,15 +413,31 @@ void BitcoinGUI::setNumBlocks(int count) if(count < total) { - progressBarLabel->setVisible(true); - progressBar->setVisible(true); - progressBar->setMaximum(total - initTotal); - progressBar->setValue(count - initTotal); + if (clientModel->getStatusBarWarnings() == "") + { + progressBarLabel->setVisible(true); + progressBarLabel->setText(tr("Synchronizing with network...")); + progressBar->setVisible(true); + progressBar->setMaximum(total - initTotal); + progressBar->setValue(count - initTotal); + } + else + { + progressBarLabel->setText(clientModel->getStatusBarWarnings()); + progressBarLabel->setVisible(true); + progressBar->setVisible(false); + } tooltip = tr("Downloaded %1 of %2 blocks of transaction history.").arg(count).arg(total); } else { - progressBarLabel->setVisible(false); + if (clientModel->getStatusBarWarnings() == "") + progressBarLabel->setVisible(false); + else + { + progressBarLabel->setText(clientModel->getStatusBarWarnings()); + progressBarLabel->setVisible(true); + } progressBar->setVisible(false); tooltip = tr("Downloaded %1 blocks of transaction history.").arg(count); } @@ -469,6 +486,19 @@ void BitcoinGUI::setNumBlocks(int count) progressBar->setToolTip(tooltip); } +void BitcoinGUI::refreshStatusBar() +{ + /* Might display multiple times in the case of multiple alerts + static QString prevStatusBar; + QString newStatusBar = clientModel->getStatusBarWarnings(); + if (prevStatusBar != newStatusBar) + { + prevStatusBar = newStatusBar; + error(tr("Network Alert"), newStatusBar); + }*/ + setNumBlocks(clientModel->getNumBlocks()); +} + void BitcoinGUI::error(const QString &title, const QString &message) { // Report errors from network/worker thread diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h index a9121921965..581d3937490 100644 --- a/src/qt/bitcoingui.h +++ b/src/qt/bitcoingui.h @@ -96,6 +96,8 @@ public slots: void setNumConnections(int count); void setNumBlocks(int count); void setEncryptionStatus(int status); + /** Set the status bar text if there are any warnings (removes sync progress bar if applicable) */ + void refreshStatusBar(); void error(const QString &title, const QString &message); /* It is currently not possible to pass a return value to another thread through diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp index 2ed3ce51dfc..5a0b4aa83ca 100644 --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -72,6 +72,11 @@ int ClientModel::getNumBlocksOfPeers() const return GetNumBlocksOfPeers(); } +QString ClientModel::getStatusBarWarnings() const +{ + return QString::fromStdString(GetWarnings("statusbar")); +} + OptionsModel *ClientModel::getOptionsModel() { return optionsModel; diff --git a/src/qt/clientmodel.h b/src/qt/clientmodel.h index c68fb0f0354..0b7c16d7a98 100644 --- a/src/qt/clientmodel.h +++ b/src/qt/clientmodel.h @@ -33,6 +33,8 @@ public: bool inInitialBlockDownload() const; // Return conservative estimate of total number of blocks, or 0 if unknown int getNumBlocksOfPeers() const; + //! Return warnings to be displayed in status bar + QString getStatusBarWarnings() const; QString formatFullVersion() const; From 1f53204045313eb0243c7b2372d241105c257ca2 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Thu, 15 Dec 2011 19:25:29 -0500 Subject: [PATCH 39/41] Bump version to 0.4.3 --- contrib/Bitcoin.app/Contents/Info.plist | 2 +- doc/README | 2 +- doc/README_windows.txt | 2 +- share/setup.nsi | 6 +++--- src/serialize.h | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/contrib/Bitcoin.app/Contents/Info.plist b/contrib/Bitcoin.app/Contents/Info.plist index 9145db10f15..1d520c93cf9 100644 --- a/contrib/Bitcoin.app/Contents/Info.plist +++ b/contrib/Bitcoin.app/Contents/Info.plist @@ -17,7 +17,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 0.4.2 + 0.4.3 CFBundleSignature ???? CFBundleVersion diff --git a/doc/README b/doc/README index 9c28f4c6929..d91509bd90d 100644 --- a/doc/README +++ b/doc/README @@ -1,4 +1,4 @@ -Bitcoin 0.4.2 BETA +Bitcoin 0.4.3 BETA Copyright (c) 2009-2011 Bitcoin Developers Distributed under the MIT/X11 software license, see the accompanying diff --git a/doc/README_windows.txt b/doc/README_windows.txt index 7a406d65a37..2f5761645a8 100644 --- a/doc/README_windows.txt +++ b/doc/README_windows.txt @@ -1,4 +1,4 @@ -Bitcoin 0.4.2 BETA +Bitcoin 0.4.3 BETA Copyright (c) 2009-2011 Bitcoin Developers Distributed under the MIT/X11 software license, see the accompanying diff --git a/share/setup.nsi b/share/setup.nsi index 4500dc48e1b..3455f7681cb 100644 --- a/share/setup.nsi +++ b/share/setup.nsi @@ -5,7 +5,7 @@ SetCompressor /SOLID lzma # General Symbol Definitions !define REGKEY "SOFTWARE\$(^Name)" -!define VERSION 0.4.2 +!define VERSION 0.4.3 !define COMPANY "Bitcoin project" !define URL http://www.bitcoin.org/ @@ -45,13 +45,13 @@ Var StartMenuGroup !insertmacro MUI_LANGUAGE English # Installer attributes -OutFile bitcoin-0.4.2-win32-setup.exe +OutFile bitcoin-0.4.3-win32-setup.exe InstallDir $PROGRAMFILES\Bitcoin CRCCheck on XPStyle on BrandingText " " ShowInstDetails show -VIProductVersion 0.4.2.0 +VIProductVersion 0.4.3.0 VIAddVersionKey ProductName Bitcoin VIAddVersionKey ProductVersion "${VERSION}" VIAddVersionKey CompanyName "${COMPANY}" diff --git a/src/serialize.h b/src/serialize.h index 64fae0367ea..7876990d04e 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 = 40200; +static const int VERSION = 40300; static const char* pszSubVer = ""; static const bool VERSION_IS_BETA = true; From ace5ce05bef68722a060d6ec6e7d1fbf307d9835 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Thu, 15 Dec 2011 19:34:37 -0500 Subject: [PATCH 40/41] Bump version to 0.5.0.3 --- bitcoin-qt.pro | 2 +- doc/README | 2 +- doc/README_windows.txt | 2 +- share/setup.nsi | 6 +++--- src/serialize.h | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/bitcoin-qt.pro b/bitcoin-qt.pro index 65a31f6d682..1eddcd542b4 100644 --- a/bitcoin-qt.pro +++ b/bitcoin-qt.pro @@ -1,6 +1,6 @@ TEMPLATE = app TARGET = -VERSION = 0.5.0.2 +VERSION = 0.5.0.3 INCLUDEPATH += src src/json src/qt DEFINES += QT_GUI BOOST_THREAD_USE_LIB CONFIG += no_include_pwd diff --git a/doc/README b/doc/README index ab19734d1d3..c3ed9c4b7e3 100644 --- a/doc/README +++ b/doc/README @@ -1,4 +1,4 @@ -Bitcoin 0.5.0.2 BETA +Bitcoin 0.5.0.3 BETA Copyright (c) 2009-2011 Bitcoin Developers Distributed under the MIT/X11 software license, see the accompanying diff --git a/doc/README_windows.txt b/doc/README_windows.txt index d54f18ec62e..8a8f82b846d 100644 --- a/doc/README_windows.txt +++ b/doc/README_windows.txt @@ -1,4 +1,4 @@ -Bitcoin 0.5.0.2 BETA +Bitcoin 0.5.0.3 BETA Copyright (c) 2009-2011 Bitcoin Developers Distributed under the MIT/X11 software license, see the accompanying diff --git a/share/setup.nsi b/share/setup.nsi index 2674597ee1e..76efe57d27f 100644 --- a/share/setup.nsi +++ b/share/setup.nsi @@ -5,7 +5,7 @@ SetCompressor /SOLID lzma # General Symbol Definitions !define REGKEY "SOFTWARE\$(^Name)" -!define VERSION 0.5.0.2 +!define VERSION 0.5.0.3 !define COMPANY "Bitcoin project" !define URL http://www.bitcoin.org/ @@ -45,13 +45,13 @@ Var StartMenuGroup !insertmacro MUI_LANGUAGE English # Installer attributes -OutFile bitcoin-0.5.0.2-win32-setup.exe +OutFile bitcoin-0.5.0.3-win32-setup.exe InstallDir $PROGRAMFILES\Bitcoin CRCCheck on XPStyle on BrandingText " " ShowInstDetails show -VIProductVersion 0.5.0.2 +VIProductVersion 0.5.0.3 VIAddVersionKey ProductName Bitcoin VIAddVersionKey ProductVersion "${VERSION}" VIAddVersionKey CompanyName "${COMPANY}" diff --git a/src/serialize.h b/src/serialize.h index d1296ed68f0..fdfd6346e99 100644 --- a/src/serialize.h +++ b/src/serialize.h @@ -60,7 +60,7 @@ class CDataStream; class CAutoFile; static const unsigned int MAX_SIZE = 0x02000000; -static const int VERSION = 50002; +static const int VERSION = 50003; static const char* pszSubVer = ""; static const bool VERSION_IS_BETA = true; From 5fe2dbd7b6a182b90128371f8e8d679d70133d6b Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Fri, 16 Dec 2011 17:47:50 -0500 Subject: [PATCH 41/41] Update debian changelog to 0.5.0.3. --- contrib/debian/changelog | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/contrib/debian/changelog b/contrib/debian/changelog index 63551410364..bef58c982fc 100644 --- a/contrib/debian/changelog +++ b/contrib/debian/changelog @@ -1,3 +1,9 @@ +bitcoin (0.5.0.3-natty0) natty; urgency=low + + * New upstream release. + + -- Matt Corallo Fri, 16 Dec 2011 13:27:00 -0500 + bitcoin (0.5.0-natty0) natty; urgency=low * New upstream release.