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 001/154] 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 002/154] 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 003/154] 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 004/154] 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 005/154] 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 006/154] 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 007/154] 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 008/154] 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 009/154] 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 010/154] 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 011/154] 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 012/154] 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 013/154] 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 014/154] 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 015/154] 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 016/154] 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 017/154] 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 018/154] 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 019/154] 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 020/154] 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 021/154] 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 022/154] 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 023/154] 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 024/154] 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 025/154] 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 026/154] 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 027/154] 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 028/154] 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 029/154] 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_Z>Ps@rFQ;l-s(F@+eAN8QoIOZ6AJ1mihqP8OPHob zl21cbB%HF1Dw((vlbM#8$6!wr@mK^C__%vNr}~HKI#fM0YPVNUNp z?jW(QgEQ|KbRIfp_yh0O0)P7e|L3NmiRd|Zdhd@obv&4YPRYbBoNd1#CCQD;ts=`3 zvLX|YnPA&!E|sZHg~Ieia?)I+c_gxC6mhd(Vb{ASIe+FnEloS?1?Jy?hDj^C)Zad7 z%O&aG3FA`>e*EJJl-Tljo#TrL%tQ-8%0&=;~f?+-Gz zzm4~g4{0_XzC={ruxtfHu`;bgIS3*m*{p>hudoj&|wM#=Qc22hey$hra><3ZCrz zyl>a!-u*~P$@B^eM}Ny$uxT$--5L!CI%#YPb9OAkfEp%j3^UwuD%RI>xNo%6-)a-6 zHxc!~384F8LwSt=01gt%m#ot zC9D$yyBRnS4E;BYUK4>o*vvZ5{?=8!!~GV<-s_ z9w`oK8wIs;X%eMH2$7Pfn;^AS+q4p(Ncj;}t<+QviA0prHh(}-8@Y{;2n5O-!}{&m z-q`E6y-a6Dmji5!;ME%iz($SqGjWnOmIl6bQBBkWNi3o_lD^h_#t3Uu?04$7Dxpow~wU2nJT{W?QcHtTz@3Osx2C8zPsvK zeERm!e+DFA$MdScvEsFT_r0oSw{N7by`8O3qnE1Zi`Qx;c|QO=Qxi}GxGd0A&=e4#=F!qUPgL!DB(IvWxJ5W-5{?_>_;T32 za4&6sL2ltF6}wA!G9%+VfHJiTC~you z+^6w34u4RxD#`4x7k?j@YyCZFfrO;Zj3xRjKdP>IDAk%tW8XLeg_tRDX)02}U?k4B zzPODwp2ukobg_J^D>rS+f_b-c$Y5Gs`kJ(9mZPNeE&|i6w5hfuayi zSd7Gz)U0`yyyX4#g#xUo&Z=;h&8h)X)w?RY1b>o1!pOuK+VpVMnqNG;V3((*SI{3x zlCZ$A6p}*46cW=0MNt`!8VEEFY&?KBwt&=ZiNoV82j)4r69R-SkQ3W0m>a!w^!3Y% z%Qh{YyRxLnv5dYxFjawNDcC}wJO5$o(iDUQ(-QbnR5HB|oT`^43ko^>yYpuJO3!t` z`hV8~79?Y)4@dHTZ@O!1#p;sHo0hJgS5f#SWp?Uv5{8@l<}T{%Pcx^e978zKYyk?` z5-bTW^+rq#z84|jR}HUo;-a76yPfAqn8$#Q&j?5fid0-y!mRY=$wwEL&e`-x`MO09 zEn3IY^l~(G2BXk1U@&IJ$j+U?Xe317V}C#S6B1?;VwONi1qmdjVA?bf4i%0x{gK*^ zlQg~)?4Un%3^)zMZwjbRrC3i9JId$Tn>TN$E~+Z4au;V5qmzZOAvkOhHpWmD4coRs zfF(8N6qeA~c$J>+7BX{-iJJzNCNV6@jC2=zipJjpevWj$P2KUqsCgmqK2Qq`eShXO zoIh7TSh?B0@9|xiSnS+M?gOid8G_ES7?FgD$L+xD(ik%=JQFJl^oC>jd}-ttl+fH- zM>rJ3n~_H}5hGo9pzCgWLt`B6cmsc3nEqo;r;+j)&~(c_5csI?_mL3~@9kK~Ay+=9 zdcdU#Oxr?tX*gAtMAAl)fD|Nc3xA)k5jSE8%|$^$DZ{<3M8`(J>A~sNF%nSw@jS~;B)W%az%^H*BNdzqP*h7gkeF$0IDpsJ9x z1v#m%$svEk~?cQ8EH9; zbhhzHZ-B<|A80x^mK>?|p8)<01pfVLDDCdX<1H@+FS<3HUdhn&9?XJIM^M7h{jI4dn<5*IG zA|>kNyVrV#`KZ5{OT(9l$V=!}ALHG_v|b#JH=m7k7}tl7gFFOW2e=yn(47VIw=F-m zWM}rW(z741FkHdX-N(uDx;YuVL`$TZ-dF?U(Kf_Tl&)(-iRO#LJwuJ5W=0ZMkoFbe zGSCUwcP{`;OkU;M=YQ7yDQ%0IRoCB68DC~zb~?5dz~~#L?Q)NK^-Q2A+#YLXFnSRo zuK{h7!!`;endCnc0F=V)UE5yX@XHk|3utTXptEUIbes?NbkudWiXpQeOI`-q0CWL^ zw|sP}0%)qkRg|;Wm*M`}NLM%{`^FovZj`qH_yh<632x8S1tlhN0rLSJ7@Uka_kjQ3 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}KN9dtOxz&8kpHc@wBL*${BfZt`W6lg z7gKG@ZaI>7~U{kTf-b zlmG1Y-L9fq#nyAo8^es4dY4$!CXqh#h3jX~-OdCpFd65$0|Ye>4E^zM`)G{ja+?nk zTM-cpd3En}<^mgJ7N7FL&g!jyn4=xDX`$+mgal){z_Rnmfuj@l%wtxy4s9Tqs zia3H|JLV_5Vo1(ag*OU5lKiYs_OS0rplhO_sO{Q#2TYWF$w#)O0hDF*Ls9LizBM+z z;zt`}hOlO;@$weLu4y2|Ezp$e!Rd8~^W5iRc#3y4Cw11i1m)gelUT2Z++lOd23o~> zQmY>}$815DX$Tyleb&9SRS`lw1c+kqW)aJi%2{lN_m^ok;$C5cg%3Gz!d0g)4624C zMSE)Y9Pf}A-Rb=Ow4;EGLxzhA+bTxcGbq<5b%(}qFL%BOMh&<`AMgZ(8Z7MU78i4(EwR(A+cQh4k5PH{+HNANl%Uupft)mQ zxjG*?*KE0-*OrEc(}z+!Rk-?8io9~+QmA~Nu2I1xcDddAVeNj5c5mnJDjMu}QkLG% z?CZ~YrkmYC$bdABmnTl7$yg0gHH8+c6B*nby(CO0oqc**ozs1`zE;+ZKd||9odeY+ ztT}4CD|h*lgVr!OhbLrTUj2p1We&p=mt*A@?z9Zgef#0Bukjpjwhe5LP6N40zmE3B z9)5d8ux!^(4q)2JOFTy@VAsBYIk1YqZod#EWbqN~a&kEG7(d*;Bzf8H2NMZiA|Opu zo}}X8Rp@Ya<9g{P9bwk76$vTHnIzZ?ZeljpN! z7q&13OQHg@bSzRLxCW^;MqLGO0uw5&AZ#On+#NKK-9H}2k#;7I`qlcy05m7MttG9YRC& z8XjG>jrJsFe`MzGVcENA6tki=7^GmXeCXRg|I> zd^y8_y5G~jmZR*4Q_U};{Y3`42}_WqoeT|sTBdxge^@Q{>^rYbFU}UlKgvDlv^#9- zZY5;YIJkhK=H<@#fsFNTnoL(3G?q6y5g2w8`WBlStX5@39+D>>avx5%0;Ub|c6_i$ zS#E-VDP}omC=7XSPhQRB&vw7{E$OK2%^ZI)R*krvM&p01uura>4TUNm9`Uy}u85Jz zH073sgmz+x>rvlCgMV@e`j@~2HFYuj`mJ=ty6bcvFZ0?g_w||B{Cc-d6xci``KD|A zsUEYNjNQFml#1IAjms?u+)6Qga%We<`%A|=PxAc}hKh5_LWZS$4PD^LpMqng6!>V+ zEb$N@M9e+#_3;I?Tr6-$?Ahdl$NM_1;nDdU3&tQpvtY(UD;WqE?i<>c@a_|EFGAqA7UqoUlZ#NN z0sF@XsR<&?kyW#94~LU=!mlkUX($b2H9K$5Se*Fy>9_{pz12N`GJ_h|^YFdqeb`*R?=_3_A;N0!nN_*>% z6o5Hte>lD3jg&8>u9`?;(ZuTN4eJW~KWb=Db)4=bUAiwRb-fy=yJttP_Eodjj(&i} z+!C+!o3AhAF6Qh7pG%kWF&6tR6*0oV!`w6v7{Ig7Mz%8!pX0JsME$!{(mWT*i+f;1 zq4Dpboea$<#r|z_HAeFGR>p+3YTX@|b z9>*4odr+UOfw>}NW@Pglj-mT1a2r~?Y8mL>&AP^$O{3EH+MglO854O#p|?#_0MuHE z=04d z1qyujnVb2{;dutCNMt^taJ8_elZ^xNX96_$<+b7otDLL+Q-+twVd;!1X6lV<@9^_> zn5Mg#C3r1%P+cQ`H4-8zN#6W>ji<)OAp6}Jkk-%4=DQjOUwUg_|NOnMj^PNg93F7* zE>uW6?)#otS7P`~|6^juy1|uO4zUY+*wkL^=Lsy zFZtW&T+dFxA*lYFoy&68w?gv?DGwXTsI-&tZ@!8t#5%04l9*8QSq7p zFnr}tO0xS8MovDsLEYF{WjVml#vAhhbeoH0I%^t`d>mAf>*2Q>IsZG??)!RU4rkU0 z*bM>mc-!lkMOBx7)Ut|u-?`G5<)e{~6IU76NU6>{T@oJNH?+OT=@u9E>+QAF-vU~q zTLg=poK~IMFM}8)!ACsj9jQuFpuXkKCmVmdJ0^#E`2zh(QsfOMp2R$5?E03nX!mEW zKxljZe$X5v?E|rXje~t;+ldA3XO5^-gv)1|69;b+?a@I zs_x*TsX+!rl!(sc!&3sTY(s48kp00enZ7}73Hbn3)liB66`1oDt**Z_d*hDKtL&&I z;HT5erK21nju2kn`qtc0O?2lxjr&cJjHai-!%iF1bC1}zAgabdM`i|?l7@mn$IY+% z8~{fc*|+b6{2RJ7jt{>xom|vXl4x&!2AgR$~Rs zU6*GyIbrMDvu2!22^Vj5)Qp_Hw9|5sE0Z>x_`dHR&+(_-nWA31sd_L8NB=FqX9H3- zOR*V|#O@E$N7W<#5fMfl(0Z1@=Pt(Snh$0UALZ^}T;*vl_8I-R&#-80^S4rdGH6U) zi5AK&6(Nc4?eS5*agDN>6%P(zzdy zGR^{=OtDk3Y?8F*Qt_%ytTaQRBk(zOar&&kkw6%H8EmPq?2lh^IIifK*@+Q#-*76{ zo|u?OfBE+Thq6(*PDvRlizNIvSvE||TB{Ouo}M+x8F>`s6qU3>(UpvP>fEw62x_bG zpOquqwCXB)PYdi2MOAZ`3>MiCkFX~T8z{fuU&0pZDtYxlP7HScu?2;tQrE zWVq$4-kDs%ftDUkcl|foiElz>zU9!kE3EW7<9b~+rRMCZ|C2*EHs|Vw*i**!IUfYi zxH<%Ej&c#qF6P9E86%mNibD0X@9_(Q7{>*C@fTJ(k$+yT-7QP@~U`;6^8U`wHFGlN{Rf0Of&S9aOg=vG3IK zyW2qi_gnVoub<%P%xbAB&AnYDtkPNcoEOG>vLip84|O-I8=Lz8eWeUV5U~z2kTnW7 z)@171N+l=>FoW{d(ZdRg_9H}kF0GdL+TN6qFq`$Z`}I%Zp*P{z4%bGy3@`Pn$l3yM zON$tXJ>ds055W39E#`9iDja#1g4&^)iKza`|HL>7#S*9I21 zKO%XkG7@yMn#sSx3-rduFmQr$QQwT8aS$1gfk!PSJIzM?QinAYW|w8nJYO>yMd&yrLME5P9Fzvf@Rwz~7MPXPc%+Cqdped|Fq)~$!U)W>h}$iYm@9dXxjaX87COF6x@lwQS(AVI zb|h)@bq2I zZmuD4JyGErZQmbHbuts3>R0^@t=)A4W&q-I@@uC@0M7jBf11G0RRL!Y^OcD;0rF^B zhI7X;qzIu>O>2|WQy8U>XA)V{YfeGFp>Xb!b5G}t1^J_67@~ggYn9~8qI6XLv#rDBvZu-hUuwMd;9#aRzKBJI1$l} ztlk6~=HGWYq)z$so8M7vu}=ZpMxW@!NLe%bFB}^}18y(f%yQN4WK{iR%?8}eY*&dp zx2f0KgIWVZ{RwU1Zp>a1kTPq7@xNgZeUKH&m>cp!8t3@uSz;m=fU39G@@?~3FgGh= z@JVAffbg!dw0<{sa@u9I>(f4jU2za6;X@EM8i_hw)@6%B&06&@mbB9#;cNKysyP}( zvr<#JI0&FZkE;VUFk(z64!g-fmnh?9=JD-{dfHIt&p@h{fJ1C}&X6z>{ODg2B2$rv z`S@hLMS2yY0+d~ z->N$w%(iM839G)QdPb5=TloP|kZf;`wavBJuq>{nfjqr;Az+9hV!pC?+|nzaM!f@g zs^FxkLLw%>x5WZJe!v;>4e{e6VQH-@AOw5nQU_Qtr|nY6O6`T6T*7b+-9Y}P?Ph=7 zPP?*Ys4o#;gdm_gGC;{<{3!={vTyb{>n~a`PaSDJ7mF++I0~?k=g5(O6>kxt)s6)! zw#z&AJl_6=Va70JO|Fh^go>me^2mDph=wo`pD^LXR2@QSvuQx>^W6)DQH^F=ZposY=_3(D~W` zA@3*Yo4<#@dI6b7Uf_HCI8AhoHfEfS8z&k@y3ETdnuKU`;!ZRYv74XKfkc<@d<5nr zF-_A7krVWhVa!il%s6P@Uh6Yp zFrYwMQ=Zzi+ALNOEq@0yRCQ|p=g)i?y^=tBnK&|PT4VAPld^vgzGa?jZkJM>AhMA()F!z0k;i7T@wW>l0Pipri zo%%rB+fpc_g_1^{4&ze9oV{tohdy;N9U$s6K;md3gfb?O)m@qbg-}lr ztt23X;F+iUKssU?aYBo(M?7f=*7z>~7i*uo^BlLFwDl6tvQ76Da+}*UA=JCCX?2UA`W|){*+`xWz_?=Gt;nMbuD7PJO%}~<@zN3^&^uPKj|7?ltB7}j9LF&z(8$Y?N0LV`T@J^)4-C@lrHSS~g3&EfoMNUGL4 zcgHmEt2Rz+cGA&9x=HAgDCh!Ly^x69&KlCm8GQ5r%E?=xkN-t3_Vv}dTAW>3G zHmtdOr}mdqtVu=mqxJT0*Zl-0A3@I8$j$qjrLV-!>J0F+zwVfXJSmmHbLrr>L32Gb zd2btaDrzIX_yc}?D9&PS9SR)f*A)gy)+U3`>Lk@P6}a&N>#aYptvaiHq8w%)AVP4ww^q@AsdN7aA3bMIi{89{|rb`>jh|8<837sK#ozwa;8U>;AOK=EPBKiFz>t+ zsm1PitaRMor=As4YW+?O7x4gp*U19*sd@fi$WwQzSiK+lnSzCE@Amf+&{BV_ JR;^-<{y(0T(|P~^ literal 7936 zcmaiZ^;^`<_xF2~ZkA37aRC7VX;~1Yq#KcrMd^}e0qGEwlnwzUrAs;_1jL(Iy1PLd zdH6j4z;~|e%sKPZ%yrJZPDW~|DG=e);R66bq@*aPbV9HaHlhN_Y*n92mg&4=){cv+~l*R0F1@Ddz za8Bb7EZc5})lKE`jw@fDR!7$^YxOi~xyWe9Rmziz(|MKC-2`SA6vz`OMRC4U(Wy&(7#E%%vduisNQDT;j>h*w6~M6LhRt`!T3z0i;P1 zG6DaBbGjc+T{PS~hGVn5Bjror*8ylUJEJLLX@sseYsB3ylvM!nqB~x|1{jq~2>e~C zY4F6F^H|&y3^0fqL^G?k!kk*_v0P@#@O9C4k)uLJb*rYmv`+nxpyC=K!re^BXl+$_ zwiniGsA-A#eNFscmVsm(y^U&53u3UeO6hOAoAWXz-Fs`y>xFo{jNcj!M%kAdpzm0 zB_MGa#(HaG&9n2PukBKvdA`=OkhG)iLZXJ_))|+|{mND3v1fNz%Hew8E`9+-0c2+h z(9JXhf4~2U(Ggr$5m;ev`~KFydRzKnwL14?5TnOqa^QaxX&}7!h;a8-ctgsHKSB(? zY|wId5V+J_uim}!yGpJL1Er7y(GAi|d)15W**hpQLt@0fQsQ^E>ocAnI6T;jjM$w0R2Y2WjgDX!q|wikhQGDt zRaEk`feT8|fPp5eB(puI>@Jd4kDwpS-C`^b0{3S9V#n*~ugC{!Ae%@oQXI6t)e&w{ zz{!|AhoKv|y%S{UmRd`kI`f*Dz^$dZhGkjnVJ&%H+<+es)BE zt$7!B5LW-BK$>**UESao=THE0Zw}Fjr3dI9&ZkrK_bxXxcdg>J=`3u>_=(u?SEx6x z`$z_k=!AUTy}cr%6EFKh_B`%nA!H(CQ3nu~ff?ipdl0#sENGKW)XA>oK7cTq>crFv zQZFBmIY}I_YLN$yx5^t-2S$FR9g-$n;iCzew3Uwic;n~WhTA1`rAH@VrLoOa^B7tL zUad*N*O)8ux!G*BB<*~G{;#XSg8$dzGt<8Hg&z^sSJ~?=3S)aiF*G8}TUFtQT5Ht? zMgk;(T-iaQeWiYUF*NStPo-*UZhilfO%nmL1O-k7nnfnNml(Y;GhIx^nHH$7X8Aky z*)77o6c|2DVRU~_27c~MvL_>!F=W?Xcj zgeK3ap5kbDR=&Y()3D!@{&py&ydp0l#L4+UX-Bpl2@L=5^%!N9E}^D#ZI%GS&sdY^ zuCwmgaRZk-N%#HH-`?4sV+(&O=}7_tq@I<}5Zi=3j<_Nraq3E(YeN}!QBO!6-#$2Y zm9SVledxS5<>G283k0aJ;f&-m{~Kj;atu{;VnD5UWC;LbWj|Mho687vrkeq*0X*-d z$4f?(vU6o}E_$c8xT^{2-?nn-o7#N-jA4QV8$r_Ei_7@jyW#8g?Pj)b(+X`NFY5H+INdNvelG=hu#jwi1zUx3~m`1JjEfLJ9{b8ytphl()-FSOQE9t zb?7q)3lqk`kKi6KotCF@bl`Y^=hjoHc?x!#X+iR{U)*Kw3;0tE z#rWLvukU8Yh?JPtk?C_jBj?pxt0*;yp=~~p^S`O&Q{pc^Q1aU7mlt(gH2a#p2{z-6 zW!U{e=}k#G6vtAJEq|%P!m1ZYWX+Htoc!YvsBr9SGQ+C;C7Jy=wI%y z^6J_5NK@+L`iYj<=DS-09pM)a9{hsKM-2|Fk!db|<^m>xyRC5X z_wHriK(iU8!qB-D(@I!YNS@6quaA=uYrlT_N7a6y_-#xfmZx~NGldJQze_-cB!Px z-RNFZFQy%b`;oOhLZXIBK1?nxjqJBqRb9qC-E4~Unr*b)jXHVU`&KafMM|ga)E7`T zUTpo?p*D_$;{Xd77na_Z-U;nLjeiEIw4Oi`O4&u696dIlv(5ig>AC>kEEU0yp5%kO zB^hI2zS-TobLVWmvBWF!5NW}5M(e>&NUEj8Sa7NhhYikU3YTPhE{B^Unw z=2iMj&iI+plD8uE7jq{KW>dJ$=lQvU2Bu1E@VQmD_&-sYc>=R{b~#q~y}XuzVJQcf zQsQeDBs*%?PiQ9`;&O3>RAB~MEJuOY9S#@c3i>P2S98Qlqf_V3l2|aq%KJH2Bt8;zHmW>xWLdlV} z!hy-rP^xX$Phd`W8$ZK4=GmGPqrOUs@k<8G9QE$nT^v>46&j%4iAgc z--;1DW`vNDj_ttEyIll|{~m9qhFiAHFU1P&DnK!AT zTWqe`lE@>QHY@7WooRxDXI0Z8M;@C7TEaLg$ZWL0Q4$jHT#oW+CNmxS;KEStDHYLp zmxdSSSn`nR!>it0FaOiZ1cURLjnSR=j#@g2S8U}@xtb8|14}2?v0|{rJQAgNH`!iY z>D^m$;d34kS5zEfTEyI$QRQ1%?i1Qv{(?XUlZeB7iTUiEy!Sey`OaH#dpX>}Kca61 zjYd09!63eYLOa4BF_=iLF^e@dsDGjt zrf@bJ!x(<|Eu%+<-X}m8^ONCVe*qIIQ7(I#@I!e;qmH17l5(k5A-i{N!^G-cg0NLc zCFTX8AAj+o3;&B8Sy=pw)Tc|1H|EPca-D|5uXN4l*qE1>q(scryB@EI-$Y+fU0(gt z0J;8q82&Hvtu)PtOq_a&tS=V98H&)8gN&$t{o77jy2(w)7@7+(5%YY92(RCRoLd0H zb?jCxVTLWRb-w;Wk=gTl;;^2{DB951>AAz~VYT+KMGY~6rOwXuIm~e?KzKs;wukkK zo{r95hE4FUocWHBVBZH<3`-`a_Jr7I&xh`5Wy#E_2+o!zFcC%3Wp5cw5f#@LhNHJw zReclcK^rrUL$%nr=`O_iz@gRFg+!Y%Ngj-y&m{%M3335A@ZA7M}t#rZ?^5w z^OWER-nH&Doi(Aubbj9gJH6O=9a(O3R(*kgxOs8?k7PxEoST(4Sc24e&Zx0(SK&Ox zev}7{#s@5k^ttI@z@txOi(FaDp1kNPTgY#Y>Bzj@f1XVB{qL(kLRQw+V!f-)nMUqNH^8sy&kb+EG3Vs>s$%ez8Cg+pZ|d7v z>C9!@&2=Nn%rS?>GI&LkkbCE0$uZ?$cy_t{@Z}}}sEd{3^}gIodTH!CtAoL?5q^;? zdYzuUxFGv89{sg0HRFPx=bzWUrYa=LFs^8lMjDZO}w3vRlAnhu*rp?yJcD z9NAdW63<158zthNJ?6ZU;wwbB&i5&^(&Co z6IWEGE)rRV_8naXGNADpgKYSL*Ji$Ymzu$aUUZBs}L)!BV#O9~t-bmimLwW6YNO>b4KKt*CW}>}Qy5Cp2lfyR?5V zm^rNk2B)t@y+!dO+hZ^8ok+%AZQR3^cSXa`>ofN2zOy}8U0p@}5u$fvu(NOX_#lO$ zp7@8&i(Evibu~-uuTw(Ltbos>wQLq1(I_E3_Ldi{FRy?9XmE(RVpL3Obz1Z(6+L8l zV{u)!gR`uA(XbB@&NUifctR#=k6|k~{dz7cLj#BYJE-e9 zZg}RkeBs^ExtH_OpBLTxzuHX9a8eA&HI zf*A=?C{@4u)3)vTzM&uW0oFuP(nz!4A}Qw1^YMw6)`itoRiu%k^*`GhmiQXZeqU=W zjK()~6wtQesNOwpt97f0G8sUTzD`&m`F=#nh=d}dRqSI9*?V` z_}as+7e8@YB1sAoE+W7Geemp|#MW1Ed(5)pcc*0t%F>c;duNAH=(>cG6D4AM z%ak7;SF@R7kR?sQc5TZ3X{H|#r}zDj;#K`)i4}65W*1ghw*D_@LrIY}bsM-LezBb2 zH$M?sMg#)5upkDw)P@48W98l}vIpP)t6~!tRHeW5v$GZ0(FAt9 zdrt=<&E!harU^3Uc9ff{yS}qWT!%6*L*S59bSx63r1(9ik4L?Sp(lZSVP(tK*!pJW zQ{c2d8K_TYQmyDCnhi5ZlpvGZfXktlc-0P+8@^JN#43&u~c z0KfM!dNMetgPG(}i^h+joSA;8f>FN@{cVBA_h}NLT~XOb;-U7s57ONkDbxf7<`}zt z%V)AcS<%Y9bA0gCA{<>?OUg_I-P6M;M;mgS__ z3d`e@58S=uD?bQyr*qU{qOAr4&QE|5X=e=Q>ObhqK^Z(mLOi^G1J7_R5x&P6df=g*c`?_F|5Z&2867P5U19-()j!pSAj z8&jZYYd*AA6Z_1EFz0S5mU(=@Uk4uSwX~!U`17=D`a+-=elztgoR_#sM`MO38?dSA zlpuGbtTbhqm3Il|_%><&z{qRt{jb~izPU#nHxtA9xtN{kh?c`cc~*WQ`G@q_1*Zzs&O3N_RUbdtWxtbWt82gPTNkFsX4&#mdhjfz4^&mNQeO zdLAOhyON&;Ng?iok0bOH80EXw)^-$Z>z4*6O>drAGsJH@}G3Bog=cTiRLO-z%i-Gf>crMUsl z&CoV#{EE>L0G{7HBt+%Uqtqw}!a%rdz*VY=thXvp z8A{Qr|H(+EKO{vu#}1YZ%#BKjKShX8z*y)2=uBb$*4G#5y8TQJ|kPIRo2BR(LybiekTy)u=y%@|s^Q zfQ0zV+y^9x#XcfRj~{{c<%aRP!L#JKrY0t+$VzII9mK%gjQyW%Upx`1It@=`N7RH@ zAD_JmCWP$chjkS|ASW{8Q9_iNHFecoHiBeF%C<%4W1eHFdubPI&jFdw5v?};_){}e;0!DYCX3&q7>T?!KsLU(z`M= z=c$-taE9rzBDcLQ)3@jXEf6a{n>6==o=FxZLKqKWHt~l>+LH#eu~!1mpJym-3iJ7I zf?4R8{XTw1bZ*jY+rLhsm3e%C5xu@GBdaB?+9}>odBsvJszoU4iqOuwy(ZCPE9?sm za1pLpSo5Q2C&JyVL<3e)JeHM12ACvX7r)j@zV=5jKZ6-sO;FuuMhA^L?cYU-=8JFa z&TuH<@L($d*At+z9^Zb(K90)eTP_KCOnU|%!mTb*R$jmN0XO2QH($tn2>}dM%s&w( zMw(({hSI2MWd%GJQv6Q&3E?FC_`w-?E20?SRzO$JxH?Dnc{;P<>O7JIXcx^o+fmLz zEN(Kmilyi;gz(1qAw5sNEy()6cpZcfa3gVa<%d1LYr%dB0GB`R@Ks>(hI0bNVEbt5 z7<5@CXtm7v()=A_w15VaEQVNw35MnV&rGlFZ(XN>q>nlTYG7zFcqnwEtpcJD9h@q`IV^m_D$X^U z=A+4061tcOw1@TaB@}Z(BLseK)F^6TBQ(lh&_zT@Evyb>&muwbX9UYy5OZ%kf6{A` z^8+?NA_C zl?G9q(9;OVJ#!PyEw3WJ*SImD)HE3%9c!Fa4JAZ`bf?Q!*JIuskm)xZn=&m7yR4Ub5rh+vD0HrKKnwEAufo^OL{%Y2QvGESa(O@e})8O|7sX_;VZcjvfJWzEZ zxI{(lDC=+cw#k?AaLuJb;JH%Nm&JRJ{FS+{3d(|{#^E;7-WOBBf8LWd*in8y?QRn< z5jm_FW5&2fYm4ya~ z!_bqyofY(rdv}||jE#R$JxN>ay|ro*S+P50iBaj(fr?&VM_+L1xYYV5={90Z;JvVKt<6StErX=zfZ)Fefy&N{ zda=b|hFXp)jawgRNS~Fab;A)nl}UYJ0S8_ z3~@B44=E$(eN!!B#n;|Ol%qW8=qz8hl5~i&l_tIM17V6Q+vdLW%w`-AigvWtzp179 z6#;7aVog2jL(6`-ti)0g5{WxS0JIwu=LHp-a92FS`M4lg1(&Idm>WCJQA)Co!=scV z3YC4Nu18(bzi_AY0>sP5;*3Ws2_YS@FJF|oj>_3)Q~c)D zU-y~M`eup{KIUHP=mjt@iviij2DO7)7N}6jMQ_CrG#H530AH9CVcG)Z-xg@ga81zw z@nrOvwweHP%NgpKS(T^e{Co7WA4i;cJu$d#x6^gkkQ3tSEGgAD`huh__&{A$z{&C5 ztGKKZpT!&P$0$XDj;YfJgz-BDhQ|}09{S_^R&^ZW5b%~_)+fRnhe_$u>iDEXY~uaA zZgSo~2I6Xp1Pd+D`+ASEmBx(49h%w2F?-?E|ROuJWZNn4CJ;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 030/154] 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 031/154] 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 032/154] 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 033/154] 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 034/154] 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 035/154] 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 036/154] 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 037/154] 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 038/154] 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 039/154] 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 040/154] 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 041/154] 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. From 9ea06992789a0072c167a9a8063e867bb4c43c00 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Fri, 16 Dec 2011 13:27:52 -0500 Subject: [PATCH 042/154] Update debian changelog to 0.5.1. --- contrib/debian/changelog | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/contrib/debian/changelog b/contrib/debian/changelog index 63551410364..b7992f729f6 100644 --- a/contrib/debian/changelog +++ b/contrib/debian/changelog @@ -1,3 +1,9 @@ +bitcoin (0.5.1-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. From 7aa253d3ec746c3d4ddbd55fab55d0eff28294f8 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Fri, 16 Dec 2011 17:58:40 -0500 Subject: [PATCH 043/154] Bump version to 0.5.2 --- bitcoin-qt.pro | 2 +- contrib/debian/changelog | 6 ++++++ doc/README | 2 +- doc/README_windows.txt | 2 +- share/setup.nsi | 6 +++--- src/serialize.h | 2 +- 6 files changed, 13 insertions(+), 7 deletions(-) diff --git a/bitcoin-qt.pro b/bitcoin-qt.pro index 66b53c23677..d7ac62e90a6 100644 --- a/bitcoin-qt.pro +++ b/bitcoin-qt.pro @@ -1,6 +1,6 @@ TEMPLATE = app TARGET = -VERSION = 0.5.1 +VERSION = 0.5.2 INCLUDEPATH += src src/json src/qt DEFINES += QT_GUI BOOST_THREAD_USE_LIB CONFIG += no_include_pwd diff --git a/contrib/debian/changelog b/contrib/debian/changelog index b7992f729f6..45106418252 100644 --- a/contrib/debian/changelog +++ b/contrib/debian/changelog @@ -1,3 +1,9 @@ +bitcoin (0.5.2-natty0) natty; urgency=low + + * New upstream release. + + -- Luke Dashjr Fri, 16 Dec 2011 17:57:00 -0500 + bitcoin (0.5.1-natty0) natty; urgency=low * New upstream release. diff --git a/doc/README b/doc/README index 5e0f8ee1ed7..07785655f24 100644 --- a/doc/README +++ b/doc/README @@ -1,4 +1,4 @@ -Bitcoin 0.5.1 BETA +Bitcoin 0.5.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 d237615f57c..b98f878b27f 100644 --- a/doc/README_windows.txt +++ b/doc/README_windows.txt @@ -1,4 +1,4 @@ -Bitcoin 0.5.1 BETA +Bitcoin 0.5.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 0c0fa048af2..abf5c566b5a 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.1 +!define VERSION 0.5.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.5.1-win32-setup.exe +OutFile bitcoin-0.5.2-win32-setup.exe InstallDir $PROGRAMFILES\Bitcoin CRCCheck on XPStyle on BrandingText " " ShowInstDetails show -VIProductVersion 0.5.1.0 +VIProductVersion 0.5.2.0 VIAddVersionKey ProductName Bitcoin VIAddVersionKey ProductVersion "${VERSION}" VIAddVersionKey CompanyName "${COMPANY}" diff --git a/src/serialize.h b/src/serialize.h index 78cff43d534..388e6559709 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 = 50100; +static const int VERSION = 50200; static const char* pszSubVer = ""; static const bool VERSION_IS_BETA = true; From 6be2c9b5b4568e38fd61298b0f64c32f78631cbd Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Fri, 16 Dec 2011 11:30:36 -0500 Subject: [PATCH 044/154] Add sipa's new dnsseed. --- src/net.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/net.cpp b/src/net.cpp index a4687731f79..4fab7a7ed6a 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1174,6 +1174,7 @@ void MapPort(bool /* unused fMapPort */) static const char *strDNSSeed[] = { "bitseed.xf2.org", "dnsseed.bluematt.me", + "seed.bitcoin.sipa.be", }; void ThreadDNSAddressSeed(void* parg) From 987f26aa1aeb2b3c546ada41ae4eab6bdee7099c Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Fri, 16 Dec 2011 18:34:47 -0500 Subject: [PATCH 045/154] Add my DNS seed domain --- src/net.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/net.cpp b/src/net.cpp index 4fab7a7ed6a..af59cee6962 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1175,6 +1175,7 @@ static const char *strDNSSeed[] = { "bitseed.xf2.org", "dnsseed.bluematt.me", "seed.bitcoin.sipa.be", + "dnsseed.bitcoin.dashjr.org", }; void ThreadDNSAddressSeed(void* parg) From 027d149352bc25f0f37363da95a0b4c723100f63 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Wed, 14 Dec 2011 01:03:55 -0500 Subject: [PATCH 046/154] Bugfix: fForRelay should be false when deciding required fee to include in blocks During the rushed transition from 0.01 BTC to 0.0005 BTC fees, we took the approach of dropping the relay and block-inclusion fee to 0.0005 BTC immediately, and only delayed adjusting the sending fee for the next release. Afterward, the relay fee was lowered to 0.0001 BTC to avoid having the same problem in the future. However, the block inclusion code was left setting fForRelay to true! This fixes that, so the lower 0.0001 BTC allowance is (as intended) only permitted for real relaying. --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index af00069d663..03e133b63cd 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2776,7 +2776,7 @@ CBlock* CreateNewBlock(CReserveKey& reservekey) // Transaction fee required depends on block size bool fAllowFree = (nBlockSize + nTxSize < 4000 || CTransaction::AllowFree(dPriority)); - int64 nMinFee = tx.GetMinFee(nBlockSize, fAllowFree, true); + int64 nMinFee = tx.GetMinFee(nBlockSize, fAllowFree); // Connecting shouldn't fail due to dependency on other memory pool transactions // because we're already processing them in order of dependency From 96f1723bb1f4155357b4e33988a2b99ee674c549 Mon Sep 17 00:00:00 2001 From: Dylan Noblesmith Date: Sat, 26 Nov 2011 06:02:04 +0000 Subject: [PATCH 047/154] Implement an mlock()'d string class for storing passphrases SecureString is identical to std::string except with secure_allocator substituting for std::allocator. This makes casting between them impossible, so converting between the two at API boundaries requires calling ::c_str() for now. --- src/bitcoinrpc.cpp | 48 ++++++++++------------------------ src/crypter.cpp | 2 +- src/crypter.h | 2 +- src/qt/askpassphrasedialog.cpp | 11 ++++---- src/qt/walletmodel.cpp | 6 ++--- src/qt/walletmodel.h | 9 ++++--- src/util.h | 4 +++ src/wallet.cpp | 6 ++--- src/wallet.h | 6 ++--- 9 files changed, 40 insertions(+), 54 deletions(-) diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp index 31ef725d793..889dd7a1b18 100644 --- a/src/bitcoinrpc.cpp +++ b/src/bitcoinrpc.cpp @@ -1451,21 +1451,16 @@ Value walletpassphrase(const Array& params, bool fHelp) throw JSONRPCError(-17, "Error: Wallet is already unlocked."); // Note that the walletpassphrase is stored in params[0] which is not mlock()ed - string strWalletPass; + SecureString strWalletPass; strWalletPass.reserve(100); - mlock(&strWalletPass[0], strWalletPass.capacity()); - strWalletPass = params[0].get_str(); + // TODO: get rid of this .c_str() by implementing SecureString::operator=(std::string) + // Alternately, find a way to make params[0] mlock()'d to begin with. + strWalletPass = params[0].get_str().c_str(); if (strWalletPass.length() > 0) { if (!pwalletMain->Unlock(strWalletPass)) - { - fill(strWalletPass.begin(), strWalletPass.end(), '\0'); - munlock(&strWalletPass[0], strWalletPass.capacity()); throw JSONRPCError(-14, "Error: The wallet passphrase entered was incorrect."); - } - fill(strWalletPass.begin(), strWalletPass.end(), '\0'); - munlock(&strWalletPass[0], strWalletPass.capacity()); } else throw runtime_error( @@ -1491,15 +1486,15 @@ Value walletpassphrasechange(const Array& params, bool fHelp) if (!pwalletMain->IsCrypted()) throw JSONRPCError(-15, "Error: running with an unencrypted wallet, but walletpassphrasechange was called."); - string strOldWalletPass; + // TODO: get rid of these .c_str() calls by implementing SecureString::operator=(std::string) + // Alternately, find a way to make params[0] mlock()'d to begin with. + SecureString strOldWalletPass; strOldWalletPass.reserve(100); - mlock(&strOldWalletPass[0], strOldWalletPass.capacity()); - strOldWalletPass = params[0].get_str(); + strOldWalletPass = params[0].get_str().c_str(); - string strNewWalletPass; + SecureString strNewWalletPass; strNewWalletPass.reserve(100); - mlock(&strNewWalletPass[0], strNewWalletPass.capacity()); - strNewWalletPass = params[1].get_str(); + strNewWalletPass = params[1].get_str().c_str(); if (strOldWalletPass.length() < 1 || strNewWalletPass.length() < 1) throw runtime_error( @@ -1507,17 +1502,7 @@ Value walletpassphrasechange(const Array& params, bool fHelp) "Changes the wallet passphrase from to ."); if (!pwalletMain->ChangeWalletPassphrase(strOldWalletPass, strNewWalletPass)) - { - fill(strOldWalletPass.begin(), strOldWalletPass.end(), '\0'); - fill(strNewWalletPass.begin(), strNewWalletPass.end(), '\0'); - munlock(&strOldWalletPass[0], strOldWalletPass.capacity()); - munlock(&strNewWalletPass[0], strNewWalletPass.capacity()); throw JSONRPCError(-14, "Error: The wallet passphrase entered was incorrect."); - } - fill(strNewWalletPass.begin(), strNewWalletPass.end(), '\0'); - fill(strOldWalletPass.begin(), strOldWalletPass.end(), '\0'); - munlock(&strOldWalletPass[0], strOldWalletPass.capacity()); - munlock(&strNewWalletPass[0], strNewWalletPass.capacity()); return Value::null; } @@ -1562,10 +1547,11 @@ Value encryptwallet(const Array& params, bool fHelp) throw runtime_error("Not Yet Implemented: use GUI to encrypt wallet, not RPC command"); #endif - string strWalletPass; + // TODO: get rid of this .c_str() by implementing SecureString::operator=(std::string) + // Alternately, find a way to make params[0] mlock()'d to begin with. + SecureString strWalletPass; strWalletPass.reserve(100); - mlock(&strWalletPass[0], strWalletPass.capacity()); - strWalletPass = params[0].get_str(); + strWalletPass = params[0].get_str().c_str(); if (strWalletPass.length() < 1) throw runtime_error( @@ -1573,13 +1559,7 @@ Value encryptwallet(const Array& params, bool fHelp) "Encrypts the wallet with ."); if (!pwalletMain->EncryptWallet(strWalletPass)) - { - fill(strWalletPass.begin(), strWalletPass.end(), '\0'); - munlock(&strWalletPass[0], strWalletPass.capacity()); throw JSONRPCError(-16, "Error: Failed to encrypt the wallet."); - } - fill(strWalletPass.begin(), strWalletPass.end(), '\0'); - munlock(&strWalletPass[0], strWalletPass.capacity()); // 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 diff --git a/src/crypter.cpp b/src/crypter.cpp index bee7a3624b8..7f53e22f1e3 100644 --- a/src/crypter.cpp +++ b/src/crypter.cpp @@ -15,7 +15,7 @@ #include "main.h" #include "util.h" -bool CCrypter::SetKeyFromPassphrase(const std::string& strKeyData, const std::vector& chSalt, const unsigned int nRounds, const unsigned int nDerivationMethod) +bool CCrypter::SetKeyFromPassphrase(const SecureString& strKeyData, const std::vector& chSalt, const unsigned int nRounds, const unsigned int nDerivationMethod) { if (nRounds < 1 || chSalt.size() != WALLET_CRYPTO_SALT_SIZE) return false; diff --git a/src/crypter.h b/src/crypter.h index e8ca30a8cc1..d7f8a39d839 100644 --- a/src/crypter.h +++ b/src/crypter.h @@ -65,7 +65,7 @@ private: bool fKeySet; public: - bool SetKeyFromPassphrase(const std::string &strKeyData, const std::vector& chSalt, const unsigned int nRounds, const unsigned int nDerivationMethod); + bool SetKeyFromPassphrase(const SecureString &strKeyData, const std::vector& chSalt, const unsigned int nRounds, const unsigned int nDerivationMethod); bool Encrypt(const CKeyingMaterial& vchPlaintext, std::vector &vchCiphertext); bool Decrypt(const std::vector& vchCiphertext, CKeyingMaterial& vchPlaintext); bool SetKey(const CKeyingMaterial& chNewKey, const std::vector& chNewIV); diff --git a/src/qt/askpassphrasedialog.cpp b/src/qt/askpassphrasedialog.cpp index b52acf4545e..4ee67e7c87b 100644 --- a/src/qt/askpassphrasedialog.cpp +++ b/src/qt/askpassphrasedialog.cpp @@ -70,16 +70,17 @@ void AskPassphraseDialog::setModel(WalletModel *model) void AskPassphraseDialog::accept() { - std::string oldpass, newpass1, newpass2; + SecureString oldpass, newpass1, newpass2; if(!model) return; - // TODO: mlock memory / munlock on return so they will not be swapped out, really need "mlockedstring" wrapper class to do this safely oldpass.reserve(MAX_PASSPHRASE_SIZE); newpass1.reserve(MAX_PASSPHRASE_SIZE); newpass2.reserve(MAX_PASSPHRASE_SIZE); - oldpass.assign(ui->passEdit1->text().toStdString()); - newpass1.assign(ui->passEdit2->text().toStdString()); - newpass2.assign(ui->passEdit3->text().toStdString()); + // TODO: get rid of this .c_str() by implementing SecureString::operator=(std::string) + // Alternately, find a way to make this input mlock()'d to begin with. + oldpass.assign(ui->passEdit1->text().toStdString().c_str()); + newpass1.assign(ui->passEdit2->text().toStdString().c_str()); + newpass2.assign(ui->passEdit3->text().toStdString().c_str()); switch(mode) { diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp index 2f989661f09..f028f10f6c6 100644 --- a/src/qt/walletmodel.cpp +++ b/src/qt/walletmodel.cpp @@ -200,7 +200,7 @@ WalletModel::EncryptionStatus WalletModel::getEncryptionStatus() const } } -bool WalletModel::setWalletEncrypted(bool encrypted, const std::string &passphrase) +bool WalletModel::setWalletEncrypted(bool encrypted, const SecureString &passphrase) { if(encrypted) { @@ -214,7 +214,7 @@ bool WalletModel::setWalletEncrypted(bool encrypted, const std::string &passphra } } -bool WalletModel::setWalletLocked(bool locked, const std::string &passPhrase) +bool WalletModel::setWalletLocked(bool locked, const SecureString &passPhrase) { if(locked) { @@ -228,7 +228,7 @@ bool WalletModel::setWalletLocked(bool locked, const std::string &passPhrase) } } -bool WalletModel::changePassphrase(const std::string &oldPass, const std::string &newPass) +bool WalletModel::changePassphrase(const SecureString &oldPass, const SecureString &newPass) { bool retval; CRITICAL_BLOCK(wallet->cs_wallet) diff --git a/src/qt/walletmodel.h b/src/qt/walletmodel.h index b7b6973b3bd..055ba184b0c 100644 --- a/src/qt/walletmodel.h +++ b/src/qt/walletmodel.h @@ -2,7 +2,8 @@ #define WALLETMODEL_H #include -#include + +#include "util.h" class OptionsModel; class AddressTableModel; @@ -72,10 +73,10 @@ public: SendCoinsReturn sendCoins(const QList &recipients); // Wallet encryption - bool setWalletEncrypted(bool encrypted, const std::string &passphrase); + bool setWalletEncrypted(bool encrypted, const SecureString &passphrase); // Passphrase only needed when unlocking - bool setWalletLocked(bool locked, const std::string &passPhrase=std::string()); - bool changePassphrase(const std::string &oldPass, const std::string &newPass); + bool setWalletLocked(bool locked, const SecureString &passPhrase=SecureString()); + bool changePassphrase(const SecureString &oldPass, const SecureString &newPass); // RAI object for unlocking wallet, returned by requestUnlock() class UnlockContext diff --git a/src/util.h b/src/util.h index 178923727a8..bcb9027148d 100644 --- a/src/util.h +++ b/src/util.h @@ -286,6 +286,10 @@ public: +// This is exactly like std::string, but with a custom allocator. +// (secure_allocator<> is defined in serialize.h) +typedef std::basic_string, secure_allocator > SecureString; + diff --git a/src/wallet.cpp b/src/wallet.cpp index af80cc16d55..28babdb3e2c 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -42,7 +42,7 @@ bool CWallet::AddCryptedKey(const vector &vchPubKey, const vector return false; } -bool CWallet::Unlock(const string& strWalletPassphrase) +bool CWallet::Unlock(const SecureString& strWalletPassphrase) { if (!IsLocked()) return false; @@ -63,7 +63,7 @@ bool CWallet::Unlock(const string& strWalletPassphrase) return false; } -bool CWallet::ChangeWalletPassphrase(const string& strOldWalletPassphrase, const string& strNewWalletPassphrase) +bool CWallet::ChangeWalletPassphrase(const SecureString& strOldWalletPassphrase, const SecureString& strNewWalletPassphrase) { bool fWasLocked = IsLocked(); @@ -122,7 +122,7 @@ public: ) }; -bool CWallet::EncryptWallet(const string& strWalletPassphrase) +bool CWallet::EncryptWallet(const SecureString& strWalletPassphrase) { if (IsCrypted()) return false; diff --git a/src/wallet.h b/src/wallet.h index 19de803390a..ca7cf673179 100644 --- a/src/wallet.h +++ b/src/wallet.h @@ -70,9 +70,9 @@ public: // Adds an encrypted key to the store, without saving it to disk (used by LoadWallet) bool LoadCryptedKey(const std::vector &vchPubKey, const std::vector &vchCryptedSecret) { return CCryptoKeyStore::AddCryptedKey(vchPubKey, vchCryptedSecret); } - bool Unlock(const std::string& strWalletPassphrase); - bool ChangeWalletPassphrase(const std::string& strOldWalletPassphrase, const std::string& strNewWalletPassphrase); - bool EncryptWallet(const std::string& strWalletPassphrase); + bool Unlock(const SecureString& strWalletPassphrase); + bool ChangeWalletPassphrase(const SecureString& strOldWalletPassphrase, const SecureString& strNewWalletPassphrase); + bool EncryptWallet(const SecureString& strWalletPassphrase); bool AddToWallet(const CWalletTx& wtxIn); bool AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pblock, bool fUpdate = false); From 863238316144b0ae8d0208ed60d86d932475cfaa Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Fri, 23 Dec 2011 02:24:46 -0800 Subject: [PATCH 048/154] Fix #722. --- contrib/gitian-descriptors/gitian.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/gitian-descriptors/gitian.yml b/contrib/gitian-descriptors/gitian.yml index 47164b0afd4..11ee4dc5804 100644 --- a/contrib/gitian-descriptors/gitian.yml +++ b/contrib/gitian-descriptors/gitian.yml @@ -39,7 +39,7 @@ 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 USE_SSL=1 + make -f makefile.unix STATIC=1 OPENSSL_INCLUDE_PATH="$INSTDIR/include" OPENSSL_LIB_PATH="$INSTDIR/lib" $MAKEOPTS bitcoind USE_UPNP=0 USE_SSL=1 mkdir -p $OUTDIR/bin/$GBUILD_BITS install -s bitcoind $OUTDIR/bin/$GBUILD_BITS cd .. From 3b8051864b98eb5a9df6327f314a45af9205a09c Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Sun, 25 Dec 2011 09:26:12 -0500 Subject: [PATCH 049/154] Be more conservative: check all transactions in blocks after last checkpoint. --- src/main.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index f21af904731..1f23844573c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -30,7 +30,6 @@ map mapNextTx; map mapBlockIndex; uint256 hashGenesisBlock("0x000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"); static CBigNum bnProofOfWorkLimit(~uint256(0) >> 32); -const int nInitialBlockThreshold = 120; // Regard blocks up until N-threshold as "initial download" CBlockIndex* pindexGenesisBlock = NULL; int nBestHeight = -1; CBigNum bnBestChainWork = 0; @@ -750,7 +749,7 @@ int GetNumBlocksOfPeers() bool IsInitialBlockDownload() { - if (pindexBest == NULL || nBestHeight < (Checkpoints::GetTotalBlocksEstimate()-nInitialBlockThreshold)) + if (pindexBest == NULL || nBestHeight < Checkpoints::GetTotalBlocksEstimate()) return true; static int64 nLastUpdate; static CBlockIndex* pindexLastBest; @@ -881,10 +880,10 @@ bool CTransaction::ConnectInputs(CTxDB& txdb, map& mapTestPoo if (pindex->nBlockPos == txindex.pos.nBlockPos && pindex->nFile == txindex.pos.nFile) return error("ConnectInputs() : tried to spend coinbase at depth %d", pindexBlock->nHeight - pindex->nHeight); - // Skip ECDSA signature verification when connecting blocks (fBlock=true) during initial download - // (before the last blockchain checkpoint). This is safe because block merkle hashes are + // Skip ECDSA signature verification when connecting blocks (fBlock=true) + // before the last blockchain checkpoint. This is safe because block merkle hashes are // still computed and checked, and any change will be caught at the next checkpoint. - if (!(fBlock && IsInitialBlockDownload())) + if (!(fBlock && (nBestHeight < Checkpoints::GetTotalBlocksEstimate()))) // Verify signature if (!VerifySignature(txPrev, *this, i)) return DoS(100,error("ConnectInputs() : %s VerifySignature failed", GetHash().ToString().substr(0,10).c_str())); From b52b6f2e3801fe14e09d646415cb798c565063d5 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Tue, 3 Jan 2012 01:28:15 +0100 Subject: [PATCH 050/154] Fix some address-handling deadlocks Made three critical blocks for cs_mapAddresses smaller, and moved writing to the database out of them. This should also improve the concurrency of the code. --- src/net.cpp | 61 +++++++++++++++++++++++++++++------------------------ 1 file changed, 34 insertions(+), 27 deletions(-) diff --git a/src/net.cpp b/src/net.cpp index af59cee6962..0f3b7cc8633 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -496,21 +496,25 @@ bool AddAddress(CAddress addr, int64 nTimePenalty, CAddrDB *pAddrDB) void AddressCurrentlyConnected(const CAddress& addr) { + CAddress *paddrFound = NULL; + CRITICAL_BLOCK(cs_mapAddresses) { // Only if it's been published already map, CAddress>::iterator it = mapAddresses.find(addr.GetKey()); if (it != mapAddresses.end()) + paddrFound = &(*it).second; + } + + if (paddrFound) + { + int64 nUpdateInterval = 20 * 60; + if (paddrFound->nTime < GetAdjustedTime() - nUpdateInterval) { - CAddress& addrFound = (*it).second; - int64 nUpdateInterval = 20 * 60; - if (addrFound.nTime < GetAdjustedTime() - nUpdateInterval) - { - // Periodically update most recently seen time - addrFound.nTime = GetAdjustedTime(); - CAddrDB addrdb; - addrdb.WriteAddress(addrFound); - } + // Periodically update most recently seen time + paddrFound->nTime = GetAdjustedTime(); + CAddrDB addrdb; + addrdb.WriteAddress(*paddrFound); } } } @@ -1205,13 +1209,13 @@ void ThreadDNSAddressSeed2(void* parg) if (!fTestNet) { printf("Loading addresses from DNS seeds (could take a while)\n"); - CAddrDB addrDB; - addrDB.TxnBegin(); for (int seed_idx = 0; seed_idx < ARRAYLEN(strDNSSeed); seed_idx++) { vector vaddr; if (Lookup(strDNSSeed[seed_idx], vaddr, NODE_NETWORK, -1, true)) { + CAddrDB addrDB; + addrDB.TxnBegin(); BOOST_FOREACH (CAddress& addr, vaddr) { if (addr.GetByte(3) != 127) @@ -1221,10 +1225,9 @@ void ThreadDNSAddressSeed2(void* parg) found++; } } + addrDB.TxnCommit(); // Save addresses (it's ok if this fails) } } - - addrDB.TxnCommit(); // Save addresses (it's ok if this fails) } printf("%d addresses found from DNS seeds\n", found); @@ -1396,27 +1399,31 @@ void ThreadOpenConnections2(void* parg) if (fShutdown) return; + bool fAddSeeds = false; + CRITICAL_BLOCK(cs_mapAddresses) { // Add seed nodes if IRC isn't working bool fTOR = (fUseProxy && addrProxy.port == htons(9050)); if (mapAddresses.empty() && (GetTime() - nStart > 60 || fTOR) && !fTestNet) - { - for (int i = 0; i < ARRAYLEN(pnSeed); i++) - { - // It'll only connect to one or two seed nodes because once it connects, - // it'll get a pile of addresses with newer timestamps. - // Seed nodes are given a random 'last seen time' of between one and two - // weeks ago. - const int64 nOneWeek = 7*24*60*60; - CAddress addr; - addr.ip = pnSeed[i]; - addr.nTime = GetTime()-GetRand(nOneWeek)-nOneWeek; - AddAddress(addr); - } - } + fAddSeeds = true; } + if (fAddSeeds) + { + for (int i = 0; i < ARRAYLEN(pnSeed); i++) + { + // It'll only connect to one or two seed nodes because once it connects, + // it'll get a pile of addresses with newer timestamps. + // Seed nodes are given a random 'last seen time' of between one and two + // weeks ago. + const int64 nOneWeek = 7*24*60*60; + CAddress addr; + addr.ip = pnSeed[i]; + addr.nTime = GetTime()-GetRand(nOneWeek)-nOneWeek; + AddAddress(addr); + } + } // // Choose an address to connect to based on most recently seen From 84393f15b60ff5392da69b7cc208ffb5e8d209f0 Mon Sep 17 00:00:00 2001 From: Gavin Andresen Date: Tue, 3 Jan 2012 10:14:22 -0500 Subject: [PATCH 051/154] Fix issue #659, and cleanup wallet/command-line argument handling a bit Conflicts: src/init.cpp src/util.cpp --- src/init.cpp | 67 ++++++++++++++++++++++++++++++++-------------------- src/irc.cpp | 17 ++++--------- src/net.cpp | 2 +- src/util.cpp | 17 +++++++++++++ src/util.h | 21 ++++++++++++++-- 5 files changed, 83 insertions(+), 41 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index 75ecfc574e0..292424fb1dc 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -180,6 +180,7 @@ bool AppInit2(int argc, char* argv[]) " -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") + + " -noirc \t " + _("Don't find peers using internet relay chat\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") + @@ -237,7 +238,6 @@ bool AppInit2(int argc, char* argv[]) } fDebug = GetBoolArg("-debug"); - fAllowDNS = GetBoolArg("-dns"); #ifndef __WXMSW__ fDaemon = GetBoolArg("-daemon"); @@ -257,10 +257,6 @@ bool AppInit2(int argc, char* argv[]) fPrintToConsole = GetBoolArg("-printtoconsole"); fPrintToDebugger = GetBoolArg("-printtodebugger"); - - fTestNet = GetBoolArg("-testnet"); - bool fTOR = (fUseProxy && addrProxy.port == htons(9050)); - fNoListen = GetBoolArg("-nolisten") || fTOR; fLogTimestamps = GetBoolArg("-logtimestamps"); for (int i = 1; i < argc; i++) @@ -365,16 +361,7 @@ bool AppInit2(int argc, char* argv[]) return false; } - // Bind to the port early so we can tell if another instance is already running. string strErrors; - if (!fNoListen) - { - if (!BindListenPort(strErrors)) - { - wxMessageBox(strErrors, "Bitcoin"); - return false; - } - } // // Load data files @@ -456,6 +443,10 @@ bool AppInit2(int argc, char* argv[]) // Add wallet transactions that aren't already in a block to mapTransactions pwalletMain->ReacceptWalletTransactions(); + // Note: Bitcoin-QT stores several settings in the wallet, so we want + // to load the wallet BEFORE parsing command-line arguments, so + // the command-line/bitcoin.conf settings override GUI setting. + // // Parameters // @@ -508,6 +499,43 @@ bool AppInit2(int argc, char* argv[]) } } + fTestNet = GetBoolArg("-testnet"); + bool fTor = (fUseProxy && addrProxy.port == htons(9050)); + if (fTor) + { + // Use SoftSetArg here so user can override any of these if they wish. + // Note: the GetBoolArg() calls for all of these must happen later. + SoftSetArg("-nolisten", true); + SoftSetArg("-noirc", true); + SoftSetArg("-nodnsseed", true); + SoftSetArg("-noupnp", true); + SoftSetArg("-upnp", false); + SoftSetArg("-dns", false); + } + + fAllowDNS = GetBoolArg("-dns"); + fNoListen = GetBoolArg("-nolisten"); + + if (fHaveUPnP) + { +#if USE_UPNP + if (GetBoolArg("-noupnp")) + fUseUPnP = false; +#else + if (GetBoolArg("-upnp")) + fUseUPnP = true; +#endif + } + + if (!fNoListen) + { + if (!BindListenPort(strErrors)) + { + wxMessageBox(strErrors, "Bitcoin"); + return false; + } + } + if (mapArgs.count("-addnode")) { BOOST_FOREACH(string strAddr, mapMultiArgs["-addnode"]) @@ -530,17 +558,6 @@ bool AppInit2(int argc, char* argv[]) wxMessageBox(_("Warning: -paytxfee is set very high. This is the transaction fee you will pay if you send a transaction."), "Bitcoin", wxOK | wxICON_EXCLAMATION); } - if (fHaveUPnP) - { -#if USE_UPNP - if (GetBoolArg("-noupnp")) - fUseUPnP = false; -#else - if (GetBoolArg("-upnp")) - fUseUPnP = true; -#endif - } - // // Create the main window and start the node // diff --git a/src/irc.cpp b/src/irc.cpp index 5278488dcd9..fe96a90a1cf 100644 --- a/src/irc.cpp +++ b/src/irc.cpp @@ -264,19 +264,14 @@ void ThreadIRCSeed2(void* parg) int nErrorWait = 10; int nRetryWait = 10; bool fNameInUse = false; - bool fTOR = (fUseProxy && addrProxy.port == htons(9050)); while (!fShutdown) { - //CAddress addrConnect("216.155.130.130:6667"); // chat.freenode.net CAddress addrConnect("92.243.23.21", 6667); // irc.lfnet.org - if (!fTOR) - { - //struct hostent* phostent = gethostbyname("chat.freenode.net"); - CAddress addrIRC("irc.lfnet.org", 6667, true); - if (addrIRC.IsValid()) - addrConnect = addrIRC; - } + + CAddress addrIRC("irc.lfnet.org", 6667, true); + if (addrIRC.IsValid()) + addrConnect = addrIRC; SOCKET hSocket; if (!ConnectSocket(addrConnect, hSocket)) @@ -406,10 +401,6 @@ void ThreadIRCSeed2(void* parg) closesocket(hSocket); hSocket = INVALID_SOCKET; - // IRC usually blocks TOR, so only try once - if (fTOR) - return; - if (GetTime() - nStart > 20 * 60) { nErrorWait /= 3; diff --git a/src/net.cpp b/src/net.cpp index 0f3b7cc8633..c7475b118cf 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1405,7 +1405,7 @@ void ThreadOpenConnections2(void* parg) { // Add seed nodes if IRC isn't working bool fTOR = (fUseProxy && addrProxy.port == htons(9050)); - if (mapAddresses.empty() && (GetTime() - nStart > 60 || fTOR) && !fTestNet) + if (mapAddresses.empty() && (GetTime() - nStart > 60 || fUseProxy) && !fTestNet) fAddSeeds = true; } diff --git a/src/util.cpp b/src/util.cpp index d6a113095da..a3f1c9507d9 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -472,6 +472,23 @@ void ParseParameters(int argc, char* argv[]) } } +bool SoftSetArg(const std::string& strArg, const std::string& strValue) +{ + if (mapArgs.count(strArg)) + return false; + mapArgs[strArg] = strValue; + return true; +} + +bool SoftSetArg(const std::string& strArg, bool fValue) +{ + if (fValue) + return SoftSetArg(strArg, std::string("1")); + else + return SoftSetArg(strArg, std::string("0")); +} + + const char* wxGetTranslation(const char* pszEnglish) { diff --git a/src/util.h b/src/util.h index 6ecc92b2b6d..9f9001e06eb 100644 --- a/src/util.h +++ b/src/util.h @@ -442,7 +442,7 @@ inline int64 GetArg(const std::string& strArg, int64 nDefault) return nDefault; } -inline bool GetBoolArg(const std::string& strArg) +inline bool GetBoolArg(const std::string& strArg, bool fDefault=false) { if (mapArgs.count(strArg)) { @@ -450,9 +450,26 @@ inline bool GetBoolArg(const std::string& strArg) return true; return (atoi(mapArgs[strArg]) != 0); } - return false; + return fDefault; } +/** + * Set an argument if it doesn't already have a value + * + * @param strArg Argument to set (e.g. "-foo") + * @param strValue Value (e.g. "1") + * @return true if argument gets set, false if it already had a value + */ +bool SoftSetArg(const std::string& strArg, const std::string& strValue); + +/** + * Set a boolean argument if it doesn't already have a value + * + * @param strArg Argument to set (e.g. "-foo") + * @param fValue Value (e.g. false) + * @return true if argument gets set, false if it already had a value + */ +bool SoftSetArg(const std::string& strArg, bool fValue); From cc6bd19660461091903568803014b39d571fd458 Mon Sep 17 00:00:00 2001 From: Gavin Andresen Date: Tue, 3 Jan 2012 11:17:04 -0500 Subject: [PATCH 052/154] I broke -testnet with my TOR option-parsing fixes. --- src/init.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/init.cpp b/src/init.cpp index 292424fb1dc..d1332e06100 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -237,6 +237,7 @@ bool AppInit2(int argc, char* argv[]) return false; } + fTestNet = GetBoolArg("-testnet"); fDebug = GetBoolArg("-debug"); #ifndef __WXMSW__ @@ -499,7 +500,6 @@ bool AppInit2(int argc, char* argv[]) } } - fTestNet = GetBoolArg("-testnet"); bool fTor = (fUseProxy && addrProxy.port == htons(9050)); if (fTor) { From fb88f1cc97d52d8cd5bc49169a1bcd4df735fc52 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Tue, 3 Jan 2012 12:21:04 -0500 Subject: [PATCH 053/154] Fix typo (#734) Conflicts: src/qt/locale/bitcoin_hu.ts src/qt/locale/bitcoin_it.ts src/qt/locale/bitcoin_pt_BR.ts src/qt/locale/bitcoin_uk.ts src/qt/locale/bitcoin_zh_CN.ts --- src/qt/forms/sendcoinsentry.ui | 2 +- src/qt/locale/bitcoin_da.ts | 2 +- src/qt/locale/bitcoin_de.ts | 2 +- src/qt/locale/bitcoin_en.ts | 2 +- src/qt/locale/bitcoin_es.ts | 2 +- src/qt/locale/bitcoin_es_CL.ts | 2 +- src/qt/locale/bitcoin_nb.ts | 2 +- src/qt/locale/bitcoin_nl.ts | 2 +- src/qt/locale/bitcoin_ru.ts | 2 +- src/qt/locale/bitcoin_zh_TW.ts | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/qt/forms/sendcoinsentry.ui b/src/qt/forms/sendcoinsentry.ui index 0297d17f157..22a3f8fdc61 100644 --- a/src/qt/forms/sendcoinsentry.ui +++ b/src/qt/forms/sendcoinsentry.ui @@ -100,7 +100,7 @@ - Choose adress from address book + Choose address from address book diff --git a/src/qt/locale/bitcoin_da.ts b/src/qt/locale/bitcoin_da.ts index 74928d32c52..b6c148f05a3 100644 --- a/src/qt/locale/bitcoin_da.ts +++ b/src/qt/locale/bitcoin_da.ts @@ -917,7 +917,7 @@ p, li { white-space: pre-wrap; } - Choose adress from address book + Choose address from address book Vælg adresse fra adressebog diff --git a/src/qt/locale/bitcoin_de.ts b/src/qt/locale/bitcoin_de.ts index f7b134a75d8..27db47528cf 100644 --- a/src/qt/locale/bitcoin_de.ts +++ b/src/qt/locale/bitcoin_de.ts @@ -916,7 +916,7 @@ p, li { white-space: pre-wrap; } - Choose adress from address book + Choose address from address book Adresse aus dem Adressbuch auswählen diff --git a/src/qt/locale/bitcoin_en.ts b/src/qt/locale/bitcoin_en.ts index df964c91e6d..0d57d9b1544 100644 --- a/src/qt/locale/bitcoin_en.ts +++ b/src/qt/locale/bitcoin_en.ts @@ -919,7 +919,7 @@ p, li { white-space: pre-wrap; } - Choose adress from address book + Choose address from address book diff --git a/src/qt/locale/bitcoin_es.ts b/src/qt/locale/bitcoin_es.ts index 49e0f0a2c7f..8c6966bfad6 100644 --- a/src/qt/locale/bitcoin_es.ts +++ b/src/qt/locale/bitcoin_es.ts @@ -936,7 +936,7 @@ p, li { white-space: pre-wrap; } - Choose adress from address book + Choose address from address book Elije dirección de la guia diff --git a/src/qt/locale/bitcoin_es_CL.ts b/src/qt/locale/bitcoin_es_CL.ts index bb9d299790f..107b90bb556 100644 --- a/src/qt/locale/bitcoin_es_CL.ts +++ b/src/qt/locale/bitcoin_es_CL.ts @@ -936,7 +936,7 @@ p, li { white-space: pre-wrap; } - Choose adress from address book + Choose address from address book Elije dirección de la guia diff --git a/src/qt/locale/bitcoin_nb.ts b/src/qt/locale/bitcoin_nb.ts index 018bc62910c..ef09e6baf7d 100644 --- a/src/qt/locale/bitcoin_nb.ts +++ b/src/qt/locale/bitcoin_nb.ts @@ -917,7 +917,7 @@ p, li { white-space: pre-wrap; } - Choose adress from address book + Choose address from address book Velg adresse fra adresseboken diff --git a/src/qt/locale/bitcoin_nl.ts b/src/qt/locale/bitcoin_nl.ts index d26e016b8b7..2b36237d2e5 100644 --- a/src/qt/locale/bitcoin_nl.ts +++ b/src/qt/locale/bitcoin_nl.ts @@ -918,7 +918,7 @@ p, li { white-space: pre-wrap; } - Choose adress from address book + Choose address from address book Kies adres uit adresboek diff --git a/src/qt/locale/bitcoin_ru.ts b/src/qt/locale/bitcoin_ru.ts index 804781b01ab..8bce04ed973 100644 --- a/src/qt/locale/bitcoin_ru.ts +++ b/src/qt/locale/bitcoin_ru.ts @@ -912,7 +912,7 @@ p, li { white-space: pre-wrap; } - Choose adress from address book + Choose address from address book Выбрать адрес из адресной книги diff --git a/src/qt/locale/bitcoin_zh_TW.ts b/src/qt/locale/bitcoin_zh_TW.ts index 48b5e599ba9..b0c4bd12d8a 100644 --- a/src/qt/locale/bitcoin_zh_TW.ts +++ b/src/qt/locale/bitcoin_zh_TW.ts @@ -916,7 +916,7 @@ p, li { white-space: pre-wrap; } - Choose adress from address book + Choose address from address book 從位址簿中選一個位址 From 20e3f2aefc6071af1d4e0754053f2fb88061ee9a Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Tue, 3 Jan 2012 11:55:58 +0100 Subject: [PATCH 054/154] Fix typo (#734) --- src/qt/forms/sendcoinsentry.ui | 2 +- src/qt/locale/bitcoin_da.ts | 2 +- src/qt/locale/bitcoin_de.ts | 2 +- src/qt/locale/bitcoin_en.ts | 2 +- src/qt/locale/bitcoin_es.ts | 2 +- src/qt/locale/bitcoin_es_CL.ts | 2 +- src/qt/locale/bitcoin_hu.ts | 2 +- src/qt/locale/bitcoin_it.ts | 2 +- src/qt/locale/bitcoin_nb.ts | 2 +- src/qt/locale/bitcoin_nl.ts | 2 +- src/qt/locale/bitcoin_pt_BR.ts | 4 ++-- src/qt/locale/bitcoin_ru.ts | 2 +- src/qt/locale/bitcoin_uk.ts | 2 +- src/qt/locale/bitcoin_zh_CN.ts | 2 +- src/qt/locale/bitcoin_zh_TW.ts | 2 +- 15 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/qt/forms/sendcoinsentry.ui b/src/qt/forms/sendcoinsentry.ui index 0297d17f157..22a3f8fdc61 100644 --- a/src/qt/forms/sendcoinsentry.ui +++ b/src/qt/forms/sendcoinsentry.ui @@ -100,7 +100,7 @@ - Choose adress from address book + Choose address from address book diff --git a/src/qt/locale/bitcoin_da.ts b/src/qt/locale/bitcoin_da.ts index 19dde6a5d75..2b6d6057670 100644 --- a/src/qt/locale/bitcoin_da.ts +++ b/src/qt/locale/bitcoin_da.ts @@ -917,7 +917,7 @@ p, li { white-space: pre-wrap; } - Choose adress from address book + Choose address from address book Vælg adresse fra adressebog diff --git a/src/qt/locale/bitcoin_de.ts b/src/qt/locale/bitcoin_de.ts index 394565e9985..1aba0d58dfa 100644 --- a/src/qt/locale/bitcoin_de.ts +++ b/src/qt/locale/bitcoin_de.ts @@ -916,7 +916,7 @@ p, li { white-space: pre-wrap; } - Choose adress from address book + Choose address from address book Adresse aus dem Adressbuch auswählen diff --git a/src/qt/locale/bitcoin_en.ts b/src/qt/locale/bitcoin_en.ts index df964c91e6d..0d57d9b1544 100644 --- a/src/qt/locale/bitcoin_en.ts +++ b/src/qt/locale/bitcoin_en.ts @@ -919,7 +919,7 @@ p, li { white-space: pre-wrap; } - Choose adress from address book + Choose address from address book diff --git a/src/qt/locale/bitcoin_es.ts b/src/qt/locale/bitcoin_es.ts index 4c1fc1aaf6e..df62780c4f7 100644 --- a/src/qt/locale/bitcoin_es.ts +++ b/src/qt/locale/bitcoin_es.ts @@ -919,7 +919,7 @@ p, li { white-space: pre-wrap; } - Choose adress from address book + Choose address from address book Elije dirección de la guia diff --git a/src/qt/locale/bitcoin_es_CL.ts b/src/qt/locale/bitcoin_es_CL.ts index c9e18a0b567..d7e110cb13b 100644 --- a/src/qt/locale/bitcoin_es_CL.ts +++ b/src/qt/locale/bitcoin_es_CL.ts @@ -919,7 +919,7 @@ p, li { white-space: pre-wrap; } - Choose adress from address book + Choose address from address book Elije dirección de la guia diff --git a/src/qt/locale/bitcoin_hu.ts b/src/qt/locale/bitcoin_hu.ts index 0c460022ffa..25a0a24a18c 100644 --- a/src/qt/locale/bitcoin_hu.ts +++ b/src/qt/locale/bitcoin_hu.ts @@ -917,7 +917,7 @@ p, li { white-space: pre-wrap; } - Choose adress from address book + Choose address from address book Válassz egy címet a címjegyzékből diff --git a/src/qt/locale/bitcoin_it.ts b/src/qt/locale/bitcoin_it.ts index c9aa980a4df..95d76005fdd 100644 --- a/src/qt/locale/bitcoin_it.ts +++ b/src/qt/locale/bitcoin_it.ts @@ -918,7 +918,7 @@ p, li { white-space: pre-wrap; }⏎ - Choose adress from address book + Choose address from address book Scegli l'indirizzo dalla rubrica diff --git a/src/qt/locale/bitcoin_nb.ts b/src/qt/locale/bitcoin_nb.ts index 6a3a4107a79..f43ba2fd394 100644 --- a/src/qt/locale/bitcoin_nb.ts +++ b/src/qt/locale/bitcoin_nb.ts @@ -917,7 +917,7 @@ p, li { white-space: pre-wrap; } - Choose adress from address book + Choose address from address book Velg adresse fra adresseboken diff --git a/src/qt/locale/bitcoin_nl.ts b/src/qt/locale/bitcoin_nl.ts index 0651775e0b5..91b39ce9989 100644 --- a/src/qt/locale/bitcoin_nl.ts +++ b/src/qt/locale/bitcoin_nl.ts @@ -918,7 +918,7 @@ p, li { white-space: pre-wrap; } - Choose adress from address book + Choose address from address book Kies adres uit adresboek diff --git a/src/qt/locale/bitcoin_pt_BR.ts b/src/qt/locale/bitcoin_pt_BR.ts index eb6c18c9e23..a9555c3dc47 100644 --- a/src/qt/locale/bitcoin_pt_BR.ts +++ b/src/qt/locale/bitcoin_pt_BR.ts @@ -910,8 +910,8 @@ p, li { white-space: pre-wrap; } - Choose adress from address book - Choose adress from address book + Choose address from address book + Choose address from address book diff --git a/src/qt/locale/bitcoin_ru.ts b/src/qt/locale/bitcoin_ru.ts index 358c4f1470c..9f782205bee 100644 --- a/src/qt/locale/bitcoin_ru.ts +++ b/src/qt/locale/bitcoin_ru.ts @@ -917,7 +917,7 @@ p, li { white-space: pre-wrap; } - Choose adress from address book + Choose address from address book Выбрать адрес из адресной книги diff --git a/src/qt/locale/bitcoin_uk.ts b/src/qt/locale/bitcoin_uk.ts index 3ea0bcc736a..57313b7a521 100644 --- a/src/qt/locale/bitcoin_uk.ts +++ b/src/qt/locale/bitcoin_uk.ts @@ -917,7 +917,7 @@ p, li { white-space: pre-wrap; } - Choose adress from address book + Choose address from address book Вибрати адресу з адресної книги diff --git a/src/qt/locale/bitcoin_zh_CN.ts b/src/qt/locale/bitcoin_zh_CN.ts index acd8fa9d5f0..3faaac3c97b 100644 --- a/src/qt/locale/bitcoin_zh_CN.ts +++ b/src/qt/locale/bitcoin_zh_CN.ts @@ -917,7 +917,7 @@ p, li { white-space: pre-wrap; } - Choose adress from address book + Choose address from address book 从地址薄选择地址 diff --git a/src/qt/locale/bitcoin_zh_TW.ts b/src/qt/locale/bitcoin_zh_TW.ts index b150620648c..56dd548f6d3 100644 --- a/src/qt/locale/bitcoin_zh_TW.ts +++ b/src/qt/locale/bitcoin_zh_TW.ts @@ -916,7 +916,7 @@ p, li { white-space: pre-wrap; } - Choose adress from address book + Choose address from address book 從位址簿中選一個位址 From 45099b19daea9b78bf9823fab8d930211f738d7d Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Wed, 28 Dec 2011 11:14:05 +0100 Subject: [PATCH 055/154] Fix transaction type in UI: not all tx'es with "from"/"to" field are necessarily IP tx'es - Also, prepare for OP_EVAL by calling all transactions without bitcoin address "SendToOther"/"RecvFromOther", (IP tx'es are so rare they can be put together with funky EV_EVAL scripts) --- src/qt/transactionrecord.cpp | 41 ++++++++++++++++---------------- src/qt/transactionrecord.h | 4 ++-- src/qt/transactiontablemodel.cpp | 17 +++++++------ src/qt/transactionview.cpp | 4 ++-- 4 files changed, 32 insertions(+), 34 deletions(-) diff --git a/src/qt/transactionrecord.cpp b/src/qt/transactionrecord.cpp index 77c5a01260d..52a3080e970 100644 --- a/src/qt/transactionrecord.cpp +++ b/src/qt/transactionrecord.cpp @@ -64,17 +64,10 @@ QList TransactionRecord::decomposeTransaction(const CWallet * sub.credit = nUnmatured; } } - else if (!mapValue["from"].empty() || !mapValue["message"].empty()) - { - // Received by IP connection - sub.type = TransactionRecord::RecvFromIP; - if (!mapValue["from"].empty()) - sub.address = mapValue["from"]; - } else { + bool foundAddress = false; // Received by Bitcoin Address - sub.type = TransactionRecord::RecvWithAddress; BOOST_FOREACH(const CTxOut& txout, wtx.vout) { if(wallet->IsMine(txout)) @@ -82,11 +75,19 @@ QList TransactionRecord::decomposeTransaction(const CWallet * CBitcoinAddress address; if (ExtractAddress(txout.scriptPubKey, wallet, address)) { + sub.type = TransactionRecord::RecvWithAddress; sub.address = address.ToString(); + foundAddress = true; + break; } - break; } } + if(!foundAddress) + { + // Received by IP connection, or other non-address transaction like OP_EVAL + sub.type = TransactionRecord::RecvFromOther; + sub.address = mapValue["from"]; + } } parts.append(sub); } @@ -127,21 +128,19 @@ QList TransactionRecord::decomposeTransaction(const CWallet * // from a transaction sent back to our own address. continue; } - else if(!mapValue["to"].empty()) - { - // Sent to IP - sub.type = TransactionRecord::SendToIP; - sub.address = mapValue["to"]; - } - else + + CBitcoinAddress address; + if (ExtractAddress(txout.scriptPubKey, 0, address)) { // Sent to Bitcoin Address sub.type = TransactionRecord::SendToAddress; - CBitcoinAddress address; - if (ExtractAddress(txout.scriptPubKey, 0, address)) - { - sub.address = address.ToString(); - } + sub.address = address.ToString(); + } + else + { + // Sent to IP, or other non-address transaction like OP_EVAL + sub.type = TransactionRecord::SendToOther; + sub.address = mapValue["to"]; } int64 nValue = txout.nValue; diff --git a/src/qt/transactionrecord.h b/src/qt/transactionrecord.h index 0050c878ee6..84bf959b178 100644 --- a/src/qt/transactionrecord.h +++ b/src/qt/transactionrecord.h @@ -56,9 +56,9 @@ public: Other, Generated, SendToAddress, - SendToIP, + SendToOther, RecvWithAddress, - RecvFromIP, + RecvFromOther, SendToSelf }; diff --git a/src/qt/transactiontablemodel.cpp b/src/qt/transactiontablemodel.cpp index 0e1733f156a..b863546691d 100644 --- a/src/qt/transactiontablemodel.cpp +++ b/src/qt/transactiontablemodel.cpp @@ -345,12 +345,11 @@ QString TransactionTableModel::formatTxType(const TransactionRecord *wtx) const { case TransactionRecord::RecvWithAddress: return tr("Received with"); - case TransactionRecord::RecvFromIP: - return tr("Received from IP"); + case TransactionRecord::RecvFromOther: + return tr("Received from"); case TransactionRecord::SendToAddress: + case TransactionRecord::SendToOther: return tr("Sent to"); - case TransactionRecord::SendToIP: - return tr("Sent to IP"); case TransactionRecord::SendToSelf: return tr("Payment to yourself"); case TransactionRecord::Generated: @@ -367,10 +366,10 @@ QVariant TransactionTableModel::txAddressDecoration(const TransactionRecord *wtx case TransactionRecord::Generated: return QIcon(":/icons/tx_mined"); case TransactionRecord::RecvWithAddress: - case TransactionRecord::RecvFromIP: + case TransactionRecord::RecvFromOther: return QIcon(":/icons/tx_input"); case TransactionRecord::SendToAddress: - case TransactionRecord::SendToIP: + case TransactionRecord::SendToOther: return QIcon(":/icons/tx_output"); default: return QIcon(":/icons/tx_inout"); @@ -382,12 +381,12 @@ QString TransactionTableModel::formatTxToAddress(const TransactionRecord *wtx, b { switch(wtx->type) { - case TransactionRecord::RecvFromIP: + case TransactionRecord::RecvFromOther: return QString::fromStdString(wtx->address); case TransactionRecord::RecvWithAddress: case TransactionRecord::SendToAddress: return lookupAddress(wtx->address, tooltip); - case TransactionRecord::SendToIP: + case TransactionRecord::SendToOther: return QString::fromStdString(wtx->address); case TransactionRecord::SendToSelf: case TransactionRecord::Generated: @@ -478,7 +477,7 @@ QVariant TransactionTableModel::txStatusDecoration(const TransactionRecord *wtx) QString TransactionTableModel::formatTooltip(const TransactionRecord *rec) const { QString tooltip = formatTxStatus(rec) + QString("\n") + formatTxType(rec); - if(rec->type==TransactionRecord::RecvFromIP || rec->type==TransactionRecord::SendToIP || + if(rec->type==TransactionRecord::RecvFromOther || rec->type==TransactionRecord::SendToOther || rec->type==TransactionRecord::SendToAddress || rec->type==TransactionRecord::RecvWithAddress) { tooltip += QString(" ") + formatTxToAddress(rec, true); diff --git a/src/qt/transactionview.cpp b/src/qt/transactionview.cpp index 2dcbf1ea8ac..3ef31854fb4 100644 --- a/src/qt/transactionview.cpp +++ b/src/qt/transactionview.cpp @@ -70,9 +70,9 @@ TransactionView::TransactionView(QWidget *parent) : typeWidget->addItem(tr("All"), TransactionFilterProxy::ALL_TYPES); typeWidget->addItem(tr("Received with"), TransactionFilterProxy::TYPE(TransactionRecord::RecvWithAddress) | - TransactionFilterProxy::TYPE(TransactionRecord::RecvFromIP)); + TransactionFilterProxy::TYPE(TransactionRecord::RecvFromOther)); typeWidget->addItem(tr("Sent to"), TransactionFilterProxy::TYPE(TransactionRecord::SendToAddress) | - TransactionFilterProxy::TYPE(TransactionRecord::SendToIP)); + TransactionFilterProxy::TYPE(TransactionRecord::SendToOther)); typeWidget->addItem(tr("To yourself"), TransactionFilterProxy::TYPE(TransactionRecord::SendToSelf)); typeWidget->addItem(tr("Mined"), TransactionFilterProxy::TYPE(TransactionRecord::Generated)); typeWidget->addItem(tr("Other"), TransactionFilterProxy::TYPE(TransactionRecord::Other)); From 99e9601e805c009b301c7cb29d541858507ae095 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Tue, 3 Jan 2012 00:03:07 -0800 Subject: [PATCH 056/154] Fix horrific performance found by gmaxwell. --- src/serialize.h | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/src/serialize.h b/src/serialize.h index 7876990d04e..b0ce0652977 100644 --- a/src/serialize.h +++ b/src/serialize.h @@ -828,6 +828,38 @@ struct secure_allocator : public std::allocator }; +// +// Allocator that clears its contents before deletion. +// +template +struct zero_after_free_allocator : public std::allocator +{ + // MSVC8 default copy constructor is broken + typedef std::allocator base; + typedef typename base::size_type size_type; + typedef typename base::difference_type difference_type; + typedef typename base::pointer pointer; + typedef typename base::const_pointer const_pointer; + typedef typename base::reference reference; + typedef typename base::const_reference const_reference; + typedef typename base::value_type value_type; + zero_after_free_allocator() throw() {} + zero_after_free_allocator(const zero_after_free_allocator& a) throw() : base(a) {} + template + zero_after_free_allocator(const zero_after_free_allocator& a) throw() : base(a) {} + ~zero_after_free_allocator() throw() {} + template struct rebind + { typedef zero_after_free_allocator<_Other> other; }; + + void deallocate(T* p, std::size_t n) + { + if (p != NULL) + memset(p, 0, sizeof(T) * n); + std::allocator::deallocate(p, n); + } +}; + + // // Double ended buffer combining vector and stream-like interfaces. @@ -837,7 +869,7 @@ struct secure_allocator : public std::allocator class CDataStream { protected: - typedef std::vector > vector_type; + typedef std::vector > vector_type; vector_type vch; unsigned int nReadPos; short state; From 09308a3882552b5b3bab67064514499532121b44 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Sat, 7 Jan 2012 13:35:25 -0500 Subject: [PATCH 057/154] Remove mentions on anonymity in debian folder. These should never have been there, bitcoin isnt anonymous without a ton of work that virtually no users will ever be willing and capable of doing. --- contrib/debian/changelog | 9 +++++++++ contrib/debian/control | 4 ++-- contrib/debian/manpages/bitcoind.1 | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/contrib/debian/changelog b/contrib/debian/changelog index bef58c982fc..0c67487fc11 100644 --- a/contrib/debian/changelog +++ b/contrib/debian/changelog @@ -1,3 +1,12 @@ +bitcoin (0.5.0.3-natty1) natty; urgency=low + + * Remove mentions on anonymity in package descriptions and manpage. + These should never have been there, bitcoin isnt anonymous without + a ton of work that virtually no users will ever be willing and + capable of doing + + -- Matt Corallo Sat, 7 Jan 2012 13:37:00 -0500 + bitcoin (0.5.0.3-natty0) natty; urgency=low * New upstream release. diff --git a/contrib/debian/control b/contrib/debian/control index 13fde5948c2..c41664ca6f9 100644 --- a/contrib/debian/control +++ b/contrib/debian/control @@ -24,7 +24,7 @@ Vcs-Browser: http://github.com/bitcoin/bitcoin Package: bitcoind Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends} -Description: peer-to-peer network based anonymous digital currency - daemon +Description: peer-to-peer network based digital currency - daemon Bitcoin is a free open source peer-to-peer electronic cash system that is completely decentralized, without the need for a central server or trusted parties. Users hold the crypto keys to their own money and @@ -42,7 +42,7 @@ Description: peer-to-peer network based anonymous digital currency - daemon Package: bitcoin-qt Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends} -Description: peer-to-peer network based anonymous digital currency - QT GUI +Description: peer-to-peer network based digital currency - QT GUI Bitcoin is a free open source peer-to-peer electronic cash system that is completely decentralized, without the need for a central server or trusted parties. Users hold the crypto keys to their own money and diff --git a/contrib/debian/manpages/bitcoind.1 b/contrib/debian/manpages/bitcoind.1 index 0179406a16d..bf46a6609ca 100644 --- a/contrib/debian/manpages/bitcoind.1 +++ b/contrib/debian/manpages/bitcoind.1 @@ -1,6 +1,6 @@ .TH BITCOIND "1" "January 2011" "bitcoind 3.19" .SH NAME -bitcoind \- peer-to-peer network based anonymous digital currency +bitcoind \- peer-to-peer network based digital currency .SH SYNOPSIS bitcoin [options] [params] .TP From 21aa161453f7ee2505684885ee60cd146bc37b65 Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Fri, 6 Jan 2012 06:55:48 +0100 Subject: [PATCH 058/154] make transaction description read-only (UI fix) --- src/qt/forms/transactiondescdialog.ui | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/qt/forms/transactiondescdialog.ui b/src/qt/forms/transactiondescdialog.ui index 2f70a38214b..9a9f6db1587 100644 --- a/src/qt/forms/transactiondescdialog.ui +++ b/src/qt/forms/transactiondescdialog.ui @@ -19,6 +19,9 @@ This pane shows a detailed description of the transaction + + true + From 2d8bc0e6da2203ba2ae62bb167110529e5b6f7d4 Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Tue, 13 Dec 2011 17:30:13 +0100 Subject: [PATCH 059/154] Add "About Qt" menu option to show built-in Qt About dialog - Most Qt programs do this, and it can be useful to find out what version of Qt was built against. --- src/qt/bitcoingui.cpp | 8 +++++++- src/qt/bitcoingui.h | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index 5968aab6c41..75d2a50a25c 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -57,6 +57,7 @@ BitcoinGUI::BitcoinGUI(QWidget *parent): walletModel(0), encryptWalletAction(0), changePassphraseAction(0), + aboutQtAction(0), trayIcon(0), notificator(0) { @@ -204,7 +205,10 @@ void BitcoinGUI::createActions() quitAction->setMenuRole(QAction::QuitRole); aboutAction = new QAction(QIcon(":/icons/bitcoin"), tr("&About %1").arg(qApp->applicationName()), this); aboutAction->setToolTip(tr("Show information about Bitcoin")); - aboutAction->setMenuRole(QAction::AboutQtRole); + aboutAction->setMenuRole(QAction::AboutRole); + aboutQtAction = new QAction(tr("About &Qt"), this); + aboutQtAction->setToolTip(tr("Show information about Qt")); + aboutQtAction->setMenuRole(QAction::AboutQtRole); optionsAction = new QAction(QIcon(":/icons/options"), tr("&Options..."), this); optionsAction->setToolTip(tr("Modify configuration options for bitcoin")); optionsAction->setMenuRole(QAction::PreferencesRole); @@ -221,6 +225,7 @@ void BitcoinGUI::createActions() connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit())); connect(optionsAction, SIGNAL(triggered()), this, SLOT(optionsClicked())); connect(aboutAction, SIGNAL(triggered()), this, SLOT(aboutClicked())); + connect(aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt())); connect(openBitcoinAction, SIGNAL(triggered()), this, SLOT(showNormal())); connect(encryptWalletAction, SIGNAL(triggered(bool)), this, SLOT(encryptWallet(bool))); connect(changePassphraseAction, SIGNAL(triggered()), this, SLOT(changePassphrase())); @@ -248,6 +253,7 @@ void BitcoinGUI::createMenuBar() QMenu *help = appMenuBar->addMenu(tr("&Help")); help->addAction(aboutAction); + help->addAction(aboutQtAction); } void BitcoinGUI::createToolBars() diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h index 581d3937490..9b672ee809d 100644 --- a/src/qt/bitcoingui.h +++ b/src/qt/bitcoingui.h @@ -79,6 +79,7 @@ private: QAction *exportAction; QAction *encryptWalletAction; QAction *changePassphraseAction; + QAction *aboutQtAction; QSystemTrayIcon *trayIcon; Notificator *notificator; From 6e1e62a04c79a93d124371fa102d7881449b3673 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Tue, 10 Jan 2012 15:50:37 -0500 Subject: [PATCH 060/154] Bump version to 0.4.4 --- 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 1d520c93cf9..bef67460c88 100644 --- a/contrib/Bitcoin.app/Contents/Info.plist +++ b/contrib/Bitcoin.app/Contents/Info.plist @@ -17,7 +17,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 0.4.3 + 0.4.4 CFBundleSignature ???? CFBundleVersion diff --git a/doc/README b/doc/README index d91509bd90d..40bda47d9c8 100644 --- a/doc/README +++ b/doc/README @@ -1,4 +1,4 @@ -Bitcoin 0.4.3 BETA +Bitcoin 0.4.4 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 2f5761645a8..f8f1c341886 100644 --- a/doc/README_windows.txt +++ b/doc/README_windows.txt @@ -1,4 +1,4 @@ -Bitcoin 0.4.3 BETA +Bitcoin 0.4.4 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 3455f7681cb..05983117909 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.3 +!define VERSION 0.4.4 !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.3-win32-setup.exe +OutFile bitcoin-0.4.4-win32-setup.exe InstallDir $PROGRAMFILES\Bitcoin CRCCheck on XPStyle on BrandingText " " ShowInstDetails show -VIProductVersion 0.4.3.0 +VIProductVersion 0.4.4.0 VIAddVersionKey ProductName Bitcoin VIAddVersionKey ProductVersion "${VERSION}" VIAddVersionKey CompanyName "${COMPANY}" diff --git a/src/serialize.h b/src/serialize.h index b0ce0652977..d7b5ec80d56 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 = 40300; +static const int VERSION = 40400; static const char* pszSubVer = ""; static const bool VERSION_IS_BETA = true; From 507848b63d980d32798689db408ce980d77a5483 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Tue, 10 Jan 2012 15:54:38 -0500 Subject: [PATCH 061/154] Bump version to 0.5.0.4 --- bitcoin-qt.pro | 2 +- contrib/debian/changelog | 6 ++++++ doc/README | 2 +- doc/README_windows.txt | 2 +- share/setup.nsi | 6 +++--- src/serialize.h | 2 +- 6 files changed, 13 insertions(+), 7 deletions(-) diff --git a/bitcoin-qt.pro b/bitcoin-qt.pro index 1eddcd542b4..19349c708d0 100644 --- a/bitcoin-qt.pro +++ b/bitcoin-qt.pro @@ -1,6 +1,6 @@ TEMPLATE = app TARGET = -VERSION = 0.5.0.3 +VERSION = 0.5.0.4 INCLUDEPATH += src src/json src/qt DEFINES += QT_GUI BOOST_THREAD_USE_LIB CONFIG += no_include_pwd diff --git a/contrib/debian/changelog b/contrib/debian/changelog index 0c67487fc11..24d6f710b6c 100644 --- a/contrib/debian/changelog +++ b/contrib/debian/changelog @@ -1,3 +1,9 @@ +bitcoin (0.5.0.4-natty0) natty; urgency=low + + * New upstream release. + + -- Matt Corallo Tue, 10 Jan 2012 15:53:00 -0500 + bitcoin (0.5.0.3-natty1) natty; urgency=low * Remove mentions on anonymity in package descriptions and manpage. diff --git a/doc/README b/doc/README index c3ed9c4b7e3..e3b8ffb3b91 100644 --- a/doc/README +++ b/doc/README @@ -1,4 +1,4 @@ -Bitcoin 0.5.0.3 BETA +Bitcoin 0.5.0.4 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 8a8f82b846d..b117f51208e 100644 --- a/doc/README_windows.txt +++ b/doc/README_windows.txt @@ -1,4 +1,4 @@ -Bitcoin 0.5.0.3 BETA +Bitcoin 0.5.0.4 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 76efe57d27f..76ae81762db 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.3 +!define VERSION 0.5.0.4 !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.3-win32-setup.exe +OutFile bitcoin-0.5.0.4-win32-setup.exe InstallDir $PROGRAMFILES\Bitcoin CRCCheck on XPStyle on BrandingText " " ShowInstDetails show -VIProductVersion 0.5.0.3 +VIProductVersion 0.5.0.4 VIAddVersionKey ProductName Bitcoin VIAddVersionKey ProductVersion "${VERSION}" VIAddVersionKey CompanyName "${COMPANY}" diff --git a/src/serialize.h b/src/serialize.h index 0f075a5bf14..5bee071e1cb 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 = 50003; +static const int VERSION = 50004; static const char* pszSubVer = ""; static const bool VERSION_IS_BETA = true; From 98811f6ad4764f63e510d703d1659589c083fa05 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Tue, 10 Jan 2012 15:58:29 -0500 Subject: [PATCH 062/154] Bump version to 0.5.3 --- bitcoin-qt.pro | 2 +- contrib/debian/changelog | 6 ++++++ doc/README | 2 +- doc/README_windows.txt | 2 +- share/setup.nsi | 6 +++--- src/serialize.h | 2 +- 6 files changed, 13 insertions(+), 7 deletions(-) diff --git a/bitcoin-qt.pro b/bitcoin-qt.pro index d7ac62e90a6..f98379904ce 100644 --- a/bitcoin-qt.pro +++ b/bitcoin-qt.pro @@ -1,6 +1,6 @@ TEMPLATE = app TARGET = -VERSION = 0.5.2 +VERSION = 0.5.3 INCLUDEPATH += src src/json src/qt DEFINES += QT_GUI BOOST_THREAD_USE_LIB CONFIG += no_include_pwd diff --git a/contrib/debian/changelog b/contrib/debian/changelog index 5e38c7bd204..0720acc35c3 100644 --- a/contrib/debian/changelog +++ b/contrib/debian/changelog @@ -1,3 +1,9 @@ +bitcoin (0.5.3-natty0) natty; urgency=low + + * New upstream release. + + -- Luke Dashjr Tue, 10 Jan 2012 15:57:00 -0500 + bitcoin (0.5.2-natty1) natty; urgency=low * Remove mentions on anonymity in package descriptions and manpage. diff --git a/doc/README b/doc/README index 07785655f24..6c6c70a3429 100644 --- a/doc/README +++ b/doc/README @@ -1,4 +1,4 @@ -Bitcoin 0.5.2 BETA +Bitcoin 0.5.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 b98f878b27f..4fdf4a54931 100644 --- a/doc/README_windows.txt +++ b/doc/README_windows.txt @@ -1,4 +1,4 @@ -Bitcoin 0.5.2 BETA +Bitcoin 0.5.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 abf5c566b5a..12a1a532daa 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.2 +!define VERSION 0.5.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.2-win32-setup.exe +OutFile bitcoin-0.5.3-win32-setup.exe InstallDir $PROGRAMFILES\Bitcoin CRCCheck on XPStyle on BrandingText " " ShowInstDetails show -VIProductVersion 0.5.2.0 +VIProductVersion 0.5.3.0 VIAddVersionKey ProductName Bitcoin VIAddVersionKey ProductVersion "${VERSION}" VIAddVersionKey CompanyName "${COMPANY}" diff --git a/src/serialize.h b/src/serialize.h index 37748e4cdfe..eacf51bc39f 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 = 50200; +static const int VERSION = 50300; static const char* pszSubVer = ""; static const bool VERSION_IS_BETA = true; From 880c47863587ef4f464c4d681713e1f24cbf1cb7 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Mon, 9 Jan 2012 23:39:26 +0100 Subject: [PATCH 063/154] Remove unused definition --- src/wallet.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/wallet.h b/src/wallet.h index 794139233d0..3560a725801 100644 --- a/src/wallet.h +++ b/src/wallet.h @@ -77,7 +77,6 @@ public: bool CreateTransaction(const std::vector >& vecSend, CWalletTx& wtxNew, CReserveKey& reservekey, int64& nFeeRet); bool CreateTransaction(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew, CReserveKey& reservekey, int64& nFeeRet); bool CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey); - bool BroadcastTransaction(CWalletTx& wtxNew); 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); From 948072c39f913d1ebe43b3b46234f9d7a0d00427 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Mon, 16 Jan 2012 22:17:48 -0500 Subject: [PATCH 064/154] Code tidyups, fixing various warnings. Partial cherry pick of: Compile with extra warnings turned on. And more makefile/code tidying up. This turns on most gcc warnings, and removes some unused variables and other code that triggers warnings. Exceptions are: -Wno-sign-compare : triggered by lots of comparisons of signed integer to foo.size(), which is unsigned. -Wno-char-subscripts : triggered by the convert-to-hex functions (I may fix this in a future commit). Conflicts: src/makefile.osx src/makefile.unix src/netbase.cpp src/rpc.cpp --- src/checkpoints.cpp | 1 - src/headers.h | 2 -- src/net.cpp | 3 --- src/net.h | 4 +++- src/serialize.h | 3 +++ 5 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/checkpoints.cpp b/src/checkpoints.cpp index c7e054df378..508f72b3765 100644 --- a/src/checkpoints.cpp +++ b/src/checkpoints.cpp @@ -52,7 +52,6 @@ namespace Checkpoints { if (fTestNet) return NULL; - int64 nResult; BOOST_REVERSE_FOREACH(const MapCheckpoints::value_type& i, mapCheckpoints) { const uint256& hash = i.second; diff --git a/src/headers.h b/src/headers.h index ab318cbb436..96db87db1ba 100644 --- a/src/headers.h +++ b/src/headers.h @@ -91,8 +91,6 @@ #endif -#pragma hdrstop - #include "serialize.h" #include "uint256.h" #include "util.h" diff --git a/src/net.cpp b/src/net.cpp index c7475b118cf..e3c0f8c3d18 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1082,7 +1082,6 @@ void ThreadMapPort2(void* parg) char port[6]; sprintf(port, "%d", GetListenPort()); - const char * rootdescurl = 0; const char * multicastif = 0; const char * minissdpdpath = 0; struct UPNPDev * devlist = 0; @@ -1104,8 +1103,6 @@ void ThreadMapPort2(void* parg) r = UPNP_GetValidIGD(devlist, &urls, &data, lanaddr, sizeof(lanaddr)); if (r == 1) { - char intClient[16]; - char intPort[6]; string strDesc = "Bitcoin " + FormatFullVersion(); #ifndef UPNPDISCOVER_SUCCESS /* miniupnpc 1.5 */ diff --git a/src/net.h b/src/net.h index 741e2a812ec..03d514ca909 100644 --- a/src/net.h +++ b/src/net.h @@ -264,7 +264,9 @@ public: // Make sure not to reuse time indexes to keep things in the same order int64 nNow = (GetTime() - 1) * 1000000; static int64 nLastTime; - nLastTime = nNow = std::max(nNow, ++nLastTime); + ++nLastTime; + nNow = std::max(nNow, nLastTime); + nLastTime = nNow; // Each retry is 2 minutes after the last nRequestTime = std::max(nRequestTime + 2 * 60 * 1000000, nNow); diff --git a/src/serialize.h b/src/serialize.h index d7b5ec80d56..385c9ab8e93 100644 --- a/src/serialize.h +++ b/src/serialize.h @@ -98,6 +98,7 @@ enum const bool fRead = false; \ unsigned int nSerSize = 0; \ ser_streamplaceholder s; \ + assert(fGetSize||fWrite||fRead); /* suppress warning */ \ s.nType = nType; \ s.nVersion = nVersion; \ {statements} \ @@ -111,6 +112,7 @@ enum const bool fWrite = true; \ const bool fRead = false; \ unsigned int nSerSize = 0; \ + assert(fGetSize||fWrite||fRead); /* suppress warning */ \ {statements} \ } \ template \ @@ -121,6 +123,7 @@ enum const bool fWrite = false; \ const bool fRead = true; \ unsigned int nSerSize = 0; \ + assert(fGetSize||fWrite||fRead); /* suppress warning */ \ {statements} \ } From 5df96269d30ec57e69676e6937b45b3608df98ac Mon Sep 17 00:00:00 2001 From: Janne Pulkkinen Date: Sat, 14 Jan 2012 21:31:49 +0200 Subject: [PATCH 065/154] *Clear all has a tooltip now *About dialog updated --- src/qt/forms/aboutdialog.ui | 2 +- src/qt/forms/sendcoinsdialog.ui | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/qt/forms/aboutdialog.ui b/src/qt/forms/aboutdialog.ui index cf7997326cc..127b90965a6 100644 --- a/src/qt/forms/aboutdialog.ui +++ b/src/qt/forms/aboutdialog.ui @@ -82,7 +82,7 @@ - Copyright © 2009-2011 Bitcoin Developers + Copyright © 2009-2012 Bitcoin Developers This is experimental software. diff --git a/src/qt/forms/sendcoinsdialog.ui b/src/qt/forms/sendcoinsdialog.ui index e5e19e10158..04cf404ae3c 100644 --- a/src/qt/forms/sendcoinsdialog.ui +++ b/src/qt/forms/sendcoinsdialog.ui @@ -80,6 +80,9 @@ 0 + + Remove all transaction fields + Clear all From c144672045e69d82e4e48479f2f1ed9956186bfb Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Mon, 16 Jan 2012 22:16:48 -0500 Subject: [PATCH 066/154] Code tidyups, fixing various warnings. Partial cherry pick of: Compile with extra warnings turned on. And more makefile/code tidying up. This turns on most gcc warnings, and removes some unused variables and other code that triggers warnings. Exceptions are: -Wno-sign-compare : triggered by lots of comparisons of signed integer to foo.size(), which is unsigned. -Wno-char-subscripts : triggered by the convert-to-hex functions (I may fix this in a future commit). Conflicts: src/makefile.osx src/makefile.unix src/netbase.cpp --- src/bitcoinrpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp index 889dd7a1b18..4031d0cbc34 100644 --- a/src/bitcoinrpc.cpp +++ b/src/bitcoinrpc.cpp @@ -1312,7 +1312,7 @@ Value listsinceblock(const Array& params, bool fHelp) CBlockIndex *block; for (block = pindexBest; block && block->nHeight > target_height; - block = block->pprev); + block = block->pprev) { } lastblock = block ? block->GetBlockHash() : 0; } From 1181bf86d14e202849a7de5e839b93a2faeb1ce0 Mon Sep 17 00:00:00 2001 From: Lars Rasmusson Date: Sat, 14 Jan 2012 12:14:36 +0100 Subject: [PATCH 067/154] Replace tabs with four spaces to comply with coding standard in doc/coding.txt --- src/net.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/net.cpp b/src/net.cpp index e3c0f8c3d18..c353473a7e2 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1107,11 +1107,11 @@ void ThreadMapPort2(void* parg) #ifndef UPNPDISCOVER_SUCCESS /* miniupnpc 1.5 */ r = UPNP_AddPortMapping(urls.controlURL, data.first.servicetype, - port, port, lanaddr, strDesc.c_str(), "TCP", 0); + port, port, lanaddr, strDesc.c_str(), "TCP", 0); #else /* miniupnpc 1.6 */ r = UPNP_AddPortMapping(urls.controlURL, data.first.servicetype, - port, port, lanaddr, strDesc.c_str(), "TCP", 0, "0"); + port, port, lanaddr, strDesc.c_str(), "TCP", 0, "0"); #endif if(r!=UPNPCOMMAND_SUCCESS) From b0870346f268d4c7f2d461c921ff63b6d967242d Mon Sep 17 00:00:00 2001 From: Lars Rasmusson Date: Sat, 14 Jan 2012 12:14:36 +0100 Subject: [PATCH 068/154] Replace tabs with four spaces to comply with coding standard in doc/coding.txt --- src/net.cpp | 4 ++-- src/qt/transactionfilterproxy.h | 2 +- src/util.h | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/net.cpp b/src/net.cpp index 18bafd02e70..d99c73f9590 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1158,11 +1158,11 @@ void ThreadMapPort2(void* parg) #ifndef UPNPDISCOVER_SUCCESS /* miniupnpc 1.5 */ r = UPNP_AddPortMapping(urls.controlURL, data.first.servicetype, - port, port, lanaddr, strDesc.c_str(), "TCP", 0); + port, port, lanaddr, strDesc.c_str(), "TCP", 0); #else /* miniupnpc 1.6 */ r = UPNP_AddPortMapping(urls.controlURL, data.first.servicetype, - port, port, lanaddr, strDesc.c_str(), "TCP", 0, "0"); + port, port, lanaddr, strDesc.c_str(), "TCP", 0, "0"); #endif if(r!=UPNPCOMMAND_SUCCESS) diff --git a/src/qt/transactionfilterproxy.h b/src/qt/transactionfilterproxy.h index 4dd2a8e5c66..17c1b482e00 100644 --- a/src/qt/transactionfilterproxy.h +++ b/src/qt/transactionfilterproxy.h @@ -29,7 +29,7 @@ public: // Set maximum number of rows returned, -1 if unlimited void setLimit(int limit); - int rowCount(const QModelIndex &parent = QModelIndex()) const; + int rowCount(const QModelIndex &parent = QModelIndex()) const; protected: bool filterAcceptsRow(int source_row, const QModelIndex & source_parent) const; diff --git a/src/util.h b/src/util.h index 78caff683de..c57e82bab03 100644 --- a/src/util.h +++ b/src/util.h @@ -749,8 +749,8 @@ inline bool AffinityBugWorkaround(void(*pfn)(void*)) inline uint32_t ByteReverse(uint32_t value) { - value = ((value & 0xFF00FF00) >> 8) | ((value & 0x00FF00FF) << 8); - return (value<<16) | (value>>16); + value = ((value & 0xFF00FF00) >> 8) | ((value & 0x00FF00FF) << 8); + return (value<<16) | (value>>16); } #endif From 54ed0a0432a3e02e41e81de63c65a871b8756178 Mon Sep 17 00:00:00 2001 From: Daniel Folkinshteyn Date: Thu, 19 Jan 2012 01:54:14 -0500 Subject: [PATCH 069/154] Update seednodes, pick long-uptime nodes with version >= 0.4.0 --- src/net.cpp | 141 ++++++++++++++++++++++++++++------------------------ 1 file changed, 77 insertions(+), 64 deletions(-) diff --git a/src/net.cpp b/src/net.cpp index c353473a7e2..b35a79deaef 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1243,70 +1243,83 @@ void ThreadDNSAddressSeed2(void* parg) unsigned int pnSeed[] = { - 0x6884ac63, 0x3ffecead, 0x2919b953, 0x0942fe50, 0x7a1d922e, 0xcdd6734a, 0x953a5bb6, 0x2c46922e, - 0xe2a5f143, 0xaa39103a, 0xa06afa5c, 0x135ffd59, 0xe8e82863, 0xf61ef029, 0xf75f042e, 0x2b363532, - 0x29b2df42, 0x16b1f64e, 0xd46e281b, 0x5280bf58, 0x60372229, 0x1be58e4f, 0xa8496f45, 0x1fb1a057, - 0x756b3844, 0x3bb79445, 0x0b375518, 0xcccb0102, 0xb682bf2e, 0x46431c02, 0x3a81073a, 0xa3771f1f, - 0x213a121f, 0x85dc2c1b, 0x56b4323b, 0xb34e8945, 0x3c40b33d, 0xfa276418, 0x1f818d29, 0xebe1e344, - 0xf6160a18, 0xf4fa384a, 0x34b09558, 0xb882b543, 0xe3ce2253, 0x6abf56d8, 0xe91b1155, 0x688ee6ad, - 0x2efc6058, 0x4792cd47, 0x0c32f757, 0x4c813a46, 0x8c93644a, 0x37507444, 0x813ad218, 0xdac06d4a, - 0xe4c63e4b, 0x21a1ea3c, 0x8d88556f, 0x30e9173a, 0x041f681b, 0xdc77ba50, 0xc0072753, 0xceddd44f, - 0x052d1743, 0xe3c77a4a, 0x13981c3a, 0x5685d918, 0x3c0e4e70, 0x3e56fb54, 0xb676ae0c, 0xac93c859, - 0x22279f43, 0x975a4542, 0xe527f071, 0xea162f2e, 0x3c65a32e, 0x5be5713b, 0x961ec418, 0xb202922e, - 0x5ef7be50, 0xce49f53e, 0x05803b47, 0x8463b055, 0x78576153, 0x3ec2ae3a, 0x4bbd7118, 0xafcee043, - 0x56a3e8ba, 0x6174de4d, 0x8d01ba4b, 0xc9af564e, 0xdbc9c547, 0xa627474d, 0xdada9244, 0xd3b3083a, - 0x523e071f, 0xd6b96f18, 0xbd527c46, 0xdf2bbb4d, 0xd37b4a4b, 0x3a6a2158, 0xc064b055, 0x18a8e055, - 0xec4dae3b, 0x0540416c, 0x475b4fbe, 0x064803b2, 0x48e9f062, 0x2898524b, 0xd315ff43, 0xf786d247, - 0xc7ea2f3e, 0xc087f043, 0xc163354b, 0x8250284d, 0xed300029, 0xbf36e05c, 0x8eb3ae4c, 0xe7aa623e, - 0x7ced0274, 0xdd362c1b, 0x362b995a, 0xca26b629, 0x3fc41618, 0xb97b364e, 0xa05b8729, 0x0f5e3c43, - 0xdf942618, 0x6aeb9b5b, 0xbf04762e, 0xfaaeb118, 0x87579958, 0x76520044, 0xc2660c5b, 0x628b201b, - 0xf193932e, 0x1c0ad045, 0xff908346, 0x8da9d4da, 0xed201c1f, 0xa47a2b1b, 0x330007d4, 0x8ba1ed47, - 0xb2f02d44, 0x7db62c1b, 0x781c454b, 0xc0300029, 0xb7062a45, 0x88b52e3a, 0x78dd6b63, 0x1cb9b718, - 0x5d358e47, 0x59912c3b, 0x79607544, 0x5197f759, 0xc023be48, 0xd1013743, 0x0f354057, 0x8e3aac3b, - 0x4114693e, 0x22316318, 0xe27dda50, 0x878eac3b, 0x4948a21f, 0x5db7f24c, 0x8ccb6157, 0x26a5de18, - 0x0a11bd43, 0x27bb1e41, 0x60a7a951, 0x3e16b35e, 0x07888b53, 0x5648a853, 0x0149fe50, 0xd070a34f, - 0x6454c96d, 0xd6e54758, 0xa96dc152, 0x65447861, 0xf6bdf95e, 0x10400202, 0x2c29d483, 0x18174732, - 0x1d840618, 0x12e61818, 0x089d3f3c, 0x917e931f, 0xd1b0c90e, 0x25bd3c42, 0xeb05775b, 0x7d550c59, - 0x6cfacb01, 0xe4224444, 0xa41dd943, 0x0f5aa643, 0x5e33731b, 0x81036d50, 0x6f46a0d1, 0x7731be43, - 0x14840e18, 0xf1e8d059, 0x661d2b1f, 0x40a3201b, 0x9407b843, 0xedf0254d, 0x7bd1a5bc, 0x073dbe51, - 0xe864a97b, 0x2efd947b, 0xb9ca0e45, 0x4e2113ad, 0xcc305731, 0xd39ca63c, 0x733df918, 0xda172b1f, - 0xaa03b34d, 0x7230fd4d, 0xf1ce6e3a, 0x2e9fab43, 0xa4010750, 0xa928bd18, 0x6809be42, 0xb19de348, - 0xff956270, 0x0d795f51, 0xd2dec247, 0x6df5774b, 0xbac11f79, 0xdfb05c75, 0x887683d8, 0xa1e83632, - 0x2c0f7671, 0x28bcb65d, 0xac2a7545, 0x3eebfc60, 0x304ad7c4, 0xa215a462, 0xc86f0f58, 0xcfb92ebe, - 0x5e23ed82, 0xf506184b, 0xec0f19b7, 0x060c59ad, 0x86ee3174, 0x85380774, 0xa199a562, 0x02b507ae, - 0x33eb2163, 0xf2112b1f, 0xb702ba50, 0x131b9618, 0x90ccd04a, 0x08f3273b, 0xecb61718, 0x64b8b44d, - 0x182bf4dc, 0xc7b68286, 0x6e318d5f, 0xfdb03654, 0xb3272e54, 0xe014ad4b, 0x274e4a31, 0x7806375c, - 0xbc34a748, 0x1b5ad94a, 0x6b54d10e, 0x73e2ae6e, 0x5529d483, 0x8455a76d, 0x99c13f47, 0x1d811741, - 0xa9782a78, 0x0b00464d, 0x7266ea50, 0x532dab46, 0x33e1413e, 0x780d0c18, 0x0fb0854e, 0x03370155, - 0x2693042e, 0xfa3d824a, 0x2bb1681b, 0x37ea2a18, 0x7fb8414b, 0x32e0713b, 0xacf38d3f, 0xa282716f, - 0xb1a09d7b, 0xa04b764b, 0x83c94d18, 0x05ee4c6d, 0x0e795f51, 0x46984352, 0xf80fc247, 0x3fccb946, - 0xd7ae244b, 0x0a8e0a4c, 0x57b141bc, 0x3647bed1, 0x1431b052, 0x803a8bbb, 0xfc69056b, 0xf5991862, - 0x14963b2e, 0xd35d5dda, 0xc6c73574, 0xc8f1405b, 0x0ca4224d, 0xecd36071, 0xa9461754, 0xe7a0ed72, - 0x559e8346, 0x1c9beec1, 0xc786ea4a, 0x9561b44d, 0x9788074d, 0x1a69934f, 0x23c5614c, 0x07c79d4b, - 0xc7ee52db, 0xc72df351, 0xcb135e44, 0xa0988346, 0xc211fc4c, 0x87dec34b, 0x1381074d, 0x04a65cb7, - 0x4409083a, 0x4a407a4c, 0x92b8d37d, 0xacf50b4d, 0xa58aa5bc, 0x448f801f, 0x9c83762e, 0x6fd5734a, - 0xfe2d454b, 0x84144c55, 0x05190e4c, 0xb2151448, 0x63867a3e, 0x16099018, 0x9c010d3c, 0x962d8f3d, - 0xd51ee453, 0x9d86801f, 0x68e87b47, 0x6bf7bb73, 0x5fc7910e, 0x10d90118, 0x3db04442, 0x729d3e4b, - 0xc397d842, 0x57bb15ad, 0x72f31f4e, 0xc9380043, 0x2bb24e18, 0xd9b8ab50, 0xb786801f, 0xf4dc4847, - 0x85f4bb51, 0x4435995b, 0x5ba07e40, 0x2c57392e, 0x3628124b, 0x9839b64b, 0x6fe8b24d, 0xaddce847, - 0x75260e45, 0x0c572a43, 0xfea21902, 0xb9f9742e, 0x5a70d443, 0x8fc5910e, 0x868d4744, 0x56245e02, - 0xd7eb5f02, 0x35c12c1b, 0x4373034b, 0x8786554c, 0xa6facf18, 0x4b11a31f, 0x3570664e, 0x5a64bc42, - 0x0b03983f, 0x8f457e4c, 0x0fd874c3, 0xb6cf31b2, 0x2bbc2d4e, 0x146ca5b2, 0x9d00b150, 0x048a4153, - 0xca4dcd43, 0xc1607cca, 0x8234cf57, 0x9c7daead, 0x3dc07658, 0xea5c6e4c, 0xf1a0084e, 0x16d2ee53, - 0x1b849418, 0xfe913a47, 0x1e988f62, 0x208b644c, 0xc55ee980, 0xbdbce747, 0xf59a384e, 0x0f56091b, - 0x7417b745, 0x0c37344e, 0x2c62ab47, 0xf8533a4d, 0x8030084d, 0x76b93c4b, 0xda6ea0ad, 0x3c54f618, - 0x63b0de1f, 0x7370d858, 0x1a70bb4c, 0xdda63b2e, 0x60b2ba50, 0x1ba7d048, 0xbe1b2c1b, 0xabea5747, - 0x29ad2e4d, 0xe8cd7642, 0x66c80e18, 0x138bf34a, 0xc6145e44, 0x2586794c, 0x07bc5478, 0x0da0b14d, - 0x8f95354e, 0x9eb11c62, 0xa1545e46, 0x2e7a2602, 0x408c9c3d, 0x59065d55, 0xf51d1a4c, 0x3bbc6a4e, - 0xc71b2a2e, 0xcdaaa545, 0x17d659d0, 0x5202e7ad, 0xf1b68445, 0x93375961, 0xbd88a043, 0x066ad655, - 0x890f6318, 0x7b7dca47, 0x99bdd662, 0x3bb4fc53, 0x1231efdc, 0xc0a99444, 0x96bbea47, 0x61ed8748, - 0x27dfa73b, 0x8d4d1754, 0x3460042e, 0x551f0c4c, 0x8d0e0718, 0x162ddc53, 0x53231718, 0x1ecd65d0, - 0x944d28bc, 0x3b79d058, 0xaff97fbc, 0x4860006c, 0xc101c90e, 0xace41743, 0xa5975d4c, 0x5cc2703e, - 0xb55a4450, 0x02d18840, 0xee2765ae, 0xd6012fd5, 0x24c94d7d, 0x8c6eec47, 0x7520ba5d, 0x9e15e460, - 0x8510b04c, 0x75ec3847, 0x1dfa6661, 0xe172b3ad, 0x5744c90e, 0x52a0a152, 0x8d6fad18, 0x67b74b6d, - 0x93a089b2, 0x0f3ac5d5, 0xe5de1855, 0x43d25747, 0x4bad804a, 0x55b408d8, 0x60a36441, 0xf553e860, - 0xdb2fa2c8, 0x03152b32, 0xdd27a7d5, 0x3116a8b8, 0x0a1d708c, 0xeee2f13c, 0x6acf436f, 0xce6eb4ca, - 0x101cd3d9, 0x1c48a6b8, 0xe57d6f44, 0x93dcf562, + 0x959bd347, 0xf8de42b2, 0x73bc0518, 0xea6edc50, 0x21b00a4d, 0xc725b43d, 0xd665464d, 0x1a2a770e, + 0x27c93946, 0x65b2fa46, 0xb80ae255, 0x66b3b446, 0xb1877a3e, 0x6ee89e3e, 0xc3175b40, 0x2a01a83c, + 0x95b1363a, 0xa079ad3d, 0xe6ca801f, 0x027f4f4a, 0x34f7f03a, 0xf790f04a, 0x16ca801f, 0x2f4d5e40, + 0x3a4d5e40, 0xc43a322e, 0xc8159753, 0x14d4724c, 0x7919a118, 0xe0bdb34e, 0x68a16b2e, 0xff64b44d, + 0x6099115b, 0x9b57b05b, 0x7bd1b4ad, 0xdf95944f, 0x29d2b73d, 0xafa8db79, 0xe247ba41, 0x24078348, + 0xf722f03c, 0x33567ebc, 0xace64ed4, 0x984d3932, 0xb5f34e55, 0x27b7024d, 0x94579247, 0x8894042e, + 0x9357d34c, 0x1063c24b, 0xcaa228b1, 0xa3c5a8b2, 0x5dc64857, 0xa2c23643, 0xa8369a54, 0x31203077, + 0x00707c5c, 0x09fc0b3a, 0x272e9e2e, 0xf80f043e, 0x9449ca3e, 0x5512c33e, 0xd106b555, 0xe8024157, + 0xe288ec29, 0xc79c5461, 0xafb63932, 0xdb02ab4b, 0x0e512777, 0x8a145a4c, 0xb201ff4f, 0x5e09314b, + 0xcd9bfbcd, 0x1c023765, 0x4394e75c, 0xa728bd4d, 0x65331552, 0xa98420b1, 0x89ecf559, 0x6e80801f, + 0xf404f118, 0xefd62b51, 0x05918346, 0x9b186d5f, 0xacabab46, 0xf912e255, 0xc188ea62, 0xcc55734e, + 0xc668064d, 0xd77a4558, 0x46201c55, 0xf17dfc80, 0xf7142f2e, 0x87bfb718, 0x8aa54fb2, 0xc451d518, + 0xc4ae8831, 0x8dd44d55, 0x5bbd206c, 0x64536b5d, 0x5c667e60, 0x3b064242, 0xfe963a42, 0xa28e6dc8, + 0xe8a9604a, 0xc989464e, 0xd124a659, 0x50065140, 0xa44dfe5e, 0x1079e655, 0x3fb986d5, 0x47895b18, + 0x7d3ce4ad, 0x4561ba50, 0x296eec62, 0x255b41ad, 0xaed35ec9, 0x55556f12, 0xc7d3154d, 0x3297b65d, + 0x8930121f, 0xabf42e4e, 0x4a29e044, 0x1212685d, 0x676c1e40, 0xce009744, 0x383a8948, 0xa2dbd0ad, + 0xecc2564d, 0x07dbc252, 0x887ee24b, 0x5171644c, 0x6bb798c1, 0x847f495d, 0x4cbb7145, 0x3bb81c32, + 0x45eb262e, 0xc8015a4e, 0x250a361b, 0xf694f946, 0xd64a183e, 0xd4f1dd59, 0x8f20ffd4, 0x51d9e55c, + 0x09521763, 0x5e02002e, 0x32c8074d, 0xe685762e, 0x8290b0bc, 0x762a922e, 0xfc5ee754, 0x83a24829, + 0x775b224d, 0x6295bb4d, 0x38ec0555, 0xbffbba50, 0xe5560260, 0x86b16a7c, 0xd372234e, 0x49a3c24b, + 0x2f6a171f, 0x4d75ed60, 0xae94115b, 0xcb543744, 0x63080c59, 0x3f9c724c, 0xc977ce18, 0x532efb18, + 0x69dc3b2e, 0x5f94d929, 0x1732bb4d, 0x9c814b4d, 0xe6b3762e, 0xc024f662, 0x8face35b, 0x6b5b044d, + 0x798c7b57, 0x79a6b44c, 0x067d3057, 0xf9e94e5f, 0x91cbe15b, 0x71405eb2, 0x2662234e, 0xcbcc4a6d, + 0xbf69d54b, 0xa79b4e55, 0xec6d3e51, 0x7c0b3c02, 0x60f83653, 0x24c1e15c, 0x1110b62e, 0x10350f59, + 0xa56f1d55, 0x3509e7a9, 0xeb128354, 0x14268e2e, 0x934e28bc, 0x8e32692e, 0x8331a21f, 0x3e633932, + 0xc812b12e, 0xc684bf2e, 0x80112d2e, 0xe0ddc96c, 0xc630ca4a, 0x5c09b3b2, 0x0b580518, 0xc8e9d54b, + 0xd169aa43, 0x17d0d655, 0x1d029963, 0x7ff87559, 0xcb701f1f, 0x6fa3e85d, 0xe45e9a54, 0xf05d1802, + 0x44d03b2e, 0x837b692e, 0xccd4354e, 0x3d6da13c, 0x3423084d, 0xf707c34a, 0x55f6db3a, 0xad26e442, + 0x6233a21f, 0x09e80e59, 0x8caeb54d, 0xbe870941, 0xb407d20e, 0x20b51018, 0x56fb152e, 0x460d2a4e, + 0xbb9a2946, 0x560eb12e, 0xed83dd29, 0xd6724f53, 0xa50aafb8, 0x451346d9, 0x88348e2e, 0x7312fead, + 0x8ecaf96f, 0x1bda4e5f, 0xf1671e40, 0x3c8c3e3b, 0x4716324d, 0xdde24ede, 0xf98cd17d, 0xa91d4644, + 0x28124eb2, 0x147d5129, 0xd022042e, 0x61733d3b, 0xad0d5e02, 0x8ce2932e, 0xe5c18502, 0x549c1e32, + 0x9685801f, 0x86e217ad, 0xd948214b, 0x4110f462, 0x3a2e894e, 0xbd35492e, 0x87e0d558, 0x64b8ef7d, + 0x7c3eb962, 0x72a84b3e, 0x7cd667c9, 0x28370a2e, 0x4bc60e7b, 0x6fc1ec60, 0x14a6983f, 0x86739a4b, + 0x46954e5f, 0x32e2e15c, 0x2e9326cf, 0xe5801c5e, 0x379607b2, 0x32151145, 0xf0e39744, 0xacb54c55, + 0xa37dfb60, 0x83b55cc9, 0x388f7ca5, 0x15034f5f, 0x3e94965b, 0x68e0ffad, 0x35280f59, 0x8fe190cf, + 0x7c6ba5b2, 0xa5e9db43, 0x4ee1fc60, 0xd9d94e5f, 0x04040677, 0x0ea9b35e, 0x5961f14f, 0x67fda063, + 0xa48a5a31, 0xc6524e55, 0x283d325e, 0x3f37515f, 0x96b94b3e, 0xacce620e, 0x6481cc5b, 0xa4a06d4b, + 0x9e95d2d9, 0xe40c03d5, 0xc2f4514b, 0xb79aad44, 0xf64be843, 0xb2064070, 0xfca00455, 0x429dfa4e, + 0x2323f173, 0xeda4185e, 0xabd5227d, 0x9efd4d58, 0xb1104758, 0x4811e955, 0xbd9ab355, 0xe921f44b, + 0x9f166dce, 0x09e279b2, 0xe0c9ac7b, 0x7901a5ad, 0xa145d4b0, 0x79104671, 0xec31e35a, 0x4fe0b555, + 0xc7d9cbad, 0xad057f55, 0xe94cc759, 0x7fe0b043, 0xe4529f2e, 0x0d4dd4b2, 0x9f11a54d, 0x031e2e4e, + 0xe6014f5f, 0x11d1ca6c, 0x26bd7f61, 0xeb86854f, 0x4d347b57, 0x116bbe2e, 0xdba7234e, 0x7bcbfd2e, + 0x174dd4b2, 0x6686762e, 0xb089ba50, 0xc6258246, 0x087e767b, 0xc4a8cb4a, 0x595dba50, 0x7f0ae502, + 0x7b1dbd5a, 0xa0603492, 0x57d1af4b, 0x9e21ffd4, 0x6393064d, 0x7407376e, 0xe484762e, 0x122a4e53, + 0x4a37aa43, 0x3888a6be, 0xee77864e, 0x039c8dd5, 0x688d89af, 0x0e988f62, 0x08218246, 0xfc2f8246, + 0xd1d97040, 0xd64cd4b2, 0x5ae4a6b8, 0x7d0de9bc, 0x8d304d61, 0x06c5c672, 0xa4c8bd4d, 0xe0fd373b, + 0x575ebe4d, 0x72d26277, 0x55570f55, 0x77b154d9, 0xe214293a, 0xfc740f4b, 0xfe3f6a57, 0xa9c55f02, + 0xae4054db, 0x2394d918, 0xb511b24a, 0xb8741ab2, 0x0758e65e, 0xc7b5795b, 0xb0a30a4c, 0xaf7f170c, + 0xf3b4762e, 0x8179576d, 0x738a1581, 0x4b95b64c, 0x9829b618, 0x1bea932e, 0x7bdeaa4b, 0xcb5e0281, + 0x65618f54, 0x0658474b, 0x27066acf, 0x40556d65, 0x7d204d53, 0xf28bc244, 0xdce23455, 0xadc0ff54, + 0x3863c948, 0xcee34e5f, 0xdeb85e02, 0x2ed17a61, 0x6a7b094d, 0x7f0cfc40, 0x59603f54, 0x3220afbc, + 0xb5dfd962, 0x125d21c0, 0x13f8d243, 0xacfefb4e, 0x86c2c147, 0x3d8bbd59, 0xbd02a21f, 0x2593042e, + 0xc6a17a7c, 0x28925861, 0xb487ed44, 0xb5f4fd6d, 0x90c28a45, 0x5a14f74d, 0x43d71b4c, 0x728ebb5d, + 0x885bf950, 0x08134dd0, 0x38ec046e, 0xc575684b, 0x50082d2e, 0xa2f47757, 0x270f86ae, 0xf3ff6462, + 0x10ed3f4e, 0x4b58d462, 0xe01ce23e, 0x8c5b092e, 0x63e52f4e, 0x22c1e85d, 0xa908f54e, 0x8591624f, + 0x2c0fb94e, 0xa280ba3c, 0xb6f41b4c, 0x24f9aa47, 0x27201647, 0x3a3ea6dc, 0xa14fc3be, 0x3c34bdd5, + 0x5b8d4f5b, 0xaadeaf4b, 0xc71cab50, 0x15697a4c, 0x9a1a734c, 0x2a037d81, 0x2590bd59, 0x48ec2741, + 0x53489c5b, 0x7f00314b, 0x2170d362, 0xf2e92542, 0x42c10b44, 0x98f0f118, 0x883a3456, 0x099a932e, + 0xea38f7bc, 0x644e9247, 0xbb61b62e, 0x30e0863d, 0x5f51be54, 0x207215c7, 0x5f306c45, 0xaa7f3932, + 0x98da7d45, 0x4e339b59, 0x2e411581, 0xa808f618, 0xad2c0c59, 0x54476741, 0x09e99fd1, 0x5db8f752, + 0xc16df8bd, 0x1dd4b44f, 0x106edf2e, 0x9e15c180, 0x2ad6b56f, 0x633a5332, 0xff33787c, 0x077cb545, + 0x6610be6d, 0x75aad2c4, 0x72fb4d5b, 0xe81e0f59, 0x576f6332, 0x47333373, 0x351ed783, 0x2d90fb50, + 0x8d5e0f6c, 0x5b27a552, 0xdb293ebb, 0xe55ef950, 0x4b133ad8, 0x75df975a, 0x7b6a8740, 0xa899464b, + 0xfab15161, 0x10f8b64d, 0xd055ea4d, 0xee8e146b, 0x4b14afb8, 0x4bc1c44a, 0x9b961dcc, 0xd111ff43, + 0xfca0b745, 0xc800e412, 0x0afad9d1, 0xf751c350, 0xf9f0cccf, 0xa290a545, 0x8ef13763, 0x7ec70d59, + 0x2b066acf, 0x65496c45, 0xade02c1b, 0xae6eb077, 0x92c1e65b, 0xc064e6a9, 0xc649e56d, 0x5287a243, + 0x36de4f5b, 0x5b1df6ad, 0x65c39a59, 0xdba805b2, 0x20067aa8, 0x6457e56d, 0x3cee26cf, 0xfd3ff26d, + 0x04f86d4a, 0x06b8e048, 0xa93bcd5c, 0x91135852, 0xbe90a643, 0x8fa0094d, 0x06d8215f, 0x2677094d, + 0xd735685c, 0x164a00c9, 0x5209ac5f, 0xa9564c5c, 0x3b504f5f, 0xcc826bd0, 0x4615042e, 0x5fe13b4a, + 0x8c81b86d, 0x879ab68c, 0x1de564b8, 0x434487d8, 0x2dcb1b63, 0x82ab524a, 0xb0676abb, 0xa13d9c62, + 0xdbb5b86d, 0x5b7f4b59, 0xaddfb44d, 0xad773532, 0x3997054c, 0x72cebd89, 0xb194544c, 0xc5b8046e, + 0x6e1adeb2, 0xaa5abb51, 0xefb54b44, 0x15efc54f, 0xe9f1bc4d, 0x5f401b6c, 0x97f018ad, 0xc82f9252, + 0x2cdc762e, 0x8e52e56d, 0x1827175e, 0x9b7d7d80, 0xb2ad6845, 0x51065140, 0x71180a18, 0x5b27006c, + 0x0621e255, 0x721cbe58, 0x670c0cb8, 0xf8bd715d, 0xe0bdc5d9, 0xed843501, 0x4b84554d, 0x7f1a18bc, + 0x53bcaf47, 0x5729d35f, 0xf0dda246, 0x22382bd0, 0x4d641fb0, 0x316afcde, 0x50a22f1f, 0x73608046, + 0xc461d84a, 0xb2dbe247, }; From 5df1a22c2e626a767a356265616f1f28e4346137 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Tue, 17 Jan 2012 21:50:08 -0500 Subject: [PATCH 070/154] Various updates to the release process --- doc/release-process.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/release-process.txt b/doc/release-process.txt index 953761b4a95..8bf944a29e6 100644 --- a/doc/release-process.txt +++ b/doc/release-process.txt @@ -1,3 +1,5 @@ +* update translations (ping tcatm on IRC for now) + * update (commit) version in sources src/serialize.h share/setup.nsi @@ -34,9 +36,9 @@ 2. windows 32-bit binary + source 3. windows installer -* upload source and builds to SF +* upload builds to SF -* create SHA1SUMS for builds, and PGP-sign it +* create SHA256SUMS for builds, and PGP-sign it * update bitcoin.org version From 3d3f9cd120e3761aa14dcb1550d977b40fafdf8c Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Tue, 17 Jan 2012 21:50:08 -0500 Subject: [PATCH 071/154] Various updates to the release process --- doc/release-process.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/release-process.txt b/doc/release-process.txt index 14d8efeb32d..9be6b782a40 100644 --- a/doc/release-process.txt +++ b/doc/release-process.txt @@ -1,3 +1,5 @@ +* update translations (ping tcatm on IRC for now) + * update (commit) version in sources bitcoin-qt.pro src/serialize.h @@ -77,9 +79,9 @@ Build output expected: Bitcoin-Qt.dmg -* upload source and builds to SourceForge +* upload builds to SourceForge -* create SHA1SUMS for builds, and PGP-sign it +* create SHA256SUMS for builds, and PGP-sign it * update bitcoin.org version From d1e56838dc067568cfce7bc85bdc228da58f2597 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Thu, 2 Feb 2012 17:27:44 -0500 Subject: [PATCH 072/154] Bugfix: Support building test_bitcoin with shared-object boost test framework Conflicts: src/makefile.unix --- src/makefile.unix | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/makefile.unix b/src/makefile.unix index 6c48199546d..9d97ae50ca6 100644 --- a/src/makefile.unix +++ b/src/makefile.unix @@ -16,6 +16,8 @@ ifdef STATIC ifeq (${STATIC}, all) LMODE2 = static endif +else + TESTDEFS += -DBOOST_TEST_DYN_LINK endif # for boost 1.37, add -mt to the boost libraries @@ -140,14 +142,14 @@ bitcoind: $(OBJS:obj/%=obj/nogui/%) $(CXX) $(xCXXFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS) obj/test/%.o: test/%.cpp - $(CXX) -c $(xCXXFLAGS) -MMD -o $@ $< + $(CXX) -c $(TESTDEFS) $(xCXXFLAGS) -MMD -o $@ $< @cp $(@:%.o=%.d) $(@:%.o=%.P); \ sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \ -e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \ rm -f $(@:%.o=%.d) test_bitcoin: obj/test/test_bitcoin.o $(filter-out obj/nogui/init.o,$(OBJS:obj/%=obj/nogui/%)) - $(CXX) $(xCXXFLAGS) -o $@ $(LIBPATHS) $^ -Wl,-Bstatic -lboost_unit_test_framework $(LDFLAGS) $(LIBS) + $(CXX) $(xCXXFLAGS) -o $@ $(LIBPATHS) $^ -Wl,-B$(LMODE) -lboost_unit_test_framework $(LDFLAGS) $(LIBS) clean: -rm -f bitcoind test_bitcoin From 1677743fca631f8fb970fe917866dd982c6ddd40 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Mon, 23 Jan 2012 14:27:08 -0500 Subject: [PATCH 073/154] Rename src/obj/test to src/obj-test to workaround bug in older GNU Make --- src/makefile.unix | 10 +++++----- src/obj-test/.gitignore | 2 ++ 2 files changed, 7 insertions(+), 5 deletions(-) create mode 100644 src/obj-test/.gitignore diff --git a/src/makefile.unix b/src/makefile.unix index 9d97ae50ca6..53948bcba68 100644 --- a/src/makefile.unix +++ b/src/makefile.unix @@ -129,7 +129,7 @@ all: bitcoind # auto-generated dependencies: -include obj/nogui/*.P --include obj/test/*.P +-include obj-test/*.P obj/nogui/%.o: %.cpp $(CXX) -c $(xCXXFLAGS) -MMD -o $@ $< @@ -141,21 +141,21 @@ obj/nogui/%.o: %.cpp bitcoind: $(OBJS:obj/%=obj/nogui/%) $(CXX) $(xCXXFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS) -obj/test/%.o: test/%.cpp +obj-test/%.o: test/%.cpp $(CXX) -c $(TESTDEFS) $(xCXXFLAGS) -MMD -o $@ $< @cp $(@:%.o=%.d) $(@:%.o=%.P); \ sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \ -e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \ rm -f $(@:%.o=%.d) -test_bitcoin: obj/test/test_bitcoin.o $(filter-out obj/nogui/init.o,$(OBJS:obj/%=obj/nogui/%)) +test_bitcoin: obj-test/test_bitcoin.o $(filter-out obj/nogui/init.o,$(OBJS:obj/%=obj/nogui/%)) $(CXX) $(xCXXFLAGS) -o $@ $(LIBPATHS) $^ -Wl,-B$(LMODE) -lboost_unit_test_framework $(LDFLAGS) $(LIBS) clean: -rm -f bitcoind test_bitcoin -rm -f obj/*.o -rm -f obj/nogui/*.o - -rm -f obj/test/*.o + -rm -f obj-test/*.o -rm -f obj/*.P -rm -f obj/nogui/*.P - -rm -f obj/test/*.P + -rm -f obj-test/*.P diff --git a/src/obj-test/.gitignore b/src/obj-test/.gitignore new file mode 100644 index 00000000000..d6b7ef32c84 --- /dev/null +++ b/src/obj-test/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore From 22388eac08a4a543686c5402ca7ec22336e53468 Mon Sep 17 00:00:00 2001 From: Gavin Andresen Date: Mon, 23 Jan 2012 15:58:06 -0500 Subject: [PATCH 074/154] Support makefile.osx building test_bitcoin with dynamic boost --- src/makefile.osx | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/makefile.osx b/src/makefile.osx index de718879356..cbd51b049f0 100644 --- a/src/makefile.osx +++ b/src/makefile.osx @@ -22,6 +22,8 @@ USE_UPNP:=1 LIBS= -dead_strip ifdef STATIC # Build STATIC if you are redistributing the bitcoind binary +TESTLIBS += \ + $(DEPSDIR)/lib/libboost_unit_test_framework-mt.a LIBS += \ $(DEPSDIR)/lib/db48/libdb_cxx-4.8.a \ $(DEPSDIR)/lib/libboost_system-mt.a \ @@ -29,8 +31,11 @@ LIBS += \ $(DEPSDIR)/lib/libboost_program_options-mt.a \ $(DEPSDIR)/lib/libboost_thread-mt.a \ $(DEPSDIR)/lib/libssl.a \ - $(DEPSDIR)/lib/libcrypto.a + $(DEPSDIR)/lib/libcrypto.a \ + -lz else +TESTLIBS += \ + -lboost_unit_test_framework-mt LIBS += \ -ldb_cxx-4.8 \ -lboost_system-mt \ @@ -38,7 +43,9 @@ LIBS += \ -lboost_program_options-mt \ -lboost_thread-mt \ -lssl \ - -lcrypto + -lcrypto \ + -lz +TESTDEFS += -DBOOST_TEST_DYN_LINK endif DEFS=-DMAC_OSX -DMSG_NOSIGNAL=0 -DUSE_SSL @@ -98,7 +105,7 @@ all: bitcoind # auto-generated dependencies: -include obj/nogui/*.P --include obj/test/*.P +-include obj-test/*.P obj/nogui/%.o: %.cpp $(CXX) -c $(CFLAGS) -MMD -o $@ $< @@ -111,20 +118,20 @@ bitcoind: $(OBJS:obj/%=obj/nogui/%) $(CXX) $(CFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS) obj/test/%.o: test/%.cpp - $(CXX) -c $(CFLAGS) -MMD -o $@ $< + $(CXX) -c $(TESTDEFS) $(CFLAGS) -MMD -o $@ $< @cp $(@:%.o=%.d) $(@:%.o=%.P); \ sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \ -e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \ rm -f $(@:%.o=%.d) test_bitcoin: obj/test/test_bitcoin.o $(filter-out obj/nogui/init.o,$(OBJS:obj/%=obj/nogui/%)) - $(CXX) $(CFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS) $(DEPSDIR)/lib/libboost_unit_test_framework-mt.a + $(CXX) $(CFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS) $(TESTLIBS) clean: -rm -f bitcoind test_bitcoin -rm -f obj/*.o -rm -f obj/nogui/*.o - -rm -f obj/test/*.o + -rm -f obj-test/*.o -rm -f obj/*.P -rm -f obj/nogui/*.P - -rm -f obj/test/*.P + -rm -f obj-test/*.P From bccbc5f4c363692d3598c16614a875dc4cd6d389 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Wed, 7 Dec 2011 00:00:04 -0500 Subject: [PATCH 075/154] Automatically refocus on new SendCoinsEntrys and scroll to them. --- src/qt/sendcoinsdialog.cpp | 7 +++++++ src/qt/sendcoinsentry.cpp | 5 +++++ src/qt/sendcoinsentry.h | 2 ++ 3 files changed, 14 insertions(+) diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp index 762f27dfa66..6d32891172f 100644 --- a/src/qt/sendcoinsdialog.cpp +++ b/src/qt/sendcoinsdialog.cpp @@ -11,6 +11,7 @@ #include #include #include +#include SendCoinsDialog::SendCoinsDialog(QWidget *parent) : QDialog(parent), @@ -188,6 +189,12 @@ SendCoinsEntry *SendCoinsDialog::addEntry() // Focus the field, so that entry can start immediately entry->clear(); + entry->setFocus(); + ui->scrollAreaWidgetContents->resize(ui->scrollAreaWidgetContents->sizeHint()); + QCoreApplication::instance()->processEvents(); + QScrollBar* bar = ui->scrollArea->verticalScrollBar(); + if (bar) + bar->setSliderPosition(bar->maximum()); return entry; } diff --git a/src/qt/sendcoinsentry.cpp b/src/qt/sendcoinsentry.cpp index 23b11ccddeb..ab5460f8c2c 100644 --- a/src/qt/sendcoinsentry.cpp +++ b/src/qt/sendcoinsentry.cpp @@ -151,3 +151,8 @@ bool SendCoinsEntry::isClear() return ui->payTo->text().isEmpty(); } +void SendCoinsEntry::setFocus() +{ + ui->payTo->setFocus(); +} + diff --git a/src/qt/sendcoinsentry.h b/src/qt/sendcoinsentry.h index ccc223b5f5f..2258706d59d 100644 --- a/src/qt/sendcoinsentry.h +++ b/src/qt/sendcoinsentry.h @@ -30,6 +30,8 @@ public: // Hence we have to set it up manually QWidget *setupTabChain(QWidget *prev); + void setFocus(); + public slots: void setRemoveEnabled(bool enabled); void clear(); From edb563e8a5e6145cef6684e6e179b428a115ec62 Mon Sep 17 00:00:00 2001 From: Gavin Andresen Date: Mon, 5 Dec 2011 15:50:22 -0500 Subject: [PATCH 076/154] Testnet difficulty calculation changes, to take effect Feb 15 2012 Allow mining of min-difficulty blocks if 20 minutes have gone by without mining a regular-difficulty block. Normal rules apply every 2016 blocks, though, so there may be a very-slow-to-confirm block at the difficulty-adjustment blocks. --- src/main.cpp | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 03e133b63cd..1c94090190f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -661,6 +661,11 @@ static const int64 nInterval = nTargetTimespan / nTargetSpacing; // unsigned int ComputeMinWork(unsigned int nBase, int64 nTime) { + // Testnet has min-difficulty blocks + // after nTargetSpacing*2 time between blocks: + if (fTestNet && nTime > nTargetSpacing*2) + return bnProofOfWorkLimit.GetCompact(); + CBigNum bnResult; bnResult.SetCompact(nBase); while (nTime > 0 && bnResult < bnProofOfWorkLimit) @@ -675,16 +680,36 @@ unsigned int ComputeMinWork(unsigned int nBase, int64 nTime) return bnResult.GetCompact(); } -unsigned int static GetNextWorkRequired(const CBlockIndex* pindexLast) +unsigned int static GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlock *pblock) { + unsigned int nProofOfWorkLimit = bnProofOfWorkLimit.GetCompact(); // Genesis block if (pindexLast == NULL) - return bnProofOfWorkLimit.GetCompact(); + return nProofOfWorkLimit; // Only change once per interval if ((pindexLast->nHeight+1) % nInterval != 0) + { + // Special rules for testnet after 15 Feb 2012: + if (fTestNet && pblock->nTime > 1329264000) + { + // If the new block's timestamp is more than 2* 10 minutes + // then allow mining of a min-difficulty block. + if (pblock->nTime - pindexLast->nTime > nTargetSpacing*2) + return nProofOfWorkLimit; + else + { + // Return the last non-special-min-difficulty-rules-block + const CBlockIndex* pindex = pindexLast; + while (pindex->pprev && pindex->nHeight % nInterval != 0 && pindex->nBits == nProofOfWorkLimit) + pindex = pindex->pprev; + return pindex->nBits; + } + } + return pindexLast->nBits; + } // Go back by what we want to be 14 days worth of blocks const CBlockIndex* pindexFirst = pindexLast; @@ -1289,7 +1314,7 @@ bool CBlock::AcceptBlock() int nHeight = pindexPrev->nHeight+1; // Check proof of work - if (nBits != GetNextWorkRequired(pindexPrev)) + if (nBits != GetNextWorkRequired(pindexPrev, this)) return error("AcceptBlock() : incorrect proof of work"); // Check timestamp against prev @@ -2812,7 +2837,7 @@ CBlock* CreateNewBlock(CReserveKey& reservekey) pblock->hashPrevBlock = pindexPrev->GetBlockHash(); pblock->hashMerkleRoot = pblock->BuildMerkleTree(); pblock->nTime = max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime()); - pblock->nBits = GetNextWorkRequired(pindexPrev); + pblock->nBits = GetNextWorkRequired(pindexPrev, pblock.get()); pblock->nNonce = 0; return pblock.release(); From e5b031f5d2a467fa28fbf7667101909a28e430bb Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Tue, 31 Jan 2012 17:36:25 -0500 Subject: [PATCH 077/154] Fix UPnP by reannouncing every 20 minutes. --- src/net.cpp | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/net.cpp b/src/net.cpp index b35a79deaef..f995ea9c2af 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1105,11 +1105,11 @@ void ThreadMapPort2(void* parg) { string strDesc = "Bitcoin " + FormatFullVersion(); #ifndef UPNPDISCOVER_SUCCESS - /* miniupnpc 1.5 */ + /* miniupnpc 1.5 */ r = UPNP_AddPortMapping(urls.controlURL, data.first.servicetype, port, port, lanaddr, strDesc.c_str(), "TCP", 0); #else - /* miniupnpc 1.6 */ + /* miniupnpc 1.6 */ r = UPNP_AddPortMapping(urls.controlURL, data.first.servicetype, port, port, lanaddr, strDesc.c_str(), "TCP", 0, "0"); #endif @@ -1119,6 +1119,7 @@ void ThreadMapPort2(void* parg) port, port, lanaddr, r, strupnperror(r)); else printf("UPnP Port Mapping successful.\n"); + int i = 1; loop { if (fShutdown || !fUseUPnP) { @@ -1128,7 +1129,26 @@ void ThreadMapPort2(void* parg) FreeUPNPUrls(&urls); return; } + if (i % 600 == 0) // Refresh every 20 minutes + { +#ifndef UPNPDISCOVER_SUCCESS + /* miniupnpc 1.5 */ + r = UPNP_AddPortMapping(urls.controlURL, data.first.servicetype, + port, port, lanaddr, strDesc.c_str(), "TCP", 0); +#else + /* miniupnpc 1.6 */ + r = UPNP_AddPortMapping(urls.controlURL, data.first.servicetype, + port, port, lanaddr, strDesc.c_str(), "TCP", 0, "0"); +#endif + + if(r!=UPNPCOMMAND_SUCCESS) + printf("AddPortMapping(%s, %s, %s) failed with code %d (%s)\n", + port, port, lanaddr, r, strupnperror(r)); + else + printf("UPnP Port Mapping successful.\n");; + } Sleep(2000); + i++; } } else { printf("No valid UPnP IGDs found\n"); From 1b6d8f3fca6aef79ea0ccb26303d982d6da78cd1 Mon Sep 17 00:00:00 2001 From: Gavin Andresen Date: Wed, 1 Feb 2012 13:24:15 -0500 Subject: [PATCH 078/154] Allow -upnp to override setting in wallet (and simplify logic a bit) --- src/init.cpp | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index d1332e06100..12e890cbb4c 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -516,16 +516,11 @@ bool AppInit2(int argc, char* argv[]) fAllowDNS = GetBoolArg("-dns"); fNoListen = GetBoolArg("-nolisten"); - if (fHaveUPnP) - { -#if USE_UPNP - if (GetBoolArg("-noupnp")) - fUseUPnP = false; -#else - if (GetBoolArg("-upnp")) - fUseUPnP = true; -#endif - } + // Command-line args override in-wallet settings: + if (mapArgs.count("-upnp")) + fUseUPnP = GetBoolArg("-upnp"); + else if (mapArgs.count("-noupnp")) + fUseUPnP = !GetBoolArg("-noupnp"); if (!fNoListen) { From 71208749839962c41b02101f27a2dd61fb1a7e73 Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Wed, 1 Feb 2012 20:14:13 +0100 Subject: [PATCH 079/154] Remove loose amp; from Portugese translation (issue #701) --- src/qt/locale/bitcoin_pt_BR.ts | 71 ++++++++++++++++++++++------------ 1 file changed, 47 insertions(+), 24 deletions(-) diff --git a/src/qt/locale/bitcoin_pt_BR.ts b/src/qt/locale/bitcoin_pt_BR.ts index a9555c3dc47..2c2f7f1ae4d 100644 --- a/src/qt/locale/bitcoin_pt_BR.ts +++ b/src/qt/locale/bitcoin_pt_BR.ts @@ -1,4 +1,6 @@ - + + + UTF-8 AboutDialog @@ -21,7 +23,7 @@ This is experimental software. Distributed under the MIT/X11 software license, see the accompanying file license.txt or http://www.opensource.org/licenses/mit-license.php. This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit (http://www.openssl.org/) and cryptographic software written by Eric Young (eay@cryptsoft.com) and UPnP software written by Thomas Bernard. - + @@ -49,7 +51,7 @@ This product includes software developed by the OpenSSL Project for use in the O &New Address... - &amp; Novo endereço ... + &Novo endereço ... @@ -59,7 +61,7 @@ This product includes software developed by the OpenSSL Project for use in the O &Copy to Clipboard - &amp; Copie para a área de transferência do sistema + &Copie para a área de transferência do sistema @@ -69,7 +71,7 @@ This product includes software developed by the OpenSSL Project for use in the O &Delete - &amp; Excluir + &Excluir @@ -89,7 +91,7 @@ This product includes software developed by the OpenSSL Project for use in the O Could not write to file %1. - + @@ -381,7 +383,7 @@ Are you sure you wish to encrypt your wallet? &File - &amp; Arquivo + &Arquivo @@ -391,7 +393,7 @@ Are you sure you wish to encrypt your wallet? &Help - &amp; Ajuda + &Ajuda @@ -416,7 +418,10 @@ Are you sure you wish to encrypt your wallet? %n active connection(s) to Bitcoin network - %n conexão ativa na rede Bitcoin%n conexões ativas na rede Bitcoin + + %n conexão ativa na rede Bitcoin + %n conexões ativas na rede Bitcoin + @@ -431,22 +436,34 @@ Are you sure you wish to encrypt your wallet? %n second(s) ago - %n segundo atrás%n segundos atrás + + %n segundo atrás + %n segundos atrás + %n minute(s) ago - %n minutos atrás%n minutos atrás + + %n minutos atrás + %n minutos atrás + %n hour(s) ago - %n hora atrás%n horas atrás + + %n hora atrás + %n horas atrás + %n day(s) ago - %n dia atrás%n dias atrás + + %n dia atrás + %n dias atrás + @@ -741,12 +758,12 @@ Address: %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;">Wallet</span></p></body></html> @@ -1113,7 +1130,10 @@ p, li { white-space: pre-wrap; } Open for %n block(s) - Open for %n blockOpen for %n blocks + + Open for %n block + Open for %n blocks + @@ -1138,7 +1158,10 @@ p, li { white-space: pre-wrap; } Mined balance will be available in %n more blocks - Mined balance will be available in %n more blockMined balance will be available in %n more blocks + + Mined balance will be available in %n more block + Mined balance will be available in %n more blocks + @@ -1441,9 +1464,9 @@ p, li { white-space: pre-wrap; } - Don't generate coins + Don't generate coins - Don't generate coins + Don't generate coins @@ -1497,16 +1520,16 @@ p, li { white-space: pre-wrap; } - Don't accept connections from outside + Don't accept connections from outside - Don't accept connections from outside + Don't accept connections from outside - Don't attempt to use UPnP to map the listening port + Don't attempt to use UPnP to map the listening port - Don't attempt to use UPnP to map the listening port + Don't attempt to use UPnP to map the listening port @@ -2330,4 +2353,4 @@ but the comment information will be blank. Bitcoin Qt - \ No newline at end of file + From c1c6de6ad4f92c6628dccc271fe4c661e450d130 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Wed, 25 Jan 2012 03:05:16 +0100 Subject: [PATCH 080/154] Check consistency of private keys Reported by onlineproof on IRC: Bitcoin does not verify whether private keys and public keys correspond, when loading a wallet. --- src/db.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/db.cpp b/src/db.cpp index f9a7d6c90a5..bd31bd79431 100644 --- a/src/db.cpp +++ b/src/db.cpp @@ -879,6 +879,8 @@ int CWalletDB::LoadWallet(CWallet* pwallet) CPrivKey pkey; ssValue >> pkey; key.SetPrivKey(pkey); + if (key.GetPubKey() != vchPubKey) + return DB_CORRUPT; } else { From c13d50d8617678c8696b1f33549ed9cc3a0b554e Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Tue, 17 Jan 2012 09:19:23 +0100 Subject: [PATCH 081/154] Revert to global progress indication (see #753) --- src/qt/bitcoingui.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index 75d2a50a25c..f80038c3fba 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -413,7 +413,6 @@ void BitcoinGUI::setNumBlocks(int count) { if(!clientModel) return; - int initTotal = clientModel->getNumBlocksAtStartup(); int total = clientModel->getNumBlocksOfPeers(); QString tooltip; @@ -424,8 +423,8 @@ void BitcoinGUI::setNumBlocks(int count) progressBarLabel->setVisible(true); progressBarLabel->setText(tr("Synchronizing with network...")); progressBar->setVisible(true); - progressBar->setMaximum(total - initTotal); - progressBar->setValue(count - initTotal); + progressBar->setMaximum(total); + progressBar->setValue(count); } else { From d841fc969a3a300ebeaa4279320235f2ff2b0533 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Thu, 26 Jan 2012 19:26:34 +0100 Subject: [PATCH 082/154] Full checking of all loaded keys --- src/db.cpp | 4 +++- src/key.h | 11 +++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/db.cpp b/src/db.cpp index bd31bd79431..600afe383d2 100644 --- a/src/db.cpp +++ b/src/db.cpp @@ -879,7 +879,7 @@ int CWalletDB::LoadWallet(CWallet* pwallet) CPrivKey pkey; ssValue >> pkey; key.SetPrivKey(pkey); - if (key.GetPubKey() != vchPubKey) + if (key.GetPubKey() != vchPubKey || !key.IsValid()) return DB_CORRUPT; } else @@ -887,6 +887,8 @@ int CWalletDB::LoadWallet(CWallet* pwallet) CWalletKey wkey; ssValue >> wkey; key.SetPrivKey(wkey.vchPrivKey); + if (key.GetPubKey() != vchPubKey || !key.IsValid()) + return DB_CORRUPT; } if (!pwallet->LoadKey(key)) return DB_CORRUPT; diff --git a/src/key.h b/src/key.h index d2e66894561..0d0b6d8bb47 100644 --- a/src/key.h +++ b/src/key.h @@ -233,6 +233,17 @@ public: { return CBitcoinAddress(GetPubKey()); } + + bool IsValid() + { + if (!fSet) + return false; + + CSecret secret = GetSecret(); + CKey key2; + key2.SetSecret(secret); + return GetPubKey() == key2.GetPubKey(); + } }; #endif From c11e2b8679e13f739a58faf2a3439d4aaed24364 Mon Sep 17 00:00:00 2001 From: Gavin Andresen Date: Wed, 18 Jan 2012 13:36:44 -0500 Subject: [PATCH 083/154] Only store transactions with missing inputs in the orphan pool. All previous versions of bitcoin could store some types of invalid transactions in the orphan-transaction list. --- src/main.cpp | 27 +++++++++++++++++++++------ src/main.h | 3 ++- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 1c94090190f..dc8503d38f9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -411,10 +411,11 @@ bool CTransaction::AcceptToMemoryPool(CTxDB& txdb, bool fCheckInputs, bool* pfMi // Check against previous transactions map mapUnused; int64 nFees = 0; - if (!ConnectInputs(txdb, mapUnused, CDiskTxPos(1,1,1), pindexBest, nFees, false, false)) + bool fInvalid = false; + if (!ConnectInputs(txdb, mapUnused, CDiskTxPos(1,1,1), pindexBest, nFees, false, false, 0, fInvalid)) { - if (pfMissingInputs) - *pfMissingInputs = true; + if (fInvalid) + return error("AcceptToMemoryPool() : FetchInputs found invalid tx %s", hash.ToString().substr(0,10).c_str()); return error("AcceptToMemoryPool() : ConnectInputs failed %s", hash.ToString().substr(0,10).c_str()); } @@ -833,8 +834,15 @@ bool CTransaction::DisconnectInputs(CTxDB& txdb) bool CTransaction::ConnectInputs(CTxDB& txdb, map& mapTestPool, CDiskTxPos posThisTx, - CBlockIndex* pindexBlock, int64& nFees, bool fBlock, bool fMiner, int64 nMinFee) + CBlockIndex* pindexBlock, int64& nFees, bool fBlock, bool fMiner, int64 nMinFee, + bool& fInvalid) { + // FetchInputs can return false either because we just haven't seen some inputs + // (in which case the transaction should be stored as an orphan) + // or because the transaction is malformed (in which case the transaction should + // be dropped). If tx is definitely invalid, fInvalid will be set to true. + fInvalid = false; + // Take over previous transactions' spent pointers if (!IsCoinBase()) { @@ -881,7 +889,12 @@ bool CTransaction::ConnectInputs(CTxDB& txdb, map& mapTestPoo } if (prevout.n >= txPrev.vout.size() || prevout.n >= txindex.vSpent.size()) + { + // Revisit this if/when transaction replacement is implemented and allows + // adding inputs: + fInvalid = true; return error("ConnectInputs() : %s prevout.n out of range %d %d %d prev tx %s\n%s", GetHash().ToString().substr(0,10).c_str(), prevout.n, txPrev.vout.size(), txindex.vSpent.size(), prevout.hash.ToString().substr(0,10).c_str(), txPrev.ToString().c_str()); + } // If prev is coinbase, check that it's matured if (txPrev.IsCoinBase()) @@ -1025,7 +1038,8 @@ bool CBlock::ConnectBlock(CTxDB& txdb, CBlockIndex* pindex) CDiskTxPos posThisTx(pindex->nFile, pindex->nBlockPos, nTxPos); nTxPos += ::GetSerializeSize(tx, SER_DISK); - if (!tx.ConnectInputs(txdb, mapQueuedChanges, posThisTx, pindex, nFees, true, false)) + bool fInvalid; + if (!tx.ConnectInputs(txdb, mapQueuedChanges, posThisTx, pindex, nFees, true, false, 0, fInvalid)) return false; } // Write queued txindex changes @@ -2806,7 +2820,8 @@ CBlock* CreateNewBlock(CReserveKey& reservekey) // Connecting shouldn't fail due to dependency on other memory pool transactions // because we're already processing them in order of dependency map mapTestPoolTmp(mapTestPool); - if (!tx.ConnectInputs(txdb, mapTestPoolTmp, CDiskTxPos(1,1,1), pindexPrev, nFees, false, true, nMinFee)) + bool fInvalid; + if (!tx.ConnectInputs(txdb, mapTestPoolTmp, CDiskTxPos(1,1,1), pindexPrev, nFees, false, true, nMinFee, fInvalid)) continue; swap(mapTestPool, mapTestPoolTmp); diff --git a/src/main.h b/src/main.h index 876a35d9cc3..8a8b3870ec7 100644 --- a/src/main.h +++ b/src/main.h @@ -631,7 +631,8 @@ public: bool ReadFromDisk(COutPoint prevout); bool DisconnectInputs(CTxDB& txdb); bool ConnectInputs(CTxDB& txdb, std::map& mapTestPool, CDiskTxPos posThisTx, - CBlockIndex* pindexBlock, int64& nFees, bool fBlock, bool fMiner, int64 nMinFee=0); + CBlockIndex* pindexBlock, int64& nFees, bool fBlock, bool fMiner, int64 nMinFee, + bool& fInvalid); bool ClientConnectInputs(); bool CheckTransaction() const; bool AcceptToMemoryPool(CTxDB& txdb, bool fCheckInputs=true, bool* pfMissingInputs=NULL); From cac23a5a0b7dc993ea1fb1513159db0af994d0ff Mon Sep 17 00:00:00 2001 From: Gregory Maxwell Date: Sun, 5 Feb 2012 02:30:43 -0500 Subject: [PATCH 084/154] Have bitcoind recommend a secure RPC password. Increase invalid password delay. Help users avoid insecure configurations a bit by recommending a secure RPC password and increasing the incorrect password delay. This may open up a RPC DOS for users with exposed RPC ports and short passwords. Since users shouldn't have exposed RPC ports OR short passwords, the DOS risk is preferable to the compromise risk. Also logs the client IP address for incorrect attempts. --- src/rpc.cpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/rpc.cpp b/src/rpc.cpp index a936edbbe47..a703334d6b1 100644 --- a/src/rpc.cpp +++ b/src/rpc.cpp @@ -2008,16 +2008,23 @@ void ThreadRPCServer2(void* parg) if (mapArgs["-rpcuser"] == "" && mapArgs["-rpcpassword"] == "") { + unsigned char rand_pwd[32]; + RAND_bytes(rand_pwd, 32); string strWhatAmI = "To use bitcoind"; if (mapArgs.count("-server")) strWhatAmI = strprintf(_("To use the %s option"), "\"-server\""); else if (mapArgs.count("-daemon")) strWhatAmI = strprintf(_("To use the %s option"), "\"-daemon\""); PrintConsole( - _("Warning: %s, you must set rpcpassword=\nin the configuration file: %s\n" + _("Warning: %s, you must set a rpcpassword in the configuration file:\n %s\n" + "It is recommended you use the following random password:\n" + "rpcuser=bitcoinrpc\n" + "rpcpassword=%s\n" + "(you do not need to remember this password)\n" "If the file does not exist, create it with owner-readable-only file permissions.\n"), strWhatAmI.c_str(), - GetConfigFile().c_str()); + GetConfigFile().c_str(), + EncodeBase58(&rand_pwd[0],&rand_pwd[0]+32).c_str()); CreateThread(Shutdown, NULL); return; } @@ -2104,12 +2111,14 @@ void ThreadRPCServer2(void* parg) } if (!HTTPAuthorized(mapHeaders)) { - // Deter brute-forcing short passwords - if (mapArgs["-rpcpassword"].size() < 15) - Sleep(50); + printf("ThreadRPCServer incorrect password attempt from %s\n",peer.address().to_string().c_str()); + /* Deter brute-forcing short passwords. + If this results in a DOS the user really + shouldn't have their RPC port exposed.*/ + if (mapArgs["-rpcpassword"].size() < 20) + Sleep(250); stream << HTTPReply(401, "") << std::flush; - printf("ThreadRPCServer incorrect password attempt\n"); continue; } From 4664aae3fe2eba4eec84d20f1e7e701ceeeb49bd Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Tue, 7 Feb 2012 22:30:21 -0500 Subject: [PATCH 085/154] Update copyrights to 2012 for files modified this year --- COPYING | 2 +- doc/README | 2 +- doc/README_windows.txt | 2 +- src/checkpoints.cpp | 2 +- src/db.cpp | 2 +- src/headers.h | 2 +- src/init.cpp | 2 +- src/irc.cpp | 2 +- src/key.h | 2 +- src/main.cpp | 2 +- src/main.h | 2 +- src/net.cpp | 2 +- src/net.h | 2 +- src/rpc.cpp | 2 +- src/serialize.h | 2 +- src/util.cpp | 2 +- src/util.h | 2 +- src/wallet.h | 2 +- 18 files changed, 18 insertions(+), 18 deletions(-) diff --git a/COPYING b/COPYING index ab042014e82..0f9223ba6b5 100644 --- a/COPYING +++ b/COPYING @@ -1,4 +1,4 @@ -Copyright (c) 2009-2011 Bitcoin Developers +Copyright (c) 2009-2012 Bitcoin Developers Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/doc/README b/doc/README index 40bda47d9c8..197f03dd56b 100644 --- a/doc/README +++ b/doc/README @@ -1,6 +1,6 @@ Bitcoin 0.4.4 BETA -Copyright (c) 2009-2011 Bitcoin Developers +Copyright (c) 2009-2012 Bitcoin Developers Distributed under the MIT/X11 software license, see the accompanying file license.txt or http://www.opensource.org/licenses/mit-license.php. This product includes software developed by the OpenSSL Project for use in diff --git a/doc/README_windows.txt b/doc/README_windows.txt index f8f1c341886..ad357130c27 100644 --- a/doc/README_windows.txt +++ b/doc/README_windows.txt @@ -1,6 +1,6 @@ Bitcoin 0.4.4 BETA -Copyright (c) 2009-2011 Bitcoin Developers +Copyright (c) 2009-2012 Bitcoin Developers Distributed under the MIT/X11 software license, see the accompanying file license.txt or http://www.opensource.org/licenses/mit-license.php. This product includes software developed by the OpenSSL Project for use in diff --git a/src/checkpoints.cpp b/src/checkpoints.cpp index 508f72b3765..f78712ef4ba 100644 --- a/src/checkpoints.cpp +++ b/src/checkpoints.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Bitcoin developers +// Copyright (c) 2009-2012 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. diff --git a/src/db.cpp b/src/db.cpp index 600afe383d2..783b0799639 100644 --- a/src/db.cpp +++ b/src/db.cpp @@ -1,5 +1,5 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto -// Copyright (c) 2011 The Bitcoin developers +// Copyright (c) 2009-2012 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. diff --git a/src/headers.h b/src/headers.h index 96db87db1ba..88a16d96d7b 100644 --- a/src/headers.h +++ b/src/headers.h @@ -1,5 +1,5 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto -// Copyright (c) 2011 The Bitcoin developers +// Copyright (c) 2009-2012 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. diff --git a/src/init.cpp b/src/init.cpp index 12e890cbb4c..079e67b9363 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1,5 +1,5 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto -// Copyright (c) 2011 The Bitcoin developers +// Copyright (c) 2009-2012 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 "headers.h" diff --git a/src/irc.cpp b/src/irc.cpp index fe96a90a1cf..b632b965461 100644 --- a/src/irc.cpp +++ b/src/irc.cpp @@ -1,5 +1,5 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto -// Copyright (c) 2011 The Bitcoin developers +// Copyright (c) 2009-2012 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. diff --git a/src/key.h b/src/key.h index 0d0b6d8bb47..8b033a029f0 100644 --- a/src/key.h +++ b/src/key.h @@ -1,5 +1,5 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto -// Copyright (c) 2011 The Bitcoin developers +// Copyright (c) 2009-2012 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_KEY_H diff --git a/src/main.cpp b/src/main.cpp index dc8503d38f9..9f12829042b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,5 +1,5 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto -// Copyright (c) 2011 The Bitcoin developers +// Copyright (c) 2009-2012 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 "headers.h" diff --git a/src/main.h b/src/main.h index 8a8b3870ec7..25cf0790134 100644 --- a/src/main.h +++ b/src/main.h @@ -1,5 +1,5 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto -// Copyright (c) 2011 The Bitcoin developers +// Copyright (c) 2009-2012 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_MAIN_H diff --git a/src/net.cpp b/src/net.cpp index f995ea9c2af..764246520ba 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1,5 +1,5 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto -// Copyright (c) 2011 The Bitcoin developers +// Copyright (c) 2009-2012 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. diff --git a/src/net.h b/src/net.h index 03d514ca909..52df06f1be5 100644 --- a/src/net.h +++ b/src/net.h @@ -1,5 +1,5 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto -// Copyright (c) 2011 The Bitcoin developers +// Copyright (c) 2009-2012 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_NET_H diff --git a/src/rpc.cpp b/src/rpc.cpp index a703334d6b1..a67f7fc9471 100644 --- a/src/rpc.cpp +++ b/src/rpc.cpp @@ -1,5 +1,5 @@ // Copyright (c) 2010 Satoshi Nakamoto -// Copyright (c) 2011 The Bitcoin developers +// Copyright (c) 2009-2012 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. diff --git a/src/serialize.h b/src/serialize.h index 385c9ab8e93..2bc3a071d77 100644 --- a/src/serialize.h +++ b/src/serialize.h @@ -1,5 +1,5 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto -// Copyright (c) 2011 The Bitcoin developers +// Copyright (c) 2009-2012 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_SERIALIZE_H diff --git a/src/util.cpp b/src/util.cpp index a3f1c9507d9..85ca02f0aae 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -1,5 +1,5 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto -// Copyright (c) 2011 The Bitcoin developers +// Copyright (c) 2009-2012 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 "headers.h" diff --git a/src/util.h b/src/util.h index 9f9001e06eb..a48979c0ef8 100644 --- a/src/util.h +++ b/src/util.h @@ -1,5 +1,5 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto -// Copyright (c) 2011 The Bitcoin developers +// Copyright (c) 2009-2012 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_UTIL_H diff --git a/src/wallet.h b/src/wallet.h index 3560a725801..4387e1a01fd 100644 --- a/src/wallet.h +++ b/src/wallet.h @@ -1,5 +1,5 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto -// Copyright (c) 2011 The Bitcoin developers +// Copyright (c) 2009-2012 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_WALLET_H From ccd69c7d2219a4a72ad1b6ea01838c3388130ea7 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Tue, 7 Feb 2012 18:20:01 -0500 Subject: [PATCH 086/154] Bugfix: Capitalize kB correctly (upstream: 9d4b05c) --- src/init.cpp | 2 +- src/qt/bitcoinstrings.cpp | 2 +- src/qt/locale/bitcoin_da.ts | 12 ++++++------ src/qt/locale/bitcoin_de.ts | 12 ++++++------ src/qt/locale/bitcoin_en.ts | 6 +++--- src/qt/locale/bitcoin_es.ts | 12 ++++++------ src/qt/locale/bitcoin_es_CL.ts | 12 ++++++------ src/qt/locale/bitcoin_nb.ts | 12 ++++++------ src/qt/locale/bitcoin_nl.ts | 12 ++++++------ src/qt/locale/bitcoin_ru.ts | 12 ++++++------ src/qt/locale/bitcoin_zh_TW.ts | 12 ++++++------ src/qt/optionsdialog.cpp | 4 ++-- 12 files changed, 55 insertions(+), 55 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index f8a63d26def..e158e15da4d 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -204,7 +204,7 @@ bool AppInit2(int argc, char* argv[]) " -upnp \t " + _("Attempt to use UPnP to map the listening port\n") + #endif #endif - " -paytxfee= \t " + _("Fee per KB to add to transactions you send\n") + + " -paytxfee= \t " + _("Fee per kB to add to transactions you send\n") + #ifdef GUI " -server \t\t " + _("Accept command line and JSON-RPC commands\n") + #endif diff --git a/src/qt/bitcoinstrings.cpp b/src/qt/bitcoinstrings.cpp index 647adb9c530..1b0a6767d78 100644 --- a/src/qt/bitcoinstrings.cpp +++ b/src/qt/bitcoinstrings.cpp @@ -24,7 +24,7 @@ QT_TRANSLATE_NOOP("bitcoin-core", "" "86400)\n"), QT_TRANSLATE_NOOP("bitcoin-core", "Don't attempt to use UPnP to map the listening port\n"), QT_TRANSLATE_NOOP("bitcoin-core", "Attempt to use UPnP to map the listening port\n"), -QT_TRANSLATE_NOOP("bitcoin-core", "Fee per KB to add to transactions you send\n"), +QT_TRANSLATE_NOOP("bitcoin-core", "Fee per kB to add to transactions you send\n"), QT_TRANSLATE_NOOP("bitcoin-core", "Accept command line and JSON-RPC commands\n"), QT_TRANSLATE_NOOP("bitcoin-core", "Run in the background as a daemon and accept commands\n"), QT_TRANSLATE_NOOP("bitcoin-core", "Use the test network\n"), diff --git a/src/qt/locale/bitcoin_da.ts b/src/qt/locale/bitcoin_da.ts index b6c148f05a3..ae1c84a4473 100644 --- a/src/qt/locale/bitcoin_da.ts +++ b/src/qt/locale/bitcoin_da.ts @@ -674,8 +674,8 @@ Adresse: %4 - Optional transaction fee per KB that helps make sure your transactions are processed quickly. Most transactions are 1KB. Fee 0.01 recommended. - Valgfri transaktionsgebyr pr. KB, der hjælper dine transaktioner med at blive behandlet hurtigt. De fleste transaktioner er på 1KB. Gebyr på 0.01 anbefales. + Optional transaction fee per kB that helps make sure your transactions are processed quickly. Most transactions are 1kB. Fee 0.01 recommended. + Valgfri transaktionsgebyr pr. kB, der hjælper dine transaktioner med at blive behandlet hurtigt. De fleste transaktioner er på 1kB. Gebyr på 0.01 anbefales. @@ -684,8 +684,8 @@ Adresse: %4 - Optional transaction fee per KB that helps make sure your transactions are processed quickly. Most transactions are 1KB. Fee 0.01 recommended. - Valgfri transaktionsgebyr pr. KB, der hjælper dine transaktioner med at blive behandlet hurtigt. De fleste transaktioner er på 1KB. Gebyr på 0.01 anbefales. + Optional transaction fee per kB that helps make sure your transactions are processed quickly. Most transactions are 1kB. Fee 0.01 recommended. + Valgfri transaktionsgebyr pr. kB, der hjælper dine transaktioner med at blive behandlet hurtigt. De fleste transaktioner er på 1kB. Gebyr på 0.01 anbefales. @@ -1523,9 +1523,9 @@ p, li { white-space: pre-wrap; } - Fee per KB to add to transactions you send + Fee per kB to add to transactions you send - Gebyr pr. KB, som skal tilføjes til transaktioner du sender + Gebyr pr. kB, som skal tilføjes til transaktioner du sender diff --git a/src/qt/locale/bitcoin_de.ts b/src/qt/locale/bitcoin_de.ts index 27db47528cf..242343b1e1f 100644 --- a/src/qt/locale/bitcoin_de.ts +++ b/src/qt/locale/bitcoin_de.ts @@ -673,8 +673,8 @@ Adresse: %4 - Optional transaction fee per KB that helps make sure your transactions are processed quickly. Most transactions are 1KB. Fee 0.01 recommended. - Zusätzliche Transaktionsgebühr pro KB, welche sicherstellt, dass Ihre Transaktionen schnell bearbeitet werden. Die meisten Transaktionen sind 1 KB groß. Eine Gebühr von 0.01 wird empfohlen. + Optional transaction fee per kB that helps make sure your transactions are processed quickly. Most transactions are 1kB. Fee 0.01 recommended. + Zusätzliche Transaktionsgebühr pro kB, welche sicherstellt, dass Ihre Transaktionen schnell bearbeitet werden. Die meisten Transaktionen sind 1 kB groß. Eine Gebühr von 0.01 wird empfohlen. @@ -683,8 +683,8 @@ Adresse: %4 - Optional transaction fee per KB that helps make sure your transactions are processed quickly. Most transactions are 1KB. Fee 0.01 recommended. - Zusätzliche Transaktionsgebühr pro KB, welche sicherstellt, dass Ihre Transaktionen schnell bearbeitet werden. Die meisten Transaktionen sind 1 KB groß. Eine Gebühr von 0.01 wird empfohlen. + Optional transaction fee per kB that helps make sure your transactions are processed quickly. Most transactions are 1kB. Fee 0.01 recommended. + Zusätzliche Transaktionsgebühr pro kB, welche sicherstellt, dass Ihre Transaktionen schnell bearbeitet werden. Die meisten Transaktionen sind 1 kB groß. Eine Gebühr von 0.01 wird empfohlen. @@ -1512,9 +1512,9 @@ p, li { white-space: pre-wrap; } - Fee per KB to add to transactions you send + Fee per kB to add to transactions you send - Gebühr pro KB, die gesendeten Transaktionen hinzugefügt wird + Gebühr pro kB, die gesendeten Transaktionen hinzugefügt wird diff --git a/src/qt/locale/bitcoin_en.ts b/src/qt/locale/bitcoin_en.ts index 0d57d9b1544..122f6d56a59 100644 --- a/src/qt/locale/bitcoin_en.ts +++ b/src/qt/locale/bitcoin_en.ts @@ -680,7 +680,7 @@ Address: %4 - Optional transaction fee per KB that helps make sure your transactions are processed quickly. Most transactions are 1KB. Fee 0.01 recommended. + Optional transaction fee per kB that helps make sure your transactions are processed quickly. Most transactions are 1kB. Fee 0.01 recommended. @@ -690,7 +690,7 @@ Address: %4 - Optional transaction fee per KB that helps make sure your transactions are processed quickly. Most transactions are 1KB. Fee 0.01 recommended. + Optional transaction fee per kB that helps make sure your transactions are processed quickly. Most transactions are 1kB. Fee 0.01 recommended. @@ -1515,7 +1515,7 @@ p, li { white-space: pre-wrap; } - Fee per KB to add to transactions you send + Fee per kB to add to transactions you send diff --git a/src/qt/locale/bitcoin_es.ts b/src/qt/locale/bitcoin_es.ts index 8c6966bfad6..815ba80ab62 100644 --- a/src/qt/locale/bitcoin_es.ts +++ b/src/qt/locale/bitcoin_es.ts @@ -693,8 +693,8 @@ Dirección: %4 - Optional transaction fee per KB that helps make sure your transactions are processed quickly. Most transactions are 1KB. Fee 0.01 recommended. - Comisión opcional a las transacciones por KB que ayuda a asegurar que tus transacciones son procesadas rápidamente. La mayoría de las transacciones son de 1KB. Se recomienda una comisión de 0.01. + Optional transaction fee per kB that helps make sure your transactions are processed quickly. Most transactions are 1kB. Fee 0.01 recommended. + Comisión opcional a las transacciones por kB que ayuda a asegurar que tus transacciones son procesadas rápidamente. La mayoría de las transacciones son de 1kB. Se recomienda una comisión de 0.01. @@ -703,8 +703,8 @@ Dirección: %4 - Optional transaction fee per KB that helps make sure your transactions are processed quickly. Most transactions are 1KB. Fee 0.01 recommended. - Comisión opcional a las transacciones por KB que ayuda a asegurar que tus transacciones son procesadas rápidamente. La mayoría de las transacciones son de 1KB. Se recomienda una comisión de 0.01. + Optional transaction fee per kB that helps make sure your transactions are processed quickly. Most transactions are 1kB. Fee 0.01 recommended. + Comisión opcional a las transacciones por kB que ayuda a asegurar que tus transacciones son procesadas rápidamente. La mayoría de las transacciones son de 1kB. Se recomienda una comisión de 0.01. @@ -1550,9 +1550,9 @@ p, li { white-space: pre-wrap; } - Fee per KB to add to transactions you send + Fee per kB to add to transactions you send - Comisión por KB para agregar a las transacciones que envias + Comisión por kB para agregar a las transacciones que envias diff --git a/src/qt/locale/bitcoin_es_CL.ts b/src/qt/locale/bitcoin_es_CL.ts index 107b90bb556..80df5ba450b 100644 --- a/src/qt/locale/bitcoin_es_CL.ts +++ b/src/qt/locale/bitcoin_es_CL.ts @@ -693,8 +693,8 @@ Dirección: %4 - Optional transaction fee per KB that helps make sure your transactions are processed quickly. Most transactions are 1KB. Fee 0.01 recommended. - Comisión de operación opcional por KB que ayuda a asegurar que tus transacciones sean procesadas rápidamente. La mayoría de las transacciones son de 1KB. Se recomienda una comisión de 0.01. + Optional transaction fee per kB that helps make sure your transactions are processed quickly. Most transactions are 1kB. Fee 0.01 recommended. + Comisión de operación opcional por kB que ayuda a asegurar que tus transacciones sean procesadas rápidamente. La mayoría de las transacciones son de 1kB. Se recomienda una comisión de 0.01. @@ -703,8 +703,8 @@ Dirección: %4 - Optional transaction fee per KB that helps make sure your transactions are processed quickly. Most transactions are 1KB. Fee 0.01 recommended. - Comisión de operación opcional por KB que ayuda a asegurar que tus transacciones sean procesadas rápidamente. La mayoría de las transacciones son de 1KB. Se recomienda una comisión de 0.01. + Optional transaction fee per kB that helps make sure your transactions are processed quickly. Most transactions are 1kB. Fee 0.01 recommended. + Comisión de operación opcional por kB que ayuda a asegurar que tus transacciones sean procesadas rápidamente. La mayoría de las transacciones son de 1kB. Se recomienda una comisión de 0.01. @@ -1550,9 +1550,9 @@ p, li { white-space: pre-wrap; } - Fee per KB to add to transactions you send + Fee per kB to add to transactions you send - Comisión por KB para agregar a las transacciones que envias + Comisión por kB para agregar a las transacciones que envias diff --git a/src/qt/locale/bitcoin_nb.ts b/src/qt/locale/bitcoin_nb.ts index ef09e6baf7d..9166af300f9 100644 --- a/src/qt/locale/bitcoin_nb.ts +++ b/src/qt/locale/bitcoin_nb.ts @@ -674,8 +674,8 @@ Adresse: %4 - Optional transaction fee per KB that helps make sure your transactions are processed quickly. Most transactions are 1KB. Fee 0.01 recommended. - Valgfritt transaksjonsgebyr per KB som hjelper for å sikre at transaksjonene dine blir raskt prosessert. De fleste transaksjoner er 1KB. Et gebyr på 0.01 anbefales. + Optional transaction fee per kB that helps make sure your transactions are processed quickly. Most transactions are 1kB. Fee 0.01 recommended. + Valgfritt transaksjonsgebyr per kB som hjelper for å sikre at transaksjonene dine blir raskt prosessert. De fleste transaksjoner er 1kB. Et gebyr på 0.01 anbefales. @@ -684,8 +684,8 @@ Adresse: %4 - Optional transaction fee per KB that helps make sure your transactions are processed quickly. Most transactions are 1KB. Fee 0.01 recommended. - Valgfritt transaksjonsgebyr per KB som hjelper for å sikre at transaksjonene dine blir raskt prosessert. De fleste transaksjoner er 1KB. Et gebyr på 0.01 anbefales. + Optional transaction fee per kB that helps make sure your transactions are processed quickly. Most transactions are 1kB. Fee 0.01 recommended. + Valgfritt transaksjonsgebyr per kB som hjelper for å sikre at transaksjonene dine blir raskt prosessert. De fleste transaksjoner er 1kB. Et gebyr på 0.01 anbefales. @@ -1524,9 +1524,9 @@ p, li { white-space: pre-wrap; } - Fee per KB to add to transactions you send + Fee per kB to add to transactions you send - Gebyr per KB som skal legges til transaksjoner du sender + Gebyr per kB som skal legges til transaksjoner du sender diff --git a/src/qt/locale/bitcoin_nl.ts b/src/qt/locale/bitcoin_nl.ts index 2b36237d2e5..4a28cac21d6 100644 --- a/src/qt/locale/bitcoin_nl.ts +++ b/src/qt/locale/bitcoin_nl.ts @@ -675,8 +675,8 @@ Adres: %4 - Optional transaction fee per KB that helps make sure your transactions are processed quickly. Most transactions are 1KB. Fee 0.01 recommended. - Optionele transactiekosten per KB die helpen ervoor te zorgen dat uw transacties snel verwerkt worden. De meeste transacties zijn 1KB. Transactiekosten van 0.01 wordt aangeraden. + Optional transaction fee per kB that helps make sure your transactions are processed quickly. Most transactions are 1kB. Fee 0.01 recommended. + Optionele transactiekosten per kB die helpen ervoor te zorgen dat uw transacties snel verwerkt worden. De meeste transacties zijn 1kB. Transactiekosten van 0.01 wordt aangeraden. @@ -685,8 +685,8 @@ Adres: %4 - Optional transaction fee per KB that helps make sure your transactions are processed quickly. Most transactions are 1KB. Fee 0.01 recommended. - Optionele transactiekosten per KB die helpen ervoor te zorgen dat uw transacties snel verwerkt worden. De meeste transacties zijn 1KB. Transactiekosten van 0.01 wordt aangeraden. + Optional transaction fee per kB that helps make sure your transactions are processed quickly. Most transactions are 1kB. Fee 0.01 recommended. + Optionele transactiekosten per kB die helpen ervoor te zorgen dat uw transacties snel verwerkt worden. De meeste transacties zijn 1kB. Transactiekosten van 0.01 wordt aangeraden. @@ -1526,9 +1526,9 @@ p, li { white-space: pre-wrap; } - Fee per KB to add to transactions you send + Fee per kB to add to transactions you send - Kosten per KB om aan transacties toe te voegen die u verstuurt + Kosten per kB om aan transacties toe te voegen die u verstuurt diff --git a/src/qt/locale/bitcoin_ru.ts b/src/qt/locale/bitcoin_ru.ts index 8bce04ed973..648caabcc34 100644 --- a/src/qt/locale/bitcoin_ru.ts +++ b/src/qt/locale/bitcoin_ru.ts @@ -669,8 +669,8 @@ Address: %4 - Optional transaction fee per KB that helps make sure your transactions are processed quickly. Most transactions are 1KB. Fee 0.01 recommended. - Опциональная комиссия за кадый KB транзакции, которое позволяет быть уверенным, что Ваша транзакция будет обработана быстро. Большинство транщакций занимают 1 KB. Рекомендованная комиссия: 0.01 BTC. + Optional transaction fee per kB that helps make sure your transactions are processed quickly. Most transactions are 1kB. Fee 0.01 recommended. + Опциональная комиссия за кадый kB транзакции, которое позволяет быть уверенным, что Ваша транзакция будет обработана быстро. Большинство транщакций занимают 1 kB. Рекомендованная комиссия: 0.01 BTC. @@ -679,8 +679,8 @@ Address: %4 - Optional transaction fee per KB that helps make sure your transactions are processed quickly. Most transactions are 1KB. Fee 0.01 recommended. - Опциональная комиссия за кадый KB транзакции, которая позволяет быть уверенным, что Ваша транзакция будет обработана быстро. Большинство транзакций занимают 1 KB. Рекомендованная комиссия: 0.01 BTC. + Optional transaction fee per kB that helps make sure your transactions are processed quickly. Most transactions are 1kB. Fee 0.01 recommended. + Опциональная комиссия за кадый kB транзакции, которая позволяет быть уверенным, что Ваша транзакция будет обработана быстро. Большинство транзакций занимают 1 kB. Рекомендованная комиссия: 0.01 BTC. @@ -1519,9 +1519,9 @@ p, li { white-space: pre-wrap; } - Fee per KB to add to transactions you send + Fee per kB to add to transactions you send - Комиссия (за каждый KB транзакции) + Комиссия (за каждый kB транзакции) diff --git a/src/qt/locale/bitcoin_zh_TW.ts b/src/qt/locale/bitcoin_zh_TW.ts index b0c4bd12d8a..562ddb32302 100644 --- a/src/qt/locale/bitcoin_zh_TW.ts +++ b/src/qt/locale/bitcoin_zh_TW.ts @@ -673,8 +673,8 @@ Address: %4 - Optional transaction fee per KB that helps make sure your transactions are processed quickly. Most transactions are 1KB. Fee 0.01 recommended. - 非必要的交易手續費, 有助於縮短你的交易處理時間. 以 KB 為計費單位, 而大部份交易的大小是 1KB. 建議設定為 0.01 位元幣. + Optional transaction fee per kB that helps make sure your transactions are processed quickly. Most transactions are 1kB. Fee 0.01 recommended. + 非必要的交易手續費, 有助於縮短你的交易處理時間. 以 kB 為計費單位, 而大部份交易的大小是 1kB. 建議設定為 0.01 位元幣. @@ -683,8 +683,8 @@ Address: %4 - Optional transaction fee per KB that helps make sure your transactions are processed quickly. Most transactions are 1KB. Fee 0.01 recommended. - 非必要的交易手續費, 有助於縮短你的交易處理時間. 以 KB 為計費單位, 而大部份交易的大小是 1KB. 建議設定為 0.01 位元幣. + Optional transaction fee per kB that helps make sure your transactions are processed quickly. Most transactions are 1kB. Fee 0.01 recommended. + 非必要的交易手續費, 有助於縮短你的交易處理時間. 以 kB 為計費單位, 而大部份交易的大小是 1kB. 建議設定為 0.01 位元幣. @@ -1524,9 +1524,9 @@ p, li { white-space: pre-wrap; } - Fee per KB to add to transactions you send + Fee per kB to add to transactions you send - 交易付款時每 KB 的交易手續費 + 交易付款時每 kB 的交易手續費 diff --git a/src/qt/optionsdialog.cpp b/src/qt/optionsdialog.cpp index ea3164e3d79..75fd4ccf186 100644 --- a/src/qt/optionsdialog.cpp +++ b/src/qt/optionsdialog.cpp @@ -214,7 +214,7 @@ MainOptionsPage::MainOptionsPage(QWidget *parent): proxy_hbox->addStretch(1); layout->addLayout(proxy_hbox); - QLabel *fee_help = new QLabel(tr("Optional transaction fee per KB that helps make sure your transactions are processed quickly. Most transactions are 1KB. Fee 0.01 recommended.")); + QLabel *fee_help = new QLabel(tr("Optional transaction fee per kB that helps make sure your transactions are processed quickly. Most transactions are 1 kB. Fee 0.01 recommended.")); fee_help->setWordWrap(true); layout->addWidget(fee_help); @@ -223,7 +223,7 @@ MainOptionsPage::MainOptionsPage(QWidget *parent): QLabel *fee_label = new QLabel(tr("Pay transaction &fee")); fee_hbox->addWidget(fee_label); fee_edit = new BitcoinAmountField(); - fee_edit->setToolTip(tr("Optional transaction fee per KB that helps make sure your transactions are processed quickly. Most transactions are 1KB. Fee 0.01 recommended.")); + fee_edit->setToolTip(tr("Optional transaction fee per kB that helps make sure your transactions are processed quickly. Most transactions are 1 kB. Fee 0.01 recommended.")); fee_label->setBuddy(fee_edit); fee_hbox->addWidget(fee_edit); From e7c3e6e4b4bbfaf6772f0c8bd6b4278d0120e6e4 Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Sun, 5 Feb 2012 11:53:52 +0100 Subject: [PATCH 087/154] Restructure credit transaction decomposition (solves issue #689) When a transaction has multiple outputs that go to the wallet, list these as multiple transactions in the UI. This is also applied to generated (coinbase) transactions. Also makes the code shorter and easier to understand. --- src/qt/transactionrecord.cpp | 60 ++++++++++++++---------------------- 1 file changed, 23 insertions(+), 37 deletions(-) diff --git a/src/qt/transactionrecord.cpp b/src/qt/transactionrecord.cpp index 52a3080e970..4059207b960 100644 --- a/src/qt/transactionrecord.cpp +++ b/src/qt/transactionrecord.cpp @@ -47,49 +47,35 @@ QList TransactionRecord::decomposeTransaction(const CWallet * // // Credit // - TransactionRecord sub(hash, nTime); - - sub.credit = nNet; - - if (wtx.IsCoinBase()) + BOOST_FOREACH(const CTxOut& txout, wtx.vout) { - // Generated - sub.type = TransactionRecord::Generated; - - if (nCredit == 0) + if(wallet->IsMine(txout)) { - int64 nUnmatured = 0; - BOOST_FOREACH(const CTxOut& txout, wtx.vout) - nUnmatured += wallet->GetCredit(txout); - sub.credit = nUnmatured; - } - } - else - { - bool foundAddress = false; - // Received by Bitcoin Address - BOOST_FOREACH(const CTxOut& txout, wtx.vout) - { - if(wallet->IsMine(txout)) + TransactionRecord sub(hash, nTime); + CBitcoinAddress address; + sub.idx = parts.size(); // sequence number + sub.credit = txout.nValue; + if (wtx.IsCoinBase()) { - CBitcoinAddress address; - if (ExtractAddress(txout.scriptPubKey, wallet, address)) - { - sub.type = TransactionRecord::RecvWithAddress; - sub.address = address.ToString(); - foundAddress = true; - break; - } + // Generated + sub.type = TransactionRecord::Generated; } - } - if(!foundAddress) - { - // Received by IP connection, or other non-address transaction like OP_EVAL - sub.type = TransactionRecord::RecvFromOther; - sub.address = mapValue["from"]; + else if (ExtractAddress(txout.scriptPubKey, wallet, address)) + { + // Received by Bitcoin Address + sub.type = TransactionRecord::RecvWithAddress; + sub.address = address.ToString(); + } + else + { + // Received by IP connection (deprecated features), or a multisignature or other non-simple transaction + sub.type = TransactionRecord::RecvFromOther; + sub.address = mapValue["from"]; + } + + parts.append(sub); } } - parts.append(sub); } else { From da6a3919a96b6070a1facc8ae8c8946bd74838e1 Mon Sep 17 00:00:00 2001 From: Gregory Maxwell Date: Sun, 5 Feb 2012 02:30:43 -0500 Subject: [PATCH 088/154] Have bitcoind recommend a secure RPC password. Increase invalid password delay. Help users avoid insecure configurations a bit by recommending a secure RPC password and increasing the incorrect password delay. This may open up a RPC DOS for users with exposed RPC ports and short passwords. Since users shouldn't have exposed RPC ports OR short passwords, the DOS risk is preferable to the compromise risk. Also logs the client IP address for incorrect attempts. --- src/bitcoinrpc.cpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp index 4031d0cbc34..821574a2ffd 100644 --- a/src/bitcoinrpc.cpp +++ b/src/bitcoinrpc.cpp @@ -2161,16 +2161,23 @@ void ThreadRPCServer2(void* parg) if (mapArgs["-rpcuser"] == "" && mapArgs["-rpcpassword"] == "") { + unsigned char rand_pwd[32]; + RAND_bytes(rand_pwd, 32); string strWhatAmI = "To use bitcoind"; if (mapArgs.count("-server")) strWhatAmI = strprintf(_("To use the %s option"), "\"-server\""); else if (mapArgs.count("-daemon")) strWhatAmI = strprintf(_("To use the %s option"), "\"-daemon\""); PrintConsole( - _("Error: %s, you must set rpcpassword=\nin the configuration file: %s\n" + _("Error: %s, you must set a rpcpassword in the configuration file:\n %s\n" + "It is recommended you use the following random password:\n" + "rpcuser=bitcoinrpc\n" + "rpcpassword=%s\n" + "(you do not need to remember this password)\n" "If the file does not exist, create it with owner-readable-only file permissions.\n"), strWhatAmI.c_str(), - GetConfigFile().c_str()); + GetConfigFile().c_str(), + EncodeBase58(&rand_pwd[0],&rand_pwd[0]+32).c_str()); #ifndef QT_GUI CreateThread(Shutdown, NULL); #endif @@ -2259,12 +2266,14 @@ void ThreadRPCServer2(void* parg) } if (!HTTPAuthorized(mapHeaders)) { - // Deter brute-forcing short passwords - if (mapArgs["-rpcpassword"].size() < 15) - Sleep(50); + printf("ThreadRPCServer incorrect password attempt from %s\n",peer.address().to_string().c_str()); + /* Deter brute-forcing short passwords. + If this results in a DOS the user really + shouldn't have their RPC port exposed.*/ + if (mapArgs["-rpcpassword"].size() < 20) + Sleep(250); stream << HTTPReply(401, "") << std::flush; - printf("ThreadRPCServer incorrect password attempt\n"); continue; } From 4bbd72cca108042cdffee74d10fcc7a540da2b51 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Tue, 7 Feb 2012 22:30:21 -0500 Subject: [PATCH 089/154] Update copyrights to 2012 for files modified this year --- COPYING | 2 +- src/bitcoinrpc.cpp | 2 +- src/db.cpp | 2 +- src/init.cpp | 2 +- src/key.h | 2 +- src/main.cpp | 2 +- src/main.h | 2 +- src/net.cpp | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/COPYING b/COPYING index ab042014e82..0f9223ba6b5 100644 --- a/COPYING +++ b/COPYING @@ -1,4 +1,4 @@ -Copyright (c) 2009-2011 Bitcoin Developers +Copyright (c) 2009-2012 Bitcoin Developers Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp index 821574a2ffd..b1d85146495 100644 --- a/src/bitcoinrpc.cpp +++ b/src/bitcoinrpc.cpp @@ -1,5 +1,5 @@ // Copyright (c) 2010 Satoshi Nakamoto -// Copyright (c) 2011 The Bitcoin developers +// Copyright (c) 2009-2012 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. diff --git a/src/db.cpp b/src/db.cpp index c2d18279dae..e681d98f1a2 100644 --- a/src/db.cpp +++ b/src/db.cpp @@ -1,5 +1,5 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto -// Copyright (c) 2011 The Bitcoin developers +// Copyright (c) 2009-2012 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. diff --git a/src/init.cpp b/src/init.cpp index e158e15da4d..3ca0dcf2513 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1,5 +1,5 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto -// Copyright (c) 2011 The Bitcoin developers +// Copyright (c) 2009-2012 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 "headers.h" diff --git a/src/key.h b/src/key.h index 010591632ed..6da0dc288d5 100644 --- a/src/key.h +++ b/src/key.h @@ -1,5 +1,5 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto -// Copyright (c) 2011 The Bitcoin developers +// Copyright (c) 2009-2012 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_KEY_H diff --git a/src/main.cpp b/src/main.cpp index 07b07447c12..1f8abc04a25 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,5 +1,5 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto -// Copyright (c) 2011 The Bitcoin developers +// Copyright (c) 2009-2012 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 "headers.h" diff --git a/src/main.h b/src/main.h index 47394ff8e93..4232d2a0f71 100644 --- a/src/main.h +++ b/src/main.h @@ -1,5 +1,5 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto -// Copyright (c) 2011 The Bitcoin developers +// Copyright (c) 2009-2012 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_MAIN_H diff --git a/src/net.cpp b/src/net.cpp index 7b92e874ac5..ad7007d1c2d 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1,5 +1,5 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto -// Copyright (c) 2011 The Bitcoin developers +// Copyright (c) 2009-2012 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. From 84d228ed839e527f8638db5f451e05bd58905f52 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Tue, 7 Feb 2012 18:20:01 -0500 Subject: [PATCH 090/154] Bugfix: Capitalize kB correctly (upstream: 9d4b05c) --- src/qt/locale/bitcoin_hu.ts | 12 ++++++------ src/qt/locale/bitcoin_it.ts | 12 ++++++------ src/qt/locale/bitcoin_pt_BR.ts | 12 ++++++------ src/qt/locale/bitcoin_uk.ts | 6 +++--- src/qt/locale/bitcoin_zh_CN.ts | 12 ++++++------ 5 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/qt/locale/bitcoin_hu.ts b/src/qt/locale/bitcoin_hu.ts index 25a0a24a18c..bc48ed889a5 100644 --- a/src/qt/locale/bitcoin_hu.ts +++ b/src/qt/locale/bitcoin_hu.ts @@ -673,8 +673,8 @@ Cím: %4 - Optional transaction fee per KB that helps make sure your transactions are processed quickly. Most transactions are 1KB. Fee 0.01 recommended. - Opcionális, KB-onkénti tranzakciós díj a tranzakcióid minél gyorsabb feldolgozásának elősegítésére. A legtöbb tranzakció 1 KB-os. 0,01 BTC ajánlott. + Optional transaction fee per kB that helps make sure your transactions are processed quickly. Most transactions are 1kB. Fee 0.01 recommended. + Opcionális, kB-onkénti tranzakciós díj a tranzakcióid minél gyorsabb feldolgozásának elősegítésére. A legtöbb tranzakció 1 kB-os. 0,01 BTC ajánlott. @@ -683,8 +683,8 @@ Cím: %4 - Optional transaction fee per KB that helps make sure your transactions are processed quickly. Most transactions are 1KB. Fee 0.01 recommended. - Opcionális, KB-onkénti tranzakciós díj a tranzakcióid minél gyorsabb feldolgozásának elősegítésére. A legtöbb tranzakció 1 KB-os. 0,01 BTC ajánlott. + Optional transaction fee per kB that helps make sure your transactions are processed quickly. Most transactions are 1kB. Fee 0.01 recommended. + Opcionális, kB-onkénti tranzakciós díj a tranzakcióid minél gyorsabb feldolgozásának elősegítésére. A legtöbb tranzakció 1 kB-os. 0,01 BTC ajánlott. @@ -1525,9 +1525,9 @@ p, li { white-space: pre-wrap; } - Fee per KB to add to transactions you send + Fee per kB to add to transactions you send - KB-onként felajánlandó díj az általad küldött tranzakciókhoz + kB-onként felajánlandó díj az általad küldött tranzakciókhoz diff --git a/src/qt/locale/bitcoin_it.ts b/src/qt/locale/bitcoin_it.ts index 95d76005fdd..02d0baa120d 100644 --- a/src/qt/locale/bitcoin_it.ts +++ b/src/qt/locale/bitcoin_it.ts @@ -675,8 +675,8 @@ Indirizzo: %4 - Optional transaction fee per KB that helps make sure your transactions are processed quickly. Most transactions are 1KB. Fee 0.01 recommended. - Commissione di transazione per ogni KB; è opzionale e contribuisce ad assicurare che le transazioni siano elaborate velocemente. La maggior parte delle transazioni è 1KB. Commissione raccomandata 0,01. + Optional transaction fee per kB that helps make sure your transactions are processed quickly. Most transactions are 1kB. Fee 0.01 recommended. + Commissione di transazione per ogni kB; è opzionale e contribuisce ad assicurare che le transazioni siano elaborate velocemente. La maggior parte delle transazioni è 1kB. Commissione raccomandata 0,01. @@ -685,8 +685,8 @@ Indirizzo: %4 - Optional transaction fee per KB that helps make sure your transactions are processed quickly. Most transactions are 1KB. Fee 0.01 recommended. - Commissione di transazione per ogni KB; è opzionale e contribuisce ad assicurare che le transazioni siano elaborate velocemente. La maggior parte delle transazioni è 1KB. Commissione raccomandata 0,01. + Optional transaction fee per kB that helps make sure your transactions are processed quickly. Most transactions are 1kB. Fee 0.01 recommended. + Commissione di transazione per ogni kB; è opzionale e contribuisce ad assicurare che le transazioni siano elaborate velocemente. La maggior parte delle transazioni è 1kB. Commissione raccomandata 0,01. @@ -1526,9 +1526,9 @@ p, li { white-space: pre-wrap; }⏎ - Fee per KB to add to transactions you send + Fee per kB to add to transactions you send - Commissione al KB da aggiungere alle transazioni in uscita + Commissione al kB da aggiungere alle transazioni in uscita diff --git a/src/qt/locale/bitcoin_pt_BR.ts b/src/qt/locale/bitcoin_pt_BR.ts index 2c2f7f1ae4d..68bd057fe2a 100644 --- a/src/qt/locale/bitcoin_pt_BR.ts +++ b/src/qt/locale/bitcoin_pt_BR.ts @@ -684,8 +684,8 @@ Address: %4 - Optional transaction fee per KB that helps make sure your transactions are processed quickly. Most transactions are 1KB. Fee 0.01 recommended. - Optional transaction fee per KB that helps make sure your transactions are processed quickly. Most transactions are 1KB. Fee 0.01 recommended. + Optional transaction fee per kB that helps make sure your transactions are processed quickly. Most transactions are 1kB. Fee 0.01 recommended. + Optional transaction fee per kB that helps make sure your transactions are processed quickly. Most transactions are 1kB. Fee 0.01 recommended. @@ -694,8 +694,8 @@ Address: %4 - Optional transaction fee per KB that helps make sure your transactions are processed quickly. Most transactions are 1KB. Fee 0.01 recommended. - Optional transaction fee per KB that helps make sure your transactions are processed quickly. Most transactions are 1KB. Fee 0.01 recommended. + Optional transaction fee per kB that helps make sure your transactions are processed quickly. Most transactions are 1kB. Fee 0.01 recommended. + Optional transaction fee per kB that helps make sure your transactions are processed quickly. Most transactions are 1kB. Fee 0.01 recommended. @@ -1541,9 +1541,9 @@ p, li { white-space: pre-wrap; } - Fee per KB to add to transactions you send + Fee per kB to add to transactions you send - Fee per KB to add to transactions you send + Fee per kB to add to transactions you send diff --git a/src/qt/locale/bitcoin_uk.ts b/src/qt/locale/bitcoin_uk.ts index 57313b7a521..6cbb51633b0 100644 --- a/src/qt/locale/bitcoin_uk.ts +++ b/src/qt/locale/bitcoin_uk.ts @@ -674,7 +674,7 @@ Address: %4 - Optional transaction fee per KB that helps make sure your transactions are processed quickly. Most transactions are 1KB. Fee 0.01 recommended. + Optional transaction fee per kB that helps make sure your transactions are processed quickly. Most transactions are 1kB. Fee 0.01 recommended. Опціональна комісія за кожен Кб переказу, яка дозволяє бути впевненим у тому, що ваш переказ буде оброблено швидко. Розмір більшості переказів рівен 1 Кб. Рекомендована комісія: 0,01. @@ -684,7 +684,7 @@ Address: %4 - Optional transaction fee per KB that helps make sure your transactions are processed quickly. Most transactions are 1KB. Fee 0.01 recommended. + Optional transaction fee per kB that helps make sure your transactions are processed quickly. Most transactions are 1kB. Fee 0.01 recommended. Опціональна комісія за кожен Кб переказу, яка дозволяє бути впевненим у тому, що ваш переказ буде оброблено швидко. Розмір більшості переказів рівен 1 Кб. Рекомендована комісія: 0,01. @@ -1525,7 +1525,7 @@ p, li { white-space: pre-wrap; } - Fee per KB to add to transactions you send + Fee per kB to add to transactions you send Комісія за Кб diff --git a/src/qt/locale/bitcoin_zh_CN.ts b/src/qt/locale/bitcoin_zh_CN.ts index 3faaac3c97b..832a86ed07b 100644 --- a/src/qt/locale/bitcoin_zh_CN.ts +++ b/src/qt/locale/bitcoin_zh_CN.ts @@ -674,8 +674,8 @@ Address: %4 - Optional transaction fee per KB that helps make sure your transactions are processed quickly. Most transactions are 1KB. Fee 0.01 recommended. - 为每1KB交易数据支付交易费将保证您的交易尽快被处理.大部分交易数据都小于1KB. 建议支付0.01个比特币的交易费. + Optional transaction fee per kB that helps make sure your transactions are processed quickly. Most transactions are 1kB. Fee 0.01 recommended. + 为每1kB交易数据支付交易费将保证您的交易尽快被处理.大部分交易数据都小于1kB. 建议支付0.01个比特币的交易费. @@ -684,8 +684,8 @@ Address: %4 - Optional transaction fee per KB that helps make sure your transactions are processed quickly. Most transactions are 1KB. Fee 0.01 recommended. - 为每1KB交易数据支付交易费将保证您的交易尽快被处理.大部分交易数据都小于1KB. 建议支付0.01个比特币的交易费. + Optional transaction fee per kB that helps make sure your transactions are processed quickly. Most transactions are 1kB. Fee 0.01 recommended. + 为每1kB交易数据支付交易费将保证您的交易尽快被处理.大部分交易数据都小于1kB. 建议支付0.01个比特币的交易费. @@ -1524,9 +1524,9 @@ p, li { white-space: pre-wrap; } - Fee per KB to add to transactions you send + Fee per kB to add to transactions you send - 每发送1KB交易所需的费用 + 每发送1kB交易所需的费用 From 76e707a44e280e2b0e6df776d16a86df1002ff3b Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Sat, 11 Feb 2012 15:25:42 +0100 Subject: [PATCH 091/154] Fix #822 --- src/rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpc.cpp b/src/rpc.cpp index a67f7fc9471..33108948d3c 100644 --- a/src/rpc.cpp +++ b/src/rpc.cpp @@ -1301,7 +1301,7 @@ void ThreadCleanWalletPassphrase(void* parg) if (nWalletUnlockTime < nMyWakeTime) nWalletUnlockTime = nMyWakeTime; } - free(parg); + delete (int*)parg; return; } From 888ac4e7a326986945ca91668c47a3d8fa981d49 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Thu, 9 Feb 2012 22:41:42 -0500 Subject: [PATCH 092/154] Get ext. IP from UPnP, make sure addrMe IsRoutable() in version. This fixes a potential bug where some NATs may replace the node's interal IP with its external IP in version messages, causing incorrect checksums when version messages begin being checksummed on February 14, 2012. --- src/net.cpp | 20 ++++++++++++++++++++ src/net.h | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/net.cpp b/src/net.cpp index 764246520ba..83e7f28c6bc 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1103,6 +1103,26 @@ void ThreadMapPort2(void* parg) r = UPNP_GetValidIGD(devlist, &urls, &data, lanaddr, sizeof(lanaddr)); if (r == 1) { + if (!addrLocalHost.IsRoutable()) + { + char externalIPAddress[40]; + r = UPNP_GetExternalIPAddress(urls.controlURL, data.first.servicetype, externalIPAddress); + if(r != UPNPCOMMAND_SUCCESS) + printf("UPnP: GetExternalIPAddress() returned %d\n", r); + else + { + if(externalIPAddress[0]) + { + printf("UPnP: ExternalIPAddress = %s\n", externalIPAddress); + CAddress addrExternalFromUPnP(externalIPAddress, 0, false, nLocalServices); + if (addrExternalFromUPnP.IsRoutable()) + addrLocalHost = addrExternalFromUPnP; + } + else + printf("UPnP: GetExternalIPAddress failed.\n"); + } + } + string strDesc = "Bitcoin " + FormatFullVersion(); #ifndef UPNPDISCOVER_SUCCESS /* miniupnpc 1.5 */ diff --git a/src/net.h b/src/net.h index 52df06f1be5..d8b90222769 100644 --- a/src/net.h +++ b/src/net.h @@ -355,7 +355,7 @@ public: /// when NTP implemented, change to just nTime = GetAdjustedTime() int64 nTime = (fInbound ? GetAdjustedTime() : GetTime()); CAddress addrYou = (fUseProxy ? CAddress("0.0.0.0") : addr); - CAddress addrMe = (fUseProxy ? CAddress("0.0.0.0") : addrLocalHost); + CAddress addrMe = (fUseProxy || !addrLocalHost.IsRoutable() ? CAddress("0.0.0.0") : addrLocalHost); RAND_bytes((unsigned char*)&nLocalHostNonce, sizeof(nLocalHostNonce)); PushMessage("version", VERSION, nLocalServices, nTime, addrYou, addrMe, nLocalHostNonce, std::string(pszSubVer), nBestHeight); From 4c38fbae959c69e524e2f7453a221b5f29a5d12f Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Fri, 10 Feb 2012 08:28:32 +0100 Subject: [PATCH 093/154] Enable accessible widgets Qt module on win32, so that people with screen readers such as NVDA can make sense of it. --- bitcoin-qt.pro | 2 +- src/init.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/bitcoin-qt.pro b/bitcoin-qt.pro index 19349c708d0..790c0751ca0 100644 --- a/bitcoin-qt.pro +++ b/bitcoin-qt.pro @@ -62,7 +62,7 @@ contains(USE_SSL, 1) { contains(BITCOIN_NEED_QT_PLUGINS, 1) { DEFINES += BITCOIN_NEED_QT_PLUGINS - QTPLUGIN += qcncodecs qjpcodecs qtwcodecs qkrcodecs + QTPLUGIN += qcncodecs qjpcodecs qtwcodecs qkrcodecs qtaccessiblewidgets } !windows { diff --git a/src/init.cpp b/src/init.cpp index 3ca0dcf2513..51e9ed604ee 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -20,6 +20,7 @@ Q_IMPORT_PLUGIN(qcncodecs) Q_IMPORT_PLUGIN(qjpcodecs) Q_IMPORT_PLUGIN(qtwcodecs) Q_IMPORT_PLUGIN(qkrcodecs) +Q_IMPORT_PLUGIN(qtaccessiblewidgets) #endif using namespace std; From 6ebb141bf941183aefc652b525c07430b35863ad Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Fri, 9 Dec 2011 22:35:57 +0100 Subject: [PATCH 094/154] Prevent window from being shown momentarily when using -min - In a previous patch, show() was added to all the page switcher functions. As the contructor calls showOverviewPage(), this means the window is shown in the constructor. - This change prevents this by connecting show() to the signal instead. --- src/qt/bitcoingui.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index f80038c3fba..5d9c0d9f00f 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -193,10 +193,15 @@ void BitcoinGUI::createActions() sendCoinsAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_2)); tabGroup->addAction(sendCoinsAction); + connect(overviewAction, SIGNAL(triggered()), this, SLOT(show())); connect(overviewAction, SIGNAL(triggered()), this, SLOT(gotoOverviewPage())); + connect(historyAction, SIGNAL(triggered()), this, SLOT(show())); connect(historyAction, SIGNAL(triggered()), this, SLOT(gotoHistoryPage())); + connect(addressBookAction, SIGNAL(triggered()), this, SLOT(show())); connect(addressBookAction, SIGNAL(triggered()), this, SLOT(gotoAddressBookPage())); + connect(receiveCoinsAction, SIGNAL(triggered()), this, SLOT(show())); connect(receiveCoinsAction, SIGNAL(triggered()), this, SLOT(gotoReceiveCoinsPage())); + connect(sendCoinsAction, SIGNAL(triggered()), this, SLOT(show())); connect(sendCoinsAction, SIGNAL(triggered()), this, SLOT(gotoSendCoinsPage())); quitAction = new QAction(QIcon(":/icons/quit"), tr("E&xit"), this); @@ -598,7 +603,6 @@ void BitcoinGUI::incomingTransaction(const QModelIndex & parent, int start, int void BitcoinGUI::gotoOverviewPage() { - show(); overviewAction->setChecked(true); centralWidget->setCurrentWidget(overviewPage); @@ -608,7 +612,6 @@ void BitcoinGUI::gotoOverviewPage() void BitcoinGUI::gotoHistoryPage() { - show(); historyAction->setChecked(true); centralWidget->setCurrentWidget(transactionsPage); @@ -619,7 +622,6 @@ void BitcoinGUI::gotoHistoryPage() void BitcoinGUI::gotoAddressBookPage() { - show(); addressBookAction->setChecked(true); centralWidget->setCurrentWidget(addressBookPage); @@ -630,7 +632,6 @@ void BitcoinGUI::gotoAddressBookPage() void BitcoinGUI::gotoReceiveCoinsPage() { - show(); receiveCoinsAction->setChecked(true); centralWidget->setCurrentWidget(receiveCoinsPage); @@ -641,7 +642,6 @@ void BitcoinGUI::gotoReceiveCoinsPage() void BitcoinGUI::gotoSendCoinsPage() { - show(); sendCoinsAction->setChecked(true); centralWidget->setCurrentWidget(sendCoinsPage); From 41cde5bbdcf76bda63cb7c55675340726c73b7fc Mon Sep 17 00:00:00 2001 From: Janne Pulkkinen Date: Fri, 3 Feb 2012 20:08:50 +0200 Subject: [PATCH 095/154] Fix Minimize to the tray instead of the taskbar --- src/qt/bitcoingui.cpp | 32 ++++++++++++++++++++++---------- src/qt/bitcoingui.h | 4 ++++ 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index 5d9c0d9f00f..cfcff136e0a 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -55,6 +55,7 @@ BitcoinGUI::BitcoinGUI(QWidget *parent): QMainWindow(parent), clientModel(0), walletModel(0), + dummyWidget(0), encryptWalletAction(0), changePassphraseAction(0), aboutQtAction(0), @@ -84,6 +85,9 @@ BitcoinGUI::BitcoinGUI(QWidget *parent): // Create the tray icon (or setup the dock icon) createTrayIcon(); + // Dummy widget used when restoring window state after minimization + dummyWidget = new QWidget(); + // Create tabs overviewPage = new OverviewPage(); @@ -157,6 +161,7 @@ BitcoinGUI::~BitcoinGUI() #ifdef Q_WS_MAC delete appMenuBar; #endif + delete dummyWidget; } void BitcoinGUI::createActions() @@ -193,15 +198,15 @@ void BitcoinGUI::createActions() sendCoinsAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_2)); tabGroup->addAction(sendCoinsAction); - connect(overviewAction, SIGNAL(triggered()), this, SLOT(show())); + connect(overviewAction, SIGNAL(triggered()), this, SLOT(showNormal())); connect(overviewAction, SIGNAL(triggered()), this, SLOT(gotoOverviewPage())); - connect(historyAction, SIGNAL(triggered()), this, SLOT(show())); + connect(historyAction, SIGNAL(triggered()), this, SLOT(showNormal())); connect(historyAction, SIGNAL(triggered()), this, SLOT(gotoHistoryPage())); - connect(addressBookAction, SIGNAL(triggered()), this, SLOT(show())); + connect(addressBookAction, SIGNAL(triggered()), this, SLOT(showNormal())); connect(addressBookAction, SIGNAL(triggered()), this, SLOT(gotoAddressBookPage())); - connect(receiveCoinsAction, SIGNAL(triggered()), this, SLOT(show())); + connect(receiveCoinsAction, SIGNAL(triggered()), this, SLOT(showNormal())); connect(receiveCoinsAction, SIGNAL(triggered()), this, SLOT(gotoReceiveCoinsPage())); - connect(sendCoinsAction, SIGNAL(triggered()), this, SLOT(show())); + connect(sendCoinsAction, SIGNAL(triggered()), this, SLOT(showNormal())); connect(sendCoinsAction, SIGNAL(triggered()), this, SLOT(gotoSendCoinsPage())); quitAction = new QAction(QIcon(":/icons/quit"), tr("E&xit"), this); @@ -379,10 +384,17 @@ void BitcoinGUI::trayIconActivated(QSystemTrayIcon::ActivationReason reason) // Click on system tray icon triggers "open bitcoin" openBitcoinAction->trigger(); } - } #endif +void BitcoinGUI::showNormal() +{ + // Reparent window to the desktop (in case it was hidden on minimize) + if(parent() != NULL) + setParent(NULL, Qt::Window); + QMainWindow::showNormal(); +} + void BitcoinGUI::optionsClicked() { if(!clientModel || !clientModel->getOptionsModel()) @@ -524,13 +536,13 @@ void BitcoinGUI::changeEvent(QEvent *e) { if(isMinimized()) { - hide(); - e->ignore(); + // Hiding the window from taskbar + setParent(dummyWidget, Qt::SubWindow); + return; } else { - show(); - e->accept(); + showNormal(); } } } diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h index 9b672ee809d..1338998a98c 100644 --- a/src/qt/bitcoingui.h +++ b/src/qt/bitcoingui.h @@ -54,6 +54,8 @@ private: QStackedWidget *centralWidget; + QWidget *dummyWidget; + OverviewPage *overviewPage; QWidget *transactionsPage; AddressBookPage *addressBookPage; @@ -107,6 +109,8 @@ public slots: */ void askFee(qint64 nFeeRequired, bool *payFee); + void showNormal(); + private slots: // UI pages void gotoOverviewPage(); From 622f1438dec6f2fc5565597ac1f88c3873549f33 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Wed, 15 Feb 2012 20:56:29 +0100 Subject: [PATCH 096/154] Bugfix: do not create CAddress for invalid accepts --- src/net.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/net.cpp b/src/net.cpp index 83e7f28c6bc..423b7543905 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -885,13 +885,17 @@ void ThreadSocketHandler2(void* parg) struct sockaddr_in sockaddr; socklen_t len = sizeof(sockaddr); SOCKET hSocket = accept(hListenSocket, (struct sockaddr*)&sockaddr, &len); - CAddress addr(sockaddr); + CAddress addr; int nInbound = 0; + if (hSocket != INVALID_SOCKET) + addr = CAddress(sockaddr); + CRITICAL_BLOCK(cs_vNodes) BOOST_FOREACH(CNode* pnode, vNodes) if (pnode->fInbound) nInbound++; + if (hSocket == INVALID_SOCKET) { if (WSAGetLastError() != WSAEWOULDBLOCK) From d52397b3c02330d17cde6952e8bbc1c492c06007 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Wed, 15 Feb 2012 21:17:15 +0100 Subject: [PATCH 097/154] Several shutdown-related fixes * do not let vnThreadsRunning[1] go negative * do not perform locking operations while vnThreadsRunning[1] is decreased * check vnThreadsRunning[1] at exit --- src/net.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/net.cpp b/src/net.cpp index 423b7543905..a8d3d0b171b 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1431,9 +1431,13 @@ void ThreadOpenConnections2(void* parg) int64 nStart = GetTime(); loop { - // Limit outbound connections vnThreadsRunning[1]--; Sleep(500); + vnThreadsRunning[1]++; + if (fShutdown) + return; + + // Limit outbound connections loop { int nOutbound = 0; @@ -1445,13 +1449,12 @@ void ThreadOpenConnections2(void* parg) nMaxOutboundConnections = min(nMaxOutboundConnections, (int)GetArg("-maxconnections", 125)); if (nOutbound < nMaxOutboundConnections) break; + vnThreadsRunning[1]--; Sleep(2000); + vnThreadsRunning[1]++; if (fShutdown) return; } - vnThreadsRunning[1]++; - if (fShutdown) - return; bool fAddSeeds = false; @@ -1845,7 +1848,7 @@ bool StopNode() fShutdown = true; nTransactionsUpdated++; int64 nStart = GetTime(); - while (vnThreadsRunning[0] > 0 || vnThreadsRunning[2] > 0 || vnThreadsRunning[3] > 0 || vnThreadsRunning[4] > 0 + while (vnThreadsRunning[0] > 0 || vnThreadsRunning[1] > 0 || vnThreadsRunning[2] > 0 || vnThreadsRunning[3] > 0 || vnThreadsRunning[4] > 0 #ifdef USE_UPNP || vnThreadsRunning[5] > 0 #endif From 6928794f56738c002fd1e129cb64ffad0533b64f Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Wed, 15 Feb 2012 16:05:55 -0500 Subject: [PATCH 098/154] Properly include $*_LIB_PATH in makefile.unix --- src/makefile.unix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/makefile.unix b/src/makefile.unix index 53948bcba68..e75dda514fa 100644 --- a/src/makefile.unix +++ b/src/makefile.unix @@ -7,7 +7,7 @@ USE_UPNP:=0 DEFS=-DNOPCH DEFS += $(addprefix -I,$(BOOST_INCLUDE_PATH) $(BDB_INCLUDE_PATH) $(OPENSSL_INCLUDE_PATH)) -LIBS += $(addprefix -l,$(BOOST_LIB_PATH) $(BDB_LIB_PATH) $(OPENSSL_LIB_PATH)) +LIBS = $(addprefix -L,$(BOOST_LIB_PATH) $(BDB_LIB_PATH) $(OPENSSL_LIB_PATH)) LMODE = dynamic LMODE2 = dynamic @@ -21,7 +21,7 @@ else endif # for boost 1.37, add -mt to the boost libraries -LIBS= \ +LIBS += \ -Wl,-B$(LMODE) \ -l boost_system$(BOOST_LIB_SUFFIX) \ -l boost_filesystem$(BOOST_LIB_SUFFIX) \ From 25be0597caebe00f5d47199404574d93d8f76995 Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Fri, 17 Feb 2012 14:46:06 +0100 Subject: [PATCH 099/154] don't allow -daemon in bitcoin-qt (changes only #defines) --- src/init.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index 51e9ed604ee..bb549ec42bb 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -209,7 +209,7 @@ bool AppInit2(int argc, char* argv[]) #ifdef GUI " -server \t\t " + _("Accept command line and JSON-RPC commands\n") + #endif -#ifndef WIN32 +#if !defined(WIN32) && !defined(GUI) " -daemon \t\t " + _("Run in the background as a daemon and accept commands\n") + #endif " -testnet \t\t " + _("Use the test network\n") + @@ -248,7 +248,7 @@ bool AppInit2(int argc, char* argv[]) fTestNet = GetBoolArg("-testnet"); fDebug = GetBoolArg("-debug"); -#ifndef WIN32 +#if !defined(WIN32) && !defined(GUI) fDaemon = GetBoolArg("-daemon"); #else fDaemon = false; @@ -279,7 +279,7 @@ bool AppInit2(int argc, char* argv[]) } #endif -#ifndef WIN32 +#if !defined(WIN32) && !defined(GUI) if (fDaemon) { // Daemonize From 43163a5a4d0fd3c849dbb2e7070b7ba4f7a70d27 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Sat, 11 Feb 2012 20:02:55 +0100 Subject: [PATCH 100/154] Macros for manual critical sections --- src/net.h | 6 +++--- src/util.h | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/net.h b/src/net.h index d8b90222769..53e13fd095e 100644 --- a/src/net.h +++ b/src/net.h @@ -277,7 +277,7 @@ public: void BeginMessage(const char* pszCommand) { - cs_vSend.Enter("cs_vSend", __FILE__, __LINE__); + ENTER_CRITICAL_SECTION(cs_vSend); if (nHeaderStart != -1) AbortMessage(); nHeaderStart = vSend.size(); @@ -296,7 +296,7 @@ public: vSend.resize(nHeaderStart); nHeaderStart = -1; nMessageStart = -1; - cs_vSend.Leave(); + LEAVE_CRITICAL_SECTION(cs_vSend); if (fDebug) printf("(aborted)\n"); @@ -334,7 +334,7 @@ public: nHeaderStart = -1; nMessageStart = -1; - cs_vSend.Leave(); + LEAVE_CRITICAL_SECTION(cs_vSend); } void EndMessageAbortIfEmpty() diff --git a/src/util.h b/src/util.h index a48979c0ef8..c4ee19fe01b 100644 --- a/src/util.h +++ b/src/util.h @@ -254,6 +254,12 @@ public: for (bool fcriticalblockonce=true; fcriticalblockonce; assert(("break caught by CRITICAL_BLOCK!" && !fcriticalblockonce)), fcriticalblockonce=false) \ for (CCriticalBlock criticalblock(cs, #cs, __FILE__, __LINE__); fcriticalblockonce; fcriticalblockonce=false) +#define ENTER_CRITICAL_SECTION(cs) \ + (cs).Enter(#cs, __FILE__, __LINE__) + +#define LEAVE_CRITICAL_SECTION(cs) \ + (cs).Leave() + class CTryCriticalBlock { protected: From 8960f2fc3353d5d7f8b9babd1aaef0e9869e39f4 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Sat, 11 Feb 2012 16:35:40 +0100 Subject: [PATCH 101/154] Fix wallet locking locking --- src/rpc.cpp | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/src/rpc.cpp b/src/rpc.cpp index 33108948d3c..5326cdc2b79 100644 --- a/src/rpc.cpp +++ b/src/rpc.cpp @@ -1279,33 +1279,31 @@ void ThreadCleanWalletPassphrase(void* parg) { int64 nMyWakeTime = GetTime() + *((int*)parg); + ENTER_CRITICAL_SECTION(cs_nWalletUnlockTime); + if (nWalletUnlockTime == 0) { - CRITICAL_BLOCK(cs_nWalletUnlockTime) - { - nWalletUnlockTime = nMyWakeTime; - } + nWalletUnlockTime = nMyWakeTime; while (GetTime() < nWalletUnlockTime) - Sleep(GetTime() - nWalletUnlockTime); - - CRITICAL_BLOCK(cs_nWalletUnlockTime) { - nWalletUnlockTime = 0; + int64 nToSleep = GetTime() - nWalletUnlockTime; + + LEAVE_CRITICAL_SECTION(cs_nWalletUnlockTime); + Sleep(nToSleep); + ENTER_CRITICAL_SECTION(cs_nWalletUnlockTime); } + + nWalletUnlockTime = 0; + pwalletMain->Lock(); } else { - CRITICAL_BLOCK(cs_nWalletUnlockTime) - { - if (nWalletUnlockTime < nMyWakeTime) - nWalletUnlockTime = nMyWakeTime; - } - delete (int*)parg; - return; + if (nWalletUnlockTime < nMyWakeTime) + nWalletUnlockTime = nMyWakeTime; } - pwalletMain->Lock(); + LEAVE_CRITICAL_SECTION(cs_nWalletUnlockTime); delete (int*)parg; } From 69ce70866d7498eb6efadca0cf57785c5cefd386 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Sat, 11 Feb 2012 18:01:24 +0100 Subject: [PATCH 102/154] Extra wallet locking fixes * Fix sign error in calculation of seconds to sleep * Do not mix GetTime() (seconds) and Sleep() (milliseconds) * Do not sleep forever if walletlock() is called * Do locking within critical section --- src/rpc.cpp | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/rpc.cpp b/src/rpc.cpp index 5326cdc2b79..da3384e398a 100644 --- a/src/rpc.cpp +++ b/src/rpc.cpp @@ -316,7 +316,7 @@ Value getinfo(const Array& params, bool fHelp) obj.push_back(Pair("keypoolsize", pwalletMain->GetKeyPoolSize())); obj.push_back(Pair("paytxfee", ValueFromAmount(nTransactionFee))); if (pwalletMain->IsCrypted()) - obj.push_back(Pair("unlocked_until", (boost::int64_t)nWalletUnlockTime)); + obj.push_back(Pair("unlocked_until", (boost::int64_t)nWalletUnlockTime / 1000)); obj.push_back(Pair("errors", GetWarnings("statusbar"))); return obj; } @@ -1277,7 +1277,7 @@ void ThreadTopUpKeyPool(void* parg) void ThreadCleanWalletPassphrase(void* parg) { - int64 nMyWakeTime = GetTime() + *((int*)parg); + int64 nMyWakeTime = GetTimeMillis() + *((int*)parg) * 1000; ENTER_CRITICAL_SECTION(cs_nWalletUnlockTime); @@ -1285,17 +1285,25 @@ void ThreadCleanWalletPassphrase(void* parg) { nWalletUnlockTime = nMyWakeTime; - while (GetTime() < nWalletUnlockTime) + do { - int64 nToSleep = GetTime() - nWalletUnlockTime; + if (nWalletUnlockTime==0) + break; + int64 nToSleep = nWalletUnlockTime - GetTimeMillis(); + if (nToSleep <= 0) + break; LEAVE_CRITICAL_SECTION(cs_nWalletUnlockTime); Sleep(nToSleep); ENTER_CRITICAL_SECTION(cs_nWalletUnlockTime); - } - nWalletUnlockTime = 0; - pwalletMain->Lock(); + } while(1); + + if (nWalletUnlockTime) + { + nWalletUnlockTime = 0; + pwalletMain->Lock(); + } } else { @@ -1408,9 +1416,9 @@ Value walletlock(const Array& params, bool fHelp) if (!pwalletMain->IsCrypted()) throw JSONRPCError(-15, "Error: running with an unencrypted wallet, but walletlock was called."); - pwalletMain->Lock(); CRITICAL_BLOCK(cs_nWalletUnlockTime) { + pwalletMain->Lock(); nWalletUnlockTime = 0; } From 82705af1eb521beefd63f81e3c5e39616fcf2076 Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Fri, 17 Feb 2012 18:00:41 +0100 Subject: [PATCH 103/154] Change #ifdef GUI to #ifdef QT_GUI, GUI is not defined anymore... --- src/init.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index bb549ec42bb..0d042f0cfbc 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -206,10 +206,10 @@ bool AppInit2(int argc, char* argv[]) #endif #endif " -paytxfee= \t " + _("Fee per kB to add to transactions you send\n") + -#ifdef GUI +#ifdef QT_GUI " -server \t\t " + _("Accept command line and JSON-RPC commands\n") + #endif -#if !defined(WIN32) && !defined(GUI) +#if !defined(WIN32) && !defined(QT_GUI) " -daemon \t\t " + _("Run in the background as a daemon and accept commands\n") + #endif " -testnet \t\t " + _("Use the test network\n") + @@ -248,7 +248,7 @@ bool AppInit2(int argc, char* argv[]) fTestNet = GetBoolArg("-testnet"); fDebug = GetBoolArg("-debug"); -#if !defined(WIN32) && !defined(GUI) +#if !defined(WIN32) && !defined(QT_GUI) fDaemon = GetBoolArg("-daemon"); #else fDaemon = false; @@ -279,7 +279,7 @@ bool AppInit2(int argc, char* argv[]) } #endif -#if !defined(WIN32) && !defined(GUI) +#if !defined(WIN32) && !defined(QT_GUI) if (fDaemon) { // Daemonize From 33e0c3a8662a11566cbb7bd382b7f6737f8c96a2 Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Fri, 17 Feb 2012 15:26:20 +0100 Subject: [PATCH 104/154] Restructure IPC URL handling (fixes #851) --- src/qt/guiutil.cpp | 14 ++++++++++++++ src/qt/guiutil.h | 1 + src/qt/sendcoinsdialog.cpp | 10 ++++++++++ src/qt/sendcoinsdialog.h | 1 + 4 files changed, 26 insertions(+) diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp index 158b84a285d..bc443ceeb65 100644 --- a/src/qt/guiutil.cpp +++ b/src/qt/guiutil.cpp @@ -72,3 +72,17 @@ bool GUIUtil::parseBitcoinURL(const QUrl *url, SendCoinsRecipient *out) } return true; } + +bool GUIUtil::parseBitcoinURL(QString url, SendCoinsRecipient *out) +{ + // Convert bitcoin:// to bitcoin: + // + // Cannot handle this later, because bitcoin:// will cause Qt to see the part after // as host, + // which will lowercase it (and thus invalidate the address). + if(url.startsWith("bitcoin://")) + { + url.replace(0, 10, "bitcoin:"); + } + QUrl urlInstance(url); + return parseBitcoinURL(&urlInstance, out); +} diff --git a/src/qt/guiutil.h b/src/qt/guiutil.h index bc4ddb8aaeb..129ab730384 100644 --- a/src/qt/guiutil.h +++ b/src/qt/guiutil.h @@ -29,6 +29,7 @@ public: // Parse "bitcoin:" URL into recipient object, return true on succesful parsing // See Bitcoin URL definition discussion here: https://bitcointalk.org/index.php?topic=33490.0 static bool parseBitcoinURL(const QUrl *url, SendCoinsRecipient *out); + static bool parseBitcoinURL(QString url, SendCoinsRecipient *out); }; #endif // GUIUTIL_H diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp index 6d32891172f..e465b4141a4 100644 --- a/src/qt/sendcoinsdialog.cpp +++ b/src/qt/sendcoinsdialog.cpp @@ -265,6 +265,16 @@ void SendCoinsDialog::handleURL(const QUrl *url) pasteEntry(rv); } +void SendCoinsDialog::handleURL(const QString &url) +{ + SendCoinsRecipient rv; + if(!GUIUtil::parseBitcoinURL(url, &rv)) + { + return; + } + pasteEntry(rv); +} + void SendCoinsDialog::setBalance(qint64 balance, qint64 unconfirmedBalance) { Q_UNUSED(unconfirmedBalance); diff --git a/src/qt/sendcoinsdialog.h b/src/qt/sendcoinsdialog.h index a14f99e8b2f..fdff05783eb 100644 --- a/src/qt/sendcoinsdialog.h +++ b/src/qt/sendcoinsdialog.h @@ -30,6 +30,7 @@ public: void pasteEntry(const SendCoinsRecipient &rv); void handleURL(const QUrl *url); + void handleURL(const QString &url); public slots: void clear(); From caad1add4f383960ca09bb466ddd16652245befe Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Sat, 18 Feb 2012 15:36:40 +0100 Subject: [PATCH 105/154] Free pwalletdbEncryption after encryping wallet Fixes a memory leak. --- src/wallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet.cpp b/src/wallet.cpp index 43fb6b6da39..9f7422d1fbc 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -183,7 +183,7 @@ bool CWallet::EncryptWallet(const string& strWalletPassphrase) if (!pwalletdbEncryption->TxnCommit()) exit(1); //We now have keys encrypted in memory, but no on disk...die to avoid confusion and let the user reload their unencrypted wallet. - pwalletdbEncryption->Close(); + delete pwalletdbEncryption; pwalletdbEncryption = NULL; } From 471e0bdc7cc79a993230672dadbd193218b6103c Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Sun, 19 Feb 2012 18:44:51 +0100 Subject: [PATCH 106/154] Fix #650: CKey::SetSecret BIGNUM leak --- src/key.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/key.h b/src/key.h index 8b033a029f0..89d82fc8036 100644 --- a/src/key.h +++ b/src/key.h @@ -153,10 +153,13 @@ public: if (vchSecret.size() != 32) throw key_error("CKey::SetSecret() : secret must be 32 bytes"); BIGNUM *bn = BN_bin2bn(&vchSecret[0],32,BN_new()); - if (bn == NULL) + if (bn == NULL) throw key_error("CKey::SetSecret() : BN_bin2bn failed"); if (!EC_KEY_regenerate_key(pkey,bn)) + { + BN_clear_free(bn); throw key_error("CKey::SetSecret() : EC_KEY_regenerate_key failed"); + } BN_clear_free(bn); fSet = true; return true; From b085138f89e93eac900a863e0d1aa14472aa32d3 Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Fri, 17 Feb 2012 18:25:14 +0100 Subject: [PATCH 107/154] Only fill in label from address book, if no label is filled in yet, fixes #840 --- src/qt/sendcoinsentry.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/qt/sendcoinsentry.cpp b/src/qt/sendcoinsentry.cpp index ab5460f8c2c..d98400c2608 100644 --- a/src/qt/sendcoinsentry.cpp +++ b/src/qt/sendcoinsentry.cpp @@ -59,8 +59,9 @@ void SendCoinsEntry::on_payTo_textChanged(const QString &address) { if(!model) return; - ui->addAsLabel->setText(model->getAddressTableModel()->labelForAddress(address)); -} + // Fill in label from address book, if no label is filled in yet + if(ui->addAsLabel->text().isEmpty()) + ui->addAsLabel->setText(model->getAddressTableModel()->labelForAddress(address));} void SendCoinsEntry::setModel(WalletModel *model) { From 001a64c71cb7f4090e953f49c32a6258e0d58767 Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Fri, 17 Feb 2012 17:53:41 +0100 Subject: [PATCH 108/154] On windows, show message box with help, as there is no stderr (fixes #702) (partial) --- src/init.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/init.cpp b/src/init.cpp index 0d042f0cfbc..c8141f2c911 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -241,7 +241,12 @@ bool AppInit2(int argc, char* argv[]) // Remove tabs strUsage.erase(std::remove(strUsage.begin(), strUsage.end(), '\t'), strUsage.end()); +#if defined(QT_GUI) && defined(WIN32) + // On windows, show a message box, as there is no stderr + wxMessageBox(strUsage, "Usage"); +#else fprintf(stderr, "%s", strUsage.c_str()); +#endif return false; } From 54fee2d0ce1e4b389700cd9d043f9475d567cc25 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Sun, 19 Feb 2012 19:05:41 +0100 Subject: [PATCH 109/154] Fix #626: RecvLine wrong error message --- src/irc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/irc.cpp b/src/irc.cpp index b632b965461..5dfab06bacd 100644 --- a/src/irc.cpp +++ b/src/irc.cpp @@ -110,14 +110,14 @@ bool RecvLine(SOCKET hSocket, string& strLine) if (nBytes == 0) { // socket closed - printf("IRC socket closed\n"); + printf("socket closed\n"); return false; } else { // socket error int nErr = WSAGetLastError(); - printf("IRC recv failed: %d\n", nErr); + printf("recv failed: %d\n", nErr); return false; } } From ab2be34059126d2eff11dd2bd20d740aea33f67d Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Sun, 19 Feb 2012 19:12:41 +0100 Subject: [PATCH 110/154] Fix #616: remove base_uint::operator&=(uint64 b) --- src/uint256.h | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/uint256.h b/src/uint256.h index 3e20201387b..ae263346a86 100644 --- a/src/uint256.h +++ b/src/uint256.h @@ -100,13 +100,6 @@ public: return *this; } - base_uint& operator&=(uint64 b) - { - pn[0] &= (unsigned int)b; - pn[1] &= (unsigned int)(b >> 32); - return *this; - } - base_uint& operator|=(uint64 b) { pn[0] |= (unsigned int)b; From 1be5779124680ad6f411377f0a052f691855d2ec Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Mon, 20 Feb 2012 22:35:08 +0100 Subject: [PATCH 111/154] ProcessBlock is sometimes called with pfrom==NULL --- src/main.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 1f8abc04a25..e94c872fbe3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1406,7 +1406,8 @@ bool ProcessBlock(CNode* pfrom, CBlock* pblock) int64 deltaTime = pblock->GetBlockTime() - pcheckpoint->nTime; if (deltaTime < 0) { - pfrom->Misbehaving(100); + if (pfrom) + pfrom->Misbehaving(100); return error("ProcessBlock() : block with timestamp before last checkpoint"); } CBigNum bnNewBlock; @@ -1415,7 +1416,8 @@ bool ProcessBlock(CNode* pfrom, CBlock* pblock) bnRequired.SetCompact(ComputeMinWork(pcheckpoint->nBits, deltaTime)); if (bnNewBlock > bnRequired) { - pfrom->Misbehaving(100); + if (pfrom) + pfrom->Misbehaving(100); return error("ProcessBlock() : block with too little proof-of-work"); } } From feb3c15335d5279931c1e0f713400fb616459d0b Mon Sep 17 00:00:00 2001 From: Gavin Andresen Date: Thu, 23 Feb 2012 13:33:30 -0500 Subject: [PATCH 112/154] Checkpoint block 168,000 --- src/checkpoints.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/checkpoints.cpp b/src/checkpoints.cpp index f78712ef4ba..f5ce053870f 100644 --- a/src/checkpoints.cpp +++ b/src/checkpoints.cpp @@ -30,6 +30,7 @@ namespace Checkpoints (118000, uint256("0x000000000000774a7f8a7a12dc906ddb9e17e75d684f15e00f8767f9e8f36553")) (134444, uint256("0x00000000000005b12ffd4cd315cd34ffd4a594f430ac814c91184a0d42d2b0fe")) (140700, uint256("0x000000000000033b512028abb90e1626d8b346fd0ed598ac0a3c371138dce2bd")) + (168000, uint256("0x000000000000099e61ea72015e79632f216fe6cb33d7899acb35b75c8303b763")) ; bool CheckBlock(int nHeight, const uint256& hash) From 0b11082d361ec08bca5025dbbc7f0b78c0fb8e13 Mon Sep 17 00:00:00 2001 From: Chris Moore Date: Fri, 24 Feb 2012 18:54:18 -0800 Subject: [PATCH 113/154] Don't show splash screen when -min is specified on the command line. --- src/qt/bitcoin.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp index 2142db5a364..54e6bb34c20 100644 --- a/src/qt/bitcoin.cpp +++ b/src/qt/bitcoin.cpp @@ -147,9 +147,12 @@ int main(int argc, char *argv[]) app.setApplicationName(QApplication::translate("main", "Bitcoin-Qt")); QSplashScreen splash(QPixmap(":/images/splash"), 0); - splash.show(); - splash.setAutoFillBackground(true); - splashref = &splash; + if (!GetBoolArg("-min")) + { + splash.show(); + splash.setAutoFillBackground(true); + splashref = &splash; + } app.processEvents(); @@ -163,7 +166,8 @@ int main(int argc, char *argv[]) // Put this in a block, so that BitcoinGUI is cleaned up properly before // calling Shutdown(). BitcoinGUI window; - splash.finish(&window); + if (splashref) + splash.finish(&window); OptionsModel optionsModel(pwalletMain); ClientModel clientModel(&optionsModel); WalletModel walletModel(pwalletMain, &optionsModel); From ef48e9b7dfde66368c27ed34f5f42de1b8e781f9 Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Sat, 25 Feb 2012 19:07:53 +0100 Subject: [PATCH 114/154] In UI, handle cases in which the last received block was generated in the future (secs<0) Fixes #874. --- src/qt/bitcoingui.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index cfcff136e0a..3c9a773f4e9 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -470,7 +470,11 @@ void BitcoinGUI::setNumBlocks(int count) QString text; // Represent time from last generated block in human readable text - if(secs < 60) + if(secs <= 0) + { + // Fully up to date. Leave text empty. + } + else if(secs < 60) { text = tr("%n second(s) ago","",secs); } @@ -490,7 +494,7 @@ void BitcoinGUI::setNumBlocks(int count) // Set icon state: spinning if catching up, tick otherwise if(secs < 30*60) { - tooltip = tr("Up to date") + QString("\n") + tooltip; + tooltip = tr("Up to date") + QString(".\n") + tooltip; labelBlocksIcon->setPixmap(QIcon(":/icons/synced").pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE)); } else @@ -500,8 +504,11 @@ void BitcoinGUI::setNumBlocks(int count) syncIconMovie->start(); } - tooltip += QString("\n"); - tooltip += tr("Last received block was generated %1.").arg(text); + if(!text.isEmpty()) + { + tooltip += QString("\n"); + tooltip += tr("Last received block was generated %1.").arg(text); + } labelBlocksIcon->setToolTip(tooltip); progressBarLabel->setToolTip(tooltip); From 3108aed0f210fe6cb698237c7eeac8715fb95e31 Mon Sep 17 00:00:00 2001 From: Gavin Andresen Date: Wed, 29 Feb 2012 10:14:18 -0500 Subject: [PATCH 115/154] DoS fix for mapOrphanTransactions --- src/main.cpp | 25 ++++++++++++++++++++++++- src/main.h | 1 + 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 9f12829042b..8b11c2bbf06 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -159,13 +159,14 @@ void static ResendWalletTransactions() // mapOrphanTransactions // -void static AddOrphanTx(const CDataStream& vMsg) +void AddOrphanTx(const CDataStream& vMsg) { CTransaction tx; CDataStream(vMsg) >> tx; uint256 hash = tx.GetHash(); if (mapOrphanTransactions.count(hash)) return; + CDataStream* pvMsg = mapOrphanTransactions[hash] = new CDataStream(vMsg); BOOST_FOREACH(const CTxIn& txin, tx.vin) mapOrphanTransactionsByPrev.insert(make_pair(txin.prevout.hash, pvMsg)); @@ -193,6 +194,23 @@ void static EraseOrphanTx(uint256 hash) mapOrphanTransactions.erase(hash); } +int LimitOrphanTxSize(int nMaxOrphans) +{ + int nEvicted = 0; + while (mapOrphanTransactions.size() > nMaxOrphans) + { + // Evict a random orphan: + std::vector randbytes(32); + RAND_bytes(&randbytes[0], 32); + uint256 randomhash(randbytes); + map::iterator it = mapOrphanTransactions.lower_bound(randomhash); + if (it == mapOrphanTransactions.end()) + it = mapOrphanTransactions.begin(); + EraseOrphanTx(it->first); + ++nEvicted; + } + return nEvicted; +} @@ -2183,6 +2201,11 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) { printf("storing orphan tx %s\n", inv.hash.ToString().substr(0,10).c_str()); AddOrphanTx(vMsg); + + // DoS prevention: do not allow mapOrphanTransactions to grow unbounded + int nEvicted = LimitOrphanTxSize(MAX_ORPHAN_TRANSACTIONS); + if (nEvicted > 0) + printf("mapOrphan overflow, removed %d tx\n", nEvicted); } } diff --git a/src/main.h b/src/main.h index 25cf0790134..3e381b060b2 100644 --- a/src/main.h +++ b/src/main.h @@ -30,6 +30,7 @@ class CBlockIndex; static const unsigned int MAX_BLOCK_SIZE = 1000000; static const unsigned int MAX_BLOCK_SIZE_GEN = MAX_BLOCK_SIZE/2; static const int MAX_BLOCK_SIGOPS = MAX_BLOCK_SIZE/50; +static const int MAX_ORPHAN_TRANSACTIONS = MAX_BLOCK_SIZE/100; static const int64 COIN = 100000000; static const int64 CENT = 1000000; static const int64 MIN_TX_FEE = 50000; From d7962747c4bfe90f9991d121fd22ac625ae2de30 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Fri, 17 Feb 2012 17:58:02 +0100 Subject: [PATCH 116/154] Do not allow overwriting unspent transactions (BIP 30) Introduce the following network rule: * a block is not valid if it contains a transaction whose hash already exists in the block chain, unless all that transaction's outputs were already spent before said block. Warning: this is effectively a network rule change, with potential risk for forking the block chain. Leaving this unfixed carries the same risk however, for attackers that can cause a reorganisation in part of the network. Thanks to Russell O'Connor and Ben Reeves. --- src/main.cpp | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 6a3bacc78e9..812a55110ff 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -792,8 +792,10 @@ bool CTransaction::DisconnectInputs(CTxDB& txdb) } // Remove transaction from index - if (!txdb.EraseTxIndex(*this)) - return error("DisconnectInputs() : EraseTxPos failed"); + // This can fail if a duplicate of this transaction was in a chain that got + // reorganized away. This is only possible if this transaction was completely + // spent, so erasing it would be a no-op anway. + txdb.EraseTxIndex(*this); return true; } @@ -982,6 +984,26 @@ bool CBlock::ConnectBlock(CTxDB& txdb, CBlockIndex* pindex) if (!CheckBlock()) return false; + // Do not allow blocks that contain transactions which 'overwrite' older transactions, + // unless those are already completely spent. + // If such overwrites are allowed, coinbases and transactions depending upon those + // can be duplicated to remove the ability to spend the first instance -- even after + // being sent to another address. + // See BIP30 and http://r6.ca/blog/20120206T005236Z.html for more information. + // This logic is not necessary for memory pool transactions, as AcceptToMemoryPool + // already refuses previously-known transaction id's entirely. + // This rule applies to all blocks whose timestamp is after March 15, 2012, 0:00 UTC. + // On testnet it is enabled as of februari 20, 2012, 0:00 UTC. + if (pindex->nTime > 1331769600 || (fTestNet && pindex->nTime > 1329696000)) + BOOST_FOREACH(CTransaction& tx, vtx) + { + CTxIndex txindexOld; + if (txdb.ReadTxIndex(tx.GetHash(), txindexOld)) + BOOST_FOREACH(CDiskTxPos &pos, txindexOld.vSpent) + if (pos.IsNull()) + return false; + } + //// issue here: it doesn't know the version unsigned int nTxPos = pindex->nBlockPos + ::GetSerializeSize(CBlock(), SER_DISK) - 1 + GetSizeOfCompactSize(vtx.size()); From 4fc8c042a2f80ce0a1a277a2dcc1240c015ed400 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Sat, 3 Mar 2012 13:44:42 -0500 Subject: [PATCH 117/154] Bugfix: Check return value of SHGetSpecialFolderPath in MyGetSpecialFolderPath Upstream commit: 21ae37d (partial) --- src/util.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/util.cpp b/src/util.cpp index 85ca02f0aae..e2e104cc88b 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -643,13 +643,17 @@ string MyGetSpecialFolderPath(int nFolder, bool fCreate) { PSHGETSPECIALFOLDERPATHA pSHGetSpecialFolderPath = (PSHGETSPECIALFOLDERPATHA)GetProcAddress(hShell32, "SHGetSpecialFolderPathA"); + bool fSuccess = false; if (pSHGetSpecialFolderPath) + fSuccess = (*pSHGetSpecialFolderPath)(NULL, pszPath, nFolder, fCreate); FreeModule(hShell32); + if (fSuccess) + return pszPath; } // Backup option - if (pszPath[0] == '\0') + pszPath[0] = '\0'; { if (nFolder == CSIDL_STARTUP) { From 88aa771536014919e955c4f7b2cada9a0dcf8561 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Sat, 3 Mar 2012 13:51:10 -0500 Subject: [PATCH 118/154] Bugfix: Fix possible buffer overflow (#901) Upstream commit: 21ae37d (partial) --- src/util.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/util.cpp b/src/util.cpp index e2e104cc88b..0f496bc455a 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -653,20 +653,25 @@ string MyGetSpecialFolderPath(int nFolder, bool fCreate) } // Backup option - pszPath[0] = '\0'; + std::string strPath; { + const char *pszEnv; if (nFolder == CSIDL_STARTUP) { - strcpy(pszPath, getenv("USERPROFILE")); - strcat(pszPath, "\\Start Menu\\Programs\\Startup"); + pszEnv = getenv("USERPROFILE"); + if (pszEnv) + strPath = pszEnv; + strPath += "\\Start Menu\\Programs\\Startup"; } else if (nFolder == CSIDL_APPDATA) { - strcpy(pszPath, getenv("APPDATA")); + pszEnv = getenv("APPDATA"); + if (pszEnv) + strPath = pszEnv; } } - return pszPath; + return strPath; } #endif From b3b4b008e39ed77e5c579fa0ca179fe785ee5e79 Mon Sep 17 00:00:00 2001 From: nomnombtc Date: Mon, 5 Mar 2012 19:33:24 +0100 Subject: [PATCH 119/154] fix typo src/net.cpp --- src/net.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/net.cpp b/src/net.cpp index b314405efc7..f37c675ff9f 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -953,7 +953,7 @@ void ThreadSocketHandler2(void* parg) } else if (CNode::IsBanned(addr.ip)) { - printf("connetion from %s dropped (banned)\n", addr.ToString().c_str()); + printf("connection from %s dropped (banned)\n", addr.ToString().c_str()); closesocket(hSocket); } else From 11c34e0f6cf9cb2715c28b85a1ec8f47bf5ca8dd Mon Sep 17 00:00:00 2001 From: Gregory Maxwell Date: Sat, 10 Mar 2012 16:05:28 -0500 Subject: [PATCH 120/154] Resolves issue #922 - "wallet passphrase timeout of several years doesn't work" 2^31 milliseconds is only about 25 days. Also clamps Sleep() to 10 years, because it currently sleeps for 0 seconds when the sleep time would cross 2^31 seconds since the epoch. Hopefully boost will be fixed by 2028. --- src/rpc.cpp | 6 +++--- src/util.h | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/rpc.cpp b/src/rpc.cpp index da3384e398a..8967b2c9968 100644 --- a/src/rpc.cpp +++ b/src/rpc.cpp @@ -1277,7 +1277,7 @@ void ThreadTopUpKeyPool(void* parg) void ThreadCleanWalletPassphrase(void* parg) { - int64 nMyWakeTime = GetTimeMillis() + *((int*)parg) * 1000; + int64 nMyWakeTime = GetTimeMillis() + *((int64*)parg) * 1000; ENTER_CRITICAL_SECTION(cs_nWalletUnlockTime); @@ -1313,7 +1313,7 @@ void ThreadCleanWalletPassphrase(void* parg) LEAVE_CRITICAL_SECTION(cs_nWalletUnlockTime); - delete (int*)parg; + delete (int64*)parg; } Value walletpassphrase(const Array& params, bool fHelp) @@ -1353,7 +1353,7 @@ Value walletpassphrase(const Array& params, bool fHelp) "Stores the wallet decryption key in memory for seconds."); CreateThread(ThreadTopUpKeyPool, NULL); - int* pnSleepTime = new int(params[1].get_int()); + int64* pnSleepTime = new int64(params[1].get_int64()); CreateThread(ThreadCleanWalletPassphrase, pnSleepTime); return Value::null; diff --git a/src/util.h b/src/util.h index c4ee19fe01b..4e4cbb9f602 100644 --- a/src/util.h +++ b/src/util.h @@ -115,7 +115,9 @@ typedef u_int SOCKET; #define Beep(n1,n2) (0) inline void Sleep(int64 n) { - boost::thread::sleep(boost::get_system_time() + boost::posix_time::milliseconds(n)); + /*Boost has a year 2038 problem— if the request sleep time is past epoch+2^31 seconds the sleep returns instantly. + So we clamp our sleeps here to 10 years and hope that boost is fixed by 2028.*/ + boost::thread::sleep(boost::get_system_time() + boost::posix_time::milliseconds(n>315576000000LL?315576000000LL:n)); } #endif From 4986c35d74afd6fc313d7637eb0220f3df500009 Mon Sep 17 00:00:00 2001 From: Gavin Andresen Date: Mon, 19 Dec 2011 19:04:47 -0500 Subject: [PATCH 121/154] Code cleanup: use ECDSA_size() instead of fixed 10,000 byte sig buffer, and explicity init static var --- src/key.h | 13 +++++++------ src/main.cpp | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/key.h b/src/key.h index 89d82fc8036..477f550bcf4 100644 --- a/src/key.h +++ b/src/key.h @@ -214,13 +214,14 @@ public: bool Sign(uint256 hash, std::vector& vchSig) { - vchSig.clear(); - unsigned char pchSig[10000]; - unsigned int nSize = 0; - if (!ECDSA_sign(0, (unsigned char*)&hash, sizeof(hash), pchSig, &nSize, pkey)) + unsigned int nSize = ECDSA_size(pkey); + vchSig.resize(nSize); // Make sure it is big enough + if (!ECDSA_sign(0, (unsigned char*)&hash, sizeof(hash), &vchSig[0], &nSize, pkey)) + { + vchSig.clear(); return false; - vchSig.resize(nSize); - memcpy(&vchSig[0], pchSig, nSize); + } + vchSig.resize(nSize); // Shrink to fit actual size return true; } diff --git a/src/main.cpp b/src/main.cpp index 652d4c1f981..cd02652660a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1921,7 +1921,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) } // Ask the first connected node for block updates - static int nAskedForBlocks; + static int nAskedForBlocks = 0; if (!pfrom->fClient && (pfrom->nVersion < 32000 || pfrom->nVersion >= 32400) && (nAskedForBlocks < 1 || vNodes.size() <= 1)) From 76a3bfa17c65481088df5713c0619f67cd856a83 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Thu, 15 Mar 2012 22:55:12 -0400 Subject: [PATCH 122/154] Fix Win32 RPC Crashes. --- bitcoin-qt.pro | 4 ++-- contrib/gitian-descriptors/qt-win32.yml | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/bitcoin-qt.pro b/bitcoin-qt.pro index 790c0751ca0..7fcb5079adb 100644 --- a/bitcoin-qt.pro +++ b/bitcoin-qt.pro @@ -251,8 +251,8 @@ isEmpty(BOOST_INCLUDE_PATH) { macx:BOOST_INCLUDE_PATH = /opt/local/include } -windows:LIBS += -lws2_32 -windows:DEFINES += WIN32 +windows:LIBS += -lmingwthrd -lws2_32 +windows:DEFINES += _MT WIN32 windows:RC_FILE = src/qt/res/bitcoin-qt.rc macx:HEADERS += src/qt/macdockiconhandler.h diff --git a/contrib/gitian-descriptors/qt-win32.yml b/contrib/gitian-descriptors/qt-win32.yml index 6eb76b21707..adccebbb918 100644 --- a/contrib/gitian-descriptors/qt-win32.yml +++ b/contrib/gitian-descriptors/qt-win32.yml @@ -47,6 +47,7 @@ script: | cp -a bin $SRCDIR/ cd $INSTDIR find . -name *.prl | xargs -l sed 's|/$||' -i + sed 's/QMAKE_LIBS_QT_ENTRY = -lmingw32 -lqtmain/QMAKE_LIBS_QT_ENTRY = -lqtmain/' -i mkspecs/unsupported/win32-g++-cross/qmake.conf #sed 's|QMAKE_PRL_LIBS.*|QMAKE_PRL_LIBS = -lQtDeclarative -lQtScript -lQtSvg -lQtSql -lQtXmlPatterns -lQtGui -lgdi32 -lcomdlg32 -loleaut32 -limm32 -lwinmm -lwinspool -lmsimg32 -lQtNetwork -lQtCore -lole32 -luuid -lws2_32 -ladvapi32 -lshell32 -luser32 -lkernel32|' -i imports/Qt/labs/particles/qmlparticlesplugin.prl # as zip stores file timestamps, use faketime to intercept stat calls to set dates for all files to reference date From ffef16404d16678d54e767dda6c301ad51fb82a7 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Fri, 16 Mar 2012 16:04:26 -0400 Subject: [PATCH 123/154] Bump version to 0.4.5 --- 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 bef67460c88..b34827e3ca8 100644 --- a/contrib/Bitcoin.app/Contents/Info.plist +++ b/contrib/Bitcoin.app/Contents/Info.plist @@ -17,7 +17,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 0.4.4 + 0.4.5 CFBundleSignature ???? CFBundleVersion diff --git a/doc/README b/doc/README index 197f03dd56b..e572b2dd530 100644 --- a/doc/README +++ b/doc/README @@ -1,4 +1,4 @@ -Bitcoin 0.4.4 BETA +Bitcoin 0.4.5 BETA Copyright (c) 2009-2012 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 ad357130c27..6a551a0b971 100644 --- a/doc/README_windows.txt +++ b/doc/README_windows.txt @@ -1,4 +1,4 @@ -Bitcoin 0.4.4 BETA +Bitcoin 0.4.5 BETA Copyright (c) 2009-2012 Bitcoin Developers Distributed under the MIT/X11 software license, see the accompanying diff --git a/share/setup.nsi b/share/setup.nsi index 05983117909..643b0ffef8b 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.4 +!define VERSION 0.4.5 !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.4-win32-setup.exe +OutFile bitcoin-0.4.5-win32-setup.exe InstallDir $PROGRAMFILES\Bitcoin CRCCheck on XPStyle on BrandingText " " ShowInstDetails show -VIProductVersion 0.4.4.0 +VIProductVersion 0.4.5.0 VIAddVersionKey ProductName Bitcoin VIAddVersionKey ProductVersion "${VERSION}" VIAddVersionKey CompanyName "${COMPANY}" diff --git a/src/serialize.h b/src/serialize.h index 2bc3a071d77..491169ff58b 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 = 40400; +static const int VERSION = 40500; static const char* pszSubVer = ""; static const bool VERSION_IS_BETA = true; From f322aa4d600f64eea8395811900dc98d562f1dac Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Fri, 16 Mar 2012 16:11:11 -0400 Subject: [PATCH 124/154] Bump version to 0.5.0.5 --- 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 7fcb5079adb..64b9670bfde 100644 --- a/bitcoin-qt.pro +++ b/bitcoin-qt.pro @@ -1,6 +1,6 @@ TEMPLATE = app TARGET = -VERSION = 0.5.0.4 +VERSION = 0.5.0.5 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 6af11c3497e..9b3c561cbe1 100644 --- a/doc/README +++ b/doc/README @@ -1,4 +1,4 @@ -Bitcoin 0.5.0.4 BETA +Bitcoin 0.5.0.5 BETA Copyright (c) 2009-2012 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 25cb0692665..c23b0ea84d5 100644 --- a/doc/README_windows.txt +++ b/doc/README_windows.txt @@ -1,4 +1,4 @@ -Bitcoin 0.5.0.4 BETA +Bitcoin 0.5.0.5 BETA Copyright (c) 2009-2012 Bitcoin Developers Distributed under the MIT/X11 software license, see the accompanying diff --git a/share/setup.nsi b/share/setup.nsi index 76ae81762db..4f764153e18 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.4 +!define VERSION 0.5.0.5 !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.4-win32-setup.exe +OutFile bitcoin-0.5.0.5-win32-setup.exe InstallDir $PROGRAMFILES\Bitcoin CRCCheck on XPStyle on BrandingText " " ShowInstDetails show -VIProductVersion 0.5.0.4 +VIProductVersion 0.5.0.5 VIAddVersionKey ProductName Bitcoin VIAddVersionKey ProductVersion "${VERSION}" VIAddVersionKey CompanyName "${COMPANY}" diff --git a/src/serialize.h b/src/serialize.h index f5772024434..f10f933b163 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 = 50004; +static const int VERSION = 50005; static const char* pszSubVer = ""; static const bool VERSION_IS_BETA = true; From 7f23df06d7126e32bb2b80df355855bc9c8b242a Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Fri, 16 Mar 2012 16:12:16 -0400 Subject: [PATCH 125/154] Bump version to 0.5.4 --- 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 34ce109fe2c..ea9b52acf80 100644 --- a/bitcoin-qt.pro +++ b/bitcoin-qt.pro @@ -1,6 +1,6 @@ TEMPLATE = app TARGET = -VERSION = 0.5.3 +VERSION = 0.5.4 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 13238149321..3d8c63a3e1a 100644 --- a/doc/README +++ b/doc/README @@ -1,4 +1,4 @@ -Bitcoin 0.5.3 BETA +Bitcoin 0.5.4 BETA Copyright (c) 2009-2012 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 f52c1d17997..b4ad595419d 100644 --- a/doc/README_windows.txt +++ b/doc/README_windows.txt @@ -1,4 +1,4 @@ -Bitcoin 0.5.3 BETA +Bitcoin 0.5.4 BETA Copyright (c) 2009-2012 Bitcoin Developers Distributed under the MIT/X11 software license, see the accompanying diff --git a/share/setup.nsi b/share/setup.nsi index 12a1a532daa..38f0a3a00a4 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.3 +!define VERSION 0.5.4 !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.3-win32-setup.exe +OutFile bitcoin-0.5.4-win32-setup.exe InstallDir $PROGRAMFILES\Bitcoin CRCCheck on XPStyle on BrandingText " " ShowInstDetails show -VIProductVersion 0.5.3.0 +VIProductVersion 0.5.4.0 VIAddVersionKey ProductName Bitcoin VIAddVersionKey ProductVersion "${VERSION}" VIAddVersionKey CompanyName "${COMPANY}" diff --git a/src/serialize.h b/src/serialize.h index 71f24f81d5b..396e1727eb6 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 = 50300; +static const int VERSION = 50400; static const char* pszSubVer = ""; static const bool VERSION_IS_BETA = true; From 458b6e64368b06f8951e2fe5849272c11923dca8 Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Wed, 15 Feb 2012 14:47:08 +0100 Subject: [PATCH 126/154] fix default suffixes in save dialog in GNOME, make it more clear that PNG is used (solves #833) --- src/qt/addressbookpage.cpp | 6 ++--- src/qt/guiutil.cpp | 49 ++++++++++++++++++++++++++++++++++++++ src/qt/guiutil.h | 15 ++++++++++++ src/qt/transactionview.cpp | 6 ++--- 4 files changed, 68 insertions(+), 8 deletions(-) diff --git a/src/qt/addressbookpage.cpp b/src/qt/addressbookpage.cpp index 0a147c9e104..76061233fc8 100644 --- a/src/qt/addressbookpage.cpp +++ b/src/qt/addressbookpage.cpp @@ -7,7 +7,6 @@ #include #include -#include #include AddressBookPage::AddressBookPage(Mode mode, Tabs tab, QWidget *parent) : @@ -206,10 +205,9 @@ void AddressBookPage::done(int retval) void AddressBookPage::exportClicked() { // CSV is currently the only supported format - QString filename = QFileDialog::getSaveFileName( + QString filename = GUIUtil::getSaveFileName( this, - tr("Export Address Book Data"), - QDir::currentPath(), + tr("Export Address Book Data"), QString(), tr("Comma separated file (*.csv)")); if (filename.isNull()) return; diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp index bc443ceeb65..d1490c8f705 100644 --- a/src/qt/guiutil.cpp +++ b/src/qt/guiutil.cpp @@ -11,6 +11,8 @@ #include #include #include +#include +#include QString GUIUtil::dateTimeStr(qint64 nTime) { @@ -86,3 +88,50 @@ bool GUIUtil::parseBitcoinURL(QString url, SendCoinsRecipient *out) QUrl urlInstance(url); return parseBitcoinURL(&urlInstance, out); } + +QString GUIUtil::getSaveFileName(QWidget *parent, const QString &caption, + const QString &dir, + const QString &filter, + QString *selectedSuffixOut) +{ + QString selectedFilter; + QString myDir; + if(dir.isEmpty()) // Default to user documents location + { + myDir = QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation); + } + else + { + myDir = dir; + } + QString result = QFileDialog::getSaveFileName(parent, caption, myDir, filter, &selectedFilter); + + /* Extract first suffix from filter pattern "Description (*.foo)" or "Description (*.foo *.bar ...) */ + QRegExp filter_re(".* \\(\\*\\.(.*)[ \\)]"); + QString selectedSuffix; + if(filter_re.exactMatch(selectedFilter)) + { + selectedSuffix = filter_re.cap(1); + } + + /* Add suffix if needed */ + QFileInfo info(result); + if(!result.isEmpty()) + { + if(info.suffix().isEmpty() && !selectedSuffix.isEmpty()) + { + /* No suffix specified, add selected suffix */ + if(!result.endsWith(".")) + result.append("."); + result.append(selectedSuffix); + } + } + + /* Return selected suffix if asked to */ + if(selectedSuffixOut) + { + *selectedSuffixOut = selectedSuffix; + } + return result; +} + diff --git a/src/qt/guiutil.h b/src/qt/guiutil.h index 129ab730384..d7523aa15c9 100644 --- a/src/qt/guiutil.h +++ b/src/qt/guiutil.h @@ -30,6 +30,21 @@ public: // See Bitcoin URL definition discussion here: https://bitcointalk.org/index.php?topic=33490.0 static bool parseBitcoinURL(const QUrl *url, SendCoinsRecipient *out); static bool parseBitcoinURL(QString url, SendCoinsRecipient *out); + + /** Get save file name, mimics QFileDialog::getSaveFileName, except that it appends a default suffix + when no suffix is provided by the user. + + @param[in] parent Parent window (or 0) + @param[in] caption Window caption (or empty, for default) + @param[in] dir Starting directory (or empty, to default to documents directory) + @param[in] filter Filter specification such as "Comma Separated Files (*.csv)" + @param[out] selectedSuffixOut Pointer to return the suffix (file type) that was selected (or 0). + Can be useful when choosing the save file format based on suffix. + */ + static QString getSaveFileName(QWidget *parent=0, const QString &caption=QString(), + const QString &dir=QString(), const QString &filter=QString(), + QString *selectedSuffixOut=0); + }; #endif // GUIUTIL_H diff --git a/src/qt/transactionview.cpp b/src/qt/transactionview.cpp index 3ef31854fb4..0bfce351a49 100644 --- a/src/qt/transactionview.cpp +++ b/src/qt/transactionview.cpp @@ -20,7 +20,6 @@ #include #include #include -#include #include #include #include @@ -265,10 +264,9 @@ void TransactionView::changedAmount(const QString &amount) void TransactionView::exportClicked() { // CSV is currently the only supported format - QString filename = QFileDialog::getSaveFileName( + QString filename = GUIUtil::getSaveFileName( this, - tr("Export Transaction Data"), - QDir::currentPath(), + tr("Export Transaction Data"), QString(), tr("Comma separated file (*.csv)")); if (filename.isNull()) return; From 91aadbdacf9a3111da76eb831ea36d6827e1d6fc Mon Sep 17 00:00:00 2001 From: Gavin Andresen Date: Thu, 16 Feb 2012 10:22:31 -0500 Subject: [PATCH 127/154] Fix issue #848 : broken mining on testnet --- src/main.cpp | 20 ++++++++++++++++++-- src/main.h | 2 ++ src/rpc.cpp | 2 +- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index cd02652660a..ebf51ae1469 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -807,6 +807,15 @@ void static InvalidChainFound(CBlockIndex* pindexNew) printf("InvalidChainFound: WARNING: Displayed transactions may not be correct! You may need to upgrade, or other nodes may need to upgrade.\n"); } +void CBlock::UpdateTime(const CBlockIndex* pindexPrev) +{ + nTime = max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime()); + + // Updating time can change work required on testnet: + if (fTestNet) + nBits = GetNextWorkRequired(pindexPrev, this); +} + @@ -2896,7 +2905,7 @@ CBlock* CreateNewBlock(CReserveKey& reservekey) // Fill in header pblock->hashPrevBlock = pindexPrev->GetBlockHash(); pblock->hashMerkleRoot = pblock->BuildMerkleTree(); - pblock->nTime = max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime()); + pblock->UpdateTime(pindexPrev); pblock->nBits = GetNextWorkRequired(pindexPrev, pblock.get()); pblock->nNonce = 0; @@ -3053,6 +3062,7 @@ void static BitcoinMiner(CWallet *pwallet) FormatHashBuffers(pblock.get(), pmidstate, pdata, phash1); unsigned int& nBlockTime = *(unsigned int*)(pdata + 64 + 4); + unsigned int& nBlockBits = *(unsigned int*)(pdata + 64 + 8); unsigned int& nBlockNonce = *(unsigned int*)(pdata + 64 + 12); @@ -3140,8 +3150,14 @@ void static BitcoinMiner(CWallet *pwallet) break; // Update nTime every few seconds - pblock->nTime = max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime()); + pblock->UpdateTime(pindexPrev); nBlockTime = ByteReverse(pblock->nTime); + if (fTestNet) + { + // Changing pblock->nTime can change work required on testnet: + nBlockBits = ByteReverse(pblock->nBits); + hashTarget = CBigNum().SetCompact(pblock->nBits).getuint256(); + } } } } diff --git a/src/main.h b/src/main.h index 3e381b060b2..278f4f01c05 100644 --- a/src/main.h +++ b/src/main.h @@ -846,6 +846,8 @@ public: return n; } + void UpdateTime(const CBlockIndex* pindexPrev); + uint256 BuildMerkleTree() const { diff --git a/src/rpc.cpp b/src/rpc.cpp index 8967b2c9968..aade32ac1d8 100644 --- a/src/rpc.cpp +++ b/src/rpc.cpp @@ -1548,7 +1548,7 @@ Value getwork(const Array& params, bool fHelp) } // Update nTime - pblock->nTime = max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime()); + pblock->UpdateTime(pindexPrev); pblock->nNonce = 0; // Update nExtraNonce From 27960a36de879634ee8c491d0f4fe8160e8a4f75 Mon Sep 17 00:00:00 2001 From: Gavin Andresen Date: Thu, 16 Feb 2012 10:22:31 -0500 Subject: [PATCH 128/154] Fix issue #848 : broken mining on testnet --- src/bitcoinrpc.cpp | 4 ++-- src/main.cpp | 20 ++++++++++++++++++-- src/main.h | 2 ++ 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp index 36490e94f71..1f57bf9cd0d 100644 --- a/src/bitcoinrpc.cpp +++ b/src/bitcoinrpc.cpp @@ -1654,7 +1654,7 @@ Value getwork(const Array& params, bool fHelp) } // Update nTime - pblock->nTime = max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime()); + pblock->UpdateTime(pindexPrev); pblock->nNonce = 0; // Update nExtraNonce @@ -1751,7 +1751,7 @@ Value getmemorypool(const Array& params, bool fHelp) } // Update nTime - pblock->nTime = max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime()); + pblock->UpdateTime(pindexPrev); pblock->nNonce = 0; Array transactions; diff --git a/src/main.cpp b/src/main.cpp index 747805450a7..78a7ec3d275 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -820,6 +820,15 @@ void static InvalidChainFound(CBlockIndex* pindexNew) printf("InvalidChainFound: WARNING: Displayed transactions may not be correct! You may need to upgrade, or other nodes may need to upgrade.\n"); } +void CBlock::UpdateTime(const CBlockIndex* pindexPrev) +{ + nTime = max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime()); + + // Updating time can change work required on testnet: + if (fTestNet) + nBits = GetNextWorkRequired(pindexPrev, this); +} + @@ -2949,7 +2958,7 @@ CBlock* CreateNewBlock(CReserveKey& reservekey) // Fill in header pblock->hashPrevBlock = pindexPrev->GetBlockHash(); pblock->hashMerkleRoot = pblock->BuildMerkleTree(); - pblock->nTime = max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime()); + pblock->UpdateTime(pindexPrev); pblock->nBits = GetNextWorkRequired(pindexPrev, pblock.get()); pblock->nNonce = 0; @@ -3105,6 +3114,7 @@ void static BitcoinMiner(CWallet *pwallet) FormatHashBuffers(pblock.get(), pmidstate, pdata, phash1); unsigned int& nBlockTime = *(unsigned int*)(pdata + 64 + 4); + unsigned int& nBlockBits = *(unsigned int*)(pdata + 64 + 8); unsigned int& nBlockNonce = *(unsigned int*)(pdata + 64 + 12); @@ -3192,8 +3202,14 @@ void static BitcoinMiner(CWallet *pwallet) break; // Update nTime every few seconds - pblock->nTime = max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime()); + pblock->UpdateTime(pindexPrev); nBlockTime = ByteReverse(pblock->nTime); + if (fTestNet) + { + // Changing pblock->nTime can change work required on testnet: + nBlockBits = ByteReverse(pblock->nBits); + hashTarget = CBigNum().SetCompact(pblock->nBits).getuint256(); + } } } } diff --git a/src/main.h b/src/main.h index a1fb548f087..083d34029a9 100644 --- a/src/main.h +++ b/src/main.h @@ -856,6 +856,8 @@ public: return n; } + void UpdateTime(const CBlockIndex* pindexPrev); + uint256 BuildMerkleTree() const { From 1db5f43dc4d151a8b0543075385a57c3e57f54a3 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Fri, 16 Mar 2012 20:31:12 -0400 Subject: [PATCH 129/154] Bugfix: Missing includes --- src/qt/addressbookpage.cpp | 1 + src/qt/transactionview.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/src/qt/addressbookpage.cpp b/src/qt/addressbookpage.cpp index 76061233fc8..2c4407a81da 100644 --- a/src/qt/addressbookpage.cpp +++ b/src/qt/addressbookpage.cpp @@ -4,6 +4,7 @@ #include "addresstablemodel.h" #include "editaddressdialog.h" #include "csvmodelwriter.h" +#include "guiutil.h" #include #include diff --git a/src/qt/transactionview.cpp b/src/qt/transactionview.cpp index 0bfce351a49..1dd4c7b542a 100644 --- a/src/qt/transactionview.cpp +++ b/src/qt/transactionview.cpp @@ -10,6 +10,7 @@ #include "transactiondescdialog.h" #include "editaddressdialog.h" #include "optionsmodel.h" +#include "guiutil.h" #include #include From 8b3a795ea6bcbd83eab83edf75e98c57269aeb6e Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Fri, 16 Mar 2012 20:31:12 -0400 Subject: [PATCH 130/154] Bugfix: Missing includes --- src/qt/addressbookpage.cpp | 1 + src/qt/transactionview.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/src/qt/addressbookpage.cpp b/src/qt/addressbookpage.cpp index 76061233fc8..2c4407a81da 100644 --- a/src/qt/addressbookpage.cpp +++ b/src/qt/addressbookpage.cpp @@ -4,6 +4,7 @@ #include "addresstablemodel.h" #include "editaddressdialog.h" #include "csvmodelwriter.h" +#include "guiutil.h" #include #include diff --git a/src/qt/transactionview.cpp b/src/qt/transactionview.cpp index 0bfce351a49..1dd4c7b542a 100644 --- a/src/qt/transactionview.cpp +++ b/src/qt/transactionview.cpp @@ -10,6 +10,7 @@ #include "transactiondescdialog.h" #include "editaddressdialog.h" #include "optionsmodel.h" +#include "guiutil.h" #include #include From 1422e5bf518bf8a86f1e62f8f6c2552d242264bf Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Thu, 15 Mar 2012 22:25:07 -0400 Subject: [PATCH 131/154] Bump version to 0.5.3.1 --- 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 121a53f019c..92b0a6f03dc 100644 --- a/bitcoin-qt.pro +++ b/bitcoin-qt.pro @@ -1,6 +1,6 @@ TEMPLATE = app TARGET = -VERSION = 0.5.3 +VERSION = 0.5.3.1 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 13238149321..f411638251b 100644 --- a/doc/README +++ b/doc/README @@ -1,4 +1,4 @@ -Bitcoin 0.5.3 BETA +Bitcoin 0.5.3.1 BETA Copyright (c) 2009-2012 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 f52c1d17997..9b47fb805ea 100644 --- a/doc/README_windows.txt +++ b/doc/README_windows.txt @@ -1,4 +1,4 @@ -Bitcoin 0.5.3 BETA +Bitcoin 0.5.3.1 BETA Copyright (c) 2009-2012 Bitcoin Developers Distributed under the MIT/X11 software license, see the accompanying diff --git a/share/setup.nsi b/share/setup.nsi index 12a1a532daa..a7d621c0956 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.3 +!define VERSION 0.5.3.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.5.3-win32-setup.exe +OutFile bitcoin-0.5.3.1-win32-setup.exe InstallDir $PROGRAMFILES\Bitcoin CRCCheck on XPStyle on BrandingText " " ShowInstDetails show -VIProductVersion 0.5.3.0 +VIProductVersion 0.5.3.1 VIAddVersionKey ProductName Bitcoin VIAddVersionKey ProductVersion "${VERSION}" VIAddVersionKey CompanyName "${COMPANY}" diff --git a/src/serialize.h b/src/serialize.h index 71f24f81d5b..e3888194055 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 = 50300; +static const int VERSION = 50301; static const char* pszSubVer = ""; static const bool VERSION_IS_BETA = true; From 1a4ac2b4d07eb9bf19d494586b0ff5c73ba2de68 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Sat, 17 Mar 2012 19:54:22 -0400 Subject: [PATCH 132/154] Move QMAKE_LIBS_QT_ENTRY adjustment to bitcoin side of build It could just as well be on either part of the gitian build, but to safely put it on the Qt side would require bumping the filename, and every gitian user rebuilding it. v0.5.3.1 put it on the Bitcoin side, and this is easier to work with and keep safe, so I'm moving it. --- bitcoin-qt.pro | 1 + contrib/gitian-descriptors/qt-win32.yml | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/bitcoin-qt.pro b/bitcoin-qt.pro index 92b0a6f03dc..33df7cd835e 100644 --- a/bitcoin-qt.pro +++ b/bitcoin-qt.pro @@ -254,6 +254,7 @@ isEmpty(BOOST_INCLUDE_PATH) { windows:LIBS += -lmingwthrd -lws2_32 windows:DEFINES += _MT WIN32 windows:RC_FILE = src/qt/res/bitcoin-qt.rc +windows:QMAKE_LIBS_QT_ENTRY -= -lmingw32 macx:HEADERS += src/qt/macdockiconhandler.h macx:OBJECTIVE_SOURCES += src/qt/macdockiconhandler.mm diff --git a/contrib/gitian-descriptors/qt-win32.yml b/contrib/gitian-descriptors/qt-win32.yml index adccebbb918..6eb76b21707 100644 --- a/contrib/gitian-descriptors/qt-win32.yml +++ b/contrib/gitian-descriptors/qt-win32.yml @@ -47,7 +47,6 @@ script: | cp -a bin $SRCDIR/ cd $INSTDIR find . -name *.prl | xargs -l sed 's|/$||' -i - sed 's/QMAKE_LIBS_QT_ENTRY = -lmingw32 -lqtmain/QMAKE_LIBS_QT_ENTRY = -lqtmain/' -i mkspecs/unsupported/win32-g++-cross/qmake.conf #sed 's|QMAKE_PRL_LIBS.*|QMAKE_PRL_LIBS = -lQtDeclarative -lQtScript -lQtSvg -lQtSql -lQtXmlPatterns -lQtGui -lgdi32 -lcomdlg32 -loleaut32 -limm32 -lwinmm -lwinspool -lmsimg32 -lQtNetwork -lQtCore -lole32 -luuid -lws2_32 -ladvapi32 -lshell32 -luser32 -lkernel32|' -i imports/Qt/labs/particles/qmlparticlesplugin.prl # as zip stores file timestamps, use faketime to intercept stat calls to set dates for all files to reference date From b3ba40c6bf7417f9db6ee67afe388953d0d77e41 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Sat, 17 Mar 2012 19:54:22 -0400 Subject: [PATCH 133/154] Move QMAKE_LIBS_QT_ENTRY adjustment to bitcoin side of build It could just as well be on either part of the gitian build, but to safely put it on the Qt side would require bumping the filename, and every gitian user rebuilding it. v0.5.3.1 put it on the Bitcoin side, and this is easier to work with and keep safe, so I'm moving it. --- bitcoin-qt.pro | 1 + contrib/gitian-descriptors/qt-win32.yml | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/bitcoin-qt.pro b/bitcoin-qt.pro index 64b9670bfde..28eba2b9ea5 100644 --- a/bitcoin-qt.pro +++ b/bitcoin-qt.pro @@ -254,6 +254,7 @@ isEmpty(BOOST_INCLUDE_PATH) { windows:LIBS += -lmingwthrd -lws2_32 windows:DEFINES += _MT WIN32 windows:RC_FILE = src/qt/res/bitcoin-qt.rc +windows:QMAKE_LIBS_QT_ENTRY -= -lmingw32 macx:HEADERS += src/qt/macdockiconhandler.h macx:OBJECTIVE_SOURCES += src/qt/macdockiconhandler.mm diff --git a/contrib/gitian-descriptors/qt-win32.yml b/contrib/gitian-descriptors/qt-win32.yml index adccebbb918..6eb76b21707 100644 --- a/contrib/gitian-descriptors/qt-win32.yml +++ b/contrib/gitian-descriptors/qt-win32.yml @@ -47,7 +47,6 @@ script: | cp -a bin $SRCDIR/ cd $INSTDIR find . -name *.prl | xargs -l sed 's|/$||' -i - sed 's/QMAKE_LIBS_QT_ENTRY = -lmingw32 -lqtmain/QMAKE_LIBS_QT_ENTRY = -lqtmain/' -i mkspecs/unsupported/win32-g++-cross/qmake.conf #sed 's|QMAKE_PRL_LIBS.*|QMAKE_PRL_LIBS = -lQtDeclarative -lQtScript -lQtSvg -lQtSql -lQtXmlPatterns -lQtGui -lgdi32 -lcomdlg32 -loleaut32 -limm32 -lwinmm -lwinspool -lmsimg32 -lQtNetwork -lQtCore -lole32 -luuid -lws2_32 -ladvapi32 -lshell32 -luser32 -lkernel32|' -i imports/Qt/labs/particles/qmlparticlesplugin.prl # as zip stores file timestamps, use faketime to intercept stat calls to set dates for all files to reference date From 0a1c5c9b104458b3e048c8e3ae5e9f347a5ab399 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Mon, 19 Mar 2012 12:15:03 -0400 Subject: [PATCH 134/154] Bump version to 0.5.0.6 --- 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 28eba2b9ea5..ff5df982479 100644 --- a/bitcoin-qt.pro +++ b/bitcoin-qt.pro @@ -1,6 +1,6 @@ TEMPLATE = app TARGET = -VERSION = 0.5.0.5 +VERSION = 0.5.0.6 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 9b3c561cbe1..dc296f4e2e5 100644 --- a/doc/README +++ b/doc/README @@ -1,4 +1,4 @@ -Bitcoin 0.5.0.5 BETA +Bitcoin 0.5.0.6 BETA Copyright (c) 2009-2012 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 c23b0ea84d5..f373b1449b3 100644 --- a/doc/README_windows.txt +++ b/doc/README_windows.txt @@ -1,4 +1,4 @@ -Bitcoin 0.5.0.5 BETA +Bitcoin 0.5.0.6 BETA Copyright (c) 2009-2012 Bitcoin Developers Distributed under the MIT/X11 software license, see the accompanying diff --git a/share/setup.nsi b/share/setup.nsi index 4f764153e18..c574269bc49 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.5 +!define VERSION 0.5.0.6 !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.5-win32-setup.exe +OutFile bitcoin-0.5.0.6-win32-setup.exe InstallDir $PROGRAMFILES\Bitcoin CRCCheck on XPStyle on BrandingText " " ShowInstDetails show -VIProductVersion 0.5.0.5 +VIProductVersion 0.5.0.6 VIAddVersionKey ProductName Bitcoin VIAddVersionKey ProductVersion "${VERSION}" VIAddVersionKey CompanyName "${COMPANY}" diff --git a/src/serialize.h b/src/serialize.h index f10f933b163..f628510a36e 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 = 50005; +static const int VERSION = 50006; static const char* pszSubVer = ""; static const bool VERSION_IS_BETA = true; From 00d832756cd1c4574774497dc1232101bea5db96 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Sun, 11 Mar 2012 17:57:44 -0400 Subject: [PATCH 135/154] Print wallet load errors (to debug.log) --- src/init.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/init.cpp b/src/init.cpp index 079e67b9363..2dccc81bf56 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -398,12 +398,14 @@ bool AppInit2(int argc, char* argv[]) else if (nLoadWalletRet == DB_NEED_REWRITE) { strErrors += _("Wallet needed to be rewritten: restart Bitcoin to complete \n"); + printf("%s", strErrors.c_str()); wxMessageBox(strErrors, "Bitcoin", wxOK | wxICON_ERROR); return false; } else strErrors += _("Error loading wallet.dat \n"); } + printf("%s", strErrors.c_str()); printf(" wallet %15"PRI64d"ms\n", GetTimeMillis() - nStart); RegisterWallet(pwalletMain); From 1194f003504fa6e9d9f59012ec736ebc7c231360 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Sun, 11 Mar 2012 18:07:40 -0400 Subject: [PATCH 136/154] Print more diagnostic info for the various DB_CORRUPT conditions --- src/db.cpp | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/src/db.cpp b/src/db.cpp index 783b0799639..7f9439bf745 100644 --- a/src/db.cpp +++ b/src/db.cpp @@ -798,7 +798,10 @@ int CWalletDB::LoadWallet(CWallet* pwallet) // Get cursor Dbc* pcursor = GetCursor(); if (!pcursor) + { + printf("Error getting wallet database cursor\n"); return DB_CORRUPT; + } loop { @@ -809,7 +812,10 @@ int CWalletDB::LoadWallet(CWallet* pwallet) if (ret == DB_NOTFOUND) break; else if (ret != 0) + { + printf("Error reading next record from wallet database\n"); return DB_CORRUPT; + } // Unserialize // Taking advantage of the fact that pair serialization @@ -879,19 +885,38 @@ int CWalletDB::LoadWallet(CWallet* pwallet) CPrivKey pkey; ssValue >> pkey; key.SetPrivKey(pkey); - if (key.GetPubKey() != vchPubKey || !key.IsValid()) + if (key.GetPubKey() != vchPubKey) + { + printf("Error reading wallet database: CPrivKey pubkey inconsistency\n"); return DB_CORRUPT; + } + if (!key.IsValid()) + { + printf("Error reading wallet database: invalid CPrivKey\n"); + return DB_CORRUPT; + } } else { CWalletKey wkey; ssValue >> wkey; key.SetPrivKey(wkey.vchPrivKey); - if (key.GetPubKey() != vchPubKey || !key.IsValid()) + if (key.GetPubKey() != vchPubKey) + { + printf("Error reading wallet database: CWalletKey pubkey inconsistency\n"); return DB_CORRUPT; + } + if (!key.IsValid()) + { + printf("Error reading wallet database: invalid CWalletKey\n"); + return DB_CORRUPT; + } } if (!pwallet->LoadKey(key)) + { + printf("Error reading wallet database: LoadKey failed\n"); return DB_CORRUPT; + } } else if (strType == "mkey") { @@ -900,7 +925,10 @@ int CWalletDB::LoadWallet(CWallet* pwallet) CMasterKey kMasterKey; ssValue >> kMasterKey; if(pwallet->mapMasterKeys.count(nID) != 0) + { + printf("Error reading wallet database: duplicate CMasterKey id %u\n", nID); return DB_CORRUPT; + } pwallet->mapMasterKeys[nID] = kMasterKey; if (pwallet->nMasterKeyMaxID < nID) pwallet->nMasterKeyMaxID = nID; @@ -912,7 +940,10 @@ int CWalletDB::LoadWallet(CWallet* pwallet) vector vchPrivKey; ssValue >> vchPrivKey; if (!pwallet->LoadCryptedKey(vchPubKey, vchPrivKey)) + { + printf("Error reading wallet database: LoadCryptedKey failed\n"); return DB_CORRUPT; + } fIsEncrypted = true; } else if (strType == "defaultkey") From 0ae535cdb2e331c81b35486ebaae09aa5e80d014 Mon Sep 17 00:00:00 2001 From: Joel Kaartinen Date: Fri, 16 Mar 2012 14:23:59 +0200 Subject: [PATCH 137/154] Make the sendcoins dialog use the configured unit type, even on the first attempt. --- src/qt/sendcoinsentry.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/qt/sendcoinsentry.cpp b/src/qt/sendcoinsentry.cpp index d98400c2608..caffaaeff28 100644 --- a/src/qt/sendcoinsentry.cpp +++ b/src/qt/sendcoinsentry.cpp @@ -66,6 +66,7 @@ void SendCoinsEntry::on_payTo_textChanged(const QString &address) void SendCoinsEntry::setModel(WalletModel *model) { this->model = model; + clear(); } void SendCoinsEntry::setRemoveEnabled(bool enabled) From e20417c333f86797ed328d990bf284080a69920b Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Fri, 17 Feb 2012 13:50:32 +0100 Subject: [PATCH 138/154] Hide window from taskbar when "minimize to tray" active by making window into Tool window --- src/qt/bitcoingui.cpp | 27 +++++++++------------------ src/qt/bitcoingui.h | 4 ---- 2 files changed, 9 insertions(+), 22 deletions(-) diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index 3c9a773f4e9..ff862cf40e1 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -55,7 +55,6 @@ BitcoinGUI::BitcoinGUI(QWidget *parent): QMainWindow(parent), clientModel(0), walletModel(0), - dummyWidget(0), encryptWalletAction(0), changePassphraseAction(0), aboutQtAction(0), @@ -85,9 +84,6 @@ BitcoinGUI::BitcoinGUI(QWidget *parent): // Create the tray icon (or setup the dock icon) createTrayIcon(); - // Dummy widget used when restoring window state after minimization - dummyWidget = new QWidget(); - // Create tabs overviewPage = new OverviewPage(); @@ -161,7 +157,6 @@ BitcoinGUI::~BitcoinGUI() #ifdef Q_WS_MAC delete appMenuBar; #endif - delete dummyWidget; } void BitcoinGUI::createActions() @@ -387,14 +382,6 @@ void BitcoinGUI::trayIconActivated(QSystemTrayIcon::ActivationReason reason) } #endif -void BitcoinGUI::showNormal() -{ - // Reparent window to the desktop (in case it was hidden on minimize) - if(parent() != NULL) - setParent(NULL, Qt::Window); - QMainWindow::showNormal(); -} - void BitcoinGUI::optionsClicked() { if(!clientModel || !clientModel->getOptionsModel()) @@ -541,15 +528,19 @@ void BitcoinGUI::changeEvent(QEvent *e) { if(clientModel && clientModel->getOptionsModel()->getMinimizeToTray()) { - if(isMinimized()) + QWindowStateChangeEvent *wsevt = static_cast(e); + bool wasMinimized = wsevt->oldState() & Qt::WindowMinimized; + bool isMinimized = windowState() & Qt::WindowMinimized; + if(!wasMinimized && isMinimized) { - // Hiding the window from taskbar - setParent(dummyWidget, Qt::SubWindow); + // Minimized, hide the window from taskbar + setWindowFlags(windowFlags() | Qt::Tool); return; } - else + else if(wasMinimized && !isMinimized) { - showNormal(); + // Unminimized, show the window in taskbar + setWindowFlags(windowFlags() &~ Qt::Tool); } } } diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h index 1338998a98c..9b672ee809d 100644 --- a/src/qt/bitcoingui.h +++ b/src/qt/bitcoingui.h @@ -54,8 +54,6 @@ private: QStackedWidget *centralWidget; - QWidget *dummyWidget; - OverviewPage *overviewPage; QWidget *transactionsPage; AddressBookPage *addressBookPage; @@ -109,8 +107,6 @@ public slots: */ void askFee(qint64 nFeeRequired, bool *payFee); - void showNormal(); - private slots: // UI pages void gotoOverviewPage(); From b4c7b6a384e69ec31ae6067a9b9692fa7b02ab56 Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Thu, 15 Mar 2012 22:30:08 +0100 Subject: [PATCH 139/154] Yet another attempt at implementing "minimize to tray" that works on all OSes --- src/qt/bitcoingui.cpp | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index ff862cf40e1..78becafe5b4 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -45,6 +45,7 @@ #include #include #include +#include #include #include @@ -523,29 +524,21 @@ void BitcoinGUI::error(const QString &title, const QString &message) void BitcoinGUI::changeEvent(QEvent *e) { + QMainWindow::changeEvent(e); #ifndef Q_WS_MAC // Ignored on Mac if(e->type() == QEvent::WindowStateChange) { if(clientModel && clientModel->getOptionsModel()->getMinimizeToTray()) { QWindowStateChangeEvent *wsevt = static_cast(e); - bool wasMinimized = wsevt->oldState() & Qt::WindowMinimized; - bool isMinimized = windowState() & Qt::WindowMinimized; - if(!wasMinimized && isMinimized) + if(!(wsevt->oldState() & Qt::WindowMinimized) && isMinimized()) { - // Minimized, hide the window from taskbar - setWindowFlags(windowFlags() | Qt::Tool); - return; - } - else if(wasMinimized && !isMinimized) - { - // Unminimized, show the window in taskbar - setWindowFlags(windowFlags() &~ Qt::Tool); + QTimer::singleShot(0, this, SLOT(hide())); + e->ignore(); } } } #endif - QMainWindow::changeEvent(e); } void BitcoinGUI::closeEvent(QCloseEvent *event) From 0e6c6e3fd1ab971c652e48fa04bac097e44e76fe Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Sat, 18 Feb 2012 13:32:25 +0100 Subject: [PATCH 140/154] Workaround for BN_bn2mpi reading/writing out of bounds When OpenSSL's BN_bn2mpi is passed a buffer of size 4, valgrind reports reading/writing one byte past it. I am unable to find evidence of this behaviour in BN_bn2mpi's source code, so it may be a spurious warning. However, this change is harmless, as only the bignum with value 0 results in an mpi serialization of size 4. --- src/bignum.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bignum.h b/src/bignum.h index 1a2406b9358..6e8d3cb8aba 100644 --- a/src/bignum.h +++ b/src/bignum.h @@ -243,7 +243,7 @@ public: std::vector getvch() const { unsigned int nSize = BN_bn2mpi(this, NULL); - if (nSize < 4) + if (nSize <= 4) return std::vector(); std::vector vch(nSize); BN_bn2mpi(this, &vch[0]); From 2f2ac3fece6c7f576c5957f05f342f2830301b54 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Tue, 13 Mar 2012 17:22:07 -0400 Subject: [PATCH 141/154] Minimal support for validating BIP16 pay-to-script-hash transactions Note this does NOT include accepting them in blocks (making them standard) --- src/main.cpp | 284 +++++++++++++++++++++++++++++++++++-------------- src/main.h | 53 ++++++++- src/script.cpp | 93 ++++++++++++++-- src/script.h | 45 +++++--- 4 files changed, 367 insertions(+), 108 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 652d4c1f981..c81f1318b08 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -374,15 +374,6 @@ bool CTransaction::AcceptToMemoryPool(CTxDB& txdb, bool fCheckInputs, bool* pfMi if ((int64)nLockTime > INT_MAX) return error("AcceptToMemoryPool() : not accepting nLockTime beyond 2038 yet"); - // Safety limits - unsigned int nSize = ::GetSerializeSize(*this, SER_NETWORK); - // Checking ECDSA signatures is a CPU bottleneck, so to avoid denial-of-service - // attacks disallow transactions with more than one SigOp per 34 bytes. - // 34 bytes because a TxOut is: - // 20-byte address + 8 byte bitcoin amount + 5 bytes of ops + 1 byte script length - if (GetSigOpCount() > nSize / 34 || nSize < 100) - return error("AcceptToMemoryPool() : nonstandard transaction"); - // Rather not work on nonstandard transactions (unless -testnet) if (!fTestNet && !IsStandard()) return error("AcceptToMemoryPool() : nonstandard transaction type"); @@ -426,17 +417,29 @@ bool CTransaction::AcceptToMemoryPool(CTxDB& txdb, bool fCheckInputs, bool* pfMi if (fCheckInputs) { - // Check against previous transactions + MapPrevTx mapInputs; map mapUnused; - int64 nFees = 0; bool fInvalid = false; - if (!ConnectInputs(txdb, mapUnused, CDiskTxPos(1,1,1), pindexBest, nFees, false, false, 0, fInvalid)) + if (!FetchInputs(txdb, mapUnused, false, false, mapInputs, fInvalid)) { if (fInvalid) return error("AcceptToMemoryPool() : FetchInputs found invalid tx %s", hash.ToString().substr(0,10).c_str()); - return error("AcceptToMemoryPool() : ConnectInputs failed %s", hash.ToString().substr(0,10).c_str()); + if (pfMissingInputs) + *pfMissingInputs = true; + return error("AcceptToMemoryPool() : FetchInputs failed %s", hash.ToString().substr(0,10).c_str()); } + // Safety limits + unsigned int nSize = ::GetSerializeSize(*this, SER_NETWORK); + // Checking ECDSA signatures is a CPU bottleneck, so to avoid denial-of-service + // attacks disallow transactions with more than one SigOp per 34 bytes. + // 34 bytes because a TxOut is: + // 20-byte address + 8 byte bitcoin amount + 5 bytes of ops + 1 byte script length + if (GetSigOpCount() > nSize / 34 || nSize < 100) + return error("AcceptToMemoryPool() : nonstandard transaction"); + + int64 nFees = GetValueIn(mapInputs)-GetValueOut(); + // Don't accept it if it can't get into a block if (nFees < GetMinFee(1000, true, true)) return error("AcceptToMemoryPool() : not enough fees"); @@ -465,6 +468,13 @@ bool CTransaction::AcceptToMemoryPool(CTxDB& txdb, bool fCheckInputs, bool* pfMi dFreeCount += nSize; } } + + // Check against previous transactions + // This is done last to help prevent CPU exhaustion denial-of-service attacks. + if (!ConnectInputs(mapInputs, mapUnused, CDiskTxPos(1,1,1), pindexBest, false, false)) + { + return error("AcceptToMemoryPool() : ConnectInputs failed %s", hash.ToString().substr(0,10).c_str()); + } } // Store transaction in memory @@ -853,9 +863,8 @@ bool CTransaction::DisconnectInputs(CTxDB& txdb) } -bool CTransaction::ConnectInputs(CTxDB& txdb, map& mapTestPool, CDiskTxPos posThisTx, - CBlockIndex* pindexBlock, int64& nFees, bool fBlock, bool fMiner, int64 nMinFee, - bool& fInvalid) +bool CTransaction::FetchInputs(CTxDB& txdb, const map& mapTestPool, + bool fBlock, bool fMiner, MapPrevTx& inputsRet, bool& fInvalid) { // FetchInputs can return false either because we just haven't seen some inputs // (in which case the transaction should be stored as an orphan) @@ -863,70 +872,143 @@ bool CTransaction::ConnectInputs(CTxDB& txdb, map& mapTestPoo // be dropped). If tx is definitely invalid, fInvalid will be set to true. fInvalid = false; + if (IsCoinBase()) + return true; // Coinbase transactions have no inputs to fetch. + + for (int i = 0; i < vin.size(); i++) + { + COutPoint prevout = vin[i].prevout; + if (inputsRet.count(prevout.hash)) + continue; // Got it already + + // Read txindex + CTxIndex& txindex = inputsRet[prevout.hash].first; + bool fFound = true; + if ((fBlock || fMiner) && mapTestPool.count(prevout.hash)) + { + // Get txindex from current proposed changes + txindex = mapTestPool.find(prevout.hash)->second; + } + else + { + // Read txindex from txdb + fFound = txdb.ReadTxIndex(prevout.hash, txindex); + } + if (!fFound && (fBlock || fMiner)) + return fMiner ? false : error("FetchInputs() : %s prev tx %s index entry not found", GetHash().ToString().substr(0,10).c_str(), prevout.hash.ToString().substr(0,10).c_str()); + + // Read txPrev + CTransaction& txPrev = inputsRet[prevout.hash].second; + if (!fFound || txindex.pos == CDiskTxPos(1,1,1)) + { + // Get prev tx from single transactions in memory + CRITICAL_BLOCK(cs_mapTransactions) + { + if (!mapTransactions.count(prevout.hash)) + return error("FetchInputs() : %s mapTransactions prev not found %s", GetHash().ToString().substr(0,10).c_str(), prevout.hash.ToString().substr(0,10).c_str()); + txPrev = mapTransactions[prevout.hash]; + } + if (!fFound) + txindex.vSpent.resize(txPrev.vout.size()); + } + else + { + // Get prev tx from disk + if (!txPrev.ReadFromDisk(txindex.pos)) + return error("FetchInputs() : %s ReadFromDisk prev tx %s failed", GetHash().ToString().substr(0,10).c_str(), prevout.hash.ToString().substr(0,10).c_str()); + } + } + + // Make sure all prevout.n's are valid: + for (int i = 0; i < vin.size(); i++) + { + const COutPoint prevout = vin[i].prevout; + assert(inputsRet.count(prevout.hash) != 0); + const CTxIndex& txindex = inputsRet[prevout.hash].first; + const CTransaction& txPrev = inputsRet[prevout.hash].second; + if (prevout.n >= txPrev.vout.size() || prevout.n >= txindex.vSpent.size()) + { + // Revisit this if/when transaction replacement is implemented and allows + // adding inputs: + fInvalid = true; + return error("FetchInputs() : %s prevout.n out of range %d %d %d prev tx %s\n%s", GetHash().ToString().substr(0,10).c_str(), prevout.n, txPrev.vout.size(), txindex.vSpent.size(), prevout.hash.ToString().substr(0,10).c_str(), txPrev.ToString().c_str()); + } + } + + return true; +} + +const CTxOut& CTransaction::GetOutputFor(const CTxIn& input, const MapPrevTx& inputs) const +{ + MapPrevTx::const_iterator mi = inputs.find(input.prevout.hash); + if (mi == inputs.end()) + throw std::runtime_error("CTransaction::GetOutputFor() : prevout.hash not found"); + + const CTransaction& txPrev = (mi->second).second; + if (input.prevout.n >= txPrev.vout.size()) + throw std::runtime_error("CTransaction::GetOutputFor() : prevout.n out of range"); + + return txPrev.vout[input.prevout.n]; +} + +int64 CTransaction::GetValueIn(const MapPrevTx& inputs) const +{ + if (IsCoinBase()) + return 0; + + int64 nResult = 0; + for (int i = 0; i < vin.size(); i++) + { + nResult += GetOutputFor(vin[i], inputs).nValue; + } + return nResult; + +} + +int CTransaction::GetP2SHSigOpCount(const MapPrevTx& inputs) const +{ + if (IsCoinBase()) + return 0; + + int nSigOps = 0; + for (int i = 0; i < vin.size(); i++) + { + const CTxOut& prevout = GetOutputFor(vin[i], inputs); + if (prevout.scriptPubKey.IsPayToScriptHash()) + nSigOps += prevout.scriptPubKey.GetSigOpCount(vin[i].scriptSig); + } + return nSigOps; +} + +bool CTransaction::ConnectInputs(MapPrevTx inputs, + map& mapTestPool, const CDiskTxPos& posThisTx, + const CBlockIndex* pindexBlock, bool fBlock, bool fMiner, bool fStrictPayToScriptHash) +{ // Take over previous transactions' spent pointers + // fBlock is true when this is called from AcceptBlock when a new best-block is added to the blockchain + // fMiner is true when called from the internal bitcoin miner + // ... both are false when called from CTransaction::AcceptToMemoryPool if (!IsCoinBase()) { int64 nValueIn = 0; + int64 nFees = 0; for (int i = 0; i < vin.size(); i++) { COutPoint prevout = vin[i].prevout; - - // Read txindex - CTxIndex txindex; - bool fFound = true; - if ((fBlock || fMiner) && mapTestPool.count(prevout.hash)) - { - // Get txindex from current proposed changes - txindex = mapTestPool[prevout.hash]; - } - else - { - // Read txindex from txdb - fFound = txdb.ReadTxIndex(prevout.hash, txindex); - } - if (!fFound && (fBlock || fMiner)) - return fMiner ? false : error("ConnectInputs() : %s prev tx %s index entry not found", GetHash().ToString().substr(0,10).c_str(), prevout.hash.ToString().substr(0,10).c_str()); - - // Read txPrev - CTransaction txPrev; - if (!fFound || txindex.pos == CDiskTxPos(1,1,1)) - { - // Get prev tx from single transactions in memory - CRITICAL_BLOCK(cs_mapTransactions) - { - if (!mapTransactions.count(prevout.hash)) - return error("ConnectInputs() : %s mapTransactions prev not found %s", GetHash().ToString().substr(0,10).c_str(), prevout.hash.ToString().substr(0,10).c_str()); - txPrev = mapTransactions[prevout.hash]; - } - if (!fFound) - txindex.vSpent.resize(txPrev.vout.size()); - } - else - { - // Get prev tx from disk - if (!txPrev.ReadFromDisk(txindex.pos)) - return error("ConnectInputs() : %s ReadFromDisk prev tx %s failed", GetHash().ToString().substr(0,10).c_str(), prevout.hash.ToString().substr(0,10).c_str()); - } + assert(inputs.count(prevout.hash) > 0); + CTxIndex& txindex = inputs[prevout.hash].first; + CTransaction& txPrev = inputs[prevout.hash].second; if (prevout.n >= txPrev.vout.size() || prevout.n >= txindex.vSpent.size()) - { - // Revisit this if/when transaction replacement is implemented and allows - // adding inputs: - fInvalid = true; return error("ConnectInputs() : %s prevout.n out of range %d %d %d prev tx %s\n%s", GetHash().ToString().substr(0,10).c_str(), prevout.n, txPrev.vout.size(), txindex.vSpent.size(), prevout.hash.ToString().substr(0,10).c_str(), txPrev.ToString().c_str()); - } // If prev is coinbase, check that it's matured if (txPrev.IsCoinBase()) - for (CBlockIndex* pindex = pindexBlock; pindex && pindexBlock->nHeight - pindex->nHeight < COINBASE_MATURITY; pindex = pindex->pprev) + for (const CBlockIndex* pindex = pindexBlock; pindex && pindexBlock->nHeight - pindex->nHeight < COINBASE_MATURITY; pindex = pindex->pprev) if (pindex->nBlockPos == txindex.pos.nBlockPos && pindex->nFile == txindex.pos.nFile) return error("ConnectInputs() : tried to spend coinbase at depth %d", pindexBlock->nHeight - pindex->nHeight); - // Verify signature - if (!VerifySignature(txPrev, *this, i)) - return error("ConnectInputs() : %s VerifySignature failed", GetHash().ToString().substr(0,10).c_str()); - - // Check for conflicts + // Check for conflicts (double-spend) if (!txindex.vSpent[prevout.n].IsNull()) return fMiner ? false : error("ConnectInputs() : %s prev tx already used at %s", GetHash().ToString().substr(0,10).c_str(), txindex.vSpent[prevout.n].ToString().c_str()); @@ -935,6 +1017,10 @@ bool CTransaction::ConnectInputs(CTxDB& txdb, map& mapTestPoo if (!MoneyRange(txPrev.vout[prevout.n].nValue) || !MoneyRange(nValueIn)) return error("ConnectInputs() : txin values out of range"); + // Verify signature + if (!VerifySignature(txPrev, *this, i, fStrictPayToScriptHash, 0)) + return error("ConnectInputs() : %s VerifySignature failed", GetHash().ToString().substr(0,10).c_str()); + // Mark outpoints as spent txindex.vSpent[prevout.n] = posThisTx; @@ -952,24 +1038,11 @@ bool CTransaction::ConnectInputs(CTxDB& txdb, map& mapTestPoo int64 nTxFee = nValueIn - GetValueOut(); if (nTxFee < 0) return error("ConnectInputs() : %s nTxFee < 0", GetHash().ToString().substr(0,10).c_str()); - if (nTxFee < nMinFee) - return false; nFees += nTxFee; if (!MoneyRange(nFees)) return error("ConnectInputs() : nFees out of range"); } - if (fBlock) - { - // Add transaction to changes - mapTestPool[GetHash()] = CTxIndex(posThisTx, vout.size()); - } - else if (fMiner) - { - // Add transaction to test pool - mapTestPool[GetHash()] = CTxIndex(CDiskTxPos(1,1,1), vout.size()); - } - return true; } @@ -995,7 +1068,7 @@ bool CTransaction::ClientConnectInputs() return false; // Verify signature - if (!VerifySignature(txPrev, *this, i)) + if (!VerifySignature(txPrev, *this, i, true, 0)) return error("ConnectInputs() : VerifySignature failed"); ///// this is redundant with the mapNextTx stuff, not sure which I want to get rid of @@ -1068,20 +1141,51 @@ bool CBlock::ConnectBlock(CTxDB& txdb, CBlockIndex* pindex) return false; } + // P2SH didn't become active until Apr 1 2012 (Feb 15 on testnet) + int64 nEvalSwitchTime = fTestNet ? 1329264000 : 1333238400; + bool fStrictPayToScriptHash = (pindex->nTime >= nEvalSwitchTime); + //// issue here: it doesn't know the version unsigned int nTxPos = pindex->nBlockPos + ::GetSerializeSize(CBlock(), SER_DISK) - 1 + GetSizeOfCompactSize(vtx.size()); map mapQueuedChanges; int64 nFees = 0; + int nSigOps = 0; BOOST_FOREACH(CTransaction& tx, vtx) { + nSigOps += tx.GetSigOpCount(); + if (nSigOps > MAX_BLOCK_SIGOPS) + return error("ConnectBlock() : too many sigops"); + CDiskTxPos posThisTx(pindex->nFile, pindex->nBlockPos, nTxPos); nTxPos += ::GetSerializeSize(tx, SER_DISK); bool fInvalid; - if (!tx.ConnectInputs(txdb, mapQueuedChanges, posThisTx, pindex, nFees, true, false, 0, fInvalid)) - return false; + MapPrevTx mapInputs; + if (!tx.IsCoinBase()) + { + if (!tx.FetchInputs(txdb, mapQueuedChanges, true, false, mapInputs, fInvalid)) + return false; + + if (fStrictPayToScriptHash) + { + // Add in sigops done by pay-to-script-hash inputs; + // this is to prevent a "rogue miner" from creating + // an incredibly-expensive-to-validate block. + nSigOps += tx.GetP2SHSigOpCount(mapInputs); + if (nSigOps > MAX_BLOCK_SIGOPS) + return error("ConnectBlock() : too many sigops"); + } + + nFees += tx.GetValueIn(mapInputs)-tx.GetValueOut(); + + if (!tx.ConnectInputs(mapInputs, mapQueuedChanges, posThisTx, pindex, true, false, fStrictPayToScriptHash)) + return false; + } + + mapQueuedChanges[tx.GetHash()] = CTxIndex(posThisTx, tx.vout.size()); } + // Write queued txindex changes for (map::iterator mi = mapQueuedChanges.begin(); mi != mapQueuedChanges.end(); ++mi) { @@ -1344,7 +1448,7 @@ bool CBlock::CheckBlock() const // Check that it's not full of nonstandard transactions if (GetSigOpCount() > MAX_BLOCK_SIGOPS) - return error("CheckBlock() : too many nonstandard transactions"); + return error("CheckBlock() : out-of-bounds SigOpCount"); // Check merkleroot if (hashMerkleRoot != BuildMerkleTree()) @@ -2854,6 +2958,8 @@ CBlock* CreateNewBlock(CReserveKey& reservekey) unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK); if (nBlockSize + nTxSize >= MAX_BLOCK_SIZE_GEN) continue; + + // Legacy limits on sigOps: int nTxSigOps = tx.GetSigOpCount(); if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS) continue; @@ -2866,14 +2972,28 @@ CBlock* CreateNewBlock(CReserveKey& reservekey) // because we're already processing them in order of dependency map mapTestPoolTmp(mapTestPool); bool fInvalid; - if (!tx.ConnectInputs(txdb, mapTestPoolTmp, CDiskTxPos(1,1,1), pindexPrev, nFees, false, true, nMinFee, fInvalid)) + MapPrevTx mapInputs; + if (!tx.FetchInputs(txdb, mapTestPoolTmp, false, true, mapInputs, fInvalid)) continue; + + int64 nTxFees = tx.GetValueIn(mapInputs)-tx.GetValueOut(); + if (nTxFees < nMinFee) + continue; + + nTxSigOps += tx.GetP2SHSigOpCount(mapInputs); + if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS) + continue; + + if (!tx.ConnectInputs(mapInputs, mapTestPoolTmp, CDiskTxPos(1,1,1), pindexPrev, false, true)) + continue; + mapTestPoolTmp[tx.GetHash()] = CTxIndex(CDiskTxPos(1,1,1), tx.vout.size()); swap(mapTestPool, mapTestPoolTmp); // Added pblock->vtx.push_back(tx); nBlockSize += nTxSize; nBlockSigOps += nTxSigOps; + nFees += nTxFees; // Add transactions that depend on this one to the priority queue uint256 hash = tx.GetHash(); diff --git a/src/main.h b/src/main.h index 3e381b060b2..f29ccde0800 100644 --- a/src/main.h +++ b/src/main.h @@ -386,6 +386,7 @@ public: }; +typedef std::map > MapPrevTx; // @@ -494,6 +495,15 @@ public: return n; } + /** Count ECDSA signature operations in pay-to-script-hash inputs. + This is a better measure of how expensive it is to process this transaction. + + @param[in] mapInputsMap of previous transactions that have outputs we're spending + @return maximum number of sigops required to validate this transaction's inputs + @see CTransaction::FetchInputs + */ + int GetP2SHSigOpCount(const MapPrevTx& mapInputs) const; + bool IsStandard() const { BOOST_FOREACH(const CTxIn& txin, vin) @@ -517,6 +527,16 @@ public: return nValueOut; } + /** Amount of bitcoins coming in to this transaction + Note that lightweight clients may not know anything besides the hash of previous transactions, + so may not be able to calculate this. + + @param[in] mapInputsMap of previous transactions that have outputs we're spending + @returnSum of value of all inputs (scriptSigs) + @see CTransaction::FetchInputs + */ + int64 GetValueIn(const MapPrevTx& mapInputs) const; + static bool AllowFree(double dPriority) { // Large (in bytes) low-priority (new, small-coin) transactions @@ -631,14 +651,41 @@ public: bool ReadFromDisk(CTxDB& txdb, COutPoint prevout); bool ReadFromDisk(COutPoint prevout); bool DisconnectInputs(CTxDB& txdb); - bool ConnectInputs(CTxDB& txdb, std::map& mapTestPool, CDiskTxPos posThisTx, - CBlockIndex* pindexBlock, int64& nFees, bool fBlock, bool fMiner, int64 nMinFee, - bool& fInvalid); + + /** Fetch from memory and/or disk. inputsRet keys are transaction hashes. + + @param[in] txdb Transaction database + @param[in] mapTestPool List of pending changes to the transaction index database + @param[in] fBlock True if being called to add a new best-block to the chain + @param[in] fMiner True if being called by CreateNewBlock + @param[out] inputsRet Pointers to this transaction's inputs + @param[out] fInvalid returns true if transaction is invalid + @return Returns true if all inputs are in txdb or mapTestPool + */ + bool FetchInputs(CTxDB& txdb, const std::map& mapTestPool, + bool fBlock, bool fMiner, MapPrevTx& inputsRet, bool& fInvalid); + + /** Sanity check previous transactions, then, if all checks succeed, + mark them as spent by this transaction. + + @param[in] inputsPrevious transactions (from FetchInputs) + @param[out] mapTestPoolKeeps track of inputs that need to be updated on disk + @param[in] posThisTxPosition of this transaction on disk + @param[in] pindexBlock + @param[in] fBlock true if called from ConnectBlock + @param[in] fMiner true if called from CreateNewBlock + @param[in] fStrictPayToScriptHash true if fully validating p2sh transactions + @return Returns true if all checks succeed + */ + bool ConnectInputs(MapPrevTx inputs, + std::map& mapTestPool, const CDiskTxPos& posThisTx, + const CBlockIndex* pindexBlock, bool fBlock, bool fMiner, bool fStrictPayToScriptHash=true); bool ClientConnectInputs(); bool CheckTransaction() const; bool AcceptToMemoryPool(CTxDB& txdb, bool fCheckInputs=true, bool* pfMissingInputs=NULL); bool AcceptToMemoryPool(bool fCheckInputs=true, bool* pfMissingInputs=NULL); protected: + const CTxOut& GetOutputFor(const CTxIn& input, const MapPrevTx& inputs) const; bool AddToMemoryPoolUnchecked(); public: bool RemoveFromMemoryPool(); diff --git a/src/script.cpp b/src/script.cpp index 6e7bcb5e14c..377a7abb28a 100644 --- a/src/script.cpp +++ b/src/script.cpp @@ -1146,16 +1146,40 @@ bool ExtractAddress(const CScript& scriptPubKey, const CKeyStore* keystore, CBit } -bool VerifyScript(const CScript& scriptSig, const CScript& scriptPubKey, const CTransaction& txTo, unsigned int nIn, int nHashType) +bool VerifyScript(const CScript& scriptSig, const CScript& scriptPubKey, const CTransaction& txTo, unsigned int nIn, + bool fValidatePayToScriptHash, int nHashType) { - vector > stack; + vector > stack, stackCopy; if (!EvalScript(stack, scriptSig, txTo, nIn, nHashType)) return false; + if (fValidatePayToScriptHash) + stackCopy = stack; if (!EvalScript(stack, scriptPubKey, txTo, nIn, nHashType)) return false; if (stack.empty()) return false; - return CastToBool(stack.back()); + + if (CastToBool(stack.back()) == false) + return false; + + // Additional validation for spend-to-script-hash transactions: + if (fValidatePayToScriptHash && scriptPubKey.IsPayToScriptHash()) + { + if (!scriptSig.IsPushOnly()) // scriptSig must be literals-only + return false; // or validation fails + + const valtype& pubKeySerialized = stackCopy.back(); + CScript pubKey2(pubKeySerialized.begin(), pubKeySerialized.end()); + popstack(stackCopy); + + if (!EvalScript(stackCopy, pubKey2, txTo, nIn, nHashType)) + return false; + if (stackCopy.empty()) + return false; + return CastToBool(stackCopy.back()); + } + + return true; } @@ -1177,14 +1201,14 @@ bool SignSignature(const CKeyStore &keystore, const CTransaction& txFrom, CTrans // Test solution if (scriptPrereq.empty()) - if (!VerifyScript(txin.scriptSig, txout.scriptPubKey, txTo, nIn, 0)) + if (!VerifyScript(txin.scriptSig, txout.scriptPubKey, txTo, nIn, true, 0)) return false; return true; } -bool VerifySignature(const CTransaction& txFrom, const CTransaction& txTo, unsigned int nIn, int nHashType) +bool VerifySignature(const CTransaction& txFrom, const CTransaction& txTo, unsigned int nIn, bool fValidatePayToScriptHash, int nHashType) { assert(nIn < txTo.vin.size()); const CTxIn& txin = txTo.vin[nIn]; @@ -1195,8 +1219,65 @@ bool VerifySignature(const CTransaction& txFrom, const CTransaction& txTo, unsig if (txin.prevout.hash != txFrom.GetHash()) return false; - if (!VerifyScript(txin.scriptSig, txout.scriptPubKey, txTo, nIn, nHashType)) + if (!VerifyScript(txin.scriptSig, txout.scriptPubKey, txTo, nIn, fValidatePayToScriptHash, nHashType)) return false; return true; } + +int CScript::GetSigOpCount(bool fAccurate) const +{ + int n = 0; + const_iterator pc = begin(); + opcodetype lastOpcode = OP_INVALIDOPCODE; + while (pc < end()) + { + opcodetype opcode; + if (!GetOp(pc, opcode)) + break; + if (opcode == OP_CHECKSIG || opcode == OP_CHECKSIGVERIFY) + n++; + else if (opcode == OP_CHECKMULTISIG || opcode == OP_CHECKMULTISIGVERIFY) + { + if (fAccurate && lastOpcode >= OP_1 && lastOpcode <= OP_16) + n += DecodeOP_N(lastOpcode); + else + n += 20; + } + lastOpcode = opcode; + } + return n; +} + +int CScript::GetSigOpCount(const CScript& scriptSig) const +{ + if (!IsPayToScriptHash()) + return GetSigOpCount(true); + + // This is a pay-to-script-hash scriptPubKey; + // get the last item that the scriptSig + // pushes onto the stack: + const_iterator pc = scriptSig.begin(); + vector data; + while (pc < scriptSig.end()) + { + opcodetype opcode; + if (!scriptSig.GetOp(pc, opcode, data)) + return 0; + if (opcode > OP_16) + return 0; + } + + /// ... and return it's opcount: + CScript subscript(data.begin(), data.end()); + return subscript.GetSigOpCount(true); +} + +bool CScript::IsPayToScriptHash() const +{ + // Extra-fast test for pay-to-script-hash CScripts: + return (this->size() == 23 && + this->at(0) == OP_HASH160 && + this->at(1) == 0x14 && + this->at(22) == OP_EQUAL); +} diff --git a/src/script.h b/src/script.h index e61ea2fd7eb..bc9fc9ab6fa 100644 --- a/src/script.h +++ b/src/script.h @@ -574,6 +574,14 @@ public: return true; } + // Encode/decode small integers: + static int DecodeOP_N(opcodetype opcode) + { + if (opcode == OP_0) + return 0; + assert(opcode >= OP_1 && opcode <= OP_16); + return (int)opcode - (int)(OP_1 - 1); + } void FindAndDelete(const CScript& b) { @@ -588,25 +596,28 @@ public: } while (GetOp(pc, opcode)); } - - - int GetSigOpCount() const + int Find(opcodetype op) const { - int n = 0; - const_iterator pc = begin(); - while (pc < end()) - { - opcodetype opcode; - if (!GetOp(pc, opcode)) - break; - if (opcode == OP_CHECKSIG || opcode == OP_CHECKSIGVERIFY) - n++; - else if (opcode == OP_CHECKMULTISIG || opcode == OP_CHECKMULTISIGVERIFY) - n += 20; - } - return n; + int nFound = 0; + opcodetype opcode; + for (const_iterator pc = begin(); pc != end() && GetOp(pc, opcode);) + if (opcode == op) + ++nFound; + return nFound; } + // Pre-version-0.6, Bitcoin always counted CHECKMULTISIGs + // as 20 sigops. With pay-to-script-hash, that changed: + // CHECKMULTISIGs serialized in scriptSigs are + // counted more accurately, assuming they are of the form + // ... OP_N CHECKMULTISIG ... + int GetSigOpCount(bool fAccurate=false) const; + + // Accurately count sigOps, including sigOps in + // pay-to-script-hash transactions: + int GetSigOpCount(const CScript& scriptSig) const; + + bool IsPayToScriptHash() const; bool IsPushOnly() const { @@ -698,6 +709,6 @@ bool IsStandard(const CScript& scriptPubKey); bool IsMine(const CKeyStore& keystore, const CScript& scriptPubKey); bool ExtractAddress(const CScript& scriptPubKey, const CKeyStore* pkeystore, CBitcoinAddress& addressRet); bool SignSignature(const CKeyStore& keystore, const CTransaction& txFrom, CTransaction& txTo, unsigned int nIn, int nHashType=SIGHASH_ALL, CScript scriptPrereq=CScript()); -bool VerifySignature(const CTransaction& txFrom, const CTransaction& txTo, unsigned int nIn, int nHashType=0); +bool VerifySignature(const CTransaction& txFrom, const CTransaction& txTo, unsigned int nIn, bool fValidatePayToScriptHash, int nHashType); #endif From fcc547346a9c9f66855b9c8584e405291c864287 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Sat, 17 Mar 2012 19:54:22 -0400 Subject: [PATCH 142/154] Move QMAKE_LIBS_QT_ENTRY adjustment to bitcoin side of build It could just as well be on either part of the gitian build, but to safely put it on the Qt side would require bumping the filename, and every gitian user rebuilding it. v0.5.3.1 put it on the Bitcoin side, and this is easier to work with and keep safe, so I'm moving it. Use `qmake MINGW_THREAD_BUGFIX=0` to disable --- bitcoin-qt.pro | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/bitcoin-qt.pro b/bitcoin-qt.pro index ff5df982479..ad6fb001ee4 100644 --- a/bitcoin-qt.pro +++ b/bitcoin-qt.pro @@ -251,10 +251,20 @@ isEmpty(BOOST_INCLUDE_PATH) { macx:BOOST_INCLUDE_PATH = /opt/local/include } -windows:LIBS += -lmingwthrd -lws2_32 -windows:DEFINES += _MT WIN32 +windows:LIBS += -lws2_32 +windows:DEFINES += WIN32 windows:RC_FILE = src/qt/res/bitcoin-qt.rc -windows:QMAKE_LIBS_QT_ENTRY -= -lmingw32 + +windows:!contains(MINGW_THREAD_BUGFIX, 0) { + # At least qmake's win32-g++-cross profile is missing the -lmingwthrd + # thread-safety flag. GCC has -mthreads to enable this, but it doesn't + # work with static linking. -lmingwthrd must come BEFORE -lmingw, so + # it is prepended to QMAKE_LIBS_QT_ENTRY. + # It can be turned off with MINGW_THREAD_BUGFIX=0, just in case it causes + # any problems on some untested qmake profile now or in the future. + DEFINES += _MT + QMAKE_LIBS_QT_ENTRY = -lmingwthrd $$QMAKE_LIBS_QT_ENTRY +} macx:HEADERS += src/qt/macdockiconhandler.h macx:OBJECTIVE_SOURCES += src/qt/macdockiconhandler.mm From e364ad962f40afb091db5f03a0c48342063672a0 Mon Sep 17 00:00:00 2001 From: Gavin Andresen Date: Tue, 20 Mar 2012 13:45:45 -0400 Subject: [PATCH 143/154] Use last checkpoint instead of hard-coded 140,700. Fixes #913. --- src/main.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 759e514ca81..c2decc339d9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1508,10 +1508,11 @@ bool CBlock::AcceptBlock() return error("AcceptBlock() : AddToBlockIndex failed"); // Relay inventory, but don't relay old inventory during initial block download + int nBlockEstimate = Checkpoints::GetTotalBlocksEstimate(); if (hashBestChain == hash) CRITICAL_BLOCK(cs_vNodes) BOOST_FOREACH(CNode* pnode, vNodes) - if (nBestHeight > (pnode->nStartingHeight != -1 ? pnode->nStartingHeight - 2000 : 140700)) + if (nBestHeight > (pnode->nStartingHeight != -1 ? pnode->nStartingHeight - 2000 : nBlockEstimate)) pnode->PushInventory(CInv(MSG_BLOCK, hash)); return true; From 68d889db3458366a161b847f38346da0a650c1ed Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Thu, 22 Mar 2012 16:15:30 -0400 Subject: [PATCH 144/154] Fix grammatical errors in translation process documentation (partial of 2fac102) --- doc/translation_process.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/doc/translation_process.md b/doc/translation_process.md index cf1000573f0..603d557cf6f 100644 --- a/doc/translation_process.md +++ b/doc/translation_process.md @@ -1,7 +1,7 @@ Translations ============ -The QT GUI can be easily be translated into other languages. Here's how we +The Qt GUI can be easily translated into other languages. Here's how we handle those translations. Files and Folders @@ -30,10 +30,10 @@ This directory contains all translations. Filenames must adhere to this format: #### Source file -`src/qt/locale/bitcoin_en.ts` is a treated in a special way. It is used as the -source for all other translations. Whenever a string in the code is change +`src/qt/locale/bitcoin_en.ts` is treated in a special way. It is used as the +source for all other translations. Whenever a string in the code is changed this file must be updated to reflect those changes. Usually, this can be -accomplished by running `lupdate` +accomplished by running `lupdate`. Syncing with transifex ---------------------- @@ -42,9 +42,9 @@ We are using http://transifex.net as a frontend for translating the client. https://www.transifex.net/projects/p/bitcoin/resource/tx/ -The "transifex client":http://help.transifex.net/features/client/index.html -will help with fetching new translations from transifex. - +The "transifex client" (see: http://help.transifex.net/features/client/) +will help with fetching new translations from transifex. Use the following +config to be able to connect with the client. ### .tx/config From 8ed1f7c1532fe3e67ca5f7fc7c1c920bbf297203 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Sun, 19 Feb 2012 19:42:15 +0100 Subject: [PATCH 145/154] Report number of (dis)connected blocks in reorganization Also report old and new best, and fork point. --- src/main.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index c2decc339d9..12703621e8d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1311,6 +1311,9 @@ bool static Reorganize(CTxDB& txdb, CBlockIndex* pindexNew) BOOST_FOREACH(CTransaction& tx, vDelete) tx.RemoveFromMemoryPool(); + printf("REORGANIZE: Disconnected %i blocks; %s..%s\n", vDisconnect.size(), pfork->GetBlockHash().ToString().substr(0,20).c_str(), pindexBest->GetBlockHash().ToString().substr(0,20).c_str()); + printf("REORGANIZE: Connected %i blocks; %s..%s\n", vConnect.size(), pfork->GetBlockHash().ToString().substr(0,20).c_str(), pindexNew->GetBlockHash().ToString().substr(0,20).c_str()); + return true; } From b6751ed1b2a71e07cd3a8af4f02ce64fec39fe88 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Wed, 21 Mar 2012 13:15:27 +0100 Subject: [PATCH 146/154] More debug output for failed reorganizations --- src/main.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 12703621e8d..5c1b138dc3c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1251,6 +1251,9 @@ bool static Reorganize(CTxDB& txdb, CBlockIndex* pindexNew) vConnect.push_back(pindex); reverse(vConnect.begin(), vConnect.end()); + printf("REORGANIZE: Disconnect %i blocks; %s..%s\n", vDisconnect.size(), pfork->GetBlockHash().ToString().substr(0,20).c_str(), pindexBest->GetBlockHash().ToString().substr(0,20).c_str()); + printf("REORGANIZE: Connect %i blocks; %s..%s\n", vConnect.size(), pfork->GetBlockHash().ToString().substr(0,20).c_str(), pindexNew->GetBlockHash().ToString().substr(0,20).c_str()); + // Disconnect shorter branch vector vResurrect; BOOST_FOREACH(CBlockIndex* pindex, vDisconnect) @@ -1259,7 +1262,7 @@ bool static Reorganize(CTxDB& txdb, CBlockIndex* pindexNew) if (!block.ReadFromDisk(pindex)) return error("Reorganize() : ReadFromDisk for disconnect failed"); if (!block.DisconnectBlock(txdb, pindex)) - return error("Reorganize() : DisconnectBlock failed"); + return error("Reorganize() : DisconnectBlock %s failed", pindex->GetBlockHash().ToString().substr(0,20).c_str()); // Queue memory transactions to resurrect BOOST_FOREACH(const CTransaction& tx, block.vtx) @@ -1279,7 +1282,7 @@ bool static Reorganize(CTxDB& txdb, CBlockIndex* pindexNew) { // Invalid block txdb.TxnAbort(); - return error("Reorganize() : ConnectBlock failed"); + return error("Reorganize() : ConnectBlock %s failed", pindex->GetBlockHash().ToString().substr(0,20).c_str()); } // Queue memory transactions to delete @@ -1311,8 +1314,7 @@ bool static Reorganize(CTxDB& txdb, CBlockIndex* pindexNew) BOOST_FOREACH(CTransaction& tx, vDelete) tx.RemoveFromMemoryPool(); - printf("REORGANIZE: Disconnected %i blocks; %s..%s\n", vDisconnect.size(), pfork->GetBlockHash().ToString().substr(0,20).c_str(), pindexBest->GetBlockHash().ToString().substr(0,20).c_str()); - printf("REORGANIZE: Connected %i blocks; %s..%s\n", vConnect.size(), pfork->GetBlockHash().ToString().substr(0,20).c_str(), pindexNew->GetBlockHash().ToString().substr(0,20).c_str()); + printf("REORGANIZE: done\n"); return true; } From 04dc79f1cc19b48531cc9a16ca502eac34d7e95b Mon Sep 17 00:00:00 2001 From: Alistair Buxton Date: Sun, 18 Mar 2012 03:03:24 +0000 Subject: [PATCH 147/154] When disconnecting a node, clear the received buffer so that we do not process any already received messages. The primary reason to do this is if a node spams hundreds of messages and we ban them, we don't want to continue processing the rest of it. --- src/net.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/net.cpp b/src/net.cpp index a8d3d0b171b..763e160edd0 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -716,6 +716,7 @@ void CNode::CloseSocketDisconnect() printf("disconnecting node %s\n", addr.ToString().c_str()); closesocket(hSocket); hSocket = INVALID_SOCKET; + vRecv.clear(); } } From 1941765ae25d7223cdd4c44deb7474ae75dc48dc Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Wed, 21 Mar 2012 22:29:33 +0100 Subject: [PATCH 148/154] Fix warning about deprecated unescaped backslash --- bitcoin-qt.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bitcoin-qt.pro b/bitcoin-qt.pro index ad6fb001ee4..2b6fc5710b6 100644 --- a/bitcoin-qt.pro +++ b/bitcoin-qt.pro @@ -204,7 +204,7 @@ CODECFORTR = UTF-8 TRANSLATIONS = $$files(src/qt/locale/bitcoin_*.ts) isEmpty(QMAKE_LRELEASE) { - win32:QMAKE_LRELEASE = $$[QT_INSTALL_BINS]\lrelease.exe + win32:QMAKE_LRELEASE = $$[QT_INSTALL_BINS]\\lrelease.exe else:QMAKE_LRELEASE = $$[QT_INSTALL_BINS]/lrelease } isEmpty(TS_DIR):TS_DIR = src/qt/locale From fea0a27ddc30f2d51c386d268499d6c50363c202 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Thu, 22 Mar 2012 04:59:59 +0100 Subject: [PATCH 149/154] Check minversion before loading the rest of the wallet When a 0.6 wallet with compressed pubkeys is created, it writes a minversion record to prevent older clients from reading it. If the 0.5 loading it sees a key record before seeing the minversion record however, it will fail with DB_CORRUPT instead of DB_TOO_NEW. --- src/db.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/db.cpp b/src/db.cpp index 7f9439bf745..bf335e7e3fd 100644 --- a/src/db.cpp +++ b/src/db.cpp @@ -795,6 +795,13 @@ int CWalletDB::LoadWallet(CWallet* pwallet) //// todo: shouldn't we catch exceptions and try to recover and continue? CRITICAL_BLOCK(pwallet->cs_wallet) { + int nMinVersion = 0; + if (Read((string)"minversion", nMinVersion)) + { + if (nMinVersion > VERSION) + return DB_TOO_NEW; + } + // Get cursor Dbc* pcursor = GetCursor(); if (!pcursor) @@ -980,13 +987,6 @@ int CWalletDB::LoadWallet(CWallet* pwallet) if (strKey == "addrProxy") ssValue >> addrProxy; if (fHaveUPnP && strKey == "fUseUPnP") ssValue >> fUseUPnP; } - else if (strType == "minversion") - { - int nMinVersion = 0; - ssValue >> nMinVersion; - if (nMinVersion > VERSION) - return DB_TOO_NEW; - } } pcursor->close(); } From 9504e415cbeb128331fa4715bcccfaad6a443731 Mon Sep 17 00:00:00 2001 From: Gavin Andresen Date: Mon, 26 Mar 2012 12:33:35 -0400 Subject: [PATCH 150/154] Remove wxWidgets .exe and locales during setup --- share/setup.nsi | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/share/setup.nsi b/share/setup.nsi index c574269bc49..55390f3521e 100644 --- a/share/setup.nsi +++ b/share/setup.nsi @@ -75,6 +75,10 @@ Section -Main SEC0000 File /r /x *.exe /x *.o ../src\*.* SetOutPath $INSTDIR WriteRegStr HKCU "${REGKEY}\Components" Main 1 + + # Remove old wxwidgets-based-bitcoin executable and locales: + Delete /REBOOTOK $INSTDIR\bitcoin.exe + RMDir /r /REBOOTOK $INSTDIR\locale SectionEnd Section -post SEC0001 From ddd0d9ae54e52a299589c3655b5b2afc7c2bfd5e Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Tue, 27 Mar 2012 20:03:28 -0400 Subject: [PATCH 151/154] Minimal support for compressed-key signature recovery (for verifymessage) Upstream commits: 11529c6e4f7288d8a64c488a726ee3821c7adefe d4d9c734c315e99136fe245c5733ca75cab9f8bf --- src/key.h | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/key.h b/src/key.h index df5cfeb32c7..9673b2a0bca 100644 --- a/src/key.h +++ b/src/key.h @@ -169,6 +169,11 @@ protected: EC_KEY* pkey; bool fSet; + void SetCompressedPubKey() + { + EC_KEY_set_conv_form(pkey, POINT_CONVERSION_COMPRESSED); + } + public: CKey() { @@ -346,7 +351,8 @@ public: { if (vchSig.size() != 65) return false; - if (vchSig[0]<27 || vchSig[0]>=31) + int nV = vchSig[0]; + if (nV<27 || nV>=35) return false; ECDSA_SIG *sig = ECDSA_SIG_new(); BN_bin2bn(&vchSig[1],32,sig->r); @@ -354,7 +360,12 @@ public: EC_KEY_free(pkey); pkey = EC_KEY_new_by_curve_name(NID_secp256k1); - if (ECDSA_SIG_recover_key_GFp(pkey, sig, (unsigned char*)&hash, sizeof(hash), vchSig[0] - 27, 0) == 1) + if (nV >= 31) + { + SetCompressedPubKey(); + nV -= 4; + } + if (ECDSA_SIG_recover_key_GFp(pkey, sig, (unsigned char*)&hash, sizeof(hash), nV - 27, 0) == 1) { fSet = true; ECDSA_SIG_free(sig); From 60f89779a3586f8afae47bb8e9c374cd5fe7f8b6 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Sat, 25 Feb 2012 19:02:30 +0100 Subject: [PATCH 152/154] Do not invoke anti-DoS system for invalid BIP16 transactions Doing so would allow an attack on old nodes, which would relay a standard transaction spending a BIP16 output in an invalid way, until reaching a new node, which will disconnect their peer. Reported by makomk on IRC. --- src/main.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index 5c1b138dc3c..4316d242f9f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1028,7 +1028,15 @@ bool CTransaction::ConnectInputs(MapPrevTx inputs, // Verify signature if (!VerifySignature(txPrev, *this, i, fStrictPayToScriptHash, 0)) + { + // only during transition phase for P2SH: do not invoke (external) + // anti-DoS code for potentially old clients relaying bad P2SH + // transactions + if (fStrictPayToScriptHash && VerifySignature(txPrev, *this, i, false, 0)) + return error("ConnectInputs() : %s P2SH VerifySignature failed", GetHash().ToString().substr(0,10).c_str()); + return error("ConnectInputs() : %s VerifySignature failed", GetHash().ToString().substr(0,10).c_str()); + } // Mark outpoints as spent txindex.vSpent[prevout.n] = posThisTx; From d15180297fb68dbc423054bbfcd421bc02b7caef Mon Sep 17 00:00:00 2001 From: Vegard Nossum Date: Sun, 31 Jul 2011 20:00:38 +0200 Subject: [PATCH 153/154] Fix testing setup There were some problems with the existing testing setup: - Makefile rules for test-file compilation used CFLAGS instead of CXXFLAGS in makefile.unix --- src/makefile.unix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/makefile.unix b/src/makefile.unix index a2cbc7c77e1..6629067d8a8 100644 --- a/src/makefile.unix +++ b/src/makefile.unix @@ -133,7 +133,7 @@ bitcoind: $(OBJS:obj/%=obj/nogui/%) $(CXX) $(CXXFLAGS) -o $@ $^ $(LIBS) obj/test/test_bitcoin.o: $(wildcard test/*.cpp) $(HEADERS) - $(CXX) -c $(CFLAGS) -o $@ test/test_bitcoin.cpp + $(CXX) -c $(CXXFLAGS) -o $@ test/test_bitcoin.cpp test_bitcoin: obj/test/test_bitcoin.o $(filter-out obj/nogui/init.o,$(OBJS:obj/%=obj/nogui/%)) $(CXX) $(CXXFLAGS) -o $@ $(LIBPATHS) $^ -Wl,-Bstatic -lboost_unit_test_framework $(LIBS) From d53fbb4a53f4431291ba5b93f0fc1e85522e42de Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Wed, 4 Apr 2012 09:35:22 -0400 Subject: [PATCH 154/154] Fix script tests for P2SH Upstream: 922e8e2929a2e78270868385aa46f96002fbcff3 --- src/test/script_tests.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/test/script_tests.cpp b/src/test/script_tests.cpp index 13feb86b977..541f5f0c499 100644 --- a/src/test/script_tests.cpp +++ b/src/test/script_tests.cpp @@ -7,8 +7,8 @@ using namespace std; extern uint256 SignatureHash(CScript scriptCode, const CTransaction& txTo, unsigned int nIn, int nHashType); -extern bool VerifyScript(const CScript& scriptSig, const CScript& scriptPubKey, const CTransaction& txTo, unsigned int nIn, int nHashType); -extern bool VerifySignature(const CTransaction& txFrom, const CTransaction& txTo, unsigned int nIn, int nHashType); +extern bool VerifyScript(const CScript& scriptSig, const CScript& scriptPubKey, const CTransaction& txTo, unsigned int nIn, + bool fValidatePayToScriptHash, int nHashType); BOOST_AUTO_TEST_SUITE(script_tests) @@ -91,15 +91,15 @@ BOOST_AUTO_TEST_CASE(script_CHECKMULTISIG12) txTo12.vout[0].nValue = 1; CScript goodsig1 = sign_multisig(scriptPubKey12, key1, txTo12); - BOOST_CHECK(VerifyScript(goodsig1, scriptPubKey12, txTo12, 0, 0)); + BOOST_CHECK(VerifyScript(goodsig1, scriptPubKey12, txTo12, 0, true, 0)); txTo12.vout[0].nValue = 2; - BOOST_CHECK(!VerifyScript(goodsig1, scriptPubKey12, txTo12, 0, 0)); + BOOST_CHECK(!VerifyScript(goodsig1, scriptPubKey12, txTo12, 0, true, 0)); CScript goodsig2 = sign_multisig(scriptPubKey12, key2, txTo12); - BOOST_CHECK(VerifyScript(goodsig2, scriptPubKey12, txTo12, 0, 0)); + BOOST_CHECK(VerifyScript(goodsig2, scriptPubKey12, txTo12, 0, true, 0)); CScript badsig1 = sign_multisig(scriptPubKey12, key3, txTo12); - BOOST_CHECK(!VerifyScript(badsig1, scriptPubKey12, txTo12, 0, 0)); + BOOST_CHECK(!VerifyScript(badsig1, scriptPubKey12, txTo12, 0, true, 0)); } BOOST_AUTO_TEST_CASE(script_CHECKMULTISIG23) @@ -127,46 +127,46 @@ BOOST_AUTO_TEST_CASE(script_CHECKMULTISIG23) std::vector keys; keys.push_back(key1); keys.push_back(key2); CScript goodsig1 = sign_multisig(scriptPubKey23, keys, txTo23); - BOOST_CHECK(VerifyScript(goodsig1, scriptPubKey23, txTo23, 0, 0)); + BOOST_CHECK(VerifyScript(goodsig1, scriptPubKey23, txTo23, 0, true, 0)); keys.clear(); keys.push_back(key1); keys.push_back(key3); CScript goodsig2 = sign_multisig(scriptPubKey23, keys, txTo23); - BOOST_CHECK(VerifyScript(goodsig2, scriptPubKey23, txTo23, 0, 0)); + BOOST_CHECK(VerifyScript(goodsig2, scriptPubKey23, txTo23, 0, true, 0)); keys.clear(); keys.push_back(key2); keys.push_back(key3); CScript goodsig3 = sign_multisig(scriptPubKey23, keys, txTo23); - BOOST_CHECK(VerifyScript(goodsig3, scriptPubKey23, txTo23, 0, 0)); + BOOST_CHECK(VerifyScript(goodsig3, scriptPubKey23, txTo23, 0, true, 0)); keys.clear(); keys.push_back(key2); keys.push_back(key2); // Can't re-use sig CScript badsig1 = sign_multisig(scriptPubKey23, keys, txTo23); - BOOST_CHECK(!VerifyScript(badsig1, scriptPubKey23, txTo23, 0, 0)); + BOOST_CHECK(!VerifyScript(badsig1, scriptPubKey23, txTo23, 0, true, 0)); keys.clear(); keys.push_back(key2); keys.push_back(key1); // sigs must be in correct order CScript badsig2 = sign_multisig(scriptPubKey23, keys, txTo23); - BOOST_CHECK(!VerifyScript(badsig2, scriptPubKey23, txTo23, 0, 0)); + BOOST_CHECK(!VerifyScript(badsig2, scriptPubKey23, txTo23, 0, true, 0)); keys.clear(); keys.push_back(key3); keys.push_back(key2); // sigs must be in correct order CScript badsig3 = sign_multisig(scriptPubKey23, keys, txTo23); - BOOST_CHECK(!VerifyScript(badsig3, scriptPubKey23, txTo23, 0, 0)); + BOOST_CHECK(!VerifyScript(badsig3, scriptPubKey23, txTo23, 0, true, 0)); keys.clear(); keys.push_back(key4); keys.push_back(key2); // sigs must match pubkeys CScript badsig4 = sign_multisig(scriptPubKey23, keys, txTo23); - BOOST_CHECK(!VerifyScript(badsig4, scriptPubKey23, txTo23, 0, 0)); + BOOST_CHECK(!VerifyScript(badsig4, scriptPubKey23, txTo23, 0, true, 0)); keys.clear(); keys.push_back(key1); keys.push_back(key4); // sigs must match pubkeys CScript badsig5 = sign_multisig(scriptPubKey23, keys, txTo23); - BOOST_CHECK(!VerifyScript(badsig5, scriptPubKey23, txTo23, 0, 0)); + BOOST_CHECK(!VerifyScript(badsig5, scriptPubKey23, txTo23, 0, true, 0)); keys.clear(); // Must have signatures CScript badsig6 = sign_multisig(scriptPubKey23, keys, txTo23); - BOOST_CHECK(!VerifyScript(badsig6, scriptPubKey23, txTo23, 0, 0)); + BOOST_CHECK(!VerifyScript(badsig6, scriptPubKey23, txTo23, 0, true, 0)); }