What changed
Bitcoin v0.3.21 → v0.3.22
Release commit message: Bugfix for dnsseed introduced by dnslookup
Previous diff: v0.3.20 → v0.3.21. Next: v0.3.22 → v0.3.23.
- base58.h modified · +27 −20
- bignum.h modified · +7 −5
- build-msw.txt removed · +0 −103
- build-osx.txt removed · +0 −242
- build-unix.txt removed · +0 −98
- coding.txt removed · +0 −41
- db.cpp modified · +10 −7
- db.h modified · +74 −62
- headers.h modified · +2 −2
- init.cpp modified · +8 −11
- init.h modified · +4 −0
- irc.cpp modified · +28 −28
- irc.h modified · +5 −1
- key.h modified · +15 −8
- license.txt removed · +0 −19
- main.cpp modified · +66 −146
- main.h modified · +136 −120
- makefile.mingw modified · +6 −5
- makefile.unix modified · +4 −6
- net.cpp modified · +150 −84
- net.h modified · +74 −80
- noui.h modified · +9 −4
- rpc.cpp modified · +76 −51
- script.cpp modified · +7 −5
- script.h modified · +32 −23
- serialize.h modified · +63 −53
- setup.nsi removed · +0 −151
- sha256.cpp removed · +0 −475
- strlcpy.h modified · +3 −1
- ui.cpp modified · +91 −72
- ui.h modified · +25 −22
- ui.rc removed · +0 −15
- uibase.cpp modified · +0 −25
- uibase.h modified · +22 −30
- uint256.h modified · +12 −4
- util.cpp modified · +7 −6
- util.h modified · +64 −41
base58.h (modified)
1--- v0.3.21/base58.h2+++ v0.3.22/base58.h3@@ -11,12 +11,17 @@4 // - E-mail usually won't line-break if there's no punctuation to break at.5 // - Doubleclicking selects the whole number as one word if it's all alphanumeric.6 //7-8+#ifndef BITCOIN_BASE58_H9+#define BITCOIN_BASE58_H10+11+#include <string>12+#include <vector>13+#include "bignum.h"14 15 static const char* pszBase58 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";16 17 18-inline string EncodeBase58(const unsigned char* pbegin, const unsigned char* pend)19+inline std::string EncodeBase58(const unsigned char* pbegin, const unsigned char* pend)20 {21 CAutoBN_CTX pctx;22 CBigNum bn58 = 58;23@@ -24,15 +29,15 @@24 25 // Convert big endian data to little endian26 // Extra zero at the end make sure bignum will interpret as a positive number27- vector<unsigned char> vchTmp(pend-pbegin+1, 0);28+ std::vector<unsigned char> vchTmp(pend-pbegin+1, 0);29 reverse_copy(pbegin, pend, vchTmp.begin());30 31 // Convert little endian data to bignum32 CBigNum bn;33 bn.setvch(vchTmp);34 35- // Convert bignum to string36- string str;37+ // Convert bignum to std::string38+ std::string str;39 str.reserve((pend - pbegin) * 138 / 100 + 1);40 CBigNum dv;41 CBigNum rem;42@@ -49,17 +54,17 @@43 for (const unsigned char* p = pbegin; p < pend && *p == 0; p++)44 str += pszBase58[0];45 46- // Convert little endian string to big endian47+ // Convert little endian std::string to big endian48 reverse(str.begin(), str.end());49 return str;50 }51 52-inline string EncodeBase58(const vector<unsigned char>& vch)53+inline std::string EncodeBase58(const std::vector<unsigned char>& vch)54 {55 return EncodeBase58(&vch[0], &vch[0] + vch.size());56 }57 58-inline bool DecodeBase58(const char* psz, vector<unsigned char>& vchRet)59+inline bool DecodeBase58(const char* psz, std::vector<unsigned char>& vchRet)60 {61 CAutoBN_CTX pctx;62 vchRet.clear();63@@ -88,7 +93,7 @@64 }65 66 // Get bignum as little endian data67- vector<unsigned char> vchTmp = bn.getvch();68+ std::vector<unsigned char> vchTmp = bn.getvch();69 70 // Trim off sign byte if present71 if (vchTmp.size() >= 2 && vchTmp.end()[-1] == 0 && vchTmp.end()[-2] >= 0x80)72@@ -105,7 +110,7 @@73 return true;74 }75 76-inline bool DecodeBase58(const string& str, vector<unsigned char>& vchRet)77+inline bool DecodeBase58(const std::string& str, std::vector<unsigned char>& vchRet)78 {79 return DecodeBase58(str.c_str(), vchRet);80 }81@@ -114,16 +119,16 @@82 83 84 85-inline string EncodeBase58Check(const vector<unsigned char>& vchIn)86+inline std::string EncodeBase58Check(const std::vector<unsigned char>& vchIn)87 {88 // add 4-byte hash check to the end89- vector<unsigned char> vch(vchIn);90+ std::vector<unsigned char> vch(vchIn);91 uint256 hash = Hash(vch.begin(), vch.end());92 vch.insert(vch.end(), (unsigned char*)&hash, (unsigned char*)&hash + 4);93 return EncodeBase58(vch);94 }95 96-inline bool DecodeBase58Check(const char* psz, vector<unsigned char>& vchRet)97+inline bool DecodeBase58Check(const char* psz, std::vector<unsigned char>& vchRet)98 {99 if (!DecodeBase58(psz, vchRet))100 return false;101@@ -142,7 +147,7 @@102 return true;103 }104 105-inline bool DecodeBase58Check(const string& str, vector<unsigned char>& vchRet)106+inline bool DecodeBase58Check(const std::string& str, std::vector<unsigned char>& vchRet)107 {108 return DecodeBase58Check(str.c_str(), vchRet);109 }110@@ -154,17 +159,17 @@111 112 #define ADDRESSVERSION ((unsigned char)(fTestNet ? 111 : 0))113 114-inline string Hash160ToAddress(uint160 hash160)115+inline std::string Hash160ToAddress(uint160 hash160)116 {117 // add 1-byte version number to the front118- vector<unsigned char> vch(1, ADDRESSVERSION);119+ std::vector<unsigned char> vch(1, ADDRESSVERSION);120 vch.insert(vch.end(), UBEGIN(hash160), UEND(hash160));121 return EncodeBase58Check(vch);122 }123 124 inline bool AddressToHash160(const char* psz, uint160& hash160Ret)125 {126- vector<unsigned char> vch;127+ std::vector<unsigned char> vch;128 if (!DecodeBase58Check(psz, vch))129 return false;130 if (vch.empty())131@@ -176,7 +181,7 @@132 return (nVersion <= ADDRESSVERSION);133 }134 135-inline bool AddressToHash160(const string& str, uint160& hash160Ret)136+inline bool AddressToHash160(const std::string& str, uint160& hash160Ret)137 {138 return AddressToHash160(str.c_str(), hash160Ret);139 }140@@ -187,7 +192,7 @@141 return AddressToHash160(psz, hash160);142 }143 144-inline bool IsValidBitcoinAddress(const string& str)145+inline bool IsValidBitcoinAddress(const std::string& str)146 {147 return IsValidBitcoinAddress(str.c_str());148 }149@@ -195,8 +200,10 @@150 151 152 153-inline string PubKeyToAddress(const vector<unsigned char>& vchPubKey)154+inline std::string PubKeyToAddress(const std::vector<unsigned char>& vchPubKey)155 {156 return Hash160ToAddress(Hash160(vchPubKey));157 }158 159+#endif160+
bignum.h (modified)
1--- v0.3.21/bignum.h2+++ v0.3.22/bignum.h3@@ -1,14 +1,14 @@4 // Copyright (c) 2009-2010 Satoshi Nakamoto5 // Distributed under the MIT/X11 software license, see the accompanying6 // file license.txt or http://www.opensource.org/licenses/mit-license.php.7+#ifndef BITCOIN_BIGNUM_H8+#define BITCOIN_BIGNUM_H9 10 #include <stdexcept>11 #include <vector>12 #include <openssl/bn.h>13 14-15-16-17+#include "util.h"18 19 class bignum_error : public std::runtime_error20 {21@@ -308,7 +308,7 @@22 CAutoBN_CTX pctx;23 CBigNum bnBase = nBase;24 CBigNum bn0 = 0;25- string str;26+ std::string str;27 CBigNum bn = *this;28 BN_set_negative(&bn, false);29 CBigNum dv;30@@ -348,7 +348,7 @@31 template<typename Stream>32 void Unserialize(Stream& s, int nType=0, int nVersion=VERSION)33 {34- vector<unsigned char> vch;35+ std::vector<unsigned char> vch;36 ::Unserialize(s, vch, nType, nVersion);37 setvch(vch);38 }39@@ -531,3 +531,5 @@40 inline bool operator<(const CBigNum& a, const CBigNum& b) { return (BN_cmp(&a, &b) < 0); }41 inline bool operator>(const CBigNum& a, const CBigNum& b) { return (BN_cmp(&a, &b) > 0); }42 43+#endif44+
build-msw.txt (removed)
1--- v0.3.21/build-msw.txt2+++ /dev/null3@@ -1,113 +1 @@4-Copyright (c) 2009-2011 Bitcoin Developers5-Distributed under the MIT/X11 software license, see the accompanying6-file license.txt or http://www.opensource.org/licenses/mit-license.php.7-This product includes software developed by the OpenSSL Project for use in8-the OpenSSL Toolkit (http://www.openssl.org/). This product includes9-cryptographic software written by Eric Young (eay@cryptsoft.com) and UPnP10-software written by Thomas Bernard.11 12-13-WINDOWS BUILD NOTES14-===================15-16-Compilers Supported17--------------------18-MinGW GCC http://tdm-gcc.tdragon.net/19- TDM-GCC with gcc 4.5.1 was used to build this release.20-MSYS 1.0.11 was also used (sh needed to compile some dependencies)21-22-23-Candidate releases were built with MSVC 10.0 (2010), but24-compiling with Visual C++ caused rendering artifacts when25-bitcoin was run.26-27-28-Dependencies29-------------30-Libraries you need to download separately and build:31-32- default path download33-wxWidgets \wxwidgets-2.9.1-mgw http://www.wxwidgets.org/downloads/34-OpenSSL \openssl-1.0.0c-mgw http://www.openssl.org/source/35-Berkeley DB \db-4.7.25.NC-mgw http://www.oracle.com/technology/software/products/berkeley-db/index.html36-Boost \boost-1.43.0-mgw http://www.boost.org/users/download/37-miniupnpc \upnpc-exe-win32-20110215 http://miniupnp.tuxfamily.org/files/38-39-Their licenses:40-wxWidgets LGPL 2.1 with very liberal exceptions41-OpenSSL Old BSD license with the problematic advertising requirement42-Berkeley DB New BSD license with additional requirement that linked software must be free open source43-Boost MIT-like license44-miniupnpc New (3-clause) BSD license45-46-Versions used in this release:47-wxWidgets 2.9.148-OpenSSL 1.0.0c49-Berkeley DB 4.7.25.NC50-Boost 1.43.051-miniupnpc 1.5-2011021552-53-54-Notes55------56-The UI layout is edited with wxFormBuilder. The project file is57-uiproject.fbp. It generates uibase.cpp and uibase.h, which define base58-classes that do the rote work of constructing all the UI elements.59-60-wxWidgets61----------62-DOS shell:63-cd \wxWidgets-2.9.1-mgw\build\msw64-mingw32-make -f makefile.gcc65-66-OpenSSL67--------68-MSYS shell:69-un-tar sources with MSYS 'tar xfz' to avoid issue with symlinks (OpenSSL ticket 2377)70-change 'MAKE' env. variable from 'C:\MinGW32\bin\mingw32-make.exe' to '/c/MinGW32/bin/mingw32-make.exe'71-72-cd /c/openssl-1.0.0c-mgw73-./config74-make75-76-perl util/mkdef.pl 32 libeay enable-static-engine > libeay32.def77-dllwrap --dllname libeay32.dll --output-lib libeay32.a --def libeay32.def libcrypto.a -lws2_32 -lgdi3278-79-after that openssl libeay is in main source dir (openssl-1.0.0c-mgw)80-81-Berkeley DB82------------83-MSYS shell:84-cd /c/db-4.7.25.NC-mgw/build_unix85-sh ../dist/configure --enable-mingw --enable-cxx86-make87-88-89-Boost90------91-DOS prompt:92-downloaded boost jam 3.1.1893-cd \boost-1.43.0-mgw94-bjam toolset=gcc --build-type=complete stage95-96-Note:97-building with boost 1.45.0 failed because of boost ticket 4614, 425898-builds fine with boost 1.43.099-100-MiniUPnPc101----------102-Building miniupnpc failed on Windows Server 2003, thus it is expected that a binary copy will be used.103-See http://miniupnp.tuxfamily.org/forum/viewtopic.php?t=642104-UPnP support is optional, make with USE_UPNP= to disable it.105-106-Get upnpc-exe-win32-20110215.zip and unzip it to \upnpc-exe-win32-20110215107-Get miniupnpc-1.5.20110215.tar.gz and copy *.h to \upnpc-exe-win32-20110215\miniupnpc108-109-Bitcoin110--------111-DOS prompt:112-cd \bitcoin113-mingw32-make bitcoin.exe bitcoind.exe -f makefile.mingw114-strip bitcoin.exe115-strip bitcoind.exe116-
build-osx.txt (removed)
1--- v0.3.21/build-osx.txt2+++ /dev/null3@@ -1,262 +1 @@4-Copyright (c) 2010 Laszlo Hanyecz5-Distributed under the MIT/X11 software license, see the accompanying6-file license.txt or http://www.opensource.org/licenses/mit-license.php.7-This product includes software developed by the OpenSSL Project for use in8-the OpenSSL Toolkit (http://www.openssl.org/). This product includes9-cryptographic software written by Eric Young (eay@cryptsoft.com) and UPnP10-software written by Thomas Bernard.11 12-13-Mac OS X build instructions14-Laszlo Hanyecz (solar@heliacal.net)15-16-17-Tested on 10.5 and 10.6 intel. PPC is not supported because it's big-endian.18-19-All of the commands should be executed in Terminal.app.. it's in20-/Applications/Utilities21-22-You need to install XCode with all the options checked so that the compiler23-and everything is available in /usr not just /Developer24-I think it comes on the DVD but you can get the current version from25-http://developer.apple.com26-27-28-1. Pick a directory to work inside.. something like ~/bitcoin works. The29-structure I use looks like this:30-(~ is your home directory)31-32-~/bitcoin33-~/bitcoin/trunk # source code34-~/bitcoin/deps # dependencies.. like libraries and headers needed to compile35-~/bitcoin/Bitcoin.app # the application bundle where you can run the app36-37-Just execute: mkdir ~/bitcoin38-This will create the top dir for you..39-40-WARNING: do not use the ~ notation with the configure scripts.. use the full41-name of the directory, for example /Users/james/bitcoin/deps for a user named42-'james'. In my examples I am using 'macosuser' so make sure you change that.43-44-2. Check out the trunk version of the bitcoin code from subversion:45-46-cd ~/bitcoin47-svn checkout https://bitcoin.svn.sourceforge.net/svnroot/bitcoin/trunk48-49-This will make ~/bitcoin/trunk for you with all the files from subversion. 50-51-3. Get and build the dependencies52-53-54-Boost55------56-57-Download from http://www.boost.org/users/download/58-I'm assuming it ended up in ~/Downloads..59-60-mkdir ~/bitcoin/deps61-cd ~/bitcoin/deps62-tar xvjf ~/Downloads/boost_1_42_0.tar.bz263-cd boost_1_42_064-./bootstrap.sh65-./bjam architecture=combined address-model=32_64 macosx-version=10.5 macosx-version-min=10.5 link=static runtime-link=static --toolset=darwin --prefix=/Users/macosuser/bitcoin/deps install66-67-If you're using Snow Leopard, you will need to specify 10.6 as your Mac OS X68-version instead of 10.5.69-70-This part takes a while.. use your judgement and fix it if something doesn't71-build for some reason.72-73-Change the prefix to whatever your directory is (my username in this example74-is macosuser). I'm also running on 10.6 so i have macosx-version=10.6 change75-to 10.5 if you're using leopard.76-77-This is what my output looked like at the end:78-...failed updating 2 targets...79-...skipped 144 targets...80-...updated 8074 targets...81-82-83-OpenSSL84--------85-86-Download from http://www.openssl.org/source/87-88-We would like to build this as a 32 bit/64 bit library so we actually build it89-2 times and join it together here.. If you downloaded with safari it already90-uncompressed it so it will just be a tar not a tar.gz91-92-cd ~/bitcoin/deps93-tar xvf ~/Downloads/openssl-1.0.0.tar94-mv openssl-1.0.0 openssl-1.0.0-i38695-tar xvf ~/Downloads/openssl-1.0.0.tar96-mv openssl-1.0.0 openssl-1.0.0-x86_6497-# build i386 (32 bit intel) binary98-cd openssl-1.0.0-i38699-./Configure --prefix=/Users/macosuser/bitcoin/deps --openssldir=/Users/macosuser/bitcoin/deps/openssl darwin-i386-cc && make100-make install # only do this on one of the architectures, to install the headers101-cd ..102-# build x86_64 (64 bit intel) binary103-cd openssl-1.0.0-x86_64104-./Configure --prefix=/Users/macosuser/bitcoin/deps --openssldir=/Users/macosuser/bitcoin/deps/openssl darwin64-x86_64-cc && make105-cd ..106-107-# combine the libs108-cd ~/bitcoin/deps109-lipo -arch i386 openssl-1.0.0-i386/libcrypto.a -arch x86_64 openssl-1.0.0-x86_64/libcrypto.a -o lib/libcrypto.a -create110-lipo -arch i386 openssl-1.0.0-i386/libssl.a -arch x86_64 openssl-1.0.0-x86_64/libssl.a -o lib/libssl.a -create111-112-Verify your binaries113-114-file lib/libcrypto.a115-116-output should look like this:117-118-lib/libcrypto.a: Mach-O universal binary with 2 architectures119-lib/libcrypto.a (for architecture i386): current ar archive random library120-lib/libcrypto.a (for architecture x86_64): current ar archive random library121-122-123-miniupnpc124----------125-126-The process for miniupnpc (optional) is similar to that of OpenSSL.127-128-Download from http://miniupnp.tuxfamily.org/files/.129-130-cd ~/bitcoin/deps131-tar xvf ~/Downloads/miniupnpc-1.5.tar132-mv miniupnpc-1.5 miniupnpc-1.5-x86_64133-tar xvf ~/Downloads/miniupnpc-1.5.tar134-mv miniupnpc-1.5 miniupnpc-1.5-i386135-# build x86_64 (64 bit intel) binary136-cd miniupnpc-1.5-x86_64137-export CFLAGS="-arch x86_64"138-export LDFLAGS="-arch x86_64"139-export PREFIX="/Users/macuser/bitcoin/deps"140-make && make install141-# build i386 (32 bit intel) binary142-cd miniupnpc-1.5-i386143-export CFLAGS="-arch i386"144-export LDFLAGS="-arch i386"145-export PREFIX="/Users/macuser/bitcoin/deps"146-make147-148-# combine the libs149-cd ~/bitcoin/deps150-lipo -arch i386 miniupnpc-1.5-i386/libminiupnpc.a -arch x86_64 miniupnpc-1.5-x86_64/libminiupnpc.a -o lib/libminiupnpc.a -create151-152-Verify your binaries153-154-file lib/libminiupnpc.a155-156-output should look like this:157-158-lib/libminiupnpc.a: Mach-O universal binary with 2 architectures159-lib/libminiupnpc.a (for architecture i386): current ar archive random library160-lib/libminiupnpc.a (for architecture x86_64): current ar archive random library161-162-163-Berkeley DB164------------165-166-Download from http://freshmeat.net/projects/berkeleydb/167-168-cd ~/bitcoin/deps169-tar xvf ~/Downloads/db-4.8.26.tar170-cd db-4.8.26/build_unix171-../dist/configure --prefix=/Users/macosuser/bitcoin/deps --enable-cxx && make && make install172-173-174-wxWidgets175----------176-177-This is the big one..178-179-Check it out from svn180-181-cd ~/bitcoin/deps182-svn checkout http://svn.wxwidgets.org/svn/wx/wxWidgets/trunk wxWidgets-trunk183-184-This will make a wxWidgets-trunk directory in deps.185-186-Use this script snippet, change your prefix to whatever your dir is:187-188-PREFIX=~/bitcoin/deps189-SRCDIR="$PREFIX/wxWidgets-trunk"190-BUILDDIR="$SRCDIR/macbuild"191-192-cd "$PREFIX" &&193-#svn checkout http://svn.wxwidgets.org/svn/wx/wxWidgets/trunk wxWidgets-trunk &&194-cd "$SRCDIR" &&195-196-[ -f include/wx/hashmap.h.orig ] || cp include/wx/hashmap.h include/wx/hashmap.h.orig &&197-sed 's/if wxUSE_STL/if 0 \&\& wxUSE_STL/g' < include/wx/hashmap.h.orig > include/wx/hashmap.h &&198-199-[ -f include/wx/hashset.h.orig ] || cp include/wx/hashset.h include/wx/hashset.h.orig &&200-sed 's/if wxUSE_STL/if 0 \&\& wxUSE_STL/g' < include/wx/hashset.h.orig > include/wx/hashset.h &&201-202-203-204-rm -vrf "$BUILDDIR" &&205-mkdir "$BUILDDIR" &&206-cd "$BUILDDIR" &&207-208-../configure --prefix="$PREFIX" \209---with-osx_cocoa \210---disable-shared \211---disable-debug_flag \212---with-macosx-version-min=10.5 \213---enable-stl \214---enable-utf8 \215---enable-universal_binary \216---with-libjpeg=builtin \217---with-libpng=builtin \218---with-regex=builtin \219---with-libtiff=builtin \220---with-zlib=builtin \221---with-expat=builtin \222---with-macosx-sdk=/Developer/SDKs/MacOSX10.5.sdk &&223-224-225-find . -name Makefile | 226-while read i; do 227- echo $i; 228- sed 's/-arch i386/-arch i386 -arch x86_64/g' < "$i" > "$i".new && 229- mv "$i" "$i".old && 230- mv "$i".new "$i"; 231-done232-233-234-235-make && 236-make install237-238-239-240-Now you should be able to build bitcoin241-242-cd ~/bitcoin/trunk243-make -f makefile.osx bitcoin244-245-Before you can run it, you need to create an application bundle for Mac OS.246-Create the directories in terminal using mkdir and copy the files into place.247-They are available at http://heliacal.net/~solar/bitcoin/mac-build/248-You need the Info.plist and the .ins file. The Contents/MacOS/bitcoin file is249-the output of the build.250-Your directory structure should look like this:251-252-Bitcoin.app253-Bitcoin.app/Contents254-Bitcoin.app/Contents/Info.plist255-Bitcoin.app/Contents/MacOS256-Bitcoin.app/Contents/MacOS/bitcoin257-Bitcoin.app/Contents/Resources258-Bitcoin.app/Contents/Resources/BitcoinAppIcon.icns259-260-To run it you can just click the Bitcoin.app in Finder, or just do open261-~/bitcoin/Bitcoin.app262-If you want to run it with arguments you can just run it without backgrounding263-by specifying the full name in terminal:264-~/bitcoin/Bitcoin.app/Contents/MacOS/bitcoin -addnode=192.75.207.66265-
build-unix.txt (removed)
1--- v0.3.21/build-unix.txt2+++ /dev/null3@@ -1,106 +1 @@4-Copyright (c) 2009-2010 Satoshi Nakamoto5-Distributed under the MIT/X11 software license, see the accompanying6-file license.txt or http://www.opensource.org/licenses/mit-license.php.7-This product includes software developed by the OpenSSL Project for use in8-the OpenSSL Toolkit (http://www.openssl.org/). This product includes9-cryptographic software written by Eric Young (eay@cryptsoft.com) and UPnP10-software written by Thomas Bernard.11 12-13-UNIX BUILD NOTES14-================15-16-To Build17---------18-19-make -f makefile.unix # Bitcoin with wxWidgets GUI20- or21-make -f makefile.unix bitcoind # Headless bitcoin22-23-24-Dependencies25-------------26-sudo apt-get install build-essential27-sudo apt-get install libgtk2.0-dev28-sudo apt-get install libssl-dev29-sudo apt-get install libdb4.7-dev30-sudo apt-get install libdb4.7++-dev31-Boost 1.40+: sudo apt-get install libboost-all-dev32-or Boost 1.37: sudo apt-get install libboost1.37-dev33-34-If using Boost 1.37, append -mt to the boost libraries in the makefile.35-36-Requires wxWidgets 2.9.0 or greater, which uses UTF-8. Don't try 2.8, it37-won't work.38-39-You need to download wxWidgets from http://www.wxwidgets.org/downloads/40-and build it yourself. See the build instructions and configure parameters41-below.42-43-Requires miniupnpc for UPnP port mapping. To compile with UPnP support,44-install miniupnpc and compile after setting USE_UPNP. It can be downloaded45-from http://miniupnp.tuxfamily.org/files/. 46-47-Licenses of statically linked libraries:48-wxWidgets LGPL 2.1 with very liberal exceptions49-Berkeley DB New BSD license with additional requirement that linked software must be free open source50-Boost MIT-like license51-miniupnpc New (3-clause) BSD license52-53-Versions used in this release:54-GCC 4.3.355-OpenSSL 0.9.8g56-wxWidgets 2.9.057-Berkeley DB 4.7.25.NC58-Boost 1.3759-miniupnpc 1.560-61-62-Notes63------64-The UI layout is edited with wxFormBuilder. The project file is65-uiproject.fbp. It generates uibase.cpp and uibase.h, which define base66-classes that do the rote work of constructing all the UI elements.67-68-The release is built with GCC and then "strip bitcoin" to strip the debug69-symbols, which reduces the executable size by about 90%.70-71-72-wxWidgets73----------74-cd /usr/local75-tar -xzvf wxWidgets-2.9.0.tar.gz76-cd wxWidgets-2.9.077-mkdir buildgtk78-cd buildgtk79-../configure --with-gtk --enable-debug --disable-shared --enable-monolithic80-make81-sudo su82-make install83-ldconfig84-85-86-miniupnpc87----------88-tar -xzvf miniupnpc-1.5.tar.gz89-cd miniupnpc-1.590-make91-sudo su92-make install93-94-95-Berkeley DB96------------97-You need Berkeley DB 4.7. Don't use 4.8, the database/log0000* files98-are incompatible. If you have to build Berkeley DB yourself:99-../dist/configure --enable-cxx100-make101-102-103-Boost104------105-If you need to build Boost yourself:106-sudo su107-./bootstrap.sh108-./bjam install109-
coding.txt (removed)
1--- v0.3.21/coding.txt2+++ /dev/null3@@ -1,42 +1 @@4-Please be consistent with the existing coding style.5 6-Block style:7-8-bool Function(char* psz, int n)9-{10- // Comment summarising what this section of code does11- for (int i = 0; i < n; i++)12- {13- // When something fails, return early14- if (!Something())15- return false;16- ...17- }18-19- // Success return is usually at the end20- return true;21-}22-23-- ANSI/Allman block style24-- 4 space indenting, no tabs25-- No extra spaces inside parenthesis; please don't do ( this )26-- No space after function names, one space after if, for and while27-28-Variable names begin with the type in lowercase, like nSomeVariable.29-Please don't put the first word of the variable name in lowercase like30-someVariable.31-32-Common types:33-n integer number: short, unsigned short, int, unsigned int,34- int64, uint64, sometimes char if used as a number35-d double, float36-f flag37-hash uint25638-p pointer or array, one p for each level of indirection39-psz pointer to null terminated string40-str string object41-v vector or similar list objects42-map map or multimap43-set set or multiset44-bn CBigNum45-
db.cpp (modified)
1--- v0.3.21/db.cpp2+++ v0.3.22/db.cpp3@@ -3,6 +3,9 @@4 // file license.txt or http://www.opensource.org/licenses/mit-license.php.5 6 #include "headers.h"7+8+using namespace std;9+using namespace boost;10 11 void ThreadFlushWalletDB(void* parg);12 13@@ -434,13 +437,13 @@14 // Calculate bnChainWork15 vector<pair<int, CBlockIndex*> > vSortedByHeight;16 vSortedByHeight.reserve(mapBlockIndex.size());17- foreach(const PAIRTYPE(uint256, CBlockIndex*)& item, mapBlockIndex)18+ BOOST_FOREACH(const PAIRTYPE(uint256, CBlockIndex*)& item, mapBlockIndex)19 {20 CBlockIndex* pindex = item.second;21 vSortedByHeight.push_back(make_pair(pindex->nHeight, pindex));22 }23 sort(vSortedByHeight.begin(), vSortedByHeight.end());24- foreach(const PAIRTYPE(int, CBlockIndex*)& item, vSortedByHeight)25+ BOOST_FOREACH(const PAIRTYPE(int, CBlockIndex*)& item, vSortedByHeight)26 {27 CBlockIndex* pindex = item.second;28 pindex->bnChainWork = (pindex->pprev ? pindex->pprev->bnChainWork : 0) + pindex->GetBlockWork();29@@ -603,7 +606,7 @@30 ListAccountCreditDebit(strAccount, entries);31 32 int64 nCreditDebit = 0;33- foreach (const CAccountingEntry& entry, entries)34+ BOOST_FOREACH (const CAccountingEntry& entry, entries)35 nCreditDebit += entry.nCreditDebit;36 37 return nCreditDebit;38@@ -778,10 +781,10 @@39 string strKey;40 ssKey >> strKey;41 42- // Menu state43+ // Options44+#ifndef GUI45 if (strKey == "fGenerateBitcoins") ssValue >> fGenerateBitcoins;46-47- // Options48+#endif49 if (strKey == "nTransactionFee") ssValue >> nTransactionFee;50 if (strKey == "addrIncoming") ssValue >> addrIncoming;51 if (strKey == "fLimitProcessors") ssValue >> fLimitProcessors;52@@ -796,7 +799,7 @@53 pcursor->close();54 }55 56- foreach(uint256 hash, vWalletUpgrade)57+ BOOST_FOREACH(uint256 hash, vWalletUpgrade)58 WriteTx(hash, mapWallet[hash]);59 60 printf("nFileVersion = %d\n", nFileVersion);
db.h (modified)
1--- v0.3.21/db.h2+++ v0.3.22/db.h3@@ -1,6 +1,16 @@4 // Copyright (c) 2009-2010 Satoshi Nakamoto5 // Distributed under the MIT/X11 software license, see the accompanying6 // file license.txt or http://www.opensource.org/licenses/mit-license.php.7+#ifndef BITCOIN_DB_H8+#define BITCOIN_DB_H9+10+#include "key.h"11+12+#include <map>13+#include <string>14+#include <vector>15+16+#include <db_cxx.h>17 18 class CTransaction;19 class CTxIndex;20@@ -15,9 +25,9 @@21 class CAccountingEntry;22 class CBlockLocator;23 24-extern map<string, string> mapAddressBook;25+extern std::map<std::string, std::string> mapAddressBook;26 extern CCriticalSection cs_mapAddressBook;27-extern vector<unsigned char> vchDefaultKey;28+extern std::vector<unsigned char> vchDefaultKey;29 extern bool fClient;30 extern int nBestHeight;31 32@@ -27,7 +37,7 @@33 34 35 extern void DBFlush(bool fShutdown);36-extern vector<unsigned char> GetKeyFromKeyPool();37+extern std::vector<unsigned char> GetKeyFromKeyPool();38 extern int64 GetOldestKeyPoolTime();39 40 41@@ -37,8 +47,8 @@42 {43 protected:44 Db* pdb;45- string strFile;46- vector<DbTxn*> vTxn;47+ std::string strFile;48+ std::vector<DbTxn*> vTxn;49 bool fReadOnly;50 51 explicit CDB(const char* pszFile, const char* pszMode="r+");52@@ -247,12 +257,12 @@53 bool ReadVersion(int& nVersion)54 {55 nVersion = 0;56- return Read(string("version"), nVersion);57+ return Read(std::string("version"), nVersion);58 }59 60 bool WriteVersion(int nVersion)61 {62- return Write(string("version"), nVersion);63+ return Write(std::string("version"), nVersion);64 }65 };66 67@@ -276,7 +286,7 @@68 bool AddTxIndex(const CTransaction& tx, const CDiskTxPos& pos, int nHeight);69 bool EraseTxIndex(const CTransaction& tx);70 bool ContainsTx(uint256 hash);71- bool ReadOwnerTxes(uint160 hash160, int nHeight, vector<CTransaction>& vtx);72+ bool ReadOwnerTxes(uint160 hash160, int nHeight, std::vector<CTransaction>& vtx);73 bool ReadDiskTx(uint256 hash, CTransaction& tx, CTxIndex& txindex);74 bool ReadDiskTx(uint256 hash, CTransaction& tx);75 bool ReadDiskTx(COutPoint outpoint, CTransaction& tx, CTxIndex& txindex);76@@ -318,14 +328,14 @@77 {78 public:79 int64 nTime;80- vector<unsigned char> vchPubKey;81+ std::vector<unsigned char> vchPubKey;82 83 CKeyPool()84 {85 nTime = GetTime();86 }87 88- CKeyPool(const vector<unsigned char>& vchPubKeyIn)89+ CKeyPool(const std::vector<unsigned char>& vchPubKeyIn)90 {91 nTime = GetTime();92 vchPubKey = vchPubKeyIn;93@@ -353,101 +363,101 @@94 CWalletDB(const CWalletDB&);95 void operator=(const CWalletDB&);96 public:97- bool ReadName(const string& strAddress, string& strName)98+ bool ReadName(const std::string& strAddress, std::string& strName)99 {100 strName = "";101- return Read(make_pair(string("name"), strAddress), strName);102- }103-104- bool WriteName(const string& strAddress, const string& strName)105+ return Read(std::make_pair(std::string("name"), strAddress), strName);106+ }107+108+ bool WriteName(const std::string& strAddress, const std::string& strName)109 {110 CRITICAL_BLOCK(cs_mapAddressBook)111 mapAddressBook[strAddress] = strName;112 nWalletDBUpdated++;113- return Write(make_pair(string("name"), strAddress), strName);114- }115-116- bool EraseName(const string& strAddress)117+ return Write(std::make_pair(std::string("name"), strAddress), strName);118+ }119+120+ bool EraseName(const std::string& strAddress)121 {122 // This should only be used for sending addresses, never for receiving addresses,123 // receiving addresses must always have an address book entry if they're not change return.124 CRITICAL_BLOCK(cs_mapAddressBook)125 mapAddressBook.erase(strAddress);126 nWalletDBUpdated++;127- return Erase(make_pair(string("name"), strAddress));128+ return Erase(std::make_pair(std::string("name"), strAddress));129 }130 131 bool ReadTx(uint256 hash, CWalletTx& wtx)132 {133- return Read(make_pair(string("tx"), hash), wtx);134+ return Read(std::make_pair(std::string("tx"), hash), wtx);135 }136 137 bool WriteTx(uint256 hash, const CWalletTx& wtx)138 {139 nWalletDBUpdated++;140- return Write(make_pair(string("tx"), hash), wtx);141+ return Write(std::make_pair(std::string("tx"), hash), wtx);142 }143 144 bool EraseTx(uint256 hash)145 {146 nWalletDBUpdated++;147- return Erase(make_pair(string("tx"), hash));148- }149-150- bool ReadKey(const vector<unsigned char>& vchPubKey, CPrivKey& vchPrivKey)151+ return Erase(std::make_pair(std::string("tx"), hash));152+ }153+154+ bool ReadKey(const std::vector<unsigned char>& vchPubKey, CPrivKey& vchPrivKey)155 {156 vchPrivKey.clear();157- return Read(make_pair(string("key"), vchPubKey), vchPrivKey);158- }159-160- bool WriteKey(const vector<unsigned char>& vchPubKey, const CPrivKey& vchPrivKey)161- {162- nWalletDBUpdated++;163- return Write(make_pair(string("key"), vchPubKey), vchPrivKey, false);164+ return Read(std::make_pair(std::string("key"), vchPubKey), vchPrivKey);165+ }166+167+ bool WriteKey(const std::vector<unsigned char>& vchPubKey, const CPrivKey& vchPrivKey)168+ {169+ nWalletDBUpdated++;170+ return Write(std::make_pair(std::string("key"), vchPubKey), vchPrivKey, false);171 }172 173 bool WriteBestBlock(const CBlockLocator& locator)174 {175 nWalletDBUpdated++;176- return Write(string("bestblock"), locator);177+ return Write(std::string("bestblock"), locator);178 }179 180 bool ReadBestBlock(CBlockLocator& locator)181 {182- return Read(string("bestblock"), locator);183- }184-185- bool ReadDefaultKey(vector<unsigned char>& vchPubKey)186+ return Read(std::string("bestblock"), locator);187+ }188+189+ bool ReadDefaultKey(std::vector<unsigned char>& vchPubKey)190 {191 vchPubKey.clear();192- return Read(string("defaultkey"), vchPubKey);193- }194-195- bool WriteDefaultKey(const vector<unsigned char>& vchPubKey)196+ return Read(std::string("defaultkey"), vchPubKey);197+ }198+199+ bool WriteDefaultKey(const std::vector<unsigned char>& vchPubKey)200 {201 vchDefaultKey = vchPubKey;202 nWalletDBUpdated++;203- return Write(string("defaultkey"), vchPubKey);204+ return Write(std::string("defaultkey"), vchPubKey);205 }206 207 template<typename T>208- bool ReadSetting(const string& strKey, T& value)209- {210- return Read(make_pair(string("setting"), strKey), value);211+ bool ReadSetting(const std::string& strKey, T& value)212+ {213+ return Read(std::make_pair(std::string("setting"), strKey), value);214 }215 216 template<typename T>217- bool WriteSetting(const string& strKey, const T& value)218- {219- nWalletDBUpdated++;220- return Write(make_pair(string("setting"), strKey), value);221- }222-223- bool ReadAccount(const string& strAccount, CAccount& account);224- bool WriteAccount(const string& strAccount, const CAccount& account);225+ bool WriteSetting(const std::string& strKey, const T& value)226+ {227+ nWalletDBUpdated++;228+ return Write(std::make_pair(std::string("setting"), strKey), value);229+ }230+231+ bool ReadAccount(const std::string& strAccount, CAccount& account);232+ bool WriteAccount(const std::string& strAccount, const CAccount& account);233 bool WriteAccountingEntry(const CAccountingEntry& acentry);234- int64 GetAccountCreditDebit(const string& strAccount);235- void ListAccountCreditDebit(const string& strAccount, list<CAccountingEntry>& acentries);236+ int64 GetAccountCreditDebit(const std::string& strAccount);237+ void ListAccountCreditDebit(const std::string& strAccount, std::list<CAccountingEntry>& acentries);238 239 bool LoadWallet();240 protected:241@@ -455,14 +465,14 @@242 void KeepKey(int64 nIndex);243 static void ReturnKey(int64 nIndex);244 friend class CReserveKey;245- friend vector<unsigned char> GetKeyFromKeyPool();246+ friend std::vector<unsigned char> GetKeyFromKeyPool();247 friend int64 GetOldestKeyPoolTime();248 };249 250 bool LoadWallet(bool& fFirstRunRet);251-void BackupWallet(const string& strDest);252-253-inline bool SetAddressBookName(const string& strAddress, const string& strName)254+void BackupWallet(const std::string& strDest);255+256+inline bool SetAddressBookName(const std::string& strAddress, const std::string& strName)257 {258 return CWalletDB().WriteName(strAddress, strName);259 }260@@ -471,7 +481,7 @@261 {262 protected:263 int64 nIndex;264- vector<unsigned char> vchPubKey;265+ std::vector<unsigned char> vchPubKey;266 public:267 CReserveKey()268 {269@@ -484,7 +494,7 @@270 ReturnKey();271 }272 273- vector<unsigned char> GetReservedKey()274+ std::vector<unsigned char> GetReservedKey()275 {276 if (nIndex == -1)277 {278@@ -513,3 +523,5 @@279 }280 };281 282+#endif283+
headers.h (modified)
1--- v0.3.21/headers.h2+++ v0.3.22/headers.h3@@ -109,8 +109,6 @@4 5 6 #pragma hdrstop7-using namespace std;8-using namespace boost;9 10 #include "strlcpy.h"11 #include "serialize.h"12@@ -133,6 +131,7 @@13 #endif14 #include "init.h"15 16+#ifdef GUI17 #include "xpm/addressbook16.xpm"18 #include "xpm/addressbook20.xpm"19 #include "xpm/bitcoin16.xpm"20@@ -145,4 +144,5 @@21 #include "xpm/send16noshadow.xpm"22 #include "xpm/send20.xpm"23 #include "xpm/about.xpm"24+#endif25
init.cpp (modified)
1--- v0.3.21/init.cpp2+++ v0.3.22/init.cpp3@@ -1,14 +1,10 @@4 // Copyright (c) 2009-2010 Satoshi Nakamoto5 // Distributed under the MIT/X11 software license, see the accompanying6 // file license.txt or http://www.opensource.org/licenses/mit-license.php.7-8 #include "headers.h"9 10-11-12-13-14-15+using namespace std;16+using namespace boost;17 18 //////////////////////////////////////////////////////////////////////////////19 //20@@ -71,7 +67,6 @@21 //22 // Start23 //24-25 #ifndef GUI26 int main(int argc, char* argv[])27 {28@@ -158,6 +153,7 @@29 " -min \t\t " + _("Start minimized\n") +30 " -datadir=<dir> \t\t " + _("Specify data directory\n") +31 " -proxy=<ip:port> \t " + _("Connect through socks4 proxy\n") +32+ " -dns \t " + _("Allow DNS lookups for addnode and connect\n") +33 " -addnode=<ip> \t " + _("Add a node to connect to\n") +34 " -connect=<ip> \t\t " + _("Connect only to the specified node\n") +35 " -nolisten \t " + _("Don't accept connections from outside\n") +36@@ -208,6 +204,7 @@37 }38 39 fDebug = GetBoolArg("-debug");40+ fAllowDNS = GetBoolArg("-dns");41 42 #ifndef __WXMSW__43 fDaemon = GetBoolArg("-daemon");44@@ -326,7 +323,7 @@45 // Make sure only a single bitcoin process is using the data directory.46 string strLockFile = GetDataDir() + "/.lock";47 FILE* file = fopen(strLockFile.c_str(), "a"); // empty lock file; created if it doesn't exist.48- fclose(file);49+ if (file) fclose(file);50 static boost::interprocess::file_lock lock(strLockFile.c_str());51 if (!lock.try_lock())52 {53@@ -456,9 +453,9 @@54 55 if (mapArgs.count("-addnode"))56 {57- foreach(string strAddr, mapMultiArgs["-addnode"])58- {59- CAddress addr(strAddr, NODE_NETWORK);60+ BOOST_FOREACH(string strAddr, mapMultiArgs["-addnode"])61+ {62+ CAddress addr(strAddr, fAllowDNS);63 addr.nTime = 0; // so it won't relay unless successfully connected64 if (addr.IsValid())65 AddAddress(addr);
init.h (modified)
1--- v0.3.21/init.h2+++ v0.3.22/init.h3@@ -1,8 +1,12 @@4 // Copyright (c) 2009-2010 Satoshi Nakamoto5 // Distributed under the MIT/X11 software license, see the accompanying6 // file license.txt or http://www.opensource.org/licenses/mit-license.php.7+#ifndef BITCOIN_INIT_H8+#define BITCOIN_INIT_H9 10 void Shutdown(void* parg);11 bool AppInit(int argc, char* argv[]);12 bool AppInit2(int argc, char* argv[]);13 14+#endif15+
irc.cpp (modified)
1--- v0.3.21/irc.cpp2+++ v0.3.22/irc.cpp3@@ -3,6 +3,9 @@4 // file license.txt or http://www.opensource.org/licenses/mit-license.php.5 6 #include "headers.h"7+8+using namespace std;9+using namespace boost;10 11 int nGotIRCAddresses = 0;12 bool fGotExternalIP = false;13@@ -41,7 +44,7 @@14 return false;15 memcpy(&tmp, &vch[0], sizeof(tmp));16 17- addr = CAddress(tmp.ip, tmp.port, NODE_NETWORK);18+ addr = CAddress(tmp.ip, ntohs(tmp.port), NODE_NETWORK);19 return true;20 }21 22@@ -215,25 +218,15 @@23 return false;24 string strHost = str.substr(str.rfind("@")+1);25 26- unsigned int a=0, b=0, c=0, d=0;27- if (sscanf(strHost.c_str(), "%u.%u.%u.%u", &a, &b, &c, &d) == 4 &&28- inet_addr(strHost.c_str()) != INADDR_NONE)29- {30- printf("GetIPFromIRC() userhost is IP %s\n", strHost.c_str());31- ipRet = CAddress(strHost).ip;32- }33- else34- {35- // Hybrid IRC used by lfnet always returns IP when you userhost yourself,36- // but in case another IRC is ever used this should work.37- printf("GetIPFromIRC() got userhost %s\n", strHost.c_str());38- if (fUseProxy)39- return false;40- struct hostent* phostent = gethostbyname(strHost.c_str());41- if (!phostent || !phostent->h_addr_list || !phostent->h_addr_list[0])42- return false;43- ipRet = *(u_long*)phostent->h_addr_list[0];44- }45+ // Hybrid IRC used by lfnet always returns IP when you userhost yourself,46+ // but in case another IRC is ever used this should work.47+ printf("GetIPFromIRC() got userhost %s\n", strHost.c_str());48+ if (fUseProxy)49+ return false;50+ CAddress addr(strHost, 0, true);51+ if (!addr.IsValid())52+ return false;53+ ipRet = addr.ip;54 55 return true;56 }57@@ -272,13 +265,13 @@58 while (!fShutdown)59 {60 //CAddress addrConnect("216.155.130.130:6667"); // chat.freenode.net61- CAddress addrConnect("92.243.23.21:6667"); // irc.lfnet.org62+ CAddress addrConnect("92.243.23.21", 6667); // irc.lfnet.org63 if (!fTOR)64 {65 //struct hostent* phostent = gethostbyname("chat.freenode.net");66- struct hostent* phostent = gethostbyname("irc.lfnet.org");67- if (phostent && phostent->h_addr_list && phostent->h_addr_list[0])68- addrConnect = CAddress(*(u_long*)phostent->h_addr_list[0], htons(6667));69+ CAddress addrIRC("irc.lfnet.org", 6667, true);70+ if (addrIRC.IsValid())71+ addrConnect = addrIRC;72 }73 74 SOCKET hSocket;75@@ -346,9 +339,16 @@76 Send(hSocket, strprintf("NICK %s\r", strMyName.c_str()).c_str());77 }78 }79-80- Send(hSocket, fTestNet ? "JOIN #bitcoinTEST\r" : "JOIN #bitcoin\r");81- Send(hSocket, fTestNet ? "WHO #bitcoinTEST\r" : "WHO #bitcoin\r");82+ 83+ if (fTestNet) {84+ Send(hSocket, "JOIN #bitcoinTEST\r");85+ Send(hSocket, "WHO #bitcoinTEST\r");86+ } else {87+ // randomly join #bitcoin00-#bitcoin9988+ int channel_number = GetRandInt(100);89+ Send(hSocket, strprintf("JOIN #bitcoin%02d\r", channel_number).c_str());90+ Send(hSocket, strprintf("WHO #bitcoin%02d\r", channel_number).c_str());91+ }92 93 int64 nStart = GetTime();94 string strLine;95@@ -390,7 +390,7 @@96 {97 addr.nTime = GetAdjustedTime();98 if (AddAddress(addr, 51 * 60))99- printf("IRC got new address\n");100+ printf("IRC got new address: %s\n", addr.ToString().c_str());101 nGotIRCAddresses++;102 }103 else
irc.h (modified)
1--- v0.3.21/irc.h2+++ v0.3.22/irc.h3@@ -1,10 +1,14 @@4 // Copyright (c) 2009-2010 Satoshi Nakamoto5 // Distributed under the MIT/X11 software license, see the accompanying6 // file license.txt or http://www.opensource.org/licenses/mit-license.php.7+#ifndef BITCOIN_IRC_H8+#define BITCOIN_IRC_H9 10-bool RecvLine(SOCKET hSocket, string& strLine);11+bool RecvLine(SOCKET hSocket, std::string& strLine);12 void ThreadIRCSeed(void* parg);13 14 extern int nGotIRCAddresses;15 extern bool fGotExternalIP;16 17+#endif18+
key.h (modified)
1--- v0.3.21/key.h2+++ v0.3.22/key.h3@@ -1,7 +1,12 @@4 // Copyright (c) 2009-2010 Satoshi Nakamoto5 // Distributed under the MIT/X11 software license, see the accompanying6 // file license.txt or http://www.opensource.org/licenses/mit-license.php.7+#ifndef BITCOIN_KEY_H8+#define BITCOIN_KEY_H9 10+#include <openssl/ec.h>11+#include <openssl/ecdsa.h>12+#include <openssl/obj_mac.h>13 14 // secp160k115 // const unsigned int PRIVATE_KEY_SIZE = 192;16@@ -36,7 +41,7 @@17 18 19 // secure_allocator is defined in serialize.h20-typedef vector<unsigned char, secure_allocator<unsigned char> > CPrivKey;21+typedef std::vector<unsigned char, secure_allocator<unsigned char> > CPrivKey;22 23 24 25@@ -109,7 +114,7 @@26 return vchPrivKey;27 }28 29- bool SetPubKey(const vector<unsigned char>& vchPubKey)30+ bool SetPubKey(const std::vector<unsigned char>& vchPubKey)31 {32 const unsigned char* pbegin = &vchPubKey[0];33 if (!o2i_ECPublicKey(&pkey, &pbegin, vchPubKey.size()))34@@ -118,19 +123,19 @@35 return true;36 }37 38- vector<unsigned char> GetPubKey() const39+ std::vector<unsigned char> GetPubKey() const40 {41 unsigned int nSize = i2o_ECPublicKey(pkey, NULL);42 if (!nSize)43 throw key_error("CKey::GetPubKey() : i2o_ECPublicKey failed");44- vector<unsigned char> vchPubKey(nSize, 0);45+ std::vector<unsigned char> vchPubKey(nSize, 0);46 unsigned char* pbegin = &vchPubKey[0];47 if (i2o_ECPublicKey(pkey, &pbegin) != nSize)48 throw key_error("CKey::GetPubKey() : i2o_ECPublicKey returned unexpected size");49 return vchPubKey;50 }51 52- bool Sign(uint256 hash, vector<unsigned char>& vchSig)53+ bool Sign(uint256 hash, std::vector<unsigned char>& vchSig)54 {55 vchSig.clear();56 unsigned char pchSig[10000];57@@ -142,7 +147,7 @@58 return true;59 }60 61- bool Verify(uint256 hash, const vector<unsigned char>& vchSig)62+ bool Verify(uint256 hash, const std::vector<unsigned char>& vchSig)63 {64 // -1 = error, 0 = bad sig, 1 = good65 if (ECDSA_verify(0, (unsigned char*)&hash, sizeof(hash), &vchSig[0], vchSig.size(), pkey) != 1)66@@ -150,7 +155,7 @@67 return true;68 }69 70- static bool Sign(const CPrivKey& vchPrivKey, uint256 hash, vector<unsigned char>& vchSig)71+ static bool Sign(const CPrivKey& vchPrivKey, uint256 hash, std::vector<unsigned char>& vchSig)72 {73 CKey key;74 if (!key.SetPrivKey(vchPrivKey))75@@ -158,7 +163,7 @@76 return key.Sign(hash, vchSig);77 }78 79- static bool Verify(const vector<unsigned char>& vchPubKey, uint256 hash, const vector<unsigned char>& vchSig)80+ static bool Verify(const std::vector<unsigned char>& vchPubKey, uint256 hash, const std::vector<unsigned char>& vchSig)81 {82 CKey key;83 if (!key.SetPubKey(vchPubKey))84@@ -167,3 +172,5 @@85 }86 };87 88+#endif89+
license.txt (removed)
1--- v0.3.21/license.txt2+++ /dev/null3@@ -1,20 +1 @@4-Copyright (c) 2009-2011 Bitcoin Developers5 6-Permission is hereby granted, free of charge, to any person obtaining a copy7-of this software and associated documentation files (the "Software"), to deal8-in the Software without restriction, including without limitation the rights9-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell10-copies of the Software, and to permit persons to whom the Software is11-furnished to do so, subject to the following conditions:12-13-The above copyright notice and this permission notice shall be included in14-all copies or substantial portions of the Software.15-16-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR17-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,18-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE19-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER20-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,21-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN22-THE SOFTWARE.23-
main.cpp (modified)
1--- v0.3.21/main.cpp2+++ v0.3.22/main.cpp3@@ -1,13 +1,11 @@4 // Copyright (c) 2009-2010 Satoshi Nakamoto5 // Distributed under the MIT/X11 software license, see the accompanying6 // file license.txt or http://www.opensource.org/licenses/mit-license.php.7-8 #include "headers.h"9 #include "cryptopp/sha.h"10 11-12-13-14+using namespace std;15+using namespace boost;16 17 //18 // Global state19@@ -65,12 +63,10 @@20 int nLimitProcessors = 1;21 int fMinimizeToTray = true;22 int fMinimizeOnClose = true;23-#ifdef USE_UPNP24 #if USE_UPNP25 int fUseUPnP = true;26 #else27 int fUseUPnP = false;28-#endif29 #endif30 31 32@@ -158,7 +154,7 @@33 // If default receiving address gets used, replace it with a new one34 CScript scriptDefaultKey;35 scriptDefaultKey.SetBitcoinAddress(vchDefaultKey);36- foreach(const CTxOut& txout, wtx.vout)37+ BOOST_FOREACH(const CTxOut& txout, wtx.vout)38 {39 if (txout.scriptPubKey == scriptDefaultKey)40 {41@@ -246,7 +242,7 @@42 if (mapOrphanTransactions.count(hash))43 return;44 CDataStream* pvMsg = mapOrphanTransactions[hash] = new CDataStream(vMsg);45- foreach(const CTxIn& txin, tx.vin)46+ BOOST_FOREACH(const CTxIn& txin, tx.vin)47 mapOrphanTransactionsByPrev.insert(make_pair(txin.prevout.hash, pvMsg));48 }49 50@@ -257,7 +253,7 @@51 const CDataStream* pvMsg = mapOrphanTransactions[hash];52 CTransaction tx;53 CDataStream(*pvMsg) >> tx;54- foreach(const CTxIn& txin, tx.vin)55+ BOOST_FOREACH(const CTxIn& txin, tx.vin)56 {57 for (multimap<uint256, CDataStream*>::iterator mi = mapOrphanTransactionsByPrev.lower_bound(txin.prevout.hash);58 mi != mapOrphanTransactionsByPrev.upper_bound(txin.prevout.hash);)59@@ -428,7 +424,7 @@60 61 // Sent/received. Standard client will never generate a send-to-multiple-recipients,62 // but non-standard clients might (so return a list of address/amount pairs)63- foreach(const CTxOut& txout, vout)64+ BOOST_FOREACH(const CTxOut& txout, vout)65 {66 string address;67 uint160 hash160;68@@ -473,13 +469,13 @@69 nGenerated = allGeneratedMature;70 if (strAccount == strSentAccount)71 {72- foreach(const PAIRTYPE(string,int64)& s, listSent)73+ BOOST_FOREACH(const PAIRTYPE(string,int64)& s, listSent)74 nSent += s.second;75 nFee = allFee;76 }77 CRITICAL_BLOCK(cs_mapAddressBook)78 {79- foreach(const PAIRTYPE(string,int64)& r, listReceived)80+ BOOST_FOREACH(const PAIRTYPE(string,int64)& r, listReceived)81 {82 if (mapAddressBook.count(r.first))83 {84@@ -559,7 +555,7 @@85 if (SetMerkleBranch() < COPY_DEPTH)86 {87 vector<uint256> vWorkQueue;88- foreach(const CTxIn& txin, vin)89+ BOOST_FOREACH(const CTxIn& txin, vin)90 vWorkQueue.push_back(txin.prevout.hash);91 92 // This critsect is OK because txdb is already open93@@ -578,7 +574,7 @@94 if (mapWallet.count(hash))95 {96 tx = mapWallet[hash];97- foreach(const CMerkleTx& txWalletPrev, mapWallet[hash].vtxPrev)98+ BOOST_FOREACH(const CMerkleTx& txWalletPrev, mapWallet[hash].vtxPrev)99 mapWalletPrev[txWalletPrev.GetHash()] = &txWalletPrev;100 }101 else if (mapWalletPrev.count(hash))102@@ -599,7 +595,7 @@103 vtxPrev.push_back(tx);104 105 if (nDepth < COPY_DEPTH)106- foreach(const CTxIn& txin, tx.vin)107+ BOOST_FOREACH(const CTxIn& txin, tx.vin)108 vWorkQueue.push_back(txin.prevout.hash);109 }110 }111@@ -630,7 +626,7 @@112 113 // Check for negative or overflow output values114 int64 nValueOut = 0;115- foreach(const CTxOut& txout, vout)116+ BOOST_FOREACH(const CTxOut& txout, vout)117 {118 if (txout.nValue < 0)119 return error("CTransaction::CheckTransaction() : txout.nValue negative");120@@ -648,7 +644,7 @@121 }122 else123 {124- foreach(const CTxIn& txin, vin)125+ BOOST_FOREACH(const CTxIn& txin, vin)126 if (txin.prevout.IsNull())127 return error("CTransaction::CheckTransaction() : prevout is null");128 }129@@ -681,8 +677,8 @@130 if (GetSigOpCount() > nSize / 34 || nSize < 100)131 return error("AcceptToMemoryPool() : nonstandard transaction");132 133- // Rather not work on nonstandard transactions134- if (!IsStandard())135+ // Rather not work on nonstandard transactions (unless -testnet)136+ if (!fTestNet && !IsStandard())137 return error("AcceptToMemoryPool() : nonstandard transaction type");138 139 // Do we already have it?140@@ -735,13 +731,13 @@141 }142 143 // Don't accept it if it can't get into a block144- if (nFees < GetMinFee(1000))145+ if (nFees < GetMinFee(1000, true, true))146 return error("AcceptToMemoryPool() : not enough fees");147 148 // Continuously rate-limit free transactions149 // This mitigates 'penny-flooding' -- sending thousands of free transactions just to150 // be annoying or make other's transactions take longer to confirm.151- if (nFees < CENT)152+ if (nFees < MIN_RELAY_TX_FEE)153 {154 static CCriticalSection cs;155 static double dFreeCount;156@@ -806,7 +802,7 @@157 // Remove transaction from memory pool158 CRITICAL_BLOCK(cs_mapTransactions)159 {160- foreach(const CTxIn& txin, vin)161+ BOOST_FOREACH(const CTxIn& txin, vin)162 mapNextTx.erase(txin.prevout);163 mapTransactions.erase(GetHash());164 nTransactionsUpdated++;165@@ -874,7 +870,7 @@166 CRITICAL_BLOCK(cs_mapTransactions)167 {168 // Add previous supporting transactions first169- foreach(CMerkleTx& tx, vtxPrev)170+ BOOST_FOREACH(CMerkleTx& tx, vtxPrev)171 {172 if (!tx.IsCoinBase())173 {174@@ -899,7 +895,7 @@175 {176 CBlock block;177 block.ReadFromDisk(pindex, true);178- foreach(CTransaction& tx, block.vtx)179+ BOOST_FOREACH(CTransaction& tx, block.vtx)180 {181 if (AddToWalletIfInvolvingMe(tx, &block))182 ret++;183@@ -918,7 +914,7 @@184 {185 fRepeat = false;186 vector<CDiskTxPos> vMissingTx;187- foreach(PAIRTYPE(const uint256, CWalletTx)& item, mapWallet)188+ BOOST_FOREACH(PAIRTYPE(const uint256, CWalletTx)& item, mapWallet)189 {190 CWalletTx& wtx = item.second;191 if (wtx.IsCoinBase() && wtx.IsSpent(0))192@@ -971,7 +967,7 @@193 194 void CWalletTx::RelayWalletTransaction(CTxDB& txdb)195 {196- foreach(const CMerkleTx& tx, vtxPrev)197+ BOOST_FOREACH(const CMerkleTx& tx, vtxPrev)198 {199 if (!tx.IsCoinBase())200 {201@@ -1016,7 +1012,7 @@202 {203 // Sort them in chronological order204 multimap<unsigned int, CWalletTx*> mapSorted;205- foreach(PAIRTYPE(const uint256, CWalletTx)& item, mapWallet)206+ BOOST_FOREACH(PAIRTYPE(const uint256, CWalletTx)& item, mapWallet)207 {208 CWalletTx& wtx = item.second;209 // Don't rebroadcast until it's had plenty of time that210@@ -1024,7 +1020,7 @@211 if (nTimeBestReceived - (int64)wtx.nTimeReceived > 5 * 60)212 mapSorted.insert(make_pair(wtx.nTimeReceived, &wtx));213 }214- foreach(PAIRTYPE(const unsigned int, CWalletTx*)& item, mapSorted)215+ BOOST_FOREACH(PAIRTYPE(const unsigned int, CWalletTx*)& item, mapSorted)216 {217 CWalletTx& wtx = *item.second;218 wtx.RelayWalletTransaction(txdb);219@@ -1200,7 +1196,7 @@220 // Relinquish previous transactions' spent pointers221 if (!IsCoinBase())222 {223- foreach(const CTxIn& txin, vin)224+ BOOST_FOREACH(const CTxIn& txin, vin)225 {226 COutPoint prevout = txin.prevout;227 228@@ -1423,7 +1419,7 @@229 230 map<uint256, CTxIndex> mapUnused;231 int64 nFees = 0;232- foreach(CTransaction& tx, vtx)233+ BOOST_FOREACH(CTransaction& tx, vtx)234 {235 CDiskTxPos posThisTx(pindex->nFile, pindex->nBlockPos, nTxPos);236 nTxPos += ::GetSerializeSize(tx, SER_DISK);237@@ -1446,7 +1442,7 @@238 }239 240 // Watch for transactions paying to me241- foreach(CTransaction& tx, vtx)242+ BOOST_FOREACH(CTransaction& tx, vtx)243 AddToWalletIfInvolvingMe(tx, this, true);244 245 return true;246@@ -1483,7 +1479,7 @@247 248 // Disconnect shorter branch249 vector<CTransaction> vResurrect;250- foreach(CBlockIndex* pindex, vDisconnect)251+ BOOST_FOREACH(CBlockIndex* pindex, vDisconnect)252 {253 CBlock block;254 if (!block.ReadFromDisk(pindex))255@@ -1492,7 +1488,7 @@256 return error("Reorganize() : DisconnectBlock failed");257 258 // Queue memory transactions to resurrect259- foreach(const CTransaction& tx, block.vtx)260+ BOOST_FOREACH(const CTransaction& tx, block.vtx)261 if (!tx.IsCoinBase())262 vResurrect.push_back(tx);263 }264@@ -1513,7 +1509,7 @@265 }266 267 // Queue memory transactions to delete268- foreach(const CTransaction& tx, block.vtx)269+ BOOST_FOREACH(const CTransaction& tx, block.vtx)270 vDelete.push_back(tx);271 }272 if (!txdb.WriteHashBestChain(pindexNew->GetBlockHash()))273@@ -1524,21 +1520,21 @@274 return error("Reorganize() : TxnCommit failed");275 276 // Disconnect shorter branch277- foreach(CBlockIndex* pindex, vDisconnect)278+ BOOST_FOREACH(CBlockIndex* pindex, vDisconnect)279 if (pindex->pprev)280 pindex->pprev->pnext = NULL;281 282 // Connect longer branch283- foreach(CBlockIndex* pindex, vConnect)284+ BOOST_FOREACH(CBlockIndex* pindex, vConnect)285 if (pindex->pprev)286 pindex->pprev->pnext = pindex;287 288 // Resurrect memory transactions that were in the disconnected branch289- foreach(CTransaction& tx, vResurrect)290+ BOOST_FOREACH(CTransaction& tx, vResurrect)291 tx.AcceptToMemoryPool(txdb, false);292 293 // Delete redundant memory transactions that are in the connected branch294- foreach(CTransaction& tx, vDelete)295+ BOOST_FOREACH(CTransaction& tx, vDelete)296 tx.RemoveFromMemoryPool();297 298 return true;299@@ -1573,7 +1569,7 @@300 pindexNew->pprev->pnext = pindexNew;301 302 // Delete redundant memory transactions303- foreach(CTransaction& tx, vtx)304+ BOOST_FOREACH(CTransaction& tx, vtx)305 tx.RemoveFromMemoryPool();306 }307 else308@@ -1684,7 +1680,7 @@309 return error("CheckBlock() : more than one coinbase");310 311 // Check transactions312- foreach(const CTransaction& tx, vtx)313+ BOOST_FOREACH(const CTransaction& tx, vtx)314 if (!tx.CheckTransaction())315 return error("CheckBlock() : CheckTransaction failed");316 317@@ -1722,7 +1718,7 @@318 return error("AcceptBlock() : block's timestamp is too early");319 320 // Check that all transactions are finalized321- foreach(const CTransaction& tx, vtx)322+ BOOST_FOREACH(const CTransaction& tx, vtx)323 if (!tx.IsFinal(nHeight, GetBlockTime()))324 return error("AcceptBlock() : contains a non-final transaction");325 326@@ -1750,7 +1746,7 @@327 // Relay inventory, but don't relay old inventory during initial block download328 if (hashBestChain == hash)329 CRITICAL_BLOCK(cs_vNodes)330- foreach(CNode* pnode, vNodes)331+ BOOST_FOREACH(CNode* pnode, vNodes)332 if (nBestHeight > (pnode->nStartingHeight != -1 ? pnode->nStartingHeight - 2000 : 118000))333 pnode->PushInventory(CInv(MSG_BLOCK, hash));334 335@@ -2122,7 +2118,7 @@336 // Alerts337 CRITICAL_BLOCK(cs_mapAlerts)338 {339- foreach(PAIRTYPE(const uint256, CAlert)& item, mapAlerts)340+ BOOST_FOREACH(PAIRTYPE(const uint256, CAlert)& item, mapAlerts)341 {342 const CAlert& alert = item.second;343 if (alert.AppliesToMe() && alert.nPriority > nPriority)344@@ -2169,7 +2165,7 @@345 }346 347 // Check if this alert has been cancelled348- foreach(PAIRTYPE(const uint256, CAlert)& item, mapAlerts)349+ BOOST_FOREACH(PAIRTYPE(const uint256, CAlert)& item, mapAlerts)350 {351 const CAlert& alert = item.second;352 if (alert.Cancels(*this))353@@ -2433,7 +2429,7 @@354 355 // Relay alerts356 CRITICAL_BLOCK(cs_mapAlerts)357- foreach(PAIRTYPE(const uint256, CAlert)& item, mapAlerts)358+ BOOST_FOREACH(PAIRTYPE(const uint256, CAlert)& item, mapAlerts)359 item.second.RelayTo(pfrom);360 361 pfrom->fSuccessfullyConnected = true;362@@ -2471,7 +2467,7 @@363 // Store the new addresses364 int64 nNow = GetAdjustedTime();365 int64 nSince = nNow - 10 * 60;366- foreach(CAddress& addr, vAddr)367+ BOOST_FOREACH(CAddress& addr, vAddr)368 {369 if (fShutdown)370 return true;371@@ -2495,7 +2491,7 @@372 uint256 hashRand = hashSalt ^ (((int64)addr.ip)<<32) ^ ((GetTime()+addr.ip)/(24*60*60));373 hashRand = Hash(BEGIN(hashRand), END(hashRand));374 multimap<uint256, CNode*> mapMix;375- foreach(CNode* pnode, vNodes)376+ BOOST_FOREACH(CNode* pnode, vNodes)377 {378 if (pnode->nVersion < 31402)379 continue;380@@ -2524,7 +2520,7 @@381 return error("message inv size() = %d", vInv.size());382 383 CTxDB txdb("r");384- foreach(const CInv& inv, vInv)385+ BOOST_FOREACH(const CInv& inv, vInv)386 {387 if (fShutdown)388 return true;389@@ -2556,7 +2552,7 @@390 if (vInv.size() > 50000)391 return error("message getdata size() = %d", vInv.size());392 393- foreach(const CInv& inv, vInv)394+ BOOST_FOREACH(const CInv& inv, vInv)395 {396 if (fShutdown)397 return true;398@@ -2719,7 +2715,7 @@399 }400 }401 402- foreach(uint256 hash, vWorkQueue)403+ BOOST_FOREACH(uint256 hash, vWorkQueue)404 EraseOrphanTx(hash);405 }406 else if (fMissingInputs)407@@ -2754,13 +2750,13 @@408 CRITICAL_BLOCK(cs_mapAddresses)409 {410 unsigned int nCount = 0;411- foreach(const PAIRTYPE(vector<unsigned char>, CAddress)& item, mapAddresses)412+ BOOST_FOREACH(const PAIRTYPE(vector<unsigned char>, CAddress)& item, mapAddresses)413 {414 const CAddress& addr = item.second;415 if (addr.nTime > nSince)416 nCount++;417 }418- foreach(const PAIRTYPE(vector<unsigned char>, CAddress)& item, mapAddresses)419+ BOOST_FOREACH(const PAIRTYPE(vector<unsigned char>, CAddress)& item, mapAddresses)420 {421 const CAddress& addr = item.second;422 if (addr.nTime > nSince && GetRand(nCount) < 2500)423@@ -2863,7 +2859,7 @@424 // Relay425 pfrom->setKnown.insert(alert.GetHash());426 CRITICAL_BLOCK(cs_vNodes)427- foreach(CNode* pnode, vNodes)428+ BOOST_FOREACH(CNode* pnode, vNodes)429 alert.RelayTo(pnode);430 }431 }432@@ -2914,7 +2910,7 @@433 nLastRebroadcast = GetTime();434 CRITICAL_BLOCK(cs_vNodes)435 {436- foreach(CNode* pnode, vNodes)437+ BOOST_FOREACH(CNode* pnode, vNodes)438 {439 // Periodically clear setAddrKnown to allow refresh broadcasts440 pnode->setAddrKnown.clear();441@@ -2966,7 +2962,7 @@442 {443 vector<CAddress> vAddr;444 vAddr.reserve(pto->vAddrToSend.size());445- foreach(const CAddress& addr, pto->vAddrToSend)446+ BOOST_FOREACH(const CAddress& addr, pto->vAddrToSend)447 {448 // returns true if wasn't already contained in the set449 if (pto->setAddrKnown.insert(addr).second)450@@ -2995,7 +2991,7 @@451 {452 vInv.reserve(pto->vInventoryToSend.size());453 vInvWait.reserve(pto->vInventoryToSend.size());454- foreach(const CInv& inv, pto->vInventoryToSend)455+ BOOST_FOREACH(const CInv& inv, pto->vInventoryToSend)456 {457 if (pto->setInventoryKnown.count(inv))458 continue;459@@ -3145,71 +3141,6 @@460 printf("ThreadBitcoinMiner exiting, %d threads remaining\n", vnThreadsRunning[3]);461 }462 463-#if defined(__GNUC__) && defined(CRYPTOPP_X86_ASM_AVAILABLE)464-void CallCPUID(int in, int& aret, int& cret)465-{466- int a, c;467- asm (468- "mov %2, %%eax; " // in into eax469- "cpuid;"470- "mov %%eax, %0;" // eax into a471- "mov %%ecx, %1;" // ecx into c472- :"=r"(a),"=r"(c) /* output */473- :"r"(in) /* input */474- :"%eax","%ebx","%ecx","%edx" /* clobbered register */475- );476- aret = a;477- cret = c;478-}479-480-bool Detect128BitSSE2()481-{482- int a, c, nBrand;483- CallCPUID(0, a, nBrand);484- bool fIntel = (nBrand == 0x6c65746e); // ntel485- bool fAMD = (nBrand == 0x444d4163); // cAMD486-487- struct488- {489- unsigned int nStepping : 4;490- unsigned int nModel : 4;491- unsigned int nFamily : 4;492- unsigned int nProcessorType : 2;493- unsigned int nUnused : 2;494- unsigned int nExtendedModel : 4;495- unsigned int nExtendedFamily : 8;496- }497- cpu;498- CallCPUID(1, a, c);499- memcpy(&cpu, &a, sizeof(cpu));500- int nFamily = cpu.nExtendedFamily + cpu.nFamily;501- int nModel = cpu.nExtendedModel*16 + cpu.nModel;502-503- // We need Intel Nehalem or AMD K10 or better for 128bit SSE2504- // Nehalem = i3/i5/i7 and some Xeon505- // K10 = Opterons with 4 or more cores, Phenom, Phenom II, Athlon II506- // Intel Core i5 family 6, model 26 or 30507- // Intel Core i7 family 6, model 26 or 30508- // Intel Core i3 family 6, model 37509- // AMD Phenom family 16, model 10510- bool fUseSSE2 = ((fIntel && nFamily * 10000 + nModel >= 60026) ||511- (fAMD && nFamily * 10000 + nModel >= 160010));512-513- // AMD reports a lower model number in 64-bit mode514- if (fAMD && sizeof(void*) > 4 && nFamily * 10000 + nModel >= 160000)515- fUseSSE2 = true;516-517- static bool fPrinted;518- if (!fPrinted)519- {520- fPrinted = true;521- printf("CPUID %08x family %d, model %d, stepping %d, fUseSSE2=%d\n", nBrand, nFamily, nModel, cpu.nStepping, fUseSSE2);522- }523- return fUseSSE2;524-}525-#else526-bool Detect128BitSSE2() { return false; }527-#endif528 529 int FormatHashBlocks(void* pbuffer, unsigned int len)530 {531@@ -3270,9 +3201,6 @@532 }533 }534 535-extern unsigned int ScanHash_4WaySSE2(char* pmidstate, char* pblock, char* phash1, char* phash, unsigned int& nHashesDone);536-537-538 539 class COrphan540 {541@@ -3290,7 +3218,7 @@542 void print() const543 {544 printf("COrphan(hash=%s, dPriority=%.1f)\n", ptx->GetHash().ToString().substr(0,10).c_str(), dPriority);545- foreach(uint256 hash, setDependsOn)546+ BOOST_FOREACH(uint256 hash, setDependsOn)547 printf(" setDependsOn %s\n", hash.ToString().substr(0,10).c_str());548 }549 };550@@ -3334,7 +3262,7 @@551 552 COrphan* porphan = NULL;553 double dPriority = 0;554- foreach(const CTxIn& txin, tx.vin)555+ BOOST_FOREACH(const CTxIn& txin, tx.vin)556 {557 // Read prev transaction558 CTransaction txPrev;559@@ -3401,7 +3329,7 @@560 561 // Transaction fee required depends on block size562 bool fAllowFree = (nBlockSize + nTxSize < 4000 || CTransaction::AllowFree(dPriority));563- int64 nMinFee = tx.GetMinFee(nBlockSize, fAllowFree);564+ int64 nMinFee = tx.GetMinFee(nBlockSize, fAllowFree, true);565 566 // Connecting shouldn't fail due to dependency on other memory pool transactions567 // because we're already processing them in order of dependency568@@ -3419,7 +3347,7 @@569 uint256 hash = tx.GetHash();570 if (mapDependers.count(hash))571 {572- foreach(COrphan* porphan, mapDependers[hash])573+ BOOST_FOREACH(COrphan* porphan, mapDependers[hash])574 {575 if (!porphan->setDependsOn.empty())576 {577@@ -3546,9 +3474,6 @@578 {579 printf("BitcoinMiner started\n");580 SetThreadPriority(THREAD_PRIORITY_LOWEST);581- bool f4WaySSE2 = Detect128BitSSE2();582- if (mapArgs.count("-4way"))583- f4WaySSE2 = GetBoolArg("-4way");584 585 // Each thread has its own key and counter586 CReserveKey reservekey;587@@ -3610,14 +3535,9 @@588 unsigned int nHashesDone = 0;589 unsigned int nNonceFound;590 591-#ifdef FOURWAYSSE2592- if (f4WaySSE2)593- // tcatm's 4-way 128-bit SSE2 SHA-256594- nNonceFound = ScanHash_4WaySSE2(pmidstate, pdata + 64, phash1, (char*)&hash, nHashesDone);595- else596-#endif597- // Crypto++ SHA-256598- nNonceFound = ScanHash_CryptoPP(pmidstate, pdata + 64, phash1, (char*)&hash, nHashesDone);599+ // Crypto++ SHA-256600+ nNonceFound = ScanHash_CryptoPP(pmidstate, pdata + 64, phash1,601+ (char*)&hash, nHashesDone);602 603 // Check if something found604 if (nNonceFound != -1)605@@ -3757,7 +3677,7 @@606 vCoins.push_back(&(*it).second);607 random_shuffle(vCoins.begin(), vCoins.end(), GetRandInt);608 609- foreach(CWalletTx* pcoin, vCoins)610+ BOOST_FOREACH(CWalletTx* pcoin, vCoins)611 {612 if (!pcoin->IsFinal() || !pcoin->IsConfirmed())613 continue;614@@ -3895,7 +3815,7 @@615 bool CreateTransaction(const vector<pair<CScript, int64> >& vecSend, CWalletTx& wtxNew, CReserveKey& reservekey, int64& nFeeRet)616 {617 int64 nValue = 0;618- foreach (const PAIRTYPE(CScript, int64)& s, vecSend)619+ BOOST_FOREACH (const PAIRTYPE(CScript, int64)& s, vecSend)620 {621 if (nValue < 0)622 return false;623@@ -3920,7 +3840,7 @@624 int64 nTotalValue = nValue + nFeeRet;625 double dPriority = 0;626 // vouts to the payees627- foreach (const PAIRTYPE(CScript, int64)& s, vecSend)628+ BOOST_FOREACH (const PAIRTYPE(CScript, int64)& s, vecSend)629 wtxNew.vout.push_back(CTxOut(s.second, s.first));630 631 // Choose coins to use632@@ -3928,7 +3848,7 @@633 int64 nValueIn = 0;634 if (!SelectCoins(nTotalValue, setCoins, nValueIn))635 return false;636- foreach(PAIRTYPE(CWalletTx*, unsigned int) pcoin, setCoins)637+ BOOST_FOREACH(PAIRTYPE(CWalletTx*, unsigned int) pcoin, setCoins)638 {639 int64 nCredit = pcoin.first->vout[pcoin.second].nValue;640 dPriority += (double)nCredit * pcoin.first->GetDepthInMainChain();641@@ -3964,12 +3884,12 @@642 reservekey.ReturnKey();643 644 // Fill vin645- foreach(const PAIRTYPE(CWalletTx*,unsigned int)& coin, setCoins)646+ BOOST_FOREACH(const PAIRTYPE(CWalletTx*,unsigned int)& coin, setCoins)647 wtxNew.vin.push_back(CTxIn(coin.first->GetHash(),coin.second));648 649 // Sign650 int nIn = 0;651- foreach(const PAIRTYPE(CWalletTx*,unsigned int)& coin, setCoins)652+ BOOST_FOREACH(const PAIRTYPE(CWalletTx*,unsigned int)& coin, setCoins)653 if (!SignSignature(*coin.first, wtxNew, nIn++))654 return false;655 656@@ -4029,7 +3949,7 @@657 658 // Mark old coins as spent659 set<CWalletTx*> setCoins;660- foreach(const CTxIn& txin, wtxNew.vin)661+ BOOST_FOREACH(const CTxIn& txin, wtxNew.vin)662 {663 CWalletTx &pcoin = mapWallet[txin.prevout.hash];664 pcoin.MarkSpent(txin.prevout.n);
main.h (modified)
1--- v0.3.21/main.h2+++ v0.3.22/main.h3@@ -1,6 +1,16 @@4 // Copyright (c) 2009-2010 Satoshi Nakamoto5 // Distributed under the MIT/X11 software license, see the accompanying6 // file license.txt or http://www.opensource.org/licenses/mit-license.php.7+#ifndef BITCOIN_MAIN_H8+#define BITCOIN_MAIN_H9+10+#include "bignum.h"11+#include "net.h"12+#include "key.h"13+#include "db.h"14+#include "script.h"15+16+#include <list>17 18 class COutPoint;19 class CInPoint;20@@ -19,6 +29,8 @@21 static const int MAX_BLOCK_SIGOPS = MAX_BLOCK_SIZE/50;22 static const int64 COIN = 100000000;23 static const int64 CENT = 1000000;24+static const int64 MIN_TX_FEE = CENT;25+static const int64 MIN_RELAY_TX_FEE = 50000;26 static const int64 MAX_MONEY = 21000000 * COIN;27 inline bool MoneyRange(int64 nValue) { return (nValue >= 0 && nValue <= MAX_MONEY); }28 static const int COINBASE_MATURITY = 100;29@@ -34,7 +46,7 @@30 31 32 extern CCriticalSection cs_main;33-extern map<uint256, CBlockIndex*> mapBlockIndex;34+extern std::map<uint256, CBlockIndex*> mapBlockIndex;35 extern uint256 hashGenesisBlock;36 extern CBigNum bnProofOfWorkLimit;37 extern CBlockIndex* pindexGenesisBlock;38@@ -44,11 +56,11 @@39 extern uint256 hashBestChain;40 extern CBlockIndex* pindexBest;41 extern unsigned int nTransactionsUpdated;42-extern map<uint256, int> mapRequestCount;43+extern std::map<uint256, int> mapRequestCount;44 extern CCriticalSection cs_mapRequestCount;45-extern map<string, string> mapAddressBook;46+extern std::map<std::string, std::string> mapAddressBook;47 extern CCriticalSection cs_mapAddressBook;48-extern vector<unsigned char> vchDefaultKey;49+extern std::vector<unsigned char> vchDefaultKey;50 extern double dHashesPerSec;51 extern int64 nHPSTimerStart;52 53@@ -72,7 +84,7 @@54 FILE* OpenBlockFile(unsigned int nFile, unsigned int nBlockPos, const char* pszMode="rb");55 FILE* AppendBlockFile(unsigned int& nFileRet);56 bool AddKey(const CKey& key);57-vector<unsigned char> GenerateNewKey();58+std::vector<unsigned char> GenerateNewKey();59 bool AddToWallet(const CWalletTx& wtxIn);60 void WalletUpdateSpent(const COutPoint& prevout);61 int ScanForWalletTransactions(CBlockIndex* pindexStart);62@@ -80,15 +92,15 @@63 bool LoadBlockIndex(bool fAllowNew=true);64 void PrintBlockTree();65 bool ProcessMessages(CNode* pfrom);66-bool ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv);67+bool ProcessMessage(CNode* pfrom, std::string strCommand, CDataStream& vRecv);68 bool SendMessages(CNode* pto, bool fSendTrickle);69 int64 GetBalance();70-bool CreateTransaction(const vector<pair<CScript, int64> >& vecSend, CWalletTx& wtxNew, CReserveKey& reservekey, int64& nFeeRet);71+bool CreateTransaction(const std::vector<std::pair<CScript, int64> >& vecSend, CWalletTx& wtxNew, CReserveKey& reservekey, int64& nFeeRet);72 bool CreateTransaction(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew, CReserveKey& reservekey, int64& nFeeRet);73 bool CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey);74 bool BroadcastTransaction(CWalletTx& wtxNew);75-string SendMoney(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew, bool fAskFee=false);76-string SendMoneyToBitcoinAddress(string strAddress, int64 nValue, CWalletTx& wtxNew, bool fAskFee=false);77+std::string SendMoney(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew, bool fAskFee=false);78+std::string SendMoneyToBitcoinAddress(std::string strAddress, int64 nValue, CWalletTx& wtxNew, bool fAskFee=false);79 void GenerateBitcoins(bool fGenerate);80 void ThreadBitcoinMiner(void* parg);81 CBlock* CreateNewBlock(CReserveKey& reservekey);82@@ -98,7 +110,7 @@83 void BitcoinMiner();84 bool CheckProofOfWork(uint256 hash, unsigned int nBits);85 bool IsInitialBlockDownload();86-string GetWarnings(string strFor);87+std::string GetWarnings(std::string strFor);88 89 90 91@@ -146,7 +158,7 @@92 return !(a == b);93 }94 95- string ToString() const96+ std::string ToString() const97 {98 if (IsNull())99 return strprintf("null");100@@ -205,7 +217,7 @@101 return !(a == b);102 }103 104- string ToString() const105+ std::string ToString() const106 {107 return strprintf("COutPoint(%s, %d)", hash.ToString().substr(0,10).c_str(), n);108 }109@@ -274,9 +286,9 @@110 return !(a == b);111 }112 113- string ToString() const114- {115- string str;116+ std::string ToString() const117+ {118+ std::string str;119 str += strprintf("CTxIn(");120 str += prevout.ToString();121 if (prevout.IsNull())122@@ -352,14 +364,14 @@123 int64 GetCredit() const124 {125 if (!MoneyRange(nValue))126- throw runtime_error("CTxOut::GetCredit() : value out of range");127+ throw std::runtime_error("CTxOut::GetCredit() : value out of range");128 return (IsMine() ? nValue : 0);129 }130 131 bool IsChange() const132 {133 // On a debit transaction, a txout that's mine but isn't in the address book is change134- vector<unsigned char> vchPubKey;135+ std::vector<unsigned char> vchPubKey;136 if (ExtractPubKey(scriptPubKey, true, vchPubKey))137 CRITICAL_BLOCK(cs_mapAddressBook)138 if (!mapAddressBook.count(PubKeyToAddress(vchPubKey)))139@@ -370,7 +382,7 @@140 int64 GetChange() const141 {142 if (!MoneyRange(nValue))143- throw runtime_error("CTxOut::GetChange() : value out of range");144+ throw std::runtime_error("CTxOut::GetChange() : value out of range");145 return (IsChange() ? nValue : 0);146 }147 148@@ -385,7 +397,7 @@149 return !(a == b);150 }151 152- string ToString() const153+ std::string ToString() const154 {155 if (scriptPubKey.size() < 6)156 return "CTxOut(error)";157@@ -409,8 +421,8 @@158 {159 public:160 int nVersion;161- vector<CTxIn> vin;162- vector<CTxOut> vout;163+ std::vector<CTxIn> vin;164+ std::vector<CTxOut> vout;165 unsigned int nLockTime;166 167 168@@ -457,7 +469,7 @@169 nBlockTime = GetAdjustedTime();170 if ((int64)nLockTime < (nLockTime < 500000000 ? (int64)nBlockHeight : nBlockTime))171 return true;172- foreach(const CTxIn& txin, vin)173+ BOOST_FOREACH(const CTxIn& txin, vin)174 if (!txin.IsFinal())175 return false;176 return true;177@@ -500,19 +512,19 @@178 int GetSigOpCount() const179 {180 int n = 0;181- foreach(const CTxIn& txin, vin)182+ BOOST_FOREACH(const CTxIn& txin, vin)183 n += txin.scriptSig.GetSigOpCount();184- foreach(const CTxOut& txout, vout)185+ BOOST_FOREACH(const CTxOut& txout, vout)186 n += txout.scriptPubKey.GetSigOpCount();187 return n;188 }189 190 bool IsStandard() const191 {192- foreach(const CTxIn& txin, vin)193+ BOOST_FOREACH(const CTxIn& txin, vin)194 if (!txin.scriptSig.IsPushOnly())195 return error("nonstandard txin: %s", txin.scriptSig.ToString().c_str());196- foreach(const CTxOut& txout, vout)197+ BOOST_FOREACH(const CTxOut& txout, vout)198 if (!::IsStandard(txout.scriptPubKey))199 return error("nonstandard txout: %s", txout.scriptPubKey.ToString().c_str());200 return true;201@@ -520,7 +532,7 @@202 203 bool IsMine() const204 {205- foreach(const CTxOut& txout, vout)206+ BOOST_FOREACH(const CTxOut& txout, vout)207 if (txout.IsMine())208 return true;209 return false;210@@ -534,11 +546,11 @@211 int64 GetDebit() const212 {213 int64 nDebit = 0;214- foreach(const CTxIn& txin, vin)215+ BOOST_FOREACH(const CTxIn& txin, vin)216 {217 nDebit += txin.GetDebit();218 if (!MoneyRange(nDebit))219- throw runtime_error("CTransaction::GetDebit() : value out of range");220+ throw std::runtime_error("CTransaction::GetDebit() : value out of range");221 }222 return nDebit;223 }224@@ -546,11 +558,11 @@225 int64 GetCredit() const226 {227 int64 nCredit = 0;228- foreach(const CTxOut& txout, vout)229+ BOOST_FOREACH(const CTxOut& txout, vout)230 {231 nCredit += txout.GetCredit();232 if (!MoneyRange(nCredit))233- throw runtime_error("CTransaction::GetCredit() : value out of range");234+ throw std::runtime_error("CTransaction::GetCredit() : value out of range");235 }236 return nCredit;237 }238@@ -560,11 +572,11 @@239 if (IsCoinBase())240 return 0;241 int64 nChange = 0;242- foreach(const CTxOut& txout, vout)243+ BOOST_FOREACH(const CTxOut& txout, vout)244 {245 nChange += txout.GetChange();246 if (!MoneyRange(nChange))247- throw runtime_error("CTransaction::GetChange() : value out of range");248+ throw std::runtime_error("CTransaction::GetChange() : value out of range");249 }250 return nChange;251 }252@@ -572,11 +584,11 @@253 int64 GetValueOut() const254 {255 int64 nValueOut = 0;256- foreach(const CTxOut& txout, vout)257+ BOOST_FOREACH(const CTxOut& txout, vout)258 {259 nValueOut += txout.nValue;260 if (!MoneyRange(txout.nValue) || !MoneyRange(nValueOut))261- throw runtime_error("CTransaction::GetValueOut() : value out of range");262+ throw std::runtime_error("CTransaction::GetValueOut() : value out of range");263 }264 return nValueOut;265 }266@@ -588,12 +600,14 @@267 return dPriority > COIN * 144 / 250;268 }269 270- int64 GetMinFee(unsigned int nBlockSize=1, bool fAllowFree=true) const271- {272- // Base fee is 1 cent per kilobyte273+ int64 GetMinFee(unsigned int nBlockSize=1, bool fAllowFree=true, bool fForRelay=false) const274+ {275+ // Base fee is either MIN_TX_FEE or MIN_RELAY_TX_FEE276+ int64 nBaseFee = fForRelay ? MIN_RELAY_TX_FEE : MIN_TX_FEE;277+278 unsigned int nBytes = ::GetSerializeSize(*this, SER_NETWORK);279 unsigned int nNewBlockSize = nBlockSize + nBytes;280- int64 nMinFee = (1 + (int64)nBytes / 1000) * CENT;281+ int64 nMinFee = (1 + (int64)nBytes / 1000) * nBaseFee;282 283 if (fAllowFree)284 {285@@ -612,11 +626,11 @@286 }287 }288 289- // To limit dust spam, require a 0.01 fee if any output is less than 0.01290- if (nMinFee < CENT)291- foreach(const CTxOut& txout, vout)292+ // To limit dust spam, require MIN_TX_FEE/MIN_RELAY_TX_FEE if any output is less than 0.01293+ if (nMinFee < nBaseFee)294+ BOOST_FOREACH(const CTxOut& txout, vout)295 if (txout.nValue < CENT)296- nMinFee = CENT;297+ nMinFee = nBaseFee;298 299 // Raise the price as the block approaches full300 if (nBlockSize != 1 && nNewBlockSize >= MAX_BLOCK_SIZE_GEN/2)301@@ -667,9 +681,9 @@302 }303 304 305- string ToString() const306- {307- string str;308+ std::string ToString() const309+ {310+ std::string str;311 str += strprintf("CTransaction(hash=%s, ver=%d, vin.size=%d, vout.size=%d, nLockTime=%d)\n",312 GetHash().ToString().substr(0,10).c_str(),313 nVersion,314@@ -693,7 +707,7 @@315 bool ReadFromDisk(CTxDB& txdb, COutPoint prevout);316 bool ReadFromDisk(COutPoint prevout);317 bool DisconnectInputs(CTxDB& txdb);318- bool ConnectInputs(CTxDB& txdb, map<uint256, CTxIndex>& mapTestPool, CDiskTxPos posThisTx,319+ bool ConnectInputs(CTxDB& txdb, std::map<uint256, CTxIndex>& mapTestPool, CDiskTxPos posThisTx,320 CBlockIndex* pindexBlock, int64& nFees, bool fBlock, bool fMiner, int64 nMinFee=0);321 bool ClientConnectInputs();322 bool CheckTransaction() const;323@@ -720,7 +734,7 @@324 {325 public:326 uint256 hashBlock;327- vector<uint256> vMerkleBranch;328+ std::vector<uint256> vMerkleBranch;329 int nIndex;330 331 // memory only332@@ -775,14 +789,14 @@333 class CWalletTx : public CMerkleTx334 {335 public:336- vector<CMerkleTx> vtxPrev;337- map<string, string> mapValue;338- vector<pair<string, string> > vOrderForm;339+ std::vector<CMerkleTx> vtxPrev;340+ std::map<std::string, std::string> mapValue;341+ std::vector<std::pair<std::string, std::string> > vOrderForm;342 unsigned int fTimeReceivedIsTxTime;343 unsigned int nTimeReceived; // time received by this node344 char fFromMe;345- string strFromAccount;346- vector<char> vfSpent;347+ std::string strFromAccount;348+ std::vector<char> vfSpent;349 350 // memory only351 mutable char fDebitCached;352@@ -849,8 +863,8 @@353 {354 pthis->mapValue["fromaccount"] = pthis->strFromAccount;355 356- string str;357- foreach(char f, vfSpent)358+ std::string str;359+ BOOST_FOREACH(char f, vfSpent)360 {361 str += (f ? '1' : '0');362 if (f)363@@ -873,7 +887,7 @@364 pthis->strFromAccount = pthis->mapValue["fromaccount"];365 366 if (mapValue.count("spent"))367- foreach(char c, pthis->mapValue["spent"])368+ BOOST_FOREACH(char c, pthis->mapValue["spent"])369 pthis->vfSpent.push_back(c != '0');370 else371 pthis->vfSpent.assign(vout.size(), fSpent);372@@ -886,7 +900,7 @@373 374 // marks certain txout's as spent375 // returns true if any update took place376- bool UpdateSpent(const vector<char>& vfNewSpent)377+ bool UpdateSpent(const std::vector<char>& vfNewSpent)378 {379 bool fReturn = false;380 for (int i=0; i < vfNewSpent.size(); i++)381@@ -915,7 +929,7 @@382 void MarkSpent(unsigned int nOut)383 {384 if (nOut >= vout.size())385- throw runtime_error("CWalletTx::MarkSpent() : nOut out of range");386+ throw std::runtime_error("CWalletTx::MarkSpent() : nOut out of range");387 vfSpent.resize(vout.size());388 if (!vfSpent[nOut])389 {390@@ -927,7 +941,7 @@391 bool IsSpent(unsigned int nOut) const392 {393 if (nOut >= vout.size())394- throw runtime_error("CWalletTx::IsSpent() : nOut out of range");395+ throw std::runtime_error("CWalletTx::IsSpent() : nOut out of range");396 if (nOut >= vfSpent.size())397 return false;398 return (!!vfSpent[nOut]);399@@ -975,7 +989,7 @@400 const CTxOut &txout = vout[i];401 nCredit += txout.GetCredit();402 if (!MoneyRange(nCredit))403- throw runtime_error("CWalletTx::GetAvailableCredit() : value out of range");404+ throw std::runtime_error("CWalletTx::GetAvailableCredit() : value out of range");405 }406 }407 408@@ -994,10 +1008,10 @@409 return nChangeCached;410 }411 412- void GetAmounts(int64& nGeneratedImmature, int64& nGeneratedMature, list<pair<string /* address */, int64> >& listReceived,413- list<pair<string /* address */, int64> >& listSent, int64& nFee, string& strSentAccount) const;414-415- void GetAccountAmounts(const string& strAccount, int64& nGenerated, int64& nReceived, 416+ void GetAmounts(int64& nGeneratedImmature, int64& nGeneratedMature, std::list<std::pair<std::string /* address */, int64> >& listReceived,417+ std::list<std::pair<std::string /* address */, int64> >& listSent, int64& nFee, std::string& strSentAccount) const;418+419+ void GetAccountAmounts(const std::string& strAccount, int64& nGenerated, int64& nReceived,420 int64& nSent, int64& nFee) const;421 422 bool IsFromMe() const423@@ -1017,8 +1031,8 @@424 425 // If no confirmations but it's from us, we can still426 // consider it confirmed if all dependencies are confirmed427- map<uint256, const CMerkleTx*> mapPrev;428- vector<const CMerkleTx*> vWorkQueue;429+ std::map<uint256, const CMerkleTx*> mapPrev;430+ std::vector<const CMerkleTx*> vWorkQueue;431 vWorkQueue.reserve(vtxPrev.size()+1);432 vWorkQueue.push_back(this);433 for (int i = 0; i < vWorkQueue.size(); i++)434@@ -1028,15 +1042,15 @@435 if (!ptx->IsFinal())436 return false;437 if (ptx->GetDepthInMainChain() >= 1)438- return true;439+ continue;440 if (!ptx->IsFromMe())441 return false;442 443 if (mapPrev.empty())444- foreach(const CMerkleTx& tx, vtxPrev)445+ BOOST_FOREACH(const CMerkleTx& tx, vtxPrev)446 mapPrev[tx.GetHash()] = &tx;447 448- foreach(const CTxIn& txin, ptx->vin)449+ BOOST_FOREACH(const CTxIn& txin, ptx->vin)450 {451 if (!mapPrev.count(txin.prevout.hash))452 return false;453@@ -1076,7 +1090,7 @@454 {455 public:456 CDiskTxPos pos;457- vector<CDiskTxPos> vSpent;458+ std::vector<CDiskTxPos> vSpent;459 460 CTxIndex()461 {462@@ -1148,10 +1162,10 @@463 unsigned int nNonce;464 465 // network and disk466- vector<CTransaction> vtx;467+ std::vector<CTransaction> vtx;468 469 // memory only470- mutable vector<uint256> vMerkleTree;471+ mutable std::vector<uint256> vMerkleTree;472 473 474 CBlock()475@@ -1206,7 +1220,7 @@476 int GetSigOpCount() const477 {478 int n = 0;479- foreach(const CTransaction& tx, vtx)480+ BOOST_FOREACH(const CTransaction& tx, vtx)481 n += tx.GetSigOpCount();482 return n;483 }484@@ -1215,14 +1229,14 @@485 uint256 BuildMerkleTree() const486 {487 vMerkleTree.clear();488- foreach(const CTransaction& tx, vtx)489+ BOOST_FOREACH(const CTransaction& tx, vtx)490 vMerkleTree.push_back(tx.GetHash());491 int j = 0;492 for (int nSize = vtx.size(); nSize > 1; nSize = (nSize + 1) / 2)493 {494 for (int i = 0; i < nSize; i += 2)495 {496- int i2 = min(i+1, nSize-1);497+ int i2 = std::min(i+1, nSize-1);498 vMerkleTree.push_back(Hash(BEGIN(vMerkleTree[j+i]), END(vMerkleTree[j+i]),499 BEGIN(vMerkleTree[j+i2]), END(vMerkleTree[j+i2])));500 }501@@ -1231,15 +1245,15 @@502 return (vMerkleTree.empty() ? 0 : vMerkleTree.back());503 }504 505- vector<uint256> GetMerkleBranch(int nIndex) const506+ std::vector<uint256> GetMerkleBranch(int nIndex) const507 {508 if (vMerkleTree.empty())509 BuildMerkleTree();510- vector<uint256> vMerkleBranch;511+ std::vector<uint256> vMerkleBranch;512 int j = 0;513 for (int nSize = vtx.size(); nSize > 1; nSize = (nSize + 1) / 2)514 {515- int i = min(nIndex^1, nSize-1);516+ int i = std::min(nIndex^1, nSize-1);517 vMerkleBranch.push_back(vMerkleTree[j+i]);518 nIndex >>= 1;519 j += nSize;520@@ -1247,11 +1261,11 @@521 return vMerkleBranch;522 }523 524- static uint256 CheckMerkleBranch(uint256 hash, const vector<uint256>& vMerkleBranch, int nIndex)525+ static uint256 CheckMerkleBranch(uint256 hash, const std::vector<uint256>& vMerkleBranch, int nIndex)526 {527 if (nIndex == -1)528 return 0;529- foreach(const uint256& otherside, vMerkleBranch)530+ BOOST_FOREACH(const uint256& otherside, vMerkleBranch)531 {532 if (nIndex & 1)533 hash = Hash(BEGIN(otherside), END(otherside), BEGIN(hash), END(hash));534@@ -1482,7 +1496,7 @@535 for (int i = 0; i < nMedianTimeSpan && pindex; i++, pindex = pindex->pprev)536 *(--pbegin) = pindex->GetBlockTime();537 538- sort(pbegin, pend);539+ std::sort(pbegin, pend);540 return pbegin[(pend - pbegin)/2];541 }542 543@@ -1500,7 +1514,7 @@544 545 546 547- string ToString() const548+ std::string ToString() const549 {550 return strprintf("CBlockIndex(nprev=%08x, pnext=%08x, nFile=%d, nBlockPos=%-6d nHeight=%d, merkle=%s, hashBlock=%s)",551 pprev, pnext, nFile, nBlockPos, nHeight,552@@ -1569,9 +1583,9 @@553 }554 555 556- string ToString() const557- {558- string str = "CDiskBlockIndex(";559+ std::string ToString() const560+ {561+ std::string str = "CDiskBlockIndex(";562 str += CBlockIndex::ToString();563 str += strprintf("\n hashBlock=%s, hashPrev=%s, hashNext=%s)",564 GetBlockHash().ToString().c_str(),565@@ -1601,7 +1615,7 @@566 class CBlockLocator567 {568 protected:569- vector<uint256> vHave;570+ std::vector<uint256> vHave;571 public:572 573 CBlockLocator()574@@ -1615,7 +1629,7 @@575 576 explicit CBlockLocator(uint256 hashBlock)577 {578- map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.find(hashBlock);579+ std::map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.find(hashBlock);580 if (mi != mapBlockIndex.end())581 Set((*mi).second);582 }583@@ -1659,9 +1673,9 @@584 // Retrace how far back it was in the sender's branch585 int nDistance = 0;586 int nStep = 1;587- foreach(const uint256& hash, vHave)588- {589- map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.find(hash);590+ BOOST_FOREACH(const uint256& hash, vHave)591+ {592+ std::map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.find(hash);593 if (mi != mapBlockIndex.end())594 {595 CBlockIndex* pindex = (*mi).second;596@@ -1678,9 +1692,9 @@597 CBlockIndex* GetBlockIndex()598 {599 // Find the first block the caller has in the main chain600- foreach(const uint256& hash, vHave)601- {602- map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.find(hash);603+ BOOST_FOREACH(const uint256& hash, vHave)604+ {605+ std::map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.find(hash);606 if (mi != mapBlockIndex.end())607 {608 CBlockIndex* pindex = (*mi).second;609@@ -1694,9 +1708,9 @@610 uint256 GetBlockHash()611 {612 // Find the first block the caller has in the main chain613- foreach(const uint256& hash, vHave)614- {615- map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.find(hash);616+ BOOST_FOREACH(const uint256& hash, vHave)617+ {618+ std::map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.find(hash);619 if (mi != mapBlockIndex.end())620 {621 CBlockIndex* pindex = (*mi).second;622@@ -1730,7 +1744,7 @@623 CPrivKey vchPrivKey;624 int64 nTimeCreated;625 int64 nTimeExpires;626- string strComment;627+ std::string strComment;628 //// todo: add something to note what created it (user, getnewaddress, change)629 //// maybe should have a map<string, string> property map630 631@@ -1763,7 +1777,7 @@632 class CAccount633 {634 public:635- vector<unsigned char> vchPubKey;636+ std::vector<unsigned char> vchPubKey;637 638 CAccount()639 {640@@ -1792,11 +1806,11 @@641 class CAccountingEntry642 {643 public:644- string strAccount;645+ std::string strAccount;646 int64 nCreditDebit;647 int64 nTime;648- string strOtherAccount;649- string strComment;650+ std::string strOtherAccount;651+ std::string strComment;652 653 CAccountingEntry()654 {655@@ -1847,16 +1861,16 @@656 int64 nExpiration;657 int nID;658 int nCancel;659- set<int> setCancel;660+ std::set<int> setCancel;661 int nMinVer; // lowest version inclusive662 int nMaxVer; // highest version inclusive663- set<string> setSubVer; // empty matches all664+ std::set<std::string> setSubVer; // empty matches all665 int nPriority;666 667 // Actions668- string strComment;669- string strStatusBar;670- string strReserved;671+ std::string strComment;672+ std::string strStatusBar;673+ std::string strReserved;674 675 IMPLEMENT_SERIALIZE676 (677@@ -1895,13 +1909,13 @@678 strReserved.clear();679 }680 681- string ToString() const682- {683- string strSetCancel;684- foreach(int n, setCancel)685+ std::string ToString() const686+ {687+ std::string strSetCancel;688+ BOOST_FOREACH(int n, setCancel)689 strSetCancel += strprintf("%d ", n);690- string strSetSubVer;691- foreach(string str, setSubVer)692+ std::string strSetSubVer;693+ BOOST_FOREACH(std::string str, setSubVer)694 strSetSubVer += "\"" + str + "\" ";695 return strprintf(696 "CAlert(\n"697@@ -1941,8 +1955,8 @@698 class CAlert : public CUnsignedAlert699 {700 public:701- vector<unsigned char> vchMsg;702- vector<unsigned char> vchSig;703+ std::vector<unsigned char> vchMsg;704+ std::vector<unsigned char> vchSig;705 706 CAlert()707 {708@@ -1984,7 +1998,7 @@709 return (alert.nID <= nCancel || setCancel.count(alert.nID));710 }711 712- bool AppliesTo(int nVersion, string strSubVerIn) const713+ bool AppliesTo(int nVersion, std::string strSubVerIn) const714 {715 return (IsInEffect() &&716 nMinVer <= nVersion && nVersion <= nMaxVer &&717@@ -2040,12 +2054,14 @@718 719 720 721-extern map<uint256, CTransaction> mapTransactions;722-extern map<uint256, CWalletTx> mapWallet;723-extern vector<uint256> vWalletUpdated;724+extern std::map<uint256, CTransaction> mapTransactions;725+extern std::map<uint256, CWalletTx> mapWallet;726+extern std::vector<uint256> vWalletUpdated;727 extern CCriticalSection cs_mapWallet;728-extern map<vector<unsigned char>, CPrivKey> mapKeys;729-extern map<uint160, vector<unsigned char> > mapPubKeys;730+extern std::map<std::vector<unsigned char>, CPrivKey> mapKeys;731+extern std::map<uint160, std::vector<unsigned char> > mapPubKeys;732 extern CCriticalSection cs_mapKeys;733 extern CKey keyUser;734 735+#endif736+
makefile.mingw (modified)
1--- v0.3.21/makefile.mingw2+++ v0.3.22/makefile.mingw3@@ -7,14 +7,14 @@4 INCLUDEPATHS= \5 -I"C:\boost-1.43.0-mgw" \6 -I"C:\db-4.7.25.NC-mgw\build_unix" \7- -I"C:\openssl-1.0.0c-mgw\include" \8+ -I"C:\openssl-1.0.0d-mgw\include" \9 -I"C:\wxWidgets-2.9.1-mgw\lib\gcc_lib\mswud" \10 -I"C:\wxWidgets-2.9.1-mgw\include"11 12 LIBPATHS= \13 -L"C:\boost-1.43.0-mgw\stage\lib" \14 -L"C:\db-4.7.25.NC-mgw\build_unix" \15- -L"C:\openssl-1.0.0c-mgw" \16+ -L"C:\openssl-1.0.0d-mgw" \17 -L"C:\wxWidgets-2.9.1-mgw\lib\gcc_lib"18 19 WXLIBS= \20@@ -26,9 +26,10 @@21 -l boost_program_options-mgw45-mt-s-1_43 \22 -l boost_thread-mgw45-mt-s-1_43 \23 -l db_cxx \24- -l eay3225+ -l ssl \26+ -l crypto27 28-DEFS=-DWIN32 -D__WXMSW__ -D_WINDOWS -DNOPCH29+DEFS=-DWIN32 -D__WXMSW__ -D_WINDOWS -DNOPCH -DUSE_SSL30 DEBUGFLAGS=-g -D__WXDEBUG__31 CFLAGS=-mthreads -O2 -w -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS)32 HEADERS=headers.h strlcpy.h serialize.h uint256.h util.h key.h bignum.h base58.h \33@@ -65,7 +66,7 @@34 cryptopp/obj/%.o: cryptopp/%.cpp35 g++ -c $(CFLAGS) -O3 -DCRYPTOPP_X86_ASM_AVAILABLE -o $@ $<36 37-obj/ui_res.o: ui.rc rc/bitcoin.ico rc/check.ico rc/send16.bmp rc/send16mask.bmp rc/send16masknoshadow.bmp rc/send20.bmp rc/send20mask.bmp rc/addressbook16.bmp rc/addressbook16mask.bmp rc/addressbook20.bmp rc/addressbook20mask.bmp38+obj/ui_res.o: ../share/ui.rc ../share/pixmaps/bitcoin.ico ../share/pixmaps/check.ico ../share/pixmaps/send16.bmp ../share/pixmaps/send16mask.bmp ../share/pixmaps/send16masknoshadow.bmp ../share/pixmaps/send20.bmp ../share/pixmaps/send20mask.bmp ../share/pixmaps/addressbook16.bmp ../share/pixmaps/addressbook16mask.bmp ../share/pixmaps/addressbook20.bmp ../share/pixmaps/addressbook20mask.bmp39 windres $(DEFS) $(INCLUDEPATHS) -o $@ -i $<40 41 bitcoin.exe: $(OBJS) obj/ui.o obj/uibase.o obj/ui_res.o
makefile.unix (modified)
1--- v0.3.21/makefile.unix2+++ v0.3.22/makefile.unix3@@ -32,7 +32,8 @@4 -Wl,-Bdynamic \5 -l gthread-2.0 \6 -l z \7- -l dl8+ -l dl \9+ -l pthread10 11 12 DEBUGFLAGS=-g -D__WXDEBUG__13@@ -62,17 +63,14 @@14 cryptopp/obj/%.o: cryptopp/%.cpp15 $(CXX) -c $(CXXFLAGS) -O3 -o $@ $<16 17-obj/sha256.o: sha256.cpp18- $(CXX) -c $(CXXFLAGS) -msse2 -O3 -march=amdfam10 -o $@ $<19-20-bitcoin: $(OBJS) obj/ui.o obj/uibase.o obj/sha256.o21+bitcoin: $(OBJS) obj/ui.o obj/uibase.o22 $(CXX) $(CXXFLAGS) -o $@ $^ $(WXLIBS) $(LIBS)23 24 25 obj/nogui/%.o: %.cpp $(HEADERS)26 $(CXX) -c $(CXXFLAGS) -o $@ $<27 28-bitcoind: $(OBJS:obj/%=obj/nogui/%) obj/sha256.o29+bitcoind: $(OBJS:obj/%=obj/nogui/%)30 $(CXX) $(CXXFLAGS) -o $@ $^ $(LIBS)31 32
net.cpp (modified)
1--- v0.3.21/net.cpp2+++ v0.3.22/net.cpp3@@ -10,6 +10,9 @@4 #include <miniupnpc/upnpcommands.h>5 #include <miniupnpc/upnperrors.h>6 #endif7+8+using namespace std;9+using namespace boost;10 11 static const int MAX_OUTBOUND_CONNECTIONS = 8;12 13@@ -29,8 +32,9 @@14 // Global state variables15 //16 bool fClient = false;17+bool fAllowDNS = false;18 uint64 nLocalServices = (fClient ? 0 : NODE_NETWORK);19-CAddress addrLocalHost(0, 0, nLocalServices);20+CAddress addrLocalHost("0.0.0.0", 0, false, nLocalServices);21 CNode* pnodeLocalHost = NULL;22 uint64 nLocalHostNonce = 0;23 array<int, 10> vnThreadsRunning;24@@ -47,11 +51,15 @@25 26 // Settings27 int fUseProxy = false;28-CAddress addrProxy("127.0.0.1:9050");29-30-31-32-33+CAddress addrProxy("127.0.0.1",9050);34+35+36+37+38+unsigned short GetListenPort()39+{40+ return (unsigned short)(GetArg("-port", GetDefaultPort()));41+}42 43 void CNode::PushGetBlocks(CBlockIndex* pindexBegin, uint256 hashEnd)44 {45@@ -92,7 +100,7 @@46 47 if (fProxy)48 {49- printf("proxy connecting %s\n", addrConnect.ToStringLog().c_str());50+ printf("proxy connecting %s\n", addrConnect.ToString().c_str());51 char pszSocks4IP[] = "\4\1\0\0\0\0\0\0user";52 memcpy(pszSocks4IP + 2, &addrConnect.port, 2);53 memcpy(pszSocks4IP + 4, &addrConnect.ip, 4);54@@ -118,14 +126,83 @@55 printf("ERROR: Proxy returned error %d\n", pchRet[1]);56 return false;57 }58- printf("proxy connected %s\n", addrConnect.ToStringLog().c_str());59+ printf("proxy connected %s\n", addrConnect.ToString().c_str());60 }61 62 hSocketRet = hSocket;63 return true;64 }65 66-67+// portDefault is in host order68+bool Lookup(const char *pszName, vector<CAddress>& vaddr, int nServices, int nMaxSolutions, bool fAllowLookup, int portDefault, bool fAllowPort)69+{70+ vaddr.clear();71+ if (pszName[0] == 0)72+ return false;73+ int port = portDefault;74+ char psz[256];75+ char *pszHost = psz;76+ strlcpy(psz, pszName, sizeof(psz));77+ if (fAllowPort)78+ {79+ char* pszColon = strrchr(psz+1,':');80+ char *pszPortEnd = NULL;81+ int portParsed = pszColon ? strtoul(pszColon+1, &pszPortEnd, 10) : 0;82+ if (pszColon && pszPortEnd && pszPortEnd[0] == 0)83+ {84+ if (psz[0] == '[' && pszColon[-1] == ']')85+ {86+ // Future: enable IPv6 colon-notation inside []87+ pszHost = psz+1;88+ pszColon[-1] = 0;89+ }90+ else91+ pszColon[0] = 0;92+ port = portParsed;93+ if (port < 0 || port > USHRT_MAX)94+ port = USHRT_MAX;95+ }96+ }97+98+ unsigned int addrIP = inet_addr(pszHost);99+ if (addrIP != INADDR_NONE)100+ {101+ // valid IP address passed102+ vaddr.push_back(CAddress(addrIP, port, nServices));103+ return true;104+ }105+106+ if (!fAllowLookup)107+ return false;108+109+ struct hostent* phostent = gethostbyname(pszHost);110+ if (!phostent)111+ return false;112+113+ if (phostent->h_addrtype != AF_INET)114+ return false;115+116+ char** ppAddr = phostent->h_addr_list;117+ while (*ppAddr != NULL && vaddr.size() != nMaxSolutions)118+ {119+ CAddress addr(((struct in_addr*)ppAddr[0])->s_addr, port, nServices);120+ if (addr.IsValid())121+ vaddr.push_back(addr);122+ ppAddr++;123+ }124+125+ return (vaddr.size() > 0);126+}127+128+// portDefault is in host order129+bool Lookup(const char *pszName, CAddress& addr, int nServices, bool fAllowLookup, int portDefault, bool fAllowPort)130+{131+ vector<CAddress> vaddr;132+ bool fRet = Lookup(pszName, vaddr, nServices, 1, fAllowLookup, portDefault, fAllowPort);133+ if (fRet)134+ addr = vaddr[0];135+ return fRet;136+}137 138 bool GetMyExternalIP2(const CAddress& addrConnect, const char* pszGet, const char* pszKeyword, unsigned int& ipRet)139 {140@@ -161,7 +238,7 @@141 strLine = strLine.substr(strspn(strLine.c_str(), " \t\n\r"));142 while (strLine.size() > 0 && isspace(strLine[strLine.size()-1]))143 strLine.resize(strLine.size()-1);144- CAddress addr(strLine.c_str());145+ CAddress addr(strLine,0,true);146 printf("GetMyExternalIP() received [%s] %s\n", strLine.c_str(), addr.ToString().c_str());147 if (addr.ip == 0 || addr.ip == INADDR_NONE || !addr.IsRoutable())148 return false;149@@ -192,13 +269,13 @@150 // <?php echo $_SERVER["REMOTE_ADDR"]; ?>151 if (nHost == 1)152 {153- addrConnect = CAddress("91.198.22.70:80"); // checkip.dyndns.org154+ addrConnect = CAddress("91.198.22.70",80); // checkip.dyndns.org155 156 if (nLookup == 1)157 {158- struct hostent* phostent = gethostbyname("checkip.dyndns.org");159- if (phostent && phostent->h_addr_list && phostent->h_addr_list[0])160- addrConnect = CAddress(*(u_long*)phostent->h_addr_list[0], htons(80));161+ CAddress addrIP("checkip.dyndns.org", 80, true);162+ if (addrIP.IsValid())163+ addrConnect = addrIP;164 }165 166 pszGet = "GET / HTTP/1.1\r\n"167@@ -211,13 +288,13 @@168 }169 else if (nHost == 2)170 {171- addrConnect = CAddress("74.208.43.192:80"); // www.showmyip.com172+ addrConnect = CAddress("74.208.43.192", 80); // www.showmyip.com173 174 if (nLookup == 1)175 {176- struct hostent* phostent = gethostbyname("www.showmyip.com");177- if (phostent && phostent->h_addr_list && phostent->h_addr_list[0])178- addrConnect = CAddress(*(u_long*)phostent->h_addr_list[0], htons(80));179+ CAddress addrIP("www.showmyip.com", 80, true);180+ if (addrIP.IsValid())181+ addrConnect = addrIP;182 }183 184 pszGet = "GET /simple/ HTTP/1.1\r\n"185@@ -260,7 +337,7 @@186 CAddress addr(addrLocalHost);187 addr.nTime = GetAdjustedTime();188 CRITICAL_BLOCK(cs_vNodes)189- foreach(CNode* pnode, vNodes)190+ BOOST_FOREACH(CNode* pnode, vNodes)191 pnode->PushAddress(addr);192 }193 }194@@ -283,7 +360,7 @@195 if (it == mapAddresses.end())196 {197 // New address198- printf("AddAddress(%s)\n", addr.ToStringLog().c_str());199+ printf("AddAddress(%s)\n", addr.ToString().c_str());200 mapAddresses.insert(make_pair(addr.GetKey(), addr));201 CAddrDB().WriteAddress(addr);202 return true;203@@ -344,7 +421,7 @@204 // call this in the destructor so it doesn't get called after it's deleted.205 CRITICAL_BLOCK(cs_vNodes)206 {207- foreach(CNode* pnode, vNodes)208+ BOOST_FOREACH(CNode* pnode, vNodes)209 {210 CRITICAL_BLOCK(pnode->cs_mapRequests)211 {212@@ -381,7 +458,7 @@213 if (pnodeLocalHost->IsSubscribed(nChannel))214 return true;215 CRITICAL_BLOCK(cs_vNodes)216- foreach(CNode* pnode, vNodes)217+ BOOST_FOREACH(CNode* pnode, vNodes)218 if (pnode->IsSubscribed(nChannel))219 return true;220 return false;221@@ -403,7 +480,7 @@222 {223 // Relay subscribe224 CRITICAL_BLOCK(cs_vNodes)225- foreach(CNode* pnode, vNodes)226+ BOOST_FOREACH(CNode* pnode, vNodes)227 if (pnode != this)228 pnode->PushMessage("subscribe", nChannel, nHops);229 }230@@ -425,7 +502,7 @@231 {232 // Relay subscription cancel233 CRITICAL_BLOCK(cs_vNodes)234- foreach(CNode* pnode, vNodes)235+ BOOST_FOREACH(CNode* pnode, vNodes)236 if (pnode != this)237 pnode->PushMessage("sub-cancel", nChannel);238 }239@@ -443,7 +520,7 @@240 {241 CRITICAL_BLOCK(cs_vNodes)242 {243- foreach(CNode* pnode, vNodes)244+ BOOST_FOREACH(CNode* pnode, vNodes)245 if (pnode->addr.ip == ip)246 return (pnode);247 }248@@ -454,7 +531,7 @@249 {250 CRITICAL_BLOCK(cs_vNodes)251 {252- foreach(CNode* pnode, vNodes)253+ BOOST_FOREACH(CNode* pnode, vNodes)254 if (pnode->addr == addr)255 return (pnode);256 }257@@ -479,7 +556,7 @@258 259 /// debug print260 printf("trying connection %s lastseen=%.1fhrs lasttry=%.1fhrs\n",261- addrConnect.ToStringLog().c_str(),262+ addrConnect.ToString().c_str(),263 (double)(addrConnect.nTime - GetAdjustedTime())/3600.0,264 (double)(addrConnect.nLastTry - GetAdjustedTime())/3600.0);265 266@@ -491,7 +568,7 @@267 if (ConnectSocket(addrConnect, hSocket))268 {269 /// debug print270- printf("connected %s\n", addrConnect.ToStringLog().c_str());271+ printf("connected %s\n", addrConnect.ToString().c_str());272 273 // Set to nonblocking274 #ifdef __WXMSW__275@@ -528,7 +605,7 @@276 {277 if (fDebug)278 printf("%s ", DateTimeStrFormat("%x %H:%M:%S", GetTime()).c_str());279- printf("disconnecting node %s\n", addr.ToStringLog().c_str());280+ printf("disconnecting node %s\n", addr.ToString().c_str());281 closesocket(hSocket);282 hSocket = INVALID_SOCKET;283 }284@@ -591,7 +668,7 @@285 {286 // Disconnect unused nodes287 vector<CNode*> vNodesCopy = vNodes;288- foreach(CNode* pnode, vNodesCopy)289+ BOOST_FOREACH(CNode* pnode, vNodesCopy)290 {291 if (pnode->fDisconnect ||292 (pnode->GetRefCount() <= 0 && pnode->vRecv.empty() && pnode->vSend.empty()))293@@ -613,7 +690,7 @@294 295 // Delete disconnected nodes296 list<CNode*> vNodesDisconnectedCopy = vNodesDisconnected;297- foreach(CNode* pnode, vNodesDisconnectedCopy)298+ BOOST_FOREACH(CNode* pnode, vNodesDisconnectedCopy)299 {300 // wait until threads are done using it301 if (pnode->GetRefCount() <= 0)302@@ -659,7 +736,7 @@303 hSocketMax = max(hSocketMax, hListenSocket);304 CRITICAL_BLOCK(cs_vNodes)305 {306- foreach(CNode* pnode, vNodes)307+ BOOST_FOREACH(CNode* pnode, vNodes)308 {309 if (pnode->hSocket == INVALID_SOCKET || pnode->hSocket < 0)310 continue;311@@ -701,7 +778,7 @@312 int nInbound = 0;313 314 CRITICAL_BLOCK(cs_vNodes)315- foreach(CNode* pnode, vNodes)316+ BOOST_FOREACH(CNode* pnode, vNodes)317 if (pnode->fInbound)318 nInbound++;319 if (hSocket == INVALID_SOCKET)320@@ -715,7 +792,7 @@321 }322 else323 {324- printf("accepted connection %s\n", addr.ToStringLog().c_str());325+ printf("accepted connection %s\n", addr.ToString().c_str());326 CNode* pnode = new CNode(hSocket, addr, true);327 pnode->AddRef();328 CRITICAL_BLOCK(cs_vNodes)329@@ -731,10 +808,10 @@330 CRITICAL_BLOCK(cs_vNodes)331 {332 vNodesCopy = vNodes;333- foreach(CNode* pnode, vNodesCopy)334+ BOOST_FOREACH(CNode* pnode, vNodesCopy)335 pnode->AddRef();336 }337- foreach(CNode* pnode, vNodesCopy)338+ BOOST_FOREACH(CNode* pnode, vNodesCopy)339 {340 if (fShutdown)341 return;342@@ -851,7 +928,7 @@343 }344 CRITICAL_BLOCK(cs_vNodes)345 {346- foreach(CNode* pnode, vNodesCopy)347+ BOOST_FOREACH(CNode* pnode, vNodesCopy)348 pnode->Release();349 }350 351@@ -892,7 +969,7 @@352 printf("ThreadMapPort started\n");353 354 char port[6];355- sprintf(port, "%d", ntohs(GetDefaultPort()));356+ sprintf(port, "%d", GetListenPort());357 358 const char * rootdescurl = 0;359 const char * multicastif = 0;360@@ -984,17 +1061,17 @@361 printf("Loading addresses from DNS seeds (could take a while)\n");362 363 for (int seed_idx = 0; seed_idx < ARRAYLEN(strDNSSeed); seed_idx++) {364- struct hostent* phostent = gethostbyname(strDNSSeed[seed_idx]);365- if (!phostent)366- continue;367-368- for (int host = 0; phostent->h_addr_list[host] != NULL; host++) {369- CAddress addr(*(unsigned int*)phostent->h_addr_list[host],370- GetDefaultPort(), NODE_NETWORK);371- addr.nTime = 0;372- if (addr.IsValid() && addr.GetByte(3) != 127) {373- AddAddress(addr);374- found++;375+ vector<CAddress> vaddr;376+ if (Lookup(strDNSSeed[seed_idx], vaddr, NODE_NETWORK, -1, true))377+ {378+ BOOST_FOREACH (CAddress& addr, vaddr)379+ {380+ if (addr.GetByte(3) != 127)381+ {382+ addr.nTime = 0;383+ AddAddress(addr);384+ found++;385+ }386 }387 }388 }389@@ -1078,9 +1155,9 @@390 {391 for (int64 nLoop = 0;; nLoop++)392 {393- foreach(string strAddr, mapMultiArgs["-connect"])394- {395- CAddress addr(strAddr, NODE_NETWORK);396+ BOOST_FOREACH(string strAddr, mapMultiArgs["-connect"])397+ {398+ CAddress addr(strAddr, fAllowDNS);399 if (addr.IsValid())400 OpenNetworkConnection(addr);401 for (int i = 0; i < 10 && i < nLoop; i++)402@@ -1096,9 +1173,9 @@403 // Connect to manually added nodes first404 if (mapArgs.count("-addnode"))405 {406- foreach(string strAddr, mapMultiArgs["-addnode"])407- {408- CAddress addr(strAddr, NODE_NETWORK);409+ BOOST_FOREACH(string strAddr, mapMultiArgs["-addnode"])410+ {411+ CAddress addr(strAddr, fAllowDNS);412 if (addr.IsValid())413 {414 OpenNetworkConnection(addr);415@@ -1120,7 +1197,7 @@416 {417 int nOutbound = 0;418 CRITICAL_BLOCK(cs_vNodes)419- foreach(CNode* pnode, vNodes)420+ BOOST_FOREACH(CNode* pnode, vNodes)421 if (!pnode->fInbound)422 nOutbound++;423 int nMaxOutboundConnections = MAX_OUTBOUND_CONNECTIONS;424@@ -1163,7 +1240,7 @@425 {426 nSeedDisconnected = GetTime();427 CRITICAL_BLOCK(cs_vNodes)428- foreach(CNode* pnode, vNodes)429+ BOOST_FOREACH(CNode* pnode, vNodes)430 if (setSeed.count(pnode->addr.ip))431 pnode->fDisconnect = true;432 }433@@ -1171,7 +1248,7 @@434 // Keep setting timestamps to 0 so they won't reconnect435 if (GetTime() - nSeedDisconnected < 60 * 60)436 {437- foreach(PAIRTYPE(const vector<unsigned char>, CAddress)& item, mapAddresses)438+ BOOST_FOREACH(PAIRTYPE(const vector<unsigned char>, CAddress)& item, mapAddresses)439 {440 if (setSeed.count(item.second.ip) && item.second.nTime != 0)441 {442@@ -1194,12 +1271,12 @@443 // Do this here so we don't have to critsect vNodes inside mapAddresses critsect.444 set<unsigned int> setConnected;445 CRITICAL_BLOCK(cs_vNodes)446- foreach(CNode* pnode, vNodes)447+ BOOST_FOREACH(CNode* pnode, vNodes)448 setConnected.insert(pnode->addr.ip & 0x0000ffff);449 450 CRITICAL_BLOCK(cs_mapAddresses)451 {452- foreach(const PAIRTYPE(vector<unsigned char>, CAddress)& item, mapAddresses)453+ BOOST_FOREACH(const PAIRTYPE(vector<unsigned char>, CAddress)& item, mapAddresses)454 {455 const CAddress& addr = item.second;456 if (!addr.IsIPv4() || !addr.IsValid() || setConnected.count(addr.ip & 0x0000ffff))457@@ -1209,7 +1286,7 @@458 459 // Randomize the order in a deterministic way, putting the standard port first460 int64 nRandomizer = (uint64)(nStart * 4951 + addr.nLastTry * 9567851 + addr.ip * 7789) % (2 * 60 * 60);461- if (addr.port != GetDefaultPort())462+ if (addr.port != htons(GetDefaultPort()))463 nRandomizer += 2 * 60 * 60;464 465 // Last seen Base retry frequency466@@ -1315,7 +1392,7 @@467 CRITICAL_BLOCK(cs_vNodes)468 {469 vNodesCopy = vNodes;470- foreach(CNode* pnode, vNodesCopy)471+ BOOST_FOREACH(CNode* pnode, vNodesCopy)472 pnode->AddRef();473 }474 475@@ -1323,7 +1400,7 @@476 CNode* pnodeTrickle = NULL;477 if (!vNodesCopy.empty())478 pnodeTrickle = vNodesCopy[GetRand(vNodesCopy.size())];479- foreach(CNode* pnode, vNodesCopy)480+ BOOST_FOREACH(CNode* pnode, vNodesCopy)481 {482 // Receive messages483 TRY_CRITICAL_BLOCK(pnode->cs_vRecv)484@@ -1340,7 +1417,7 @@485 486 CRITICAL_BLOCK(cs_vNodes)487 {488- foreach(CNode* pnode, vNodesCopy)489+ BOOST_FOREACH(CNode* pnode, vNodesCopy)490 pnode->Release();491 }492 493@@ -1362,14 +1439,11 @@494 495 496 497-498-499-500 bool BindListenPort(string& strError)501 {502 strError = "";503 int nOne = 1;504- addrLocalHost.port = GetDefaultPort();505+ addrLocalHost.port = htons(GetListenPort());506 507 #ifdef __WXMSW__508 // Initialize Windows Sockets509@@ -1421,7 +1495,7 @@510 memset(&sockaddr, 0, sizeof(sockaddr));511 sockaddr.sin_family = AF_INET;512 sockaddr.sin_addr.s_addr = INADDR_ANY; // bind to all IPs on this computer513- sockaddr.sin_port = GetDefaultPort();514+ sockaddr.sin_port = htons(GetListenPort());515 if (::bind(hListenSocket, (struct sockaddr*)&sockaddr, sizeof(sockaddr)) == SOCKET_ERROR)516 {517 int nErr = WSAGetLastError();518@@ -1448,29 +1522,21 @@519 void StartNode(void* parg)520 {521 if (pnodeLocalHost == NULL)522- pnodeLocalHost = new CNode(INVALID_SOCKET, CAddress("127.0.0.1", nLocalServices));523+ pnodeLocalHost = new CNode(INVALID_SOCKET, CAddress("127.0.0.1", 0, false, nLocalServices));524 525 #ifdef __WXMSW__526 // Get local host ip527 char pszHostName[1000] = "";528 if (gethostname(pszHostName, sizeof(pszHostName)) != SOCKET_ERROR)529 {530- struct hostent* phostent = gethostbyname(pszHostName);531- if (phostent)532- {533- // Take the first IP that isn't loopback 127.x.x.x534- for (int i = 0; phostent->h_addr_list[i] != NULL; i++)535- printf("host ip %d: %s\n", i, CAddress(*(unsigned int*)phostent->h_addr_list[i]).ToStringIP().c_str());536- for (int i = 0; phostent->h_addr_list[i] != NULL; i++)537- {538- CAddress addr(*(unsigned int*)phostent->h_addr_list[i], GetDefaultPort(), nLocalServices);539- if (addr.IsValid() && addr.GetByte(3) != 127)540+ vector<CAddress> vaddr;541+ if (Lookup(pszHostName, vaddr, nLocalServices, -1, true))542+ BOOST_FOREACH (const CAddress &addr, vaddr)543+ if (addr.GetByte(3) != 127)544 {545 addrLocalHost = addr;546 break;547 }548- }549- }550 }551 #else552 // Get local host ip553@@ -1491,7 +1557,7 @@554 printf("ipv4 %s: %s\n", ifa->ifa_name, pszIP);555 556 // Take the first IP that isn't loopback 127.x.x.x557- CAddress addr(*(unsigned int*)&s4->sin_addr, GetDefaultPort(), nLocalServices);558+ CAddress addr(*(unsigned int*)&s4->sin_addr, GetListenPort(), nLocalServices);559 if (addr.IsValid() && addr.GetByte(3) != 127)560 {561 addrLocalHost = addr;562@@ -1586,7 +1652,7 @@563 ~CNetCleanup()564 {565 // Close sockets566- foreach(CNode* pnode, vNodes)567+ BOOST_FOREACH(CNode* pnode, vNodes)568 if (pnode->hSocket != INVALID_SOCKET)569 closesocket(pnode->hSocket);570 if (hListenSocket != INVALID_SOCKET)
net.h (modified)
1--- v0.3.21/net.h2+++ v0.3.22/net.h3@@ -1,6 +1,16 @@4 // Copyright (c) 2009-2010 Satoshi Nakamoto5 // Distributed under the MIT/X11 software license, see the accompanying6 // file license.txt or http://www.opensource.org/licenses/mit-license.php.7+#ifndef BITCOIN_NET_H8+#define BITCOIN_NET_H9+10+#include <deque>11+#include <boost/array.hpp>12+#include <openssl/rand.h>13+14+#ifndef __WXMSW__15+#include <arpa/inet.h>16+#endif17 18 class CMessageHeader;19 class CAddress;20@@ -12,7 +22,7 @@21 22 23 24-inline unsigned short GetDefaultPort() { return fTestNet ? htons(18333) : htons(8333); }25+inline unsigned short GetDefaultPort() { return fTestNet ? 18333 : 8333; }26 static const unsigned int PUBLISH_HOPS = 5;27 enum28 {29@@ -23,6 +33,8 @@30 31 32 bool ConnectSocket(const CAddress& addrConnect, SOCKET& hSocketRet);33+bool Lookup(const char *pszName, std::vector<CAddress>& vaddr, int nServices, int nMaxSolutions, bool fAllowLookup = false, int portDefault = 0, bool fAllowPort = false);34+bool Lookup(const char *pszName, CAddress& addr, int nServices, bool fAllowLookup = false, int portDefault = 0, bool fAllowPort = false);35 bool GetMyExternalIP(unsigned int& ipRet);36 bool AddAddress(CAddress addr, int64 nTimePenalty=0);37 void AddressCurrentlyConnected(const CAddress& addr);38@@ -32,7 +44,7 @@39 bool AnySubscribed(unsigned int nChannel);40 void MapPort(bool fMapPort);41 void DNSAddressSeed();42-bool BindListenPort(string& strError=REF(string()));43+bool BindListenPort(std::string& strError=REF(std::string()));44 void StartNode(void* parg);45 bool StopNode();46 47@@ -87,12 +99,12 @@48 READWRITE(nChecksum);49 )50 51- string GetCommand()52+ std::string GetCommand()53 {54 if (pchCommand[COMMAND_SIZE-1] == 0)55- return string(pchCommand, pchCommand + strlen(pchCommand));56+ return std::string(pchCommand, pchCommand + strlen(pchCommand));57 else58- return string(pchCommand, pchCommand + COMMAND_SIZE);59+ return std::string(pchCommand, pchCommand + COMMAND_SIZE);60 }61 62 bool IsValid()63@@ -156,7 +168,7 @@64 {65 Init();66 ip = ipIn;67- port = (portIn == 0 ? GetDefaultPort() : portIn);68+ port = htons(portIn == 0 ? GetDefaultPort() : portIn);69 nServices = nServicesIn;70 }71 72@@ -168,18 +180,28 @@73 nServices = nServicesIn;74 }75 76- explicit CAddress(const char* pszIn, uint64 nServicesIn=NODE_NETWORK)77+ explicit CAddress(const char* pszIn, int portIn, bool fNameLookup = false, uint64 nServicesIn=NODE_NETWORK)78 {79 Init();80- SetAddress(pszIn);81- nServices = nServicesIn;82- }83-84- explicit CAddress(string strIn, uint64 nServicesIn=NODE_NETWORK)85+ Lookup(pszIn, *this, nServicesIn, fNameLookup, portIn);86+ }87+88+ explicit CAddress(const char* pszIn, bool fNameLookup = false, uint64 nServicesIn=NODE_NETWORK)89 {90 Init();91- SetAddress(strIn.c_str());92- nServices = nServicesIn;93+ Lookup(pszIn, *this, nServicesIn, fNameLookup, 0, true);94+ }95+96+ explicit CAddress(std::string strIn, int portIn, bool fNameLookup = false, uint64 nServicesIn=NODE_NETWORK)97+ {98+ Init();99+ Lookup(strIn.c_str(), *this, nServicesIn, fNameLookup, portIn);100+ }101+102+ explicit CAddress(std::string strIn, bool fNameLookup = false, uint64 nServicesIn=NODE_NETWORK)103+ {104+ Init();105+ Lookup(strIn.c_str(), *this, nServicesIn, fNameLookup, 0, true);106 }107 108 void Init()109@@ -187,35 +209,9 @@110 nServices = NODE_NETWORK;111 memcpy(pchReserved, pchIPv4, sizeof(pchReserved));112 ip = INADDR_NONE;113- port = GetDefaultPort();114+ port = htons(GetDefaultPort());115 nTime = 100000000;116 nLastTry = 0;117- }118-119- bool SetAddress(const char* pszIn)120- {121- ip = INADDR_NONE;122- port = GetDefaultPort();123- char psz[100];124- strlcpy(psz, pszIn, sizeof(psz));125- unsigned int a=0, b=0, c=0, d=0, e=0;126- if (sscanf(psz, "%u.%u.%u.%u:%u", &a, &b, &c, &d, &e) < 4)127- return false;128- char* pszPort = strchr(psz, ':');129- if (pszPort)130- {131- *pszPort++ = '\0';132- port = htons(atoi(pszPort));133- if (atoi(pszPort) < 0 || atoi(pszPort) > USHRT_MAX)134- port = htons(USHRT_MAX);135- }136- ip = inet_addr(psz);137- return IsValid();138- }139-140- bool SetAddress(string strIn)141- {142- return SetAddress(strIn.c_str());143 }144 145 IMPLEMENT_SERIALIZE146@@ -259,16 +255,16 @@147 return false;148 }149 150- vector<unsigned char> GetKey() const151+ std::vector<unsigned char> GetKey() const152 {153 CDataStream ss;154 ss.reserve(18);155 ss << FLATDATA(pchReserved) << ip << port;156 157 #if defined(_MSC_VER) && _MSC_VER < 1300158- return vector<unsigned char>((unsigned char*)&ss.begin()[0], (unsigned char*)&ss.end()[0]);159+ return std::vector<unsigned char>((unsigned char*)&ss.begin()[0], (unsigned char*)&ss.end()[0]);160 #else161- return vector<unsigned char>(ss.begin(), ss.end());162+ return std::vector<unsigned char>(ss.begin(), ss.end());163 #endif164 }165 166@@ -315,27 +311,22 @@167 return ((unsigned char*)&ip)[3-n];168 }169 170- string ToStringIPPort() const171+ std::string ToStringIPPort() const172 {173 return strprintf("%u.%u.%u.%u:%u", GetByte(3), GetByte(2), GetByte(1), GetByte(0), ntohs(port));174 }175 176- string ToStringIP() const177+ std::string ToStringIP() const178 {179 return strprintf("%u.%u.%u.%u", GetByte(3), GetByte(2), GetByte(1), GetByte(0));180 }181 182- string ToStringPort() const183+ std::string ToStringPort() const184 {185 return strprintf("%u", ntohs(port));186 }187 188- string ToStringLog() const189- {190- return "";191- }192-193- string ToString() const194+ std::string ToString() const195 {196 return strprintf("%u.%u.%u.%u:%u", GetByte(3), GetByte(2), GetByte(1), GetByte(0), ntohs(port));197 }198@@ -383,7 +374,7 @@199 hash = hashIn;200 }201 202- CInv(const string& strType, const uint256& hashIn)203+ CInv(const std::string& strType, const uint256& hashIn)204 {205 int i;206 for (i = 1; i < ARRAYLEN(ppszTypeName); i++)207@@ -422,7 +413,7 @@208 return ppszTypeName[type];209 }210 211- string ToString() const212+ std::string ToString() const213 {214 return strprintf("%s %s", GetCommand(), hash.ToString().substr(0,20).c_str());215 }216@@ -460,21 +451,22 @@217 218 219 extern bool fClient;220+extern bool fAllowDNS;221 extern uint64 nLocalServices;222 extern CAddress addrLocalHost;223 extern CNode* pnodeLocalHost;224 extern uint64 nLocalHostNonce;225-extern array<int, 10> vnThreadsRunning;226+extern boost::array<int, 10> vnThreadsRunning;227 extern SOCKET hListenSocket;228 229-extern vector<CNode*> vNodes;230+extern std::vector<CNode*> vNodes;231 extern CCriticalSection cs_vNodes;232-extern map<vector<unsigned char>, CAddress> mapAddresses;233+extern std::map<std::vector<unsigned char>, CAddress> mapAddresses;234 extern CCriticalSection cs_mapAddresses;235-extern map<CInv, CDataStream> mapRelay;236-extern deque<pair<int64, CInv> > vRelayExpiration;237+extern std::map<CInv, CDataStream> mapRelay;238+extern std::deque<std::pair<int64, CInv> > vRelayExpiration;239 extern CCriticalSection cs_mapRelay;240-extern map<CInv, int64> mapAlreadyAskedFor;241+extern std::map<CInv, int64> mapAlreadyAskedFor;242 243 // Settings244 extern int fUseProxy;245@@ -503,7 +495,7 @@246 unsigned int nMessageStart;247 CAddress addr;248 int nVersion;249- string strSubVer;250+ std::string strSubVer;251 bool fClient;252 bool fInbound;253 bool fNetworkNode;254@@ -513,7 +505,7 @@255 int nRefCount;256 public:257 int64 nReleaseTime;258- map<uint256, CRequestTracker> mapRequests;259+ std::map<uint256, CRequestTracker> mapRequests;260 CCriticalSection cs_mapRequests;261 uint256 hashContinue;262 CBlockIndex* pindexLastGetBlocksBegin;263@@ -521,19 +513,19 @@264 int nStartingHeight;265 266 // flood relay267- vector<CAddress> vAddrToSend;268- set<CAddress> setAddrKnown;269+ std::vector<CAddress> vAddrToSend;270+ std::set<CAddress> setAddrKnown;271 bool fGetAddr;272- set<uint256> setKnown;273+ std::set<uint256> setKnown;274 275 // inventory based relay276- set<CInv> setInventoryKnown;277- vector<CInv> vInventoryToSend;278+ std::set<CInv> setInventoryKnown;279+ std::vector<CInv> vInventoryToSend;280 CCriticalSection cs_inventory;281- multimap<int64, CInv> mapAskFor;282+ std::multimap<int64, CInv> mapAskFor;283 284 // publish and subscription285- vector<char> vfSubscribe;286+ std::vector<char> vfSubscribe;287 288 289 CNode(SOCKET hSocketIn, CAddress addrIn, bool fInboundIn=false)290@@ -595,13 +587,13 @@291 292 int GetRefCount()293 {294- return max(nRefCount, 0) + (GetTime() < nReleaseTime ? 1 : 0);295+ return std::max(nRefCount, 0) + (GetTime() < nReleaseTime ? 1 : 0);296 }297 298 CNode* AddRef(int64 nTimeout=0)299 {300 if (nTimeout != 0)301- nReleaseTime = max(nReleaseTime, GetTime() + nTimeout);302+ nReleaseTime = std::max(nReleaseTime, GetTime() + nTimeout);303 else304 nRefCount++;305 return this;306@@ -652,11 +644,11 @@307 // Make sure not to reuse time indexes to keep things in the same order308 int64 nNow = (GetTime() - 1) * 1000000;309 static int64 nLastTime;310- nLastTime = nNow = max(nNow, ++nLastTime);311+ nLastTime = nNow = std::max(nNow, ++nLastTime);312 313 // Each retry is 2 minutes after the last314- nRequestTime = max(nRequestTime + 2 * 60 * 1000000, nNow);315- mapAskFor.insert(make_pair(nRequestTime, inv));316+ nRequestTime = std::max(nRequestTime + 2 * 60 * 1000000, nNow);317+ mapAskFor.insert(std::make_pair(nRequestTime, inv));318 }319 320 321@@ -740,7 +732,7 @@322 CAddress addrMe = (fUseProxy ? CAddress("0.0.0.0") : addrLocalHost);323 RAND_bytes((unsigned char*)&nLocalHostNonce, sizeof(nLocalHostNonce));324 PushMessage("version", VERSION, nLocalServices, nTime, addrYou, addrMe,325- nLocalHostNonce, string(pszSubVer), nBestHeight);326+ nLocalHostNonce, std::string(pszSubVer), nBestHeight);327 }328 329 330@@ -966,7 +958,7 @@331 {332 // Put on lists to offer to the other nodes333 CRITICAL_BLOCK(cs_vNodes)334- foreach(CNode* pnode, vNodes)335+ BOOST_FOREACH(CNode* pnode, vNodes)336 pnode->PushInventory(inv);337 }338 339@@ -993,7 +985,7 @@340 341 // Save original serialized message so newer versions are preserved342 mapRelay[inv] = ss;343- vRelayExpiration.push_back(make_pair(GetTime() + 15 * 60, inv));344+ vRelayExpiration.push_back(std::make_pair(GetTime() + 15 * 60, inv));345 }346 347 RelayInventory(inv);348@@ -1025,7 +1017,7 @@349 350 // Relay351 CRITICAL_BLOCK(cs_vNodes)352- foreach(CNode* pnode, vNodes)353+ BOOST_FOREACH(CNode* pnode, vNodes)354 if (pnode != pfrom && (nHops < PUBLISH_HOPS || pnode->IsSubscribed(nChannel)))355 pnode->PushMessage("publish", nChannel, nHops, obj);356 }357@@ -1036,7 +1028,7 @@358 uint256 hash = obj.GetHash();359 360 CRITICAL_BLOCK(cs_vNodes)361- foreach(CNode* pnode, vNodes)362+ BOOST_FOREACH(CNode* pnode, vNodes)363 if (pnode != pfrom && (nHops < PUBLISH_HOPS || pnode->IsSubscribed(nChannel)))364 pnode->PushMessage("pub-cancel", nChannel, nHops, hash);365 366@@ -1054,3 +1046,5 @@367 AdvertStopPublish(pfrom, nChannel, nHops, obj);368 }369 370+#endif371+
noui.h (modified)
1--- v0.3.21/noui.h2+++ v0.3.22/noui.h3@@ -1,7 +1,10 @@4 // Copyright (c) 2010 Satoshi Nakamoto5 // Distributed under the MIT/X11 software license, see the accompanying6 // file license.txt or http://www.opensource.org/licenses/mit-license.php.7+#ifndef BITCOIN_NOUI_H8+#define BITCOIN_NOUI_H9 10+#include <string>11 12 typedef void wxWindow;13 #define wxYES 0x0000000214@@ -31,7 +34,7 @@15 #define wxMORE 0x0001000016 #define wxSETUP 0x0002000017 18-inline int MyMessageBox(const string& message, const string& caption="Message", int style=wxOK, wxWindow* parent=NULL, int x=-1, int y=-1)19+inline int MyMessageBox(const std::string& message, const std::string& caption="Message", int style=wxOK, wxWindow* parent=NULL, int x=-1, int y=-1)20 {21 printf("%s: %s\n", caption.c_str(), message.c_str());22 fprintf(stderr, "%s: %s\n", caption.c_str(), message.c_str());23@@ -39,17 +42,17 @@24 }25 #define wxMessageBox MyMessageBox26 27-inline int ThreadSafeMessageBox(const string& message, const string& caption, int style=wxOK, wxWindow* parent=NULL, int x=-1, int y=-1)28+inline int ThreadSafeMessageBox(const std::string& message, const std::string& caption, int style=wxOK, wxWindow* parent=NULL, int x=-1, int y=-1)29 {30 return MyMessageBox(message, caption, style, parent, x, y);31 }32 33-inline bool ThreadSafeAskFee(int64 nFeeRequired, const string& strCaption, wxWindow* parent)34+inline bool ThreadSafeAskFee(int64 nFeeRequired, const std::string& strCaption, wxWindow* parent)35 {36 return true;37 }38 39-inline void CalledSetStatusBar(const string& strText, int nField)40+inline void CalledSetStatusBar(const std::string& strText, int nField)41 {42 }43 44@@ -61,3 +64,5 @@45 {46 }47 48+#endif49+
rpc.cpp (modified)
1--- v0.3.21/rpc.cpp2+++ v0.3.22/rpc.cpp3@@ -21,6 +21,8 @@4 // a certain size around 145MB. If we need access to json_spirit outside this5 // file, we could use the compiled json_spirit option.6 7+using namespace std;8+using namespace boost;9 using namespace boost::asio;10 using namespace json_spirit;11 12@@ -81,7 +83,7 @@13 entry.push_back(Pair("confirmations", wtx.GetDepthInMainChain()));14 entry.push_back(Pair("txid", wtx.GetHash().GetHex()));15 entry.push_back(Pair("time", (boost::int64_t)wtx.GetTxTime()));16- foreach(const PAIRTYPE(string,string)& item, wtx.mapValue)17+ BOOST_FOREACH(const PAIRTYPE(string,string)& item, wtx.mapValue)18 entry.push_back(Pair(item.first, item.second));19 }20 21@@ -197,12 +199,26 @@22 {23 // Floating point number that is a multiple of the minimum difficulty,24 // minimum difficulty = 1.0.25+26 if (pindexBest == NULL)27 return 1.0;28- int nShift = 256 - 32 - 31; // to fit in a uint29- double dMinimum = (CBigNum().SetCompact(bnProofOfWorkLimit.GetCompact()) >> nShift).getuint();30- double dCurrently = (CBigNum().SetCompact(pindexBest->nBits) >> nShift).getuint();31- return dMinimum / dCurrently;32+ int nShift = (pindexBest->nBits >> 24) & 0xff;33+34+ double dDiff =35+ (double)0x0000ffff / (double)(pindexBest->nBits & 0x00ffffff);36+37+ while (nShift < 29)38+ {39+ dDiff *= 256.0;40+ nShift++;41+ }42+ while (nShift > 29)43+ {44+ dDiff /= 256.0;45+ nShift--;46+ }47+48+ return dDiff;49 }50 51 Value getdifficulty(const Array& params, bool fHelp)52@@ -336,7 +352,7 @@53 ++it)54 {55 const CWalletTx& wtx = (*it).second;56- foreach(const CTxOut& txout, wtx.vout)57+ BOOST_FOREACH(const CTxOut& txout, wtx.vout)58 if (txout.scriptPubKey == scriptPubKey)59 account.vchPubKey.clear();60 }61@@ -449,7 +465,7 @@62 Array ret;63 CRITICAL_BLOCK(cs_mapAddressBook)64 {65- foreach(const PAIRTYPE(string, string)& item, mapAddressBook)66+ BOOST_FOREACH(const PAIRTYPE(string, string)& item, mapAddressBook)67 {68 const string& strAddress = item.first;69 const string& strName = item.second;70@@ -465,12 +481,28 @@71 return ret;72 }73 74+Value settxfee(const Array& params, bool fHelp)75+{76+ if (fHelp || params.size() < 1 || params.size() > 1)77+ throw runtime_error(78+ "settxfee <amount>\n"79+ "<amount> is a real and is rounded to the nearest 0.00000001");80+81+ // Amount82+ int64 nAmount = 0;83+ if (params[0].get_real() != 0.0)84+ nAmount = AmountFromValue(params[0]); // rejects 0.0 amounts85+86+ nTransactionFee = nAmount;87+ return true;88+}89+90 Value sendtoaddress(const Array& params, bool fHelp)91 {92 if (fHelp || params.size() < 2 || params.size() > 4)93 throw runtime_error(94 "sendtoaddress <bitcoinaddress> <amount> [comment] [comment-to]\n"95- "<amount> is a real and is rounded to the nearest 0.01");96+ "<amount> is a real and is rounded to the nearest 0.00000001");97 98 string strAddress = params[0].get_str();99 100@@ -525,7 +557,7 @@101 if (wtx.IsCoinBase() || !wtx.IsFinal())102 continue;103 104- foreach(const CTxOut& txout, wtx.vout)105+ BOOST_FOREACH(const CTxOut& txout, wtx.vout)106 if (txout.scriptPubKey == scriptPubKey)107 if (wtx.GetDepthInMainChain() >= nMinDepth)108 nAmount += txout.nValue;109@@ -540,7 +572,7 @@110 {111 CRITICAL_BLOCK(cs_mapAddressBook)112 {113- foreach(const PAIRTYPE(string, string)& item, mapAddressBook)114+ BOOST_FOREACH(const PAIRTYPE(string, string)& item, mapAddressBook)115 {116 const string& strAddress = item.first;117 const string& strName = item.second;118@@ -584,7 +616,7 @@119 if (wtx.IsCoinBase() || !wtx.IsFinal())120 continue;121 122- foreach(const CTxOut& txout, wtx.vout)123+ BOOST_FOREACH(const CTxOut& txout, wtx.vout)124 if (setPubKey.count(txout.scriptPubKey))125 if (wtx.GetDepthInMainChain() >= nMinDepth)126 nAmount += txout.nValue;127@@ -662,9 +694,9 @@128 list<pair<string, int64> > listSent;129 wtx.GetAmounts(allGeneratedImmature, allGeneratedMature, listReceived, listSent, allFee, strSentAccount);130 if (wtx.GetDepthInMainChain() >= nMinDepth)131- foreach(const PAIRTYPE(string,int64)& r, listReceived)132+ BOOST_FOREACH(const PAIRTYPE(string,int64)& r, listReceived)133 nBalance += r.second;134- foreach(const PAIRTYPE(string,int64)& r, listSent)135+ BOOST_FOREACH(const PAIRTYPE(string,int64)& r, listSent)136 nBalance -= r.second;137 nBalance -= allFee;138 nBalance += allGeneratedMature;139@@ -702,21 +734,6 @@140 CWalletDB walletdb;141 walletdb.TxnBegin();142 143- // Check funds144- if (!strFrom.empty())145- {146- int64 nBalance = GetAccountBalance(walletdb, strFrom, nMinDepth);147- if (nAmount > nBalance)148- throw JSONRPCError(-6, "Account has insufficient funds");149- }150- else151- {152- // move from "" account special case153- int64 nBalance = GetAccountBalance(walletdb, strTo, nMinDepth);154- if (nAmount > GetBalance() - nBalance)155- throw JSONRPCError(-6, "Account has insufficient funds");156- }157-158 int64 nNow = GetAdjustedTime();159 160 // Debit161@@ -748,7 +765,7 @@162 if (fHelp || params.size() < 3 || params.size() > 6)163 throw runtime_error(164 "sendfrom <fromaccount> <tobitcoinaddress> <amount> [minconf=1] [comment] [comment-to]\n"165- "<amount> is a real and is rounded to the nearest 0.01");166+ "<amount> is a real and is rounded to the nearest 0.00000001");167 168 string strAccount = AccountFromValue(params[0]);169 string strAddress = params[1].get_str();170@@ -803,7 +820,7 @@171 vector<pair<CScript, int64> > vecSend;172 173 int64 totalAmount = 0;174- foreach(const Pair& s, sendTo)175+ BOOST_FOREACH(const Pair& s, sendTo)176 {177 uint160 hash160;178 string strAddress = s.name_;179@@ -884,7 +901,7 @@180 if (nDepth < nMinDepth)181 continue;182 183- foreach(const CTxOut& txout, wtx.vout)184+ BOOST_FOREACH(const CTxOut& txout, wtx.vout)185 {186 // Only counting our own bitcoin addresses and not ip addresses187 uint160 hash160 = txout.scriptPubKey.GetBitcoinAddressHash160();188@@ -903,7 +920,7 @@189 map<string, tallyitem> mapAccountTally;190 CRITICAL_BLOCK(cs_mapAddressBook)191 {192- foreach(const PAIRTYPE(string, string)& item, mapAddressBook)193+ BOOST_FOREACH(const PAIRTYPE(string, string)& item, mapAddressBook)194 {195 const string& strAddress = item.first;196 const string& strAccount = item.second;197@@ -1023,7 +1040,7 @@198 // Sent199 if ((!listSent.empty() || nFee != 0) && (fAllAccounts || strAccount == strSentAccount))200 {201- foreach(const PAIRTYPE(string, int64)& s, listSent)202+ BOOST_FOREACH(const PAIRTYPE(string, int64)& s, listSent)203 {204 Object entry;205 entry.push_back(Pair("account", strSentAccount));206@@ -1041,7 +1058,7 @@207 if (listReceived.size() > 0 && wtx.GetDepthInMainChain() >= nMinDepth)208 CRITICAL_BLOCK(cs_mapAddressBook)209 {210- foreach(const PAIRTYPE(string, int64)& r, listReceived)211+ BOOST_FOREACH(const PAIRTYPE(string, int64)& r, listReceived)212 {213 string account;214 if (mapAddressBook.count(r.first))215@@ -1081,10 +1098,10 @@216 217 Value listtransactions(const Array& params, bool fHelp)218 {219- if (fHelp || params.size() > 2)220- throw runtime_error(221- "listtransactions [account] [count=10]\n"222- "Returns up to [count] most recent transactions for account <account>.");223+ if (fHelp || params.size() > 3)224+ throw runtime_error(225+ "listtransactions [account] [count=10] [from=0]\n"226+ "Returns up to [count] most recent transactions skipping the first [from] transactions for account [account].");227 228 string strAccount = "*";229 if (params.size() > 0)230@@ -1092,6 +1109,9 @@231 int nCount = 10;232 if (params.size() > 1)233 nCount = params[1].get_int();234+ int nFrom = 0;235+ if (params.size() > 2)236+ nFrom = params[2].get_int();237 238 Array ret;239 CWalletDB walletdb;240@@ -1110,13 +1130,14 @@241 }242 list<CAccountingEntry> acentries;243 walletdb.ListAccountCreditDebit(strAccount, acentries);244- foreach(CAccountingEntry& entry, acentries)245+ BOOST_FOREACH(CAccountingEntry& entry, acentries)246 {247 txByTime.insert(make_pair(entry.nTime, TxPair((CWalletTx*)0, &entry)));248 }249 250 // Now: iterate backwards until we have nCount items to return:251- for (TxItems::reverse_iterator it = txByTime.rbegin(); it != txByTime.rend(); ++it)252+ TxItems::reverse_iterator it = txByTime.rbegin();253+ for (std::advance(it, nFrom); it != txByTime.rend(); ++it)254 {255 CWalletTx *const pwtx = (*it).second.first;256 if (pwtx != 0)257@@ -1157,7 +1178,7 @@258 CRITICAL_BLOCK(cs_mapWallet)259 CRITICAL_BLOCK(cs_mapAddressBook)260 {261- foreach(const PAIRTYPE(string, string)& entry, mapAddressBook) {262+ BOOST_FOREACH(const PAIRTYPE(string, string)& entry, mapAddressBook) {263 uint160 hash160;264 if(AddressToHash160(entry.first, hash160) && mapPubKeys.count(hash160)) // This address belongs to me265 mapAccountBalances[entry.second] = 0;266@@ -1172,12 +1193,12 @@267 list<pair<string, int64> > listSent;268 wtx.GetAmounts(nGeneratedImmature, nGeneratedMature, listReceived, listSent, nFee, strSentAccount);269 mapAccountBalances[strSentAccount] -= nFee;270- foreach(const PAIRTYPE(string, int64)& s, listSent)271+ BOOST_FOREACH(const PAIRTYPE(string, int64)& s, listSent)272 mapAccountBalances[strSentAccount] -= s.second;273 if (wtx.GetDepthInMainChain() >= nMinDepth)274 {275 mapAccountBalances[""] += nGeneratedMature;276- foreach(const PAIRTYPE(string, int64)& r, listReceived)277+ BOOST_FOREACH(const PAIRTYPE(string, int64)& r, listReceived)278 if (mapAddressBook.count(r.first))279 mapAccountBalances[mapAddressBook[r.first]] += r.second;280 else281@@ -1188,11 +1209,11 @@282 283 list<CAccountingEntry> acentries;284 CWalletDB().ListAccountCreditDebit("*", acentries);285- foreach(const CAccountingEntry& entry, acentries)286+ BOOST_FOREACH(const CAccountingEntry& entry, acentries)287 mapAccountBalances[entry.strAccount] += entry.nCreditDebit;288 289 Object ret;290- foreach(const PAIRTYPE(string, int64)& accountBalance, mapAccountBalances) {291+ BOOST_FOREACH(const PAIRTYPE(string, int64)& accountBalance, mapAccountBalances) {292 ret.push_back(Pair(accountBalance.first, ValueFromAmount(accountBalance.second)));293 }294 return ret;295@@ -1315,7 +1336,7 @@296 {297 // Deallocate old blocks since they're obsolete now298 mapNewBlock.clear();299- foreach(CBlock* pblock, vNewBlock)300+ BOOST_FOREACH(CBlock* pblock, vNewBlock)301 delete pblock;302 vNewBlock.clear();303 }304@@ -1437,6 +1458,7 @@305 make_pair("listtransactions", &listtransactions),306 make_pair("getwork", &getwork),307 make_pair("listaccounts", &listaccounts),308+ make_pair("settxfee", &settxfee),309 };310 map<string, rpcfn_type> mapCallTable(pCallTable, pCallTable + sizeof(pCallTable)/sizeof(pCallTable[0]));311 312@@ -1484,7 +1506,7 @@313 << "Content-Type: application/json\r\n"314 << "Content-Length: " << strMsg.size() << "\r\n"315 << "Accept: application/json\r\n";316- foreach(const PAIRTYPE(string, string)& item, mapRequestHeaders)317+ BOOST_FOREACH(const PAIRTYPE(string, string)& item, mapRequestHeaders)318 s << item.first << ": " << item.second << "\r\n";319 s << "\r\n" << strMsg;320 321@@ -1570,10 +1592,11 @@322 {323 string strHeader = str.substr(0, nColon);324 boost::trim(strHeader);325+ boost::to_lower(strHeader);326 string strValue = str.substr(nColon+1);327 boost::trim(strValue);328 mapHeadersRet[strHeader] = strValue;329- if (strHeader == "Content-Length")330+ if (strHeader == "content-length")331 nLen = atoi(strValue.c_str());332 }333 }334@@ -1643,7 +1666,7 @@335 336 bool HTTPAuthorized(map<string, string>& mapHeaders)337 {338- string strAuth = mapHeaders["Authorization"];339+ string strAuth = mapHeaders["authorization"];340 if (strAuth.substr(0,6) != "Basic ")341 return false;342 string strUserPass64 = strAuth.substr(6); boost::trim(strUserPass64);343@@ -1703,7 +1726,7 @@344 if (strAddress == asio::ip::address_v4::loopback().to_string())345 return true;346 const vector<string>& vAllow = mapMultiArgs["-rpcallowip"];347- foreach(string strAllow, vAllow)348+ BOOST_FOREACH(string strAllow, vAllow)349 if (WildcardMatch(strAddress, strAllow))350 return true;351 return false;352@@ -1872,7 +1895,7 @@353 }354 355 // Check authorization356- if (mapHeaders.count("Authorization") == 0)357+ if (mapHeaders.count("authorization") == 0)358 {359 stream << HTTPReply(401, "") << std::flush;360 continue;361@@ -2069,6 +2092,7 @@362 if (strMethod == "setgenerate" && n > 0) ConvertTo<bool>(params[0]);363 if (strMethod == "setgenerate" && n > 1) ConvertTo<boost::int64_t>(params[1]);364 if (strMethod == "sendtoaddress" && n > 1) ConvertTo<double>(params[1]);365+ if (strMethod == "settxfee" && n > 0) ConvertTo<double>(params[0]);366 if (strMethod == "getamountreceived" && n > 1) ConvertTo<boost::int64_t>(params[1]); // deprecated367 if (strMethod == "getreceivedbyaddress" && n > 1) ConvertTo<boost::int64_t>(params[1]);368 if (strMethod == "getreceivedbyaccount" && n > 1) ConvertTo<boost::int64_t>(params[1]);369@@ -2087,6 +2111,7 @@370 if (strMethod == "sendfrom" && n > 2) ConvertTo<double>(params[2]);371 if (strMethod == "sendfrom" && n > 3) ConvertTo<boost::int64_t>(params[3]);372 if (strMethod == "listtransactions" && n > 1) ConvertTo<boost::int64_t>(params[1]);373+ if (strMethod == "listtransactions" && n > 2) ConvertTo<boost::int64_t>(params[2]);374 if (strMethod == "listaccounts" && n > 0) ConvertTo<boost::int64_t>(params[0]);375 if (strMethod == "sendmany" && n > 1)376 {
script.cpp (modified)
1--- v0.3.21/script.cpp2+++ v0.3.22/script.cpp3@@ -1,8 +1,10 @@4 // Copyright (c) 2009-2010 Satoshi Nakamoto5 // Distributed under the MIT/X11 software license, see the accompanying6 // file license.txt or http://www.opensource.org/licenses/mit-license.php.7-8 #include "headers.h"9+10+using namespace std;11+using namespace boost;12 13 bool CheckSig(vector<unsigned char> vchSig, vector<unsigned char> vchPubKey, CScript scriptCode, const CTransaction& txTo, unsigned int nIn, int nHashType);14 15@@ -974,7 +976,7 @@16 17 // Scan templates18 const CScript& script1 = scriptPubKey;19- foreach(const CScript& script2, vTemplates)20+ BOOST_FOREACH(const CScript& script2, vTemplates)21 {22 vSolutionRet.clear();23 opcodetype opcode1, opcode2;24@@ -1030,7 +1032,7 @@25 // Compile solution26 CRITICAL_BLOCK(cs_mapKeys)27 {28- foreach(PAIRTYPE(opcodetype, valtype)& item, vSolution)29+ BOOST_FOREACH(PAIRTYPE(opcodetype, valtype)& item, vSolution)30 {31 if (item.first == OP_PUBKEY)32 {33@@ -1100,7 +1102,7 @@34 35 CRITICAL_BLOCK(cs_mapKeys)36 {37- foreach(PAIRTYPE(opcodetype, valtype)& item, vSolution)38+ BOOST_FOREACH(PAIRTYPE(opcodetype, valtype)& item, vSolution)39 {40 valtype vchPubKey;41 if (item.first == OP_PUBKEY)42@@ -1133,7 +1135,7 @@43 if (!Solver(scriptPubKey, vSolution))44 return false;45 46- foreach(PAIRTYPE(opcodetype, valtype)& item, vSolution)47+ BOOST_FOREACH(PAIRTYPE(opcodetype, valtype)& item, vSolution)48 {49 if (item.first == OP_PUBKEYHASH)50 {
script.h (modified)
1--- v0.3.21/script.h2+++ v0.3.22/script.h3@@ -1,6 +1,13 @@4 // Copyright (c) 2009-2010 Satoshi Nakamoto5 // Distributed under the MIT/X11 software license, see the accompanying6 // file license.txt or http://www.opensource.org/licenses/mit-license.php.7+#ifndef H_BITCOIN_SCRIPT8+#define H_BITCOIN_SCRIPT9+10+#include "base58.h"11+12+#include <string>13+#include <vector>14 15 class CTransaction;16 17@@ -310,7 +317,7 @@18 19 20 21-inline string ValueString(const vector<unsigned char>& vch)22+inline std::string ValueString(const std::vector<unsigned char>& vch)23 {24 if (vch.size() <= 4)25 return strprintf("%d", CBigNum(vch).getint());26@@ -318,10 +325,10 @@27 return HexStr(vch);28 }29 30-inline string StackString(const vector<vector<unsigned char> >& vStack)31+inline std::string StackString(const std::vector<std::vector<unsigned char> >& vStack)32 {33- string str;34- foreach(const vector<unsigned char>& vch, vStack)35+ std::string str;36+ BOOST_FOREACH(const std::vector<unsigned char>& vch, vStack)37 {38 if (!str.empty())39 str += " ";40@@ -338,7 +345,7 @@41 42 43 44-class CScript : public vector<unsigned char>45+class CScript : public std::vector<unsigned char>46 {47 protected:48 CScript& push_int64(int64 n)49@@ -371,10 +378,10 @@50 51 public:52 CScript() { }53- CScript(const CScript& b) : vector<unsigned char>(b.begin(), b.end()) { }54- CScript(const_iterator pbegin, const_iterator pend) : vector<unsigned char>(pbegin, pend) { }55+ CScript(const CScript& b) : std::vector<unsigned char>(b.begin(), b.end()) { }56+ CScript(const_iterator pbegin, const_iterator pend) : std::vector<unsigned char>(pbegin, pend) { }57 #ifndef _MSC_VER58- CScript(const unsigned char* pbegin, const unsigned char* pend) : vector<unsigned char>(pbegin, pend) { }59+ CScript(const unsigned char* pbegin, const unsigned char* pend) : std::vector<unsigned char>(pbegin, pend) { }60 #endif61 62 CScript& operator+=(const CScript& b)63@@ -405,7 +412,7 @@64 explicit CScript(opcodetype b) { operator<<(b); }65 explicit CScript(const uint256& b) { operator<<(b); }66 explicit CScript(const CBigNum& b) { operator<<(b); }67- explicit CScript(const vector<unsigned char>& b) { operator<<(b); }68+ explicit CScript(const std::vector<unsigned char>& b) { operator<<(b); }69 70 71 CScript& operator<<(char b) { return push_int64(b); }72@@ -422,7 +429,7 @@73 CScript& operator<<(opcodetype opcode)74 {75 if (opcode < 0 || opcode > 0xff)76- throw runtime_error("CScript::operator<<() : invalid opcode");77+ throw std::runtime_error("CScript::operator<<() : invalid opcode");78 insert(end(), (unsigned char)opcode);79 return *this;80 }81@@ -447,7 +454,7 @@82 return *this;83 }84 85- CScript& operator<<(const vector<unsigned char>& b)86+ CScript& operator<<(const std::vector<unsigned char>& b)87 {88 if (b.size() < OP_PUSHDATA1)89 {90@@ -483,7 +490,7 @@91 }92 93 94- bool GetOp(iterator& pc, opcodetype& opcodeRet, vector<unsigned char>& vchRet)95+ bool GetOp(iterator& pc, opcodetype& opcodeRet, std::vector<unsigned char>& vchRet)96 {97 // Wrapper so it can be called with either iterator or const_iterator98 const_iterator pc2 = pc;99@@ -500,7 +507,7 @@100 return fRet;101 }102 103- bool GetOp(const_iterator& pc, opcodetype& opcodeRet, vector<unsigned char>& vchRet) const104+ bool GetOp(const_iterator& pc, opcodetype& opcodeRet, std::vector<unsigned char>& vchRet) const105 {106 return GetOp2(pc, opcodeRet, &vchRet);107 }108@@ -510,7 +517,7 @@109 return GetOp2(pc, opcodeRet, NULL);110 }111 112- bool GetOp2(const_iterator& pc, opcodetype& opcodeRet, vector<unsigned char>* pvchRet) const113+ bool GetOp2(const_iterator& pc, opcodetype& opcodeRet, std::vector<unsigned char>* pvchRet) const114 {115 opcodeRet = OP_INVALIDOPCODE;116 if (pvchRet)117@@ -617,7 +624,7 @@118 uint160 GetBitcoinAddressHash160() const119 {120 opcodetype opcode;121- vector<unsigned char> vch;122+ std::vector<unsigned char> vch;123 CScript::const_iterator pc = begin();124 if (!GetOp(pc, opcode, vch) || opcode != OP_DUP) return 0;125 if (!GetOp(pc, opcode, vch) || opcode != OP_HASH160) return 0;126@@ -629,7 +636,7 @@127 return hash160;128 }129 130- string GetBitcoinAddress() const131+ std::string GetBitcoinAddress() const132 {133 uint160 hash160 = GetBitcoinAddressHash160();134 if (hash160 == 0)135@@ -643,12 +650,12 @@136 *this << OP_DUP << OP_HASH160 << hash160 << OP_EQUALVERIFY << OP_CHECKSIG;137 }138 139- void SetBitcoinAddress(const vector<unsigned char>& vchPubKey)140+ void SetBitcoinAddress(const std::vector<unsigned char>& vchPubKey)141 {142 SetBitcoinAddress(Hash160(vchPubKey));143 }144 145- bool SetBitcoinAddress(const string& strAddress)146+ bool SetBitcoinAddress(const std::string& strAddress)147 {148 this->clear();149 uint160 hash160;150@@ -664,11 +671,11 @@151 printf("CScript(%s)\n", HexStr(begin(), end(), true).c_str());152 }153 154- string ToString() const155- {156- string str;157+ std::string ToString() const158+ {159+ std::string str;160 opcodetype opcode;161- vector<unsigned char> vch;162+ std::vector<unsigned char> vch;163 const_iterator pc = begin();164 while (pc < end())165 {166@@ -703,8 +710,10 @@167 uint256 SignatureHash(CScript scriptCode, const CTransaction& txTo, unsigned int nIn, int nHashType);168 bool IsStandard(const CScript& scriptPubKey);169 bool IsMine(const CScript& scriptPubKey);170-bool ExtractPubKey(const CScript& scriptPubKey, bool fMineOnly, vector<unsigned char>& vchPubKeyRet);171+bool ExtractPubKey(const CScript& scriptPubKey, bool fMineOnly, std::vector<unsigned char>& vchPubKeyRet);172 bool ExtractHash160(const CScript& scriptPubKey, uint160& hash160Ret);173 bool SignSignature(const CTransaction& txFrom, CTransaction& txTo, unsigned int nIn, int nHashType=SIGHASH_ALL, CScript scriptPrereq=CScript());174 bool VerifySignature(const CTransaction& txFrom, const CTransaction& txTo, unsigned int nIn, int nHashType=0);175 176+#endif177+
serialize.h (modified)
1--- v0.3.21/serialize.h2+++ v0.3.22/serialize.h3@@ -1,15 +1,23 @@4 // Copyright (c) 2009-2010 Satoshi Nakamoto5 // Distributed under the MIT/X11 software license, see the accompanying6 // file license.txt or http://www.opensource.org/licenses/mit-license.php.7+#ifndef BITCOIN_SERIALIZE_H8+#define BITCOIN_SERIALIZE_H9 10 #include <string>11 #include <vector>12 #include <map>13 #include <set>14+#include <cassert>15+#include <climits>16+#include <cstring>17+#include <cstdio>18+19 #include <boost/type_traits/is_fundamental.hpp>20 #include <boost/tuple/tuple.hpp>21 #include <boost/tuple/tuple_comparison.hpp>22 #include <boost/tuple/tuple_io.hpp>23+24 #if defined(_MSC_VER) || defined(__BORLANDC__)25 typedef __int64 int64;26 typedef unsigned __int64 uint64;27@@ -25,7 +33,7 @@28 class CAutoFile;29 static const unsigned int MAX_SIZE = 0x02000000;30 31-static const int VERSION = 32100;32+static const int VERSION = 32200;33 static const char* pszSubVer = "";34 static const bool VERSION_IS_BETA = true;35 36@@ -277,11 +285,11 @@37 class CFixedFieldString38 {39 protected:40- const string* pcstr;41- string* pstr;42+ const std::string* pcstr;43+ std::string* pstr;44 public:45- explicit CFixedFieldString(const string& str) : pcstr(&str), pstr(NULL) { }46- explicit CFixedFieldString(string& str) : pcstr(&str), pstr(&str) { }47+ explicit CFixedFieldString(const std::string& str) : pcstr(&str), pstr(NULL) { }48+ explicit CFixedFieldString(std::string& str) : pcstr(&str), pstr(&str) { }49 50 unsigned int GetSerializeSize(int, int=0) const51 {52@@ -317,9 +325,9 @@53 //54 55 // string56-template<typename C> unsigned int GetSerializeSize(const basic_string<C>& str, int, int=0);57-template<typename Stream, typename C> void Serialize(Stream& os, const basic_string<C>& str, int, int=0);58-template<typename Stream, typename C> void Unserialize(Stream& is, basic_string<C>& str, int, int=0);59+template<typename C> unsigned int GetSerializeSize(const std::basic_string<C>& str, int, int=0);60+template<typename Stream, typename C> void Serialize(Stream& os, const std::basic_string<C>& str, int, int=0);61+template<typename Stream, typename C> void Unserialize(Stream& is, std::basic_string<C>& str, int, int=0);62 63 // vector64 template<typename T, typename A> unsigned int GetSerializeSize_impl(const std::vector<T, A>& v, int nType, int nVersion, const boost::true_type&);65@@ -398,13 +406,13 @@66 // string67 //68 template<typename C>69-unsigned int GetSerializeSize(const basic_string<C>& str, int, int)70+unsigned int GetSerializeSize(const std::basic_string<C>& str, int, int)71 {72 return GetSizeOfCompactSize(str.size()) + str.size() * sizeof(str[0]);73 }74 75 template<typename Stream, typename C>76-void Serialize(Stream& os, const basic_string<C>& str, int, int)77+void Serialize(Stream& os, const std::basic_string<C>& str, int, int)78 {79 WriteCompactSize(os, str.size());80 if (!str.empty())81@@ -412,7 +420,7 @@82 }83 84 template<typename Stream, typename C>85-void Unserialize(Stream& is, basic_string<C>& str, int, int)86+void Unserialize(Stream& is, std::basic_string<C>& str, int, int)87 {88 unsigned int nSize = ReadCompactSize(is);89 str.resize(nSize);90@@ -483,7 +491,7 @@91 unsigned int i = 0;92 while (i < nSize)93 {94- unsigned int blk = min(nSize - i, (unsigned int)(1 + 4999999 / sizeof(T)));95+ unsigned int blk = std::min(nSize - i, (unsigned int)(1 + 4999999 / sizeof(T)));96 v.resize(i + blk);97 is.read((char*)&v[i], blk * sizeof(T));98 i += blk;99@@ -526,19 +534,19 @@100 //101 inline unsigned int GetSerializeSize(const CScript& v, int nType, int nVersion)102 {103- return GetSerializeSize((const vector<unsigned char>&)v, nType, nVersion);104+ return GetSerializeSize((const std::vector<unsigned char>&)v, nType, nVersion);105 }106 107 template<typename Stream>108 void Serialize(Stream& os, const CScript& v, int nType, int nVersion)109 {110- Serialize(os, (const vector<unsigned char>&)v, nType, nVersion);111+ Serialize(os, (const std::vector<unsigned char>&)v, nType, nVersion);112 }113 114 template<typename Stream>115 void Unserialize(Stream& is, CScript& v, int nType, int nVersion)116 {117- Unserialize(is, (vector<unsigned char>&)v, nType, nVersion);118+ Unserialize(is, (std::vector<unsigned char>&)v, nType, nVersion);119 }120 121 122@@ -575,26 +583,26 @@123 unsigned int GetSerializeSize(const boost::tuple<T0, T1, T2>& item, int nType, int nVersion)124 {125 unsigned int nSize = 0;126- nSize += GetSerializeSize(get<0>(item), nType, nVersion);127- nSize += GetSerializeSize(get<1>(item), nType, nVersion);128- nSize += GetSerializeSize(get<2>(item), nType, nVersion);129+ nSize += GetSerializeSize(boost::get<0>(item), nType, nVersion);130+ nSize += GetSerializeSize(boost::get<1>(item), nType, nVersion);131+ nSize += GetSerializeSize(boost::get<2>(item), nType, nVersion);132 return nSize;133 }134 135 template<typename Stream, typename T0, typename T1, typename T2>136 void Serialize(Stream& os, const boost::tuple<T0, T1, T2>& item, int nType, int nVersion)137 {138- Serialize(os, get<0>(item), nType, nVersion);139- Serialize(os, get<1>(item), nType, nVersion);140- Serialize(os, get<2>(item), nType, nVersion);141+ Serialize(os, boost::get<0>(item), nType, nVersion);142+ Serialize(os, boost::get<1>(item), nType, nVersion);143+ Serialize(os, boost::get<2>(item), nType, nVersion);144 }145 146 template<typename Stream, typename T0, typename T1, typename T2>147 void Unserialize(Stream& is, boost::tuple<T0, T1, T2>& item, int nType, int nVersion)148 {149- Unserialize(is, get<0>(item), nType, nVersion);150- Unserialize(is, get<1>(item), nType, nVersion);151- Unserialize(is, get<2>(item), nType, nVersion);152+ Unserialize(is, boost::get<0>(item), nType, nVersion);153+ Unserialize(is, boost::get<1>(item), nType, nVersion);154+ Unserialize(is, boost::get<2>(item), nType, nVersion);155 }156 157 158@@ -606,29 +614,29 @@159 unsigned int GetSerializeSize(const boost::tuple<T0, T1, T2, T3>& item, int nType, int nVersion)160 {161 unsigned int nSize = 0;162- nSize += GetSerializeSize(get<0>(item), nType, nVersion);163- nSize += GetSerializeSize(get<1>(item), nType, nVersion);164- nSize += GetSerializeSize(get<2>(item), nType, nVersion);165- nSize += GetSerializeSize(get<3>(item), nType, nVersion);166+ nSize += GetSerializeSize(boost::get<0>(item), nType, nVersion);167+ nSize += GetSerializeSize(boost::get<1>(item), nType, nVersion);168+ nSize += GetSerializeSize(boost::get<2>(item), nType, nVersion);169+ nSize += GetSerializeSize(boost::get<3>(item), nType, nVersion);170 return nSize;171 }172 173 template<typename Stream, typename T0, typename T1, typename T2, typename T3>174 void Serialize(Stream& os, const boost::tuple<T0, T1, T2, T3>& item, int nType, int nVersion)175 {176- Serialize(os, get<0>(item), nType, nVersion);177- Serialize(os, get<1>(item), nType, nVersion);178- Serialize(os, get<2>(item), nType, nVersion);179- Serialize(os, get<3>(item), nType, nVersion);180+ Serialize(os, boost::get<0>(item), nType, nVersion);181+ Serialize(os, boost::get<1>(item), nType, nVersion);182+ Serialize(os, boost::get<2>(item), nType, nVersion);183+ Serialize(os, boost::get<3>(item), nType, nVersion);184 }185 186 template<typename Stream, typename T0, typename T1, typename T2, typename T3>187 void Unserialize(Stream& is, boost::tuple<T0, T1, T2, T3>& item, int nType, int nVersion)188 {189- Unserialize(is, get<0>(item), nType, nVersion);190- Unserialize(is, get<1>(item), nType, nVersion);191- Unserialize(is, get<2>(item), nType, nVersion);192- Unserialize(is, get<3>(item), nType, nVersion);193+ Unserialize(is, boost::get<0>(item), nType, nVersion);194+ Unserialize(is, boost::get<1>(item), nType, nVersion);195+ Unserialize(is, boost::get<2>(item), nType, nVersion);196+ Unserialize(is, boost::get<3>(item), nType, nVersion);197 }198 199 200@@ -661,7 +669,7 @@201 typename std::map<K, T, Pred, A>::iterator mi = m.begin();202 for (unsigned int i = 0; i < nSize; i++)203 {204- pair<K, T> item;205+ std::pair<K, T> item;206 Unserialize(is, item, nType, nVersion);207 mi = m.insert(mi, item);208 }209@@ -773,7 +781,7 @@210 {211 if (p != NULL)212 memset(p, 0, sizeof(T) * n);213- allocator<T>::deallocate(p, n);214+ std::allocator<T>::deallocate(p, n);215 }216 };217 218@@ -787,7 +795,7 @@219 class CDataStream220 {221 protected:222- typedef vector<char, secure_allocator<char> > vector_type;223+ typedef std::vector<char, secure_allocator<char> > vector_type;224 vector_type vch;225 unsigned int nReadPos;226 short state;227@@ -828,12 +836,12 @@228 Init(nTypeIn, nVersionIn);229 }230 231- CDataStream(const vector<char>& vchIn, int nTypeIn=SER_NETWORK, int nVersionIn=VERSION) : vch(vchIn.begin(), vchIn.end())232+ CDataStream(const std::vector<char>& vchIn, int nTypeIn=SER_NETWORK, int nVersionIn=VERSION) : vch(vchIn.begin(), vchIn.end())233 {234 Init(nTypeIn, nVersionIn);235 }236 237- CDataStream(const vector<unsigned char>& vchIn, int nTypeIn=SER_NETWORK, int nVersionIn=VERSION) : vch((char*)&vchIn.begin()[0], (char*)&vchIn.end()[0])238+ CDataStream(const std::vector<unsigned char>& vchIn, int nTypeIn=SER_NETWORK, int nVersionIn=VERSION) : vch((char*)&vchIn.begin()[0], (char*)&vchIn.end()[0])239 {240 Init(nTypeIn, nVersionIn);241 }242@@ -844,7 +852,7 @@243 nType = nTypeIn;244 nVersion = nVersionIn;245 state = 0;246- exceptmask = ios::badbit | ios::failbit;247+ exceptmask = std::ios::badbit | std::ios::failbit;248 }249 250 CDataStream& operator+=(const CDataStream& b)251@@ -860,9 +868,9 @@252 return (ret);253 }254 255- string str() const256- {257- return (string(begin(), end()));258+ std::string str() const259+ {260+ return (std::string(begin(), end()));261 }262 263 264@@ -895,7 +903,7 @@265 vch.insert(it, first, last);266 }267 268- void insert(iterator it, vector<char>::const_iterator first, vector<char>::const_iterator last)269+ void insert(iterator it, std::vector<char>::const_iterator first, std::vector<char>::const_iterator last)270 {271 if (it == vch.begin() + nReadPos && last - first <= nReadPos)272 {273@@ -985,7 +993,7 @@274 }275 276 bool eof() const { return size() == 0; }277- bool fail() const { return state & (ios::badbit | ios::failbit); }278+ bool fail() const { return state & (std::ios::badbit | std::ios::failbit); }279 bool good() const { return !eof() && (state == 0); }280 void clear(short n) { state = n; } // name conflict with vector clear()281 short exceptions() { return exceptmask; }282@@ -1009,7 +1017,7 @@283 {284 if (nReadPosNext > vch.size())285 {286- setstate(ios::failbit, "CDataStream::read() : end of data");287+ setstate(std::ios::failbit, "CDataStream::read() : end of data");288 memset(pch, 0, nSize);289 nSize = vch.size() - nReadPos;290 }291@@ -1032,7 +1040,7 @@292 {293 if (nReadPosNext > vch.size())294 {295- setstate(ios::failbit, "CDataStream::ignore() : end of data");296+ setstate(std::ios::failbit, "CDataStream::ignore() : end of data");297 nSize = vch.size() - nReadPos;298 }299 nReadPos = 0;300@@ -1167,7 +1175,7 @@301 nType = nTypeIn;302 nVersion = nVersionIn;303 state = 0;304- exceptmask = ios::badbit | ios::failbit;305+ exceptmask = std::ios::badbit | std::ios::failbit;306 }307 308 ~CAutoFile()309@@ -1201,7 +1209,7 @@310 throw std::ios_base::failure(psz);311 }312 313- bool fail() const { return state & (ios::badbit | ios::failbit); }314+ bool fail() const { return state & (std::ios::badbit | std::ios::failbit); }315 bool good() const { return state == 0; }316 void clear(short n = 0) { state = n; }317 short exceptions() { return exceptmask; }318@@ -1219,7 +1227,7 @@319 if (!file)320 throw std::ios_base::failure("CAutoFile::read : file handle is NULL");321 if (fread(pch, 1, nSize, file) != nSize)322- setstate(ios::failbit, feof(file) ? "CAutoFile::read : end of file" : "CAutoFile::read : fread failed");323+ setstate(std::ios::failbit, feof(file) ? "CAutoFile::read : end of file" : "CAutoFile::read : fread failed");324 return (*this);325 }326 327@@ -1228,7 +1236,7 @@328 if (!file)329 throw std::ios_base::failure("CAutoFile::write : file handle is NULL");330 if (fwrite(pch, 1, nSize, file) != nSize)331- setstate(ios::failbit, "CAutoFile::write : write failed");332+ setstate(std::ios::failbit, "CAutoFile::write : write failed");333 return (*this);334 }335 336@@ -1260,3 +1268,5 @@337 }338 };339 340+#endif341+
setup.nsi (removed)
1--- v0.3.21/setup.nsi2+++ /dev/null3@@ -1,152 +1 @@4-Name Bitcoin5 6-RequestExecutionLevel highest7-8-# General Symbol Definitions9-!define REGKEY "SOFTWARE\$(^Name)"10-!define VERSION 0.3.2111-!define COMPANY "Bitcoin project"12-!define URL http://www.bitcoin.org/13-14-# MUI Symbol Definitions15-!define MUI_ICON "src\rc\bitcoin.ico"16-!define MUI_FINISHPAGE_NOAUTOCLOSE17-!define MUI_STARTMENUPAGE_REGISTRY_ROOT HKLM18-!define MUI_STARTMENUPAGE_REGISTRY_KEY ${REGKEY}19-!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME StartMenuGroup20-!define MUI_STARTMENUPAGE_DEFAULTFOLDER Bitcoin21-!define MUI_FINISHPAGE_RUN $INSTDIR\bitcoin.exe22-!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico"23-!define MUI_UNFINISHPAGE_NOAUTOCLOSE24-25-# Included files26-!include Sections.nsh27-!include MUI2.nsh28-29-# Variables30-Var StartMenuGroup31-32-# Installer pages33-!insertmacro MUI_PAGE_WELCOME34-!insertmacro MUI_PAGE_DIRECTORY35-!insertmacro MUI_PAGE_STARTMENU Application $StartMenuGroup36-!insertmacro MUI_PAGE_INSTFILES37-!insertmacro MUI_PAGE_FINISH38-!insertmacro MUI_UNPAGE_CONFIRM39-!insertmacro MUI_UNPAGE_INSTFILES40-41-# Installer languages42-!insertmacro MUI_LANGUAGE English43-44-# Installer attributes45-OutFile bitcoin-0.3.21-win32-setup.exe46-InstallDir $PROGRAMFILES\Bitcoin47-CRCCheck on48-XPStyle on49-ShowInstDetails show50-VIProductVersion 0.3.21.051-VIAddVersionKey ProductName Bitcoin52-VIAddVersionKey ProductVersion "${VERSION}"53-VIAddVersionKey CompanyName "${COMPANY}"54-VIAddVersionKey CompanyWebsite "${URL}"55-VIAddVersionKey FileVersion "${VERSION}"56-VIAddVersionKey FileDescription ""57-VIAddVersionKey LegalCopyright ""58-InstallDirRegKey HKCU "${REGKEY}" Path59-ShowUninstDetails show60-61-# Installer sections62-Section -Main SEC000063- SetOutPath $INSTDIR64- SetOverwrite on65- File bitcoin.exe66- File libeay32.dll67- File license.txt68- File readme.txt69- SetOutPath $INSTDIR\daemon70- File /r daemon\*.*71- SetOutPath $INSTDIR\locale72- File /r locale\*.*73- SetOutPath $INSTDIR\src74- File /r src\*.*75- SetOutPath $INSTDIR76- WriteRegStr HKCU "${REGKEY}\Components" Main 177-SectionEnd78-79-Section -post SEC000180- WriteRegStr HKCU "${REGKEY}" Path $INSTDIR81- SetOutPath $INSTDIR82- WriteUninstaller $INSTDIR\uninstall.exe83- !insertmacro MUI_STARTMENU_WRITE_BEGIN Application84- CreateDirectory $SMPROGRAMS\$StartMenuGroup85- CreateShortcut "$SMPROGRAMS\$StartMenuGroup\Bitcoin.lnk" $INSTDIR\bitcoin.exe86- CreateShortcut "$SMPROGRAMS\$StartMenuGroup\Uninstall Bitcoin.lnk" $INSTDIR\uninstall.exe87- !insertmacro MUI_STARTMENU_WRITE_END88- WriteRegStr HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayName "$(^Name)"89- WriteRegStr HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayVersion "${VERSION}"90- WriteRegStr HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" Publisher "${COMPANY}"91- WriteRegStr HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" URLInfoAbout "${URL}"92- WriteRegStr HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayIcon $INSTDIR\uninstall.exe93- WriteRegStr HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" UninstallString $INSTDIR\uninstall.exe94- WriteRegDWORD HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" NoModify 195- WriteRegDWORD HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" NoRepair 196-SectionEnd97-98-# Macro for selecting uninstaller sections99-!macro SELECT_UNSECTION SECTION_NAME UNSECTION_ID100- Push $R0101- ReadRegStr $R0 HKCU "${REGKEY}\Components" "${SECTION_NAME}"102- StrCmp $R0 1 0 next${UNSECTION_ID}103- !insertmacro SelectSection "${UNSECTION_ID}"104- GoTo done${UNSECTION_ID}105-next${UNSECTION_ID}:106- !insertmacro UnselectSection "${UNSECTION_ID}"107-done${UNSECTION_ID}:108- Pop $R0109-!macroend110-111-# Uninstaller sections112-Section /o -un.Main UNSEC0000113- Delete /REBOOTOK $INSTDIR\bitcoin.exe114- Delete /REBOOTOK $INSTDIR\libeay32.dll115- Delete /REBOOTOK $INSTDIR\license.txt116- Delete /REBOOTOK $INSTDIR\readme.txt117- RMDir /r /REBOOTOK $INSTDIR\daemon118- RMDir /r /REBOOTOK $INSTDIR\locale119- RMDir /r /REBOOTOK $INSTDIR\src120- DeleteRegValue HKCU "${REGKEY}\Components" Main121-SectionEnd122-123-Section -un.post UNSEC0001124- DeleteRegKey HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)"125- Delete /REBOOTOK "$SMPROGRAMS\$StartMenuGroup\Uninstall Bitcoin.lnk"126- Delete /REBOOTOK "$SMPROGRAMS\$StartMenuGroup\Bitcoin.lnk"127- Delete /REBOOTOK "$SMSTARTUP\Bitcoin.lnk"128- Delete /REBOOTOK $INSTDIR\uninstall.exe129- Delete /REBOOTOK $INSTDIR\debug.log130- Delete /REBOOTOK $INSTDIR\db.log131- DeleteRegValue HKCU "${REGKEY}" StartMenuGroup132- DeleteRegValue HKCU "${REGKEY}" Path133- DeleteRegKey /IfEmpty HKCU "${REGKEY}\Components"134- DeleteRegKey /IfEmpty HKCU "${REGKEY}"135- RmDir /REBOOTOK $SMPROGRAMS\$StartMenuGroup136- RmDir /REBOOTOK $INSTDIR137- Push $R0138- StrCpy $R0 $StartMenuGroup 1139- StrCmp $R0 ">" no_smgroup140-no_smgroup:141- Pop $R0142-SectionEnd143-144-# Installer functions145-Function .onInit146- InitPluginsDir147-FunctionEnd148-149-# Uninstaller functions150-Function un.onInit151- ReadRegStr $INSTDIR HKCU "${REGKEY}" Path152- !insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuGroup153- !insertmacro SELECT_UNSECTION Main ${UNSEC0000}154-FunctionEnd155-
sha256.cpp (removed)
1--- v0.3.21/sha256.cpp2+++ /dev/null3@@ -1,476 +1 @@4-// Copyright (c) 2010 Nils Schneider5-// Distributed under the MIT/X11 software license, see the accompanying6-// file license.txt or http://www.opensource.org/licenses/mit-license.php.7 8-// 4-way 128-bit SSE2 SHA-2569-10-#ifdef FOURWAYSSE211-12-#include <string.h>13-#include <assert.h>14-15-#include <xmmintrin.h>16-#include <stdint.h>17-#include <stdio.h>18-19-#define NPAR 3220-21-extern void DoubleBlockSHA256(const void* pin, void* pout, const void* pinit, unsigned int hash[8][NPAR], const void* init2);22-23-static const unsigned int sha256_consts[] = {24- 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, /* 0 */25- 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,26- 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, /* 8 */27- 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,28- 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, /* 16 */29- 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,30- 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, /* 24 */31- 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,32- 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, /* 32 */33- 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,34- 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, /* 40 */35- 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,36- 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, /* 48 */37- 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,38- 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, /* 56 */39- 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f240-};41-42-43-static inline __m128i Ch(const __m128i b, const __m128i c, const __m128i d) {44- return (b & c) ^ (~b & d);45-}46-47-static inline __m128i Maj(const __m128i b, const __m128i c, const __m128i d) {48- return (b & c) ^ (b & d) ^ (c & d);49-}50-51-static inline __m128i ROTR(__m128i x, const int n) {52- return _mm_srli_epi32(x, n) | _mm_slli_epi32(x, 32 - n);53-}54-55-static inline __m128i SHR(__m128i x, const int n) {56- return _mm_srli_epi32(x, n);57-}58-59-/* SHA256 Functions */60-#define BIGSIGMA0_256(x) (ROTR((x), 2) ^ ROTR((x), 13) ^ ROTR((x), 22))61-#define BIGSIGMA1_256(x) (ROTR((x), 6) ^ ROTR((x), 11) ^ ROTR((x), 25))62-#define SIGMA0_256(x) (ROTR((x), 7) ^ ROTR((x), 18) ^ SHR((x), 3))63-#define SIGMA1_256(x) (ROTR((x), 17) ^ ROTR((x), 19) ^ SHR((x), 10))64-65-static inline unsigned int store32(const __m128i x, int i) {66- union { unsigned int ret[4]; __m128i x; } box;67- box.x = x;68- return box.ret[i];69-}70-71-static inline void store_epi32(const __m128i x, unsigned int *x0, unsigned int *x1, unsigned int *x2, unsigned int *x3) {72- union { unsigned int ret[4]; __m128i x; } box;73- box.x = x;74- *x0 = box.ret[3]; *x1 = box.ret[2]; *x2 = box.ret[1]; *x3 = box.ret[0];75-}76-77-#define add4(x0, x1, x2, x3) _mm_add_epi32(_mm_add_epi32(_mm_add_epi32(x0, x1), x2), x3)78-#define add5(x0, x1, x2, x3, x4) _mm_add_epi32(add4(x0, x1, x2, x3), x4)79-80-#define SHA256ROUND(a, b, c, d, e, f, g, h, i, w) \81- T1 = add5(h, BIGSIGMA1_256(e), Ch(e, f, g), _mm_set1_epi32(sha256_consts[i]), w); \82-d = _mm_add_epi32(d, T1); \83-h = _mm_add_epi32(T1, _mm_add_epi32(BIGSIGMA0_256(a), Maj(a, b, c)));84-85-static inline void dumpreg(__m128i x, char *msg) {86- union { unsigned int ret[4]; __m128i x; } box;87- box.x = x ;88- printf("%s %08x %08x %08x %08x\n", msg, box.ret[0], box.ret[1], box.ret[2], box.ret[3]);89-}90-91-#if 192-#define dumpstate(i) printf("%s: %08x %08x %08x %08x %08x %08x %08x %08x %08x\n", \93- __func__, store32(w0, i), store32(a, i), store32(b, i), store32(c, i), store32(d, i), store32(e, i), store32(f, i), store32(g, i), store32(h, i));94-#else95-#define dumpstate()96-#endif97-98-// Align by increasing pointer, must have extra space at end of buffer99-template <size_t nBytes, typename T>100-T* alignup(T* p)101-{102- union103- {104- T* ptr;105- size_t n;106- } u;107- u.ptr = p;108- u.n = (u.n + (nBytes-1)) & ~(nBytes-1);109- return u.ptr;110-}111-112-static const unsigned int pSHA256InitState[8] =113-{0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19};114-115-116-unsigned int ScanHash_4WaySSE2(char* pmidstate, char* pdata, char* phash1, char* phash, unsigned int& nHashesDone)117-{118- unsigned int& nNonce = *(unsigned int*)(pdata + 12);119- for (;;)120- {121- nNonce += NPAR;122- unsigned int thashbuf[9][NPAR];123- unsigned int (&thash)[9][NPAR] = *alignup<16>(&thashbuf);124- DoubleBlockSHA256(pdata, phash1, pmidstate, thash, pSHA256InitState);125-126- for (int j = 0; j < NPAR; j++)127- {128- if (thash[7][j] == 0)129- {130- for (int i = 0; i < 32/4; i++)131- ((unsigned int*)phash)[i] = thash[i][j];132- return nNonce + j;133- }134- }135-136- if ((nNonce & 0xffff) == 0)137- {138- nHashesDone = 0xffff+1;139- return -1;140- }141- }142-}143-144-145-void DoubleBlockSHA256(const void* pin, void* pad, const void *pre, unsigned int thash[9][NPAR], const void *init)146-{147- unsigned int* In = (unsigned int*)pin;148- unsigned int* Pad = (unsigned int*)pad;149- unsigned int* hPre = (unsigned int*)pre;150- unsigned int* hInit = (unsigned int*)init;151- unsigned int i, j, k;152-153- /* vectors used in calculation */154- __m128i w0, w1, w2, w3, w4, w5, w6, w7;155- __m128i w8, w9, w10, w11, w12, w13, w14, w15;156- __m128i T1;157- __m128i a, b, c, d, e, f, g, h;158- __m128i nonce;159-160- /* nonce offset for vector */161- __m128i offset = _mm_set_epi32(0x00000003, 0x00000002, 0x00000001, 0x00000000);162-163-164- for(k = 0; k<NPAR; k+=4) {165- w0 = _mm_set1_epi32(In[0]);166- w1 = _mm_set1_epi32(In[1]);167- w2 = _mm_set1_epi32(In[2]);168- //w3 = _mm_set1_epi32(In[3]); nonce will be later hacked into the hash169- w4 = _mm_set1_epi32(In[4]);170- w5 = _mm_set1_epi32(In[5]);171- w6 = _mm_set1_epi32(In[6]);172- w7 = _mm_set1_epi32(In[7]);173- w8 = _mm_set1_epi32(In[8]);174- w9 = _mm_set1_epi32(In[9]);175- w10 = _mm_set1_epi32(In[10]);176- w11 = _mm_set1_epi32(In[11]);177- w12 = _mm_set1_epi32(In[12]);178- w13 = _mm_set1_epi32(In[13]);179- w14 = _mm_set1_epi32(In[14]);180- w15 = _mm_set1_epi32(In[15]);181-182- /* hack nonce into lowest byte of w3 */183- nonce = _mm_set1_epi32(In[3]);184- nonce = _mm_add_epi32(nonce, offset);185- nonce = _mm_add_epi32(nonce, _mm_set1_epi32(k));186- w3 = nonce;187-188- a = _mm_set1_epi32(hPre[0]);189- b = _mm_set1_epi32(hPre[1]);190- c = _mm_set1_epi32(hPre[2]);191- d = _mm_set1_epi32(hPre[3]);192- e = _mm_set1_epi32(hPre[4]);193- f = _mm_set1_epi32(hPre[5]);194- g = _mm_set1_epi32(hPre[6]);195- h = _mm_set1_epi32(hPre[7]);196-197- SHA256ROUND(a, b, c, d, e, f, g, h, 0, w0);198- SHA256ROUND(h, a, b, c, d, e, f, g, 1, w1);199- SHA256ROUND(g, h, a, b, c, d, e, f, 2, w2);200- SHA256ROUND(f, g, h, a, b, c, d, e, 3, w3);201- SHA256ROUND(e, f, g, h, a, b, c, d, 4, w4);202- SHA256ROUND(d, e, f, g, h, a, b, c, 5, w5);203- SHA256ROUND(c, d, e, f, g, h, a, b, 6, w6);204- SHA256ROUND(b, c, d, e, f, g, h, a, 7, w7);205- SHA256ROUND(a, b, c, d, e, f, g, h, 8, w8);206- SHA256ROUND(h, a, b, c, d, e, f, g, 9, w9);207- SHA256ROUND(g, h, a, b, c, d, e, f, 10, w10);208- SHA256ROUND(f, g, h, a, b, c, d, e, 11, w11);209- SHA256ROUND(e, f, g, h, a, b, c, d, 12, w12);210- SHA256ROUND(d, e, f, g, h, a, b, c, 13, w13);211- SHA256ROUND(c, d, e, f, g, h, a, b, 14, w14);212- SHA256ROUND(b, c, d, e, f, g, h, a, 15, w15);213-214- w0 = add4(SIGMA1_256(w14), w9, SIGMA0_256(w1), w0);215- SHA256ROUND(a, b, c, d, e, f, g, h, 16, w0);216- w1 = add4(SIGMA1_256(w15), w10, SIGMA0_256(w2), w1);217- SHA256ROUND(h, a, b, c, d, e, f, g, 17, w1);218- w2 = add4(SIGMA1_256(w0), w11, SIGMA0_256(w3), w2);219- SHA256ROUND(g, h, a, b, c, d, e, f, 18, w2);220- w3 = add4(SIGMA1_256(w1), w12, SIGMA0_256(w4), w3);221- SHA256ROUND(f, g, h, a, b, c, d, e, 19, w3);222- w4 = add4(SIGMA1_256(w2), w13, SIGMA0_256(w5), w4);223- SHA256ROUND(e, f, g, h, a, b, c, d, 20, w4);224- w5 = add4(SIGMA1_256(w3), w14, SIGMA0_256(w6), w5);225- SHA256ROUND(d, e, f, g, h, a, b, c, 21, w5);226- w6 = add4(SIGMA1_256(w4), w15, SIGMA0_256(w7), w6);227- SHA256ROUND(c, d, e, f, g, h, a, b, 22, w6);228- w7 = add4(SIGMA1_256(w5), w0, SIGMA0_256(w8), w7);229- SHA256ROUND(b, c, d, e, f, g, h, a, 23, w7);230- w8 = add4(SIGMA1_256(w6), w1, SIGMA0_256(w9), w8);231- SHA256ROUND(a, b, c, d, e, f, g, h, 24, w8);232- w9 = add4(SIGMA1_256(w7), w2, SIGMA0_256(w10), w9);233- SHA256ROUND(h, a, b, c, d, e, f, g, 25, w9);234- w10 = add4(SIGMA1_256(w8), w3, SIGMA0_256(w11), w10);235- SHA256ROUND(g, h, a, b, c, d, e, f, 26, w10);236- w11 = add4(SIGMA1_256(w9), w4, SIGMA0_256(w12), w11);237- SHA256ROUND(f, g, h, a, b, c, d, e, 27, w11);238- w12 = add4(SIGMA1_256(w10), w5, SIGMA0_256(w13), w12);239- SHA256ROUND(e, f, g, h, a, b, c, d, 28, w12);240- w13 = add4(SIGMA1_256(w11), w6, SIGMA0_256(w14), w13);241- SHA256ROUND(d, e, f, g, h, a, b, c, 29, w13);242- w14 = add4(SIGMA1_256(w12), w7, SIGMA0_256(w15), w14);243- SHA256ROUND(c, d, e, f, g, h, a, b, 30, w14);244- w15 = add4(SIGMA1_256(w13), w8, SIGMA0_256(w0), w15);245- SHA256ROUND(b, c, d, e, f, g, h, a, 31, w15);246-247- w0 = add4(SIGMA1_256(w14), w9, SIGMA0_256(w1), w0);248- SHA256ROUND(a, b, c, d, e, f, g, h, 32, w0);249- w1 = add4(SIGMA1_256(w15), w10, SIGMA0_256(w2), w1);250- SHA256ROUND(h, a, b, c, d, e, f, g, 33, w1);251- w2 = add4(SIGMA1_256(w0), w11, SIGMA0_256(w3), w2);252- SHA256ROUND(g, h, a, b, c, d, e, f, 34, w2);253- w3 = add4(SIGMA1_256(w1), w12, SIGMA0_256(w4), w3);254- SHA256ROUND(f, g, h, a, b, c, d, e, 35, w3);255- w4 = add4(SIGMA1_256(w2), w13, SIGMA0_256(w5), w4);256- SHA256ROUND(e, f, g, h, a, b, c, d, 36, w4);257- w5 = add4(SIGMA1_256(w3), w14, SIGMA0_256(w6), w5);258- SHA256ROUND(d, e, f, g, h, a, b, c, 37, w5);259- w6 = add4(SIGMA1_256(w4), w15, SIGMA0_256(w7), w6);260- SHA256ROUND(c, d, e, f, g, h, a, b, 38, w6);261- w7 = add4(SIGMA1_256(w5), w0, SIGMA0_256(w8), w7);262- SHA256ROUND(b, c, d, e, f, g, h, a, 39, w7);263- w8 = add4(SIGMA1_256(w6), w1, SIGMA0_256(w9), w8);264- SHA256ROUND(a, b, c, d, e, f, g, h, 40, w8);265- w9 = add4(SIGMA1_256(w7), w2, SIGMA0_256(w10), w9);266- SHA256ROUND(h, a, b, c, d, e, f, g, 41, w9);267- w10 = add4(SIGMA1_256(w8), w3, SIGMA0_256(w11), w10);268- SHA256ROUND(g, h, a, b, c, d, e, f, 42, w10);269- w11 = add4(SIGMA1_256(w9), w4, SIGMA0_256(w12), w11);270- SHA256ROUND(f, g, h, a, b, c, d, e, 43, w11);271- w12 = add4(SIGMA1_256(w10), w5, SIGMA0_256(w13), w12);272- SHA256ROUND(e, f, g, h, a, b, c, d, 44, w12);273- w13 = add4(SIGMA1_256(w11), w6, SIGMA0_256(w14), w13);274- SHA256ROUND(d, e, f, g, h, a, b, c, 45, w13);275- w14 = add4(SIGMA1_256(w12), w7, SIGMA0_256(w15), w14);276- SHA256ROUND(c, d, e, f, g, h, a, b, 46, w14);277- w15 = add4(SIGMA1_256(w13), w8, SIGMA0_256(w0), w15);278- SHA256ROUND(b, c, d, e, f, g, h, a, 47, w15);279-280- w0 = add4(SIGMA1_256(w14), w9, SIGMA0_256(w1), w0);281- SHA256ROUND(a, b, c, d, e, f, g, h, 48, w0);282- w1 = add4(SIGMA1_256(w15), w10, SIGMA0_256(w2), w1);283- SHA256ROUND(h, a, b, c, d, e, f, g, 49, w1);284- w2 = add4(SIGMA1_256(w0), w11, SIGMA0_256(w3), w2);285- SHA256ROUND(g, h, a, b, c, d, e, f, 50, w2);286- w3 = add4(SIGMA1_256(w1), w12, SIGMA0_256(w4), w3);287- SHA256ROUND(f, g, h, a, b, c, d, e, 51, w3);288- w4 = add4(SIGMA1_256(w2), w13, SIGMA0_256(w5), w4);289- SHA256ROUND(e, f, g, h, a, b, c, d, 52, w4);290- w5 = add4(SIGMA1_256(w3), w14, SIGMA0_256(w6), w5);291- SHA256ROUND(d, e, f, g, h, a, b, c, 53, w5);292- w6 = add4(SIGMA1_256(w4), w15, SIGMA0_256(w7), w6);293- SHA256ROUND(c, d, e, f, g, h, a, b, 54, w6);294- w7 = add4(SIGMA1_256(w5), w0, SIGMA0_256(w8), w7);295- SHA256ROUND(b, c, d, e, f, g, h, a, 55, w7);296- w8 = add4(SIGMA1_256(w6), w1, SIGMA0_256(w9), w8);297- SHA256ROUND(a, b, c, d, e, f, g, h, 56, w8);298- w9 = add4(SIGMA1_256(w7), w2, SIGMA0_256(w10), w9);299- SHA256ROUND(h, a, b, c, d, e, f, g, 57, w9);300- w10 = add4(SIGMA1_256(w8), w3, SIGMA0_256(w11), w10);301- SHA256ROUND(g, h, a, b, c, d, e, f, 58, w10);302- w11 = add4(SIGMA1_256(w9), w4, SIGMA0_256(w12), w11);303- SHA256ROUND(f, g, h, a, b, c, d, e, 59, w11);304- w12 = add4(SIGMA1_256(w10), w5, SIGMA0_256(w13), w12);305- SHA256ROUND(e, f, g, h, a, b, c, d, 60, w12);306- w13 = add4(SIGMA1_256(w11), w6, SIGMA0_256(w14), w13);307- SHA256ROUND(d, e, f, g, h, a, b, c, 61, w13);308- w14 = add4(SIGMA1_256(w12), w7, SIGMA0_256(w15), w14);309- SHA256ROUND(c, d, e, f, g, h, a, b, 62, w14);310- w15 = add4(SIGMA1_256(w13), w8, SIGMA0_256(w0), w15);311- SHA256ROUND(b, c, d, e, f, g, h, a, 63, w15);312-313-#define store_load(x, i, dest) \314- T1 = _mm_set1_epi32((hPre)[i]); \315- dest = _mm_add_epi32(T1, x);316-317- store_load(a, 0, w0);318- store_load(b, 1, w1);319- store_load(c, 2, w2);320- store_load(d, 3, w3);321- store_load(e, 4, w4);322- store_load(f, 5, w5);323- store_load(g, 6, w6);324- store_load(h, 7, w7);325-326- w8 = _mm_set1_epi32(Pad[8]);327- w9 = _mm_set1_epi32(Pad[9]);328- w10 = _mm_set1_epi32(Pad[10]);329- w11 = _mm_set1_epi32(Pad[11]);330- w12 = _mm_set1_epi32(Pad[12]);331- w13 = _mm_set1_epi32(Pad[13]);332- w14 = _mm_set1_epi32(Pad[14]);333- w15 = _mm_set1_epi32(Pad[15]);334-335- a = _mm_set1_epi32(hInit[0]);336- b = _mm_set1_epi32(hInit[1]);337- c = _mm_set1_epi32(hInit[2]);338- d = _mm_set1_epi32(hInit[3]);339- e = _mm_set1_epi32(hInit[4]);340- f = _mm_set1_epi32(hInit[5]);341- g = _mm_set1_epi32(hInit[6]);342- h = _mm_set1_epi32(hInit[7]);343-344- SHA256ROUND(a, b, c, d, e, f, g, h, 0, w0);345- SHA256ROUND(h, a, b, c, d, e, f, g, 1, w1);346- SHA256ROUND(g, h, a, b, c, d, e, f, 2, w2);347- SHA256ROUND(f, g, h, a, b, c, d, e, 3, w3);348- SHA256ROUND(e, f, g, h, a, b, c, d, 4, w4);349- SHA256ROUND(d, e, f, g, h, a, b, c, 5, w5);350- SHA256ROUND(c, d, e, f, g, h, a, b, 6, w6);351- SHA256ROUND(b, c, d, e, f, g, h, a, 7, w7);352- SHA256ROUND(a, b, c, d, e, f, g, h, 8, w8);353- SHA256ROUND(h, a, b, c, d, e, f, g, 9, w9);354- SHA256ROUND(g, h, a, b, c, d, e, f, 10, w10);355- SHA256ROUND(f, g, h, a, b, c, d, e, 11, w11);356- SHA256ROUND(e, f, g, h, a, b, c, d, 12, w12);357- SHA256ROUND(d, e, f, g, h, a, b, c, 13, w13);358- SHA256ROUND(c, d, e, f, g, h, a, b, 14, w14);359- SHA256ROUND(b, c, d, e, f, g, h, a, 15, w15);360-361- w0 = add4(SIGMA1_256(w14), w9, SIGMA0_256(w1), w0);362- SHA256ROUND(a, b, c, d, e, f, g, h, 16, w0);363- w1 = add4(SIGMA1_256(w15), w10, SIGMA0_256(w2), w1);364- SHA256ROUND(h, a, b, c, d, e, f, g, 17, w1);365- w2 = add4(SIGMA1_256(w0), w11, SIGMA0_256(w3), w2);366- SHA256ROUND(g, h, a, b, c, d, e, f, 18, w2);367- w3 = add4(SIGMA1_256(w1), w12, SIGMA0_256(w4), w3);368- SHA256ROUND(f, g, h, a, b, c, d, e, 19, w3);369- w4 = add4(SIGMA1_256(w2), w13, SIGMA0_256(w5), w4);370- SHA256ROUND(e, f, g, h, a, b, c, d, 20, w4);371- w5 = add4(SIGMA1_256(w3), w14, SIGMA0_256(w6), w5);372- SHA256ROUND(d, e, f, g, h, a, b, c, 21, w5);373- w6 = add4(SIGMA1_256(w4), w15, SIGMA0_256(w7), w6);374- SHA256ROUND(c, d, e, f, g, h, a, b, 22, w6);375- w7 = add4(SIGMA1_256(w5), w0, SIGMA0_256(w8), w7);376- SHA256ROUND(b, c, d, e, f, g, h, a, 23, w7);377- w8 = add4(SIGMA1_256(w6), w1, SIGMA0_256(w9), w8);378- SHA256ROUND(a, b, c, d, e, f, g, h, 24, w8);379- w9 = add4(SIGMA1_256(w7), w2, SIGMA0_256(w10), w9);380- SHA256ROUND(h, a, b, c, d, e, f, g, 25, w9);381- w10 = add4(SIGMA1_256(w8), w3, SIGMA0_256(w11), w10);382- SHA256ROUND(g, h, a, b, c, d, e, f, 26, w10);383- w11 = add4(SIGMA1_256(w9), w4, SIGMA0_256(w12), w11);384- SHA256ROUND(f, g, h, a, b, c, d, e, 27, w11);385- w12 = add4(SIGMA1_256(w10), w5, SIGMA0_256(w13), w12);386- SHA256ROUND(e, f, g, h, a, b, c, d, 28, w12);387- w13 = add4(SIGMA1_256(w11), w6, SIGMA0_256(w14), w13);388- SHA256ROUND(d, e, f, g, h, a, b, c, 29, w13);389- w14 = add4(SIGMA1_256(w12), w7, SIGMA0_256(w15), w14);390- SHA256ROUND(c, d, e, f, g, h, a, b, 30, w14);391- w15 = add4(SIGMA1_256(w13), w8, SIGMA0_256(w0), w15);392- SHA256ROUND(b, c, d, e, f, g, h, a, 31, w15);393-394- w0 = add4(SIGMA1_256(w14), w9, SIGMA0_256(w1), w0);395- SHA256ROUND(a, b, c, d, e, f, g, h, 32, w0);396- w1 = add4(SIGMA1_256(w15), w10, SIGMA0_256(w2), w1);397- SHA256ROUND(h, a, b, c, d, e, f, g, 33, w1);398- w2 = add4(SIGMA1_256(w0), w11, SIGMA0_256(w3), w2);399- SHA256ROUND(g, h, a, b, c, d, e, f, 34, w2);400- w3 = add4(SIGMA1_256(w1), w12, SIGMA0_256(w4), w3);401- SHA256ROUND(f, g, h, a, b, c, d, e, 35, w3);402- w4 = add4(SIGMA1_256(w2), w13, SIGMA0_256(w5), w4);403- SHA256ROUND(e, f, g, h, a, b, c, d, 36, w4);404- w5 = add4(SIGMA1_256(w3), w14, SIGMA0_256(w6), w5);405- SHA256ROUND(d, e, f, g, h, a, b, c, 37, w5);406- w6 = add4(SIGMA1_256(w4), w15, SIGMA0_256(w7), w6);407- SHA256ROUND(c, d, e, f, g, h, a, b, 38, w6);408- w7 = add4(SIGMA1_256(w5), w0, SIGMA0_256(w8), w7);409- SHA256ROUND(b, c, d, e, f, g, h, a, 39, w7);410- w8 = add4(SIGMA1_256(w6), w1, SIGMA0_256(w9), w8);411- SHA256ROUND(a, b, c, d, e, f, g, h, 40, w8);412- w9 = add4(SIGMA1_256(w7), w2, SIGMA0_256(w10), w9);413- SHA256ROUND(h, a, b, c, d, e, f, g, 41, w9);414- w10 = add4(SIGMA1_256(w8), w3, SIGMA0_256(w11), w10);415- SHA256ROUND(g, h, a, b, c, d, e, f, 42, w10);416- w11 = add4(SIGMA1_256(w9), w4, SIGMA0_256(w12), w11);417- SHA256ROUND(f, g, h, a, b, c, d, e, 43, w11);418- w12 = add4(SIGMA1_256(w10), w5, SIGMA0_256(w13), w12);419- SHA256ROUND(e, f, g, h, a, b, c, d, 44, w12);420- w13 = add4(SIGMA1_256(w11), w6, SIGMA0_256(w14), w13);421- SHA256ROUND(d, e, f, g, h, a, b, c, 45, w13);422- w14 = add4(SIGMA1_256(w12), w7, SIGMA0_256(w15), w14);423- SHA256ROUND(c, d, e, f, g, h, a, b, 46, w14);424- w15 = add4(SIGMA1_256(w13), w8, SIGMA0_256(w0), w15);425- SHA256ROUND(b, c, d, e, f, g, h, a, 47, w15);426-427- w0 = add4(SIGMA1_256(w14), w9, SIGMA0_256(w1), w0);428- SHA256ROUND(a, b, c, d, e, f, g, h, 48, w0);429- w1 = add4(SIGMA1_256(w15), w10, SIGMA0_256(w2), w1);430- SHA256ROUND(h, a, b, c, d, e, f, g, 49, w1);431- w2 = add4(SIGMA1_256(w0), w11, SIGMA0_256(w3), w2);432- SHA256ROUND(g, h, a, b, c, d, e, f, 50, w2);433- w3 = add4(SIGMA1_256(w1), w12, SIGMA0_256(w4), w3);434- SHA256ROUND(f, g, h, a, b, c, d, e, 51, w3);435- w4 = add4(SIGMA1_256(w2), w13, SIGMA0_256(w5), w4);436- SHA256ROUND(e, f, g, h, a, b, c, d, 52, w4);437- w5 = add4(SIGMA1_256(w3), w14, SIGMA0_256(w6), w5);438- SHA256ROUND(d, e, f, g, h, a, b, c, 53, w5);439- w6 = add4(SIGMA1_256(w4), w15, SIGMA0_256(w7), w6);440- SHA256ROUND(c, d, e, f, g, h, a, b, 54, w6);441- w7 = add4(SIGMA1_256(w5), w0, SIGMA0_256(w8), w7);442- SHA256ROUND(b, c, d, e, f, g, h, a, 55, w7);443- w8 = add4(SIGMA1_256(w6), w1, SIGMA0_256(w9), w8);444- SHA256ROUND(a, b, c, d, e, f, g, h, 56, w8);445- w9 = add4(SIGMA1_256(w7), w2, SIGMA0_256(w10), w9);446- SHA256ROUND(h, a, b, c, d, e, f, g, 57, w9);447- w10 = add4(SIGMA1_256(w8), w3, SIGMA0_256(w11), w10);448- SHA256ROUND(g, h, a, b, c, d, e, f, 58, w10);449- w11 = add4(SIGMA1_256(w9), w4, SIGMA0_256(w12), w11);450- SHA256ROUND(f, g, h, a, b, c, d, e, 59, w11);451- w12 = add4(SIGMA1_256(w10), w5, SIGMA0_256(w13), w12);452- SHA256ROUND(e, f, g, h, a, b, c, d, 60, w12);453- w13 = add4(SIGMA1_256(w11), w6, SIGMA0_256(w14), w13);454- SHA256ROUND(d, e, f, g, h, a, b, c, 61, w13);455- w14 = add4(SIGMA1_256(w12), w7, SIGMA0_256(w15), w14);456- SHA256ROUND(c, d, e, f, g, h, a, b, 62, w14);457- w15 = add4(SIGMA1_256(w13), w8, SIGMA0_256(w0), w15);458- SHA256ROUND(b, c, d, e, f, g, h, a, 63, w15);459-460- /* store resulsts directly in thash */461-#define store_2(x,i) \462- w0 = _mm_set1_epi32(hInit[i]); \463- *(__m128i *)&(thash)[i][0+k] = _mm_add_epi32(w0, x);464-465- store_2(a, 0);466- store_2(b, 1);467- store_2(c, 2);468- store_2(d, 3);469- store_2(e, 4);470- store_2(f, 5);471- store_2(g, 6);472- store_2(h, 7);473- *(__m128i *)&(thash)[8][0+k] = nonce;474- }475-476-}477-478-#endif // FOURWAYSSE2479-
strlcpy.h (modified)
1--- v0.3.21/strlcpy.h2+++ v0.3.22/strlcpy.h3@@ -13,7 +13,8 @@4 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF5 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.6 */7-8+#ifndef BITCOIN_STRLCPY_H9+#define BITCOIN_STRLCPY_H10 /*11 * Copy src to string dst of size siz. At most siz-1 characters12 * will be copied. Always NUL terminates (unless siz == 0).13@@ -82,4 +83,5 @@14 15 return(dlen + (s - src)); /* count does not include NUL */16 }17+#endif18
ui.cpp (modified)
1--- v0.3.21/ui.cpp2+++ v0.3.22/ui.cpp3@@ -7,6 +7,8 @@4 #include <crtdbg.h>5 #endif6 7+using namespace std;8+using namespace boost;9 10 11 DEFINE_EVENT_TYPE(wxEVT_UITHREADCALL)12@@ -16,6 +18,13 @@13 bool fClosedToTray = false;14 wxLocale g_locale;15 16+#ifdef __WXMSW__17+double nScaleX = 1.0;18+double nScaleY = 1.0;19+#else20+static const double nScaleX = 1.0;21+static const double nScaleY = 1.0;22+#endif23 24 25 26@@ -196,7 +205,7 @@27 28 bool ThreadSafeAskFee(int64 nFeeRequired, const string& strCaption, wxWindow* parent)29 {30- if (nFeeRequired < CENT || nFeeRequired <= nTransactionFee || fDaemon)31+ if (nFeeRequired < MIN_TX_FEE || nFeeRequired <= nTransactionFee || fDaemon)32 return true;33 string strMessage = strprintf(34 _("This transaction is over the size limit. You can still send it for a fee of %s, "35@@ -261,9 +270,10 @@36 fOnSetFocusAddress = false;37 fRefresh = false;38 m_choiceFilter->SetSelection(0);39- double dResize = 1.0;40+ double dResize = nScaleX;41 #ifdef __WXMSW__42 SetIcon(wxICON(bitcoin));43+ SetSize(dResize * GetSize().GetWidth(), nScaleY * GetSize().GetHeight());44 #else45 SetIcon(bitcoin80_xpm);46 SetBackgroundColour(m_toolBar->GetBackgroundColour());47@@ -294,7 +304,7 @@48 dResize -= 0.01;49 #endif50 wxListCtrl* pplistCtrl[] = {m_listCtrlAll, m_listCtrlSentReceived, m_listCtrlSent, m_listCtrlReceived};51- foreach(wxListCtrl* p, pplistCtrl)52+ BOOST_FOREACH(wxListCtrl* p, pplistCtrl)53 {54 p->InsertColumn(0, "", wxLIST_FORMAT_LEFT, dResize * 0);55 p->InsertColumn(1, "", wxLIST_FORMAT_LEFT, dResize * 0);56@@ -528,7 +538,7 @@57 {58 string strOut;59 bool fOneSpace = false;60- foreach(unsigned char c, strIn)61+ BOOST_FOREACH(unsigned char c, strIn)62 {63 if (isspace(c))64 {65@@ -609,7 +619,7 @@66 if (nCredit == 0)67 {68 int64 nUnmatured = 0;69- foreach(const CTxOut& txout, wtx.vout)70+ BOOST_FOREACH(const CTxOut& txout, wtx.vout)71 nUnmatured += txout.GetCredit();72 if (wtx.IsInMainChain())73 {74@@ -644,7 +654,7 @@75 // Received by Bitcoin Address76 if (!fShowReceived)77 return false;78- foreach(const CTxOut& txout, wtx.vout)79+ BOOST_FOREACH(const CTxOut& txout, wtx.vout)80 {81 if (txout.IsMine())82 {83@@ -687,11 +697,11 @@84 else85 {86 bool fAllFromMe = true;87- foreach(const CTxIn& txin, wtx.vin)88+ BOOST_FOREACH(const CTxIn& txin, wtx.vin)89 fAllFromMe = fAllFromMe && txin.IsMine();90 91 bool fAllToMe = true;92- foreach(const CTxOut& txout, wtx.vout)93+ BOOST_FOREACH(const CTxOut& txout, wtx.vout)94 fAllToMe = fAllToMe && txout.IsMine();95 96 if (fAllFromMe && fAllToMe)97@@ -776,9 +786,9 @@98 // Mixed debit transaction, can't break down payees99 //100 bool fAllMine = true;101- foreach(const CTxOut& txout, wtx.vout)102+ BOOST_FOREACH(const CTxOut& txout, wtx.vout)103 fAllMine = fAllMine && txout.IsMine();104- foreach(const CTxIn& txin, wtx.vin)105+ BOOST_FOREACH(const CTxIn& txin, wtx.vin)106 fAllMine = fAllMine && txin.IsMine();107 108 InsertLine(fNew, nIndex, hash, strSort, colour,109@@ -1006,7 +1016,7 @@110 string strTop;111 if (m_listCtrl->GetItemCount())112 strTop = (string)m_listCtrl->GetItemText(0);113- foreach(uint256 hash, vWalletUpdated)114+ BOOST_FOREACH(uint256 hash, vWalletUpdated)115 {116 map<uint256, CWalletTx>::iterator mi = mapWallet.find(hash);117 if (mi != mapWallet.end())118@@ -1094,12 +1104,6 @@119 Close(true);120 }121 122-void CMainFrame::OnMenuOptionsGenerate(wxCommandEvent& event)123-{124- // Options->Generate Coins125- GenerateBitcoins(event.IsChecked());126-}127-128 void CMainFrame::OnUpdateUIOptionsGenerate(wxUpdateUIEvent& event)129 {130 event.Check(fGenerateBitcoins);131@@ -1223,6 +1227,9 @@132 133 CTxDetailsDialog::CTxDetailsDialog(wxWindow* parent, CWalletTx wtx) : CTxDetailsDialogBase(parent)134 {135+#ifdef __WXMSW__136+ SetSize(nScaleX * GetSize().GetWidth(), nScaleY * GetSize().GetHeight());137+#endif138 CRITICAL_BLOCK(cs_mapAddressBook)139 {140 string strHTML;141@@ -1271,7 +1278,7 @@142 if (nNet > 0)143 {144 // Credit145- foreach(const CTxOut& txout, wtx.vout)146+ BOOST_FOREACH(const CTxOut& txout, wtx.vout)147 {148 if (txout.IsMine())149 {150@@ -1322,7 +1329,7 @@151 // Coinbase152 //153 int64 nUnmatured = 0;154- foreach(const CTxOut& txout, wtx.vout)155+ BOOST_FOREACH(const CTxOut& txout, wtx.vout)156 nUnmatured += txout.GetCredit();157 strHTML += _("<b>Credit:</b> ");158 if (wtx.IsInMainChain())159@@ -1341,11 +1348,11 @@160 else161 {162 bool fAllFromMe = true;163- foreach(const CTxIn& txin, wtx.vin)164+ BOOST_FOREACH(const CTxIn& txin, wtx.vin)165 fAllFromMe = fAllFromMe && txin.IsMine();166 167 bool fAllToMe = true;168- foreach(const CTxOut& txout, wtx.vout)169+ BOOST_FOREACH(const CTxOut& txout, wtx.vout)170 fAllToMe = fAllToMe && txout.IsMine();171 172 if (fAllFromMe)173@@ -1353,7 +1360,7 @@174 //175 // Debit176 //177- foreach(const CTxOut& txout, wtx.vout)178+ BOOST_FOREACH(const CTxOut& txout, wtx.vout)179 {180 if (txout.IsMine())181 continue;182@@ -1394,10 +1401,10 @@183 //184 // Mixed debit transaction185 //186- foreach(const CTxIn& txin, wtx.vin)187+ BOOST_FOREACH(const CTxIn& txin, wtx.vin)188 if (txin.IsMine())189 strHTML += _("<b>Debit:</b> ") + FormatMoney(-txin.GetDebit()) + "<br>";190- foreach(const CTxOut& txout, wtx.vout)191+ BOOST_FOREACH(const CTxOut& txout, wtx.vout)192 if (txout.IsMine())193 strHTML += _("<b>Credit:</b> ") + FormatMoney(txout.GetCredit()) + "<br>";194 }195@@ -1424,10 +1431,10 @@196 if (fDebug)197 {198 strHTML += "<hr><br>debug print<br><br>";199- foreach(const CTxIn& txin, wtx.vin)200+ BOOST_FOREACH(const CTxIn& txin, wtx.vin)201 if (txin.IsMine())202 strHTML += "<b>Debit:</b> " + FormatMoney(-txin.GetDebit()) + "<br>";203- foreach(const CTxOut& txout, wtx.vout)204+ BOOST_FOREACH(const CTxOut& txout, wtx.vout)205 if (txout.IsMine())206 strHTML += "<b>Credit:</b> " + FormatMoney(txout.GetCredit()) + "<br>";207 208@@ -1437,7 +1444,7 @@209 strHTML += "<br><b>Inputs:</b><br>";210 CRITICAL_BLOCK(cs_mapWallet)211 {212- foreach(const CTxIn& txin, wtx.vin)213+ BOOST_FOREACH(const CTxIn& txin, wtx.vin)214 {215 COutPoint prevout = txin.prevout;216 map<uint256, CWalletTx>::iterator mi = mapWallet.find(prevout.hash);217@@ -1637,6 +1644,8 @@218 SelectPage(0);219 #ifndef __WXMSW__220 SetSize(1.0 * GetSize().GetWidth(), 1.2 * GetSize().GetHeight());221+#else222+ SetSize(nScaleX * GetSize().GetWidth(), nScaleY * GetSize().GetHeight());223 #endif224 #if defined(__WXGTK__) || defined(__WXMAC_OSX__)225 m_checkBoxStartOnSystemStartup->SetLabel(_("&Start Bitcoin on window system startup"));226@@ -1655,13 +1664,6 @@227 228 // Init values229 m_textCtrlTransactionFee->SetValue(FormatMoney(nTransactionFee));230- m_checkBoxLimitProcessors->SetValue(fLimitProcessors);231- m_spinCtrlLimitProcessors->Enable(fLimitProcessors);232- m_spinCtrlLimitProcessors->SetValue(nLimitProcessors);233- int nProcessors = wxThread::GetCPUCount();234- if (nProcessors < 1)235- nProcessors = 999;236- m_spinCtrlLimitProcessors->SetRange(1, nProcessors);237 m_checkBoxStartOnSystemStartup->SetValue(fTmpStartOnSystemStartup = GetStartOnSystemStartup());238 m_checkBoxMinimizeToTray->SetValue(fMinimizeToTray);239 m_checkBoxMinimizeOnClose->SetValue(fMinimizeOnClose);240@@ -1702,11 +1704,6 @@241 m_textCtrlTransactionFee->SetValue(FormatMoney(nTmp));242 }243 244-void COptionsDialog::OnCheckBoxLimitProcessors(wxCommandEvent& event)245-{246- m_spinCtrlLimitProcessors->Enable(event.IsChecked());247-}248-249 void COptionsDialog::OnCheckBoxUseProxy(wxCommandEvent& event)250 {251 m_textCtrlProxyIP->Enable(event.IsChecked());252@@ -1754,20 +1751,6 @@253 int64 nPrevTransactionFee = nTransactionFee;254 if (ParseMoney(m_textCtrlTransactionFee->GetValue(), nTransactionFee) && nTransactionFee != nPrevTransactionFee)255 walletdb.WriteSetting("nTransactionFee", nTransactionFee);256-257- int nPrevMaxProc = (fLimitProcessors ? nLimitProcessors : INT_MAX);258- if (fLimitProcessors != m_checkBoxLimitProcessors->GetValue())259- {260- fLimitProcessors = m_checkBoxLimitProcessors->GetValue();261- walletdb.WriteSetting("fLimitProcessors", fLimitProcessors);262- }263- if (nLimitProcessors != m_spinCtrlLimitProcessors->GetValue())264- {265- nLimitProcessors = m_spinCtrlLimitProcessors->GetValue();266- walletdb.WriteSetting("nLimitProcessors", nLimitProcessors);267- }268- if (fGenerateBitcoins && (fLimitProcessors ? nLimitProcessors : INT_MAX) > nPrevMaxProc)269- GenerateBitcoins(fGenerateBitcoins);270 271 if (fTmpStartOnSystemStartup != m_checkBoxStartOnSystemStartup->GetValue())272 {273@@ -1833,6 +1816,8 @@274 fontTmp.SetPointSize(8);275 m_staticTextMain->SetFont(fontTmp);276 SetSize(GetSize().GetWidth() + 44, GetSize().GetHeight() + 10);277+#else278+ SetSize(nScaleX * GetSize().GetWidth(), nScaleY * GetSize().GetHeight());279 #endif280 }281 282@@ -1859,6 +1844,7 @@283 m_bitmapCheckMark->Show(false);284 fEnabledPrev = true;285 m_textCtrlAddress->SetFocus();286+ 287 //// todo: should add a display of your balance for convenience288 #ifndef __WXMSW__289 wxFont fontTmp = m_staticTextInstructions->GetFont();290@@ -1866,12 +1852,21 @@291 fontTmp.SetPointSize(9);292 m_staticTextInstructions->SetFont(fontTmp);293 SetSize(725, 180);294-#endif295-296+#else297+ SetSize(nScaleX * GetSize().GetWidth(), nScaleY * GetSize().GetHeight());298+#endif299+ 300 // Set Icon301- wxIcon iconSend;302- iconSend.CopyFromBitmap(wxBitmap(send16noshadow_xpm));303- SetIcon(iconSend);304+ if (nScaleX == 1.0 && nScaleY == 1.0) // We don't have icons of the proper size otherwise305+ {306+ wxIcon iconSend;307+ iconSend.CopyFromBitmap(wxBitmap(send16noshadow_xpm));308+ SetIcon(iconSend);309+ }310+#ifdef __WXMSW__311+ else312+ SetIcon(wxICON(bitcoin));313+#endif314 315 // Fixup the tab order316 m_buttonPaste->MoveAfterInTabOrder(m_buttonCancel);317@@ -1960,6 +1955,7 @@318 {319 wxMessageBox(strError + " ", _("Sending..."));320 EndModal(false);321+ return;322 }323 }324 }325@@ -2020,6 +2016,8 @@326 fWorkDone = false;327 #ifndef __WXMSW__328 SetSize(1.2 * GetSize().GetWidth(), 1.08 * GetSize().GetHeight());329+#else330+ SetSize(nScaleX * GetSize().GetWidth(), nScaleY * GetSize().GetHeight());331 #endif332 333 SetTitle(strprintf(_("Sending %s to %s"), FormatMoney(nPrice).c_str(), wtx.mapValue["to"].c_str()));334@@ -2343,6 +2341,10 @@335 336 CAddressBookDialog::CAddressBookDialog(wxWindow* parent, const wxString& strInitSelected, int nPageIn, bool fDuringSendIn) : CAddressBookDialogBase(parent)337 {338+#ifdef __WXMSW__339+ SetSize(nScaleX * GetSize().GetWidth(), nScaleY * GetSize().GetHeight());340+#endif341+342 // Set initially selected page343 wxNotebookEvent event;344 event.SetSelection(nPageIn);345@@ -2354,9 +2356,16 @@346 m_buttonCancel->Show(false);347 348 // Set Icon349- wxIcon iconAddressBook;350- iconAddressBook.CopyFromBitmap(wxBitmap(addressbook16_xpm));351- SetIcon(iconAddressBook);352+ if (nScaleX == 1.0 && nScaleY == 1.0) // We don't have icons of the proper size otherwise353+ {354+ wxIcon iconAddressBook;355+ iconAddressBook.CopyFromBitmap(wxBitmap(addressbook16_xpm));356+ SetIcon(iconAddressBook);357+ }358+#ifdef __WXMSW__359+ else360+ SetIcon(wxICON(bitcoin));361+#endif362 363 // Init column headers364 m_listCtrlSending->InsertColumn(0, _("Name"), wxLIST_FORMAT_LEFT, 200);365@@ -2371,7 +2380,7 @@366 CRITICAL_BLOCK(cs_mapAddressBook)367 {368 string strDefaultReceiving = (string)pframeMain->m_textCtrlAddress->GetValue();369- foreach(const PAIRTYPE(string, string)& item, mapAddressBook)370+ BOOST_FOREACH(const PAIRTYPE(string, string)& item, mapAddressBook)371 {372 string strAddress = item.first;373 string strName = item.second;374@@ -2605,6 +2614,7 @@375 enum376 {377 ID_TASKBAR_RESTORE = 10001,378+ ID_TASKBAR_SEND,379 ID_TASKBAR_OPTIONS,380 ID_TASKBAR_GENERATE,381 ID_TASKBAR_EXIT,382@@ -2613,8 +2623,8 @@383 BEGIN_EVENT_TABLE(CMyTaskBarIcon, wxTaskBarIcon)384 EVT_TASKBAR_LEFT_DCLICK(CMyTaskBarIcon::OnLeftButtonDClick)385 EVT_MENU(ID_TASKBAR_RESTORE, CMyTaskBarIcon::OnMenuRestore)386+ EVT_MENU(ID_TASKBAR_SEND, CMyTaskBarIcon::OnMenuSend)387 EVT_MENU(ID_TASKBAR_OPTIONS, CMyTaskBarIcon::OnMenuOptions)388- EVT_MENU(ID_TASKBAR_GENERATE, CMyTaskBarIcon::OnMenuGenerate)389 EVT_UPDATE_UI(ID_TASKBAR_GENERATE, CMyTaskBarIcon::OnUpdateUIGenerate)390 EVT_MENU(ID_TASKBAR_EXIT, CMyTaskBarIcon::OnMenuExit)391 END_EVENT_TABLE()392@@ -2665,6 +2675,13 @@393 Restore();394 }395 396+void CMyTaskBarIcon::OnMenuSend(wxCommandEvent& event)397+{398+ // Taskbar: Send399+ CSendDialog dialog(pframeMain);400+ dialog.ShowModal();401+}402+403 void CMyTaskBarIcon::OnMenuOptions(wxCommandEvent& event)404 {405 // Since it's modal, get the main window to do it406@@ -2681,11 +2698,6 @@407 pframeMain->Raise();408 }409 410-void CMyTaskBarIcon::OnMenuGenerate(wxCommandEvent& event)411-{412- GenerateBitcoins(event.IsChecked());413-}414-415 void CMyTaskBarIcon::OnUpdateUIGenerate(wxUpdateUIEvent& event)416 {417 event.Check(fGenerateBitcoins);418@@ -2706,8 +2718,8 @@419 {420 wxMenu* pmenu = new wxMenu;421 pmenu->Append(ID_TASKBAR_RESTORE, _("&Open Bitcoin"));422+ pmenu->Append(ID_TASKBAR_SEND, _("&Send Bitcoins"));423 pmenu->Append(ID_TASKBAR_OPTIONS, _("O&ptions..."));424- pmenu->AppendCheckItem(ID_TASKBAR_GENERATE, _("&Generate Coins"))->Check(fGenerateBitcoins);425 #ifndef __WXMAC_OSX__ // Mac has built-in quit menu426 pmenu->AppendSeparator();427 pmenu->Append(ID_TASKBAR_EXIT, _("E&xit"));428@@ -2839,9 +2851,6 @@429 extern int g_isPainting;430 g_isPainting = 10000;431 #endif432-#ifdef GUI433- wxImage::AddHandler(new wxPNGHandler);434-#endif435 #if defined(__WXMSW__ ) || defined(__WXMAC_OSX__)436 SetAppName("Bitcoin");437 #else438@@ -2872,6 +2881,16 @@439 g_locale.AddCatalog("wxstd"); // wxWidgets standard translations, if any440 g_locale.AddCatalog("bitcoin");441 442+#ifdef __WXMSW__443+ HDC hdc = GetDC(NULL);444+ if (hdc)445+ {446+ nScaleX = GetDeviceCaps(hdc, LOGPIXELSX) / 96.0;447+ nScaleY = GetDeviceCaps(hdc, LOGPIXELSY) / 96.0;448+ ReleaseDC(NULL, hdc);449+ }450+#endif451+452 return AppInit(argc, argv);453 }454
ui.h (modified)
1--- v0.3.21/ui.h2+++ v0.3.22/ui.h3@@ -1,6 +1,8 @@4 // Copyright (c) 2009-2010 Satoshi Nakamoto5 // Distributed under the MIT/X11 software license, see the accompanying6 // file license.txt or http://www.opensource.org/licenses/mit-license.php.7+#ifndef BITCOIN_UI_H8+#define BITCOIN_UI_H9 10 DECLARE_EVENT_TYPE(wxEVT_UITHREADCALL, -1)11 12@@ -12,9 +14,9 @@13 14 void HandleCtrlA(wxKeyEvent& event);15 void UIThreadCall(boost::function0<void>);16-int ThreadSafeMessageBox(const string& message, const string& caption="Message", int style=wxOK, wxWindow* parent=NULL, int x=-1, int y=-1);17-bool ThreadSafeAskFee(int64 nFeeRequired, const string& strCaption, wxWindow* parent);18-void CalledSetStatusBar(const string& strText, int nField);19+int ThreadSafeMessageBox(const std::string& message, const std::string& caption="Message", int style=wxOK, wxWindow* parent=NULL, int x=-1, int y=-1);20+bool ThreadSafeAskFee(int64 nFeeRequired, const std::string& strCaption, wxWindow* parent);21+void CalledSetStatusBar(const std::string& strText, int nField);22 void MainFrameRepaint();23 void CreateMainWindow();24 void SetStartOnSystemStartup(bool fAutoStart);25@@ -28,8 +30,8 @@26 if (!fDaemon)27 return wxMessageBox(message, caption, style, parent, x, y);28 #endif29- printf("wxMessageBox %s: %s\n", string(caption).c_str(), string(message).c_str());30- fprintf(stderr, "%s: %s\n", string(caption).c_str(), string(message).c_str());31+ printf("wxMessageBox %s: %s\n", std::string(caption).c_str(), std::string(message).c_str());32+ fprintf(stderr, "%s: %s\n", std::string(caption).c_str(), std::string(message).c_str());33 return wxOK;34 }35 #define wxMessageBox MyMessageBox36@@ -52,7 +54,6 @@37 void OnPaint(wxPaintEvent& event);38 void OnPaintListCtrl(wxPaintEvent& event);39 void OnMenuFileExit(wxCommandEvent& event);40- void OnMenuOptionsGenerate(wxCommandEvent& event);41 void OnUpdateUIOptionsGenerate(wxUpdateUIEvent& event);42 void OnMenuOptionsChangeYourAddress(wxCommandEvent& event);43 void OnMenuOptionsOptions(wxCommandEvent& event);44@@ -94,8 +95,8 @@45 bool fRefresh;46 47 void OnUIThreadCall(wxCommandEvent& event);48- int GetSortIndex(const string& strSort);49- void InsertLine(bool fNew, int nIndex, uint256 hashKey, string strSort, const wxColour& colour, const wxString& str1, const wxString& str2, const wxString& str3, const wxString& str4, const wxString& str5);50+ int GetSortIndex(const std::string& strSort);51+ void InsertLine(bool fNew, int nIndex, uint256 hashKey, std::string strSort, const wxColour& colour, const wxString& str1, const wxString& str2, const wxString& str3, const wxString& str4, const wxString& str5);52 bool DeleteLine(uint256 hashKey);53 bool InsertTransaction(const CWalletTx& wtx, bool fNew, int nIndex=-1);54 void RefreshListCtrl();55@@ -127,7 +128,6 @@56 // Event handlers57 void OnListBox(wxCommandEvent& event);58 void OnKillFocusTransactionFee(wxFocusEvent& event);59- void OnCheckBoxLimitProcessors(wxCommandEvent& event);60 void OnCheckBoxUseProxy(wxCommandEvent& event);61 void OnKillFocusProxy(wxFocusEvent& event);62 63@@ -178,8 +178,8 @@64 65 // Custom66 bool fEnabledPrev;67- string strFromSave;68- string strMessageSave;69+ std::string strFromSave;70+ std::string strMessageSave;71 };72 73 74@@ -213,8 +213,8 @@75 void Close();76 void Repaint();77 bool Status();78- bool Status(const string& str);79- bool Error(const string& str);80+ bool Status(const std::string& str);81+ bool Error(const std::string& str);82 void StartTransfer();83 void OnReply2(CDataStream& vRecv);84 void OnReply3(CDataStream& vRecv);85@@ -259,7 +259,7 @@86 wxString GetSelectedAddress();87 wxString GetSelectedSendingAddress();88 wxString GetSelectedReceivingAddress();89- bool CheckIfMine(const string& strAddress, const string& strTitle);90+ bool CheckIfMine(const std::string& strAddress, const std::string& strTitle);91 };92 93 94@@ -283,11 +283,11 @@95 public:96 /** Constructor */97 CGetTextFromUserDialog(wxWindow* parent,98- const string& strCaption,99- const string& strMessage1,100- const string& strValue1="",101- const string& strMessage2="",102- const string& strValue2="") : CGetTextFromUserDialogBase(parent, wxID_ANY, strCaption)103+ const std::string& strCaption,104+ const std::string& strMessage1,105+ const std::string& strValue1="",106+ const std::string& strMessage2="",107+ const std::string& strValue2="") : CGetTextFromUserDialogBase(parent, wxID_ANY, strCaption)108 {109 int x = GetSize().GetWidth();110 int y = GetSize().GetHeight();111@@ -310,9 +310,9 @@112 }113 114 // Custom115- string GetValue() { return (string)m_textCtrl1->GetValue(); }116- string GetValue1() { return (string)m_textCtrl1->GetValue(); }117- string GetValue2() { return (string)m_textCtrl2->GetValue(); }118+ std::string GetValue() { return (std::string)m_textCtrl1->GetValue(); }119+ std::string GetValue1() { return (std::string)m_textCtrl1->GetValue(); }120+ std::string GetValue2() { return (std::string)m_textCtrl2->GetValue(); }121 };122 123 124@@ -323,6 +323,7 @@125 // Event handlers126 void OnLeftButtonDClick(wxTaskBarIconEvent& event);127 void OnMenuRestore(wxCommandEvent& event);128+ void OnMenuSend(wxCommandEvent& event);129 void OnMenuOptions(wxCommandEvent& event);130 void OnUpdateUIGenerate(wxUpdateUIEvent& event);131 void OnMenuGenerate(wxCommandEvent& event);132@@ -343,3 +344,5 @@133 DECLARE_EVENT_TABLE()134 };135 136+#endif137+
ui.rc (removed)
1--- v0.3.21/ui.rc2+++ /dev/null3@@ -1,16 +1 @@4-bitcoin ICON "rc/bitcoin.ico"5 6-#include "wx/msw/wx.rc"7-8-check ICON "rc/check.ico"9-send16 BITMAP "rc/send16.bmp"10-send16mask BITMAP "rc/send16mask.bmp"11-send16masknoshadow BITMAP "rc/send16masknoshadow.bmp"12-send20 BITMAP "rc/send20.bmp"13-send20mask BITMAP "rc/send20mask.bmp"14-addressbook16 BITMAP "rc/addressbook16.bmp"15-addressbook16mask BITMAP "rc/addressbook16mask.bmp"16-addressbook20 BITMAP "rc/addressbook20.bmp"17-addressbook20mask BITMAP "rc/addressbook20mask.bmp"18-favicon ICON "rc/favicon.ico"19-
uibase.cpp (modified)
1--- v0.3.21/uibase.cpp2+++ v0.3.22/uibase.cpp3@@ -28,10 +28,6 @@4 m_menubar->Append( m_menuFile, _("&File") );5 6 m_menuOptions = new wxMenu();7- wxMenuItem* m_menuOptionsGenerateBitcoins;8- m_menuOptionsGenerateBitcoins = new wxMenuItem( m_menuOptions, wxID_OPTIONSGENERATEBITCOINS, wxString( _("&Generate Coins") ) , wxEmptyString, wxITEM_CHECK );9- m_menuOptions->Append( m_menuOptionsGenerateBitcoins );10- 11 wxMenuItem* m_menuOptionsChangeYourAddress;12 m_menuOptionsChangeYourAddress = new wxMenuItem( m_menuOptions, wxID_ANY, wxString( _("&Your Receiving Addresses...") ) , wxEmptyString, wxITEM_NORMAL );13 m_menuOptions->Append( m_menuOptionsChangeYourAddress );14@@ -190,8 +186,6 @@15 this->Connect( wxEVT_MOUSEWHEEL, wxMouseEventHandler( CMainFrameBase::OnMouseEvents ) );16 this->Connect( wxEVT_PAINT, wxPaintEventHandler( CMainFrameBase::OnPaint ) );17 this->Connect( m_menuFileExit->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( CMainFrameBase::OnMenuFileExit ) );18- this->Connect( m_menuOptionsGenerateBitcoins->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( CMainFrameBase::OnMenuOptionsGenerate ) );19- this->Connect( m_menuOptionsGenerateBitcoins->GetId(), wxEVT_UPDATE_UI, wxUpdateUIEventHandler( CMainFrameBase::OnUpdateUIOptionsGenerate ) );20 this->Connect( m_menuOptionsChangeYourAddress->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( CMainFrameBase::OnMenuOptionsChangeYourAddress ) );21 this->Connect( m_menuOptionsOptions->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( CMainFrameBase::OnMenuOptionsOptions ) );22 this->Connect( m_menuHelpAbout->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( CMainFrameBase::OnMenuHelpAbout ) );23@@ -250,8 +244,6 @@24 this->Disconnect( wxEVT_MOUSEWHEEL, wxMouseEventHandler( CMainFrameBase::OnMouseEvents ) );25 this->Disconnect( wxEVT_PAINT, wxPaintEventHandler( CMainFrameBase::OnPaint ) );26 this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( CMainFrameBase::OnMenuFileExit ) );27- this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( CMainFrameBase::OnMenuOptionsGenerate ) );28- this->Disconnect( wxID_ANY, wxEVT_UPDATE_UI, wxUpdateUIEventHandler( CMainFrameBase::OnUpdateUIOptionsGenerate ) );29 this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( CMainFrameBase::OnMenuOptionsChangeYourAddress ) );30 this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( CMainFrameBase::OnMenuOptionsOptions ) );31 this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( CMainFrameBase::OnMenuHelpAbout ) );32@@ -350,21 +342,6 @@33 34 bSizer69->Add( 0, 16, 0, wxEXPAND, 5 );35 36- wxBoxSizer* bSizer71;37- bSizer71 = new wxBoxSizer( wxHORIZONTAL );38- 39- m_checkBoxLimitProcessors = new wxCheckBox( m_panelMain, wxID_ANY, _("&Limit coin generation to"), wxDefaultPosition, wxDefaultSize, 0 );40- bSizer71->Add( m_checkBoxLimitProcessors, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );41- 42- m_spinCtrlLimitProcessors = new wxSpinCtrl( m_panelMain, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 48,-1 ), wxSP_ARROW_KEYS, 1, 999, 1 );43- bSizer71->Add( m_spinCtrlLimitProcessors, 0, wxALIGN_CENTER_VERTICAL, 5 );44- 45- m_staticText35 = new wxStaticText( m_panelMain, wxID_ANY, _("processors"), wxDefaultPosition, wxDefaultSize, 0 );46- m_staticText35->Wrap( -1 );47- bSizer71->Add( m_staticText35, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );48- 49- bSizer69->Add( bSizer71, 0, 0, 5 );50- 51 m_checkBoxStartOnSystemStartup = new wxCheckBox( m_panelMain, wxID_ANY, _("&Start Bitcoin on system startup"), wxDefaultPosition, wxDefaultSize, 0 );52 bSizer69->Add( m_checkBoxStartOnSystemStartup, 0, wxALL, 5 );53 54@@ -479,7 +456,6 @@55 56 // Connect Events57 m_listBox->Connect( wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler( COptionsDialogBase::OnListBox ), NULL, this );58- m_checkBoxLimitProcessors->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( COptionsDialogBase::OnCheckBoxLimitProcessors ), NULL, this );59 m_checkBoxMinimizeToTray->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( COptionsDialogBase::OnCheckBoxMinimizeToTray ), NULL, this );60 m_checkBoxUseProxy->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( COptionsDialogBase::OnCheckBoxUseProxy ), NULL, this );61 m_textCtrlProxyIP->Connect( wxEVT_KILL_FOCUS, wxFocusEventHandler( COptionsDialogBase::OnKillFocusProxy ), NULL, this );62@@ -494,7 +470,6 @@63 {64 // Disconnect Events65 m_listBox->Disconnect( wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler( COptionsDialogBase::OnListBox ), NULL, this );66- m_checkBoxLimitProcessors->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( COptionsDialogBase::OnCheckBoxLimitProcessors ), NULL, this );67 m_checkBoxMinimizeToTray->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( COptionsDialogBase::OnCheckBoxMinimizeToTray ), NULL, this );68 m_checkBoxUseProxy->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( COptionsDialogBase::OnCheckBoxUseProxy ), NULL, this );69 m_textCtrlProxyIP->Disconnect( wxEVT_KILL_FOCUS, wxFocusEventHandler( COptionsDialogBase::OnKillFocusProxy ), NULL, this );
uibase.h (modified)
1--- v0.3.21/uibase.h2+++ v0.3.22/uibase.h3@@ -34,36 +34,34 @@4 #include <wx/dialog.h>5 #include <wx/listbox.h>6 #include <wx/checkbox.h>7-#include <wx/spinctrl.h>8 #include <wx/scrolwin.h>9 #include <wx/statbmp.h>10 11 ///////////////////////////////////////////////////////////////////////////12 13 #define wxID_MAINFRAME 100014-#define wxID_OPTIONSGENERATEBITCOINS 100115-#define wxID_BUTTONSEND 100216-#define wxID_BUTTONRECEIVE 100317-#define wxID_TEXTCTRLADDRESS 100418-#define wxID_BUTTONNEW 100519-#define wxID_BUTTONCOPY 100620-#define wxID_PROXYIP 100721-#define wxID_PROXYPORT 100822-#define wxID_TRANSACTIONFEE 100923-#define wxID_TEXTCTRLPAYTO 101024-#define wxID_BUTTONPASTE 101125-#define wxID_BUTTONADDRESSBOOK 101226-#define wxID_TEXTCTRLAMOUNT 101327-#define wxID_CHOICETRANSFERTYPE 101428-#define wxID_LISTCTRL 101529-#define wxID_BUTTONRENAME 101630-#define wxID_PANELSENDING 101731-#define wxID_LISTCTRLSENDING 101832-#define wxID_PANELRECEIVING 101933-#define wxID_LISTCTRLRECEIVING 102034-#define wxID_BUTTONDELETE 102135-#define wxID_BUTTONEDIT 102236-#define wxID_TEXTCTRL 102337+#define wxID_BUTTONSEND 100138+#define wxID_BUTTONRECEIVE 100239+#define wxID_TEXTCTRLADDRESS 100340+#define wxID_BUTTONNEW 100441+#define wxID_BUTTONCOPY 100542+#define wxID_PROXYIP 100643+#define wxID_PROXYPORT 100744+#define wxID_TRANSACTIONFEE 100845+#define wxID_TEXTCTRLPAYTO 100946+#define wxID_BUTTONPASTE 101047+#define wxID_BUTTONADDRESSBOOK 101148+#define wxID_TEXTCTRLAMOUNT 101249+#define wxID_CHOICETRANSFERTYPE 101350+#define wxID_LISTCTRL 101451+#define wxID_BUTTONRENAME 101552+#define wxID_PANELSENDING 101653+#define wxID_LISTCTRLSENDING 101754+#define wxID_PANELRECEIVING 101855+#define wxID_LISTCTRLRECEIVING 101956+#define wxID_BUTTONDELETE 102057+#define wxID_BUTTONEDIT 102158+#define wxID_TEXTCTRL 102259 60 ///////////////////////////////////////////////////////////////////////////////61 /// Class CMainFrameBase62@@ -99,8 +97,6 @@63 virtual void OnMouseEvents( wxMouseEvent& event ) { event.Skip(); }64 virtual void OnPaint( wxPaintEvent& event ) { event.Skip(); }65 virtual void OnMenuFileExit( wxCommandEvent& event ) { event.Skip(); }66- virtual void OnMenuOptionsGenerate( wxCommandEvent& event ) { event.Skip(); }67- virtual void OnUpdateUIOptionsGenerate( wxUpdateUIEvent& event ) { event.Skip(); }68 virtual void OnMenuOptionsChangeYourAddress( wxCommandEvent& event ) { event.Skip(); }69 virtual void OnMenuOptionsOptions( wxCommandEvent& event ) { event.Skip(); }70 virtual void OnMenuHelpAbout( wxCommandEvent& event ) { event.Skip(); }71@@ -165,9 +161,6 @@72 wxScrolledWindow* m_scrolledWindow;73 wxPanel* m_panelMain;74 75- wxCheckBox* m_checkBoxLimitProcessors;76- wxSpinCtrl* m_spinCtrlLimitProcessors;77- wxStaticText* m_staticText35;78 wxCheckBox* m_checkBoxStartOnSystemStartup;79 wxCheckBox* m_checkBoxMinimizeToTray;80 wxCheckBox* m_checkBoxUseUPnP;81@@ -192,7 +185,6 @@82 83 // Virtual event handlers, overide them in your derived class84 virtual void OnListBox( wxCommandEvent& event ) { event.Skip(); }85- virtual void OnCheckBoxLimitProcessors( wxCommandEvent& event ) { event.Skip(); }86 virtual void OnCheckBoxMinimizeToTray( wxCommandEvent& event ) { event.Skip(); }87 virtual void OnCheckBoxUseProxy( wxCommandEvent& event ) { event.Skip(); }88 virtual void OnKillFocusProxy( wxFocusEvent& event ) { event.Skip(); }
uint256.h (modified)
1--- v0.3.21/uint256.h2+++ v0.3.22/uint256.h3@@ -1,9 +1,15 @@4 // Copyright (c) 2009-2010 Satoshi Nakamoto5 // Distributed under the MIT/X11 software license, see the accompanying6 // file license.txt or http://www.opensource.org/licenses/mit-license.php.7+#ifndef BITCOIN_UINT256_H8+#define BITCOIN_UINT256_H9+10+#include "serialize.h"11 12 #include <limits.h>13 #include <string>14+#include <vector>15+16 #if defined(_MSC_VER) || defined(__BORLANDC__)17 typedef __int64 int64;18 typedef unsigned __int64 uint64;19@@ -16,7 +22,7 @@20 #endif21 22 23-inline int Testuint256AdHoc(vector<string> vArg);24+inline int Testuint256AdHoc(std::vector<std::string> vArg);25 26 27 28@@ -296,7 +302,7 @@29 char psz[sizeof(pn)*2 + 1];30 for (int i = 0; i < sizeof(pn); i++)31 sprintf(psz + i*2, "%02x", ((unsigned char*)pn)[sizeof(pn) - i - 1]);32- return string(psz, psz + sizeof(pn)*2);33+ return std::string(psz, psz + sizeof(pn)*2);34 }35 36 void SetHex(const char* psz)37@@ -377,7 +383,7 @@38 39 friend class uint160;40 friend class uint256;41- friend inline int Testuint256AdHoc(vector<string> vArg);42+ friend inline int Testuint256AdHoc(std::vector<std::string> vArg);43 };44 45 typedef base_uint<160> base_uint160;46@@ -626,7 +632,7 @@47 48 49 50-inline int Testuint256AdHoc(vector<string> vArg)51+inline int Testuint256AdHoc(std::vector<std::string> vArg)52 {53 uint256 g(0);54 55@@ -756,3 +762,5 @@56 return (0);57 }58 59+#endif60+
util.cpp (modified)
1--- v0.3.21/util.cpp2+++ v0.3.22/util.cpp3@@ -1,9 +1,10 @@4 // Copyright (c) 2009-2010 Satoshi Nakamoto5 // Distributed under the MIT/X11 software license, see the accompanying6 // file license.txt or http://www.opensource.org/licenses/mit-license.php.7-8 #include "headers.h"9 10+using namespace std;11+using namespace boost;12 13 map<string, string> mapArgs;14 map<string, vector<string> > mapMultiArgs;15@@ -270,7 +271,7 @@16 if (ret >= 0 && ret < limit)17 break;18 if (p != buffer)19- delete p;20+ delete[] p;21 limit *= 2;22 p = new char[limit];23 if (p == NULL)24@@ -278,7 +279,7 @@25 }26 string str(p, p+ret);27 if (p != buffer)28- delete p;29+ delete[] p;30 return str;31 }32 33@@ -704,7 +705,7 @@34 if (!pfMkdir[nVariation])35 {36 pfMkdir[nVariation] = true;37- filesystem::create_directory(pszDir);38+ boost::filesystem::create_directory(pszDir);39 }40 }41 42@@ -855,7 +856,7 @@43 {44 // If nobody has a time different than ours but within 5 minutes of ours, give a warning45 bool fMatch = false;46- foreach(int64 nOffset, vTimeOffsets)47+ BOOST_FOREACH(int64 nOffset, vTimeOffsets)48 if (nOffset != 0 && abs64(nOffset) < 5 * 60)49 fMatch = true;50 51@@ -869,7 +870,7 @@52 }53 }54 }55- foreach(int64 n, vTimeOffsets)56+ BOOST_FOREACH(int64 n, vTimeOffsets)57 printf("%+"PRI64d" ", n);58 printf("| nTimeOffset = %+"PRI64d" (%+"PRI64d" minutes)\n", nTimeOffset, nTimeOffset/60);59 }
util.h (modified)
1--- v0.3.21/util.h2+++ v0.3.22/util.h3@@ -1,6 +1,28 @@4 // Copyright (c) 2009-2010 Satoshi Nakamoto5 // Distributed under the MIT/X11 software license, see the accompanying6 // file license.txt or http://www.opensource.org/licenses/mit-license.php.7+#ifndef BITCOIN_UTIL_H8+#define BITCOIN_UTIL_H9+10+#include "uint256.h"11+12+#ifndef __WXMSW__13+#include <sys/types.h>14+#include <sys/time.h>15+#include <sys/resource.h>16+#endif17+#include <map>18+#include <vector>19+#include <string>20+21+#include <boost/foreach.hpp>22+#include <boost/thread.hpp>23+#include <boost/interprocess/sync/interprocess_recursive_mutex.hpp>24+#include <boost/date_time/gregorian/gregorian_types.hpp>25+#include <boost/date_time/posix_time/posix_time_types.hpp>26+27+#include <openssl/sha.h>28+#include <openssl/ripemd.h>29 30 31 #if defined(_MSC_VER) || defined(__BORLANDC__)32@@ -17,7 +39,6 @@33 #define __forceinline inline34 #endif35 36-#define foreach BOOST_FOREACH37 #define loop for (;;)38 #define BEGIN(a) ((char*)&(a))39 #define END(a) ((char*)&((&(a))[1]))40@@ -134,8 +155,8 @@41 42 43 44-extern map<string, string> mapArgs;45-extern map<string, vector<string> > mapMultiArgs;46+extern std::map<std::string, std::string> mapArgs;47+extern std::map<std::string, std::vector<std::string> > mapMultiArgs;48 extern bool fDebug;49 extern bool fPrintToConsole;50 extern bool fPrintToDebugger;51@@ -145,7 +166,7 @@52 extern bool fDaemon;53 extern bool fServer;54 extern bool fCommandLine;55-extern string strMiscWarning;56+extern std::string strMiscWarning;57 extern bool fTestNet;58 extern bool fNoListen;59 extern bool fLogTimestamps;60@@ -154,39 +175,39 @@61 void RandAddSeedPerfmon();62 int OutputDebugStringF(const char* pszFormat, ...);63 int my_snprintf(char* buffer, size_t limit, const char* format, ...);64-string strprintf(const char* format, ...);65+std::string strprintf(const char* format, ...);66 bool error(const char* format, ...);67 void LogException(std::exception* pex, const char* pszThread);68 void PrintException(std::exception* pex, const char* pszThread);69 void PrintExceptionContinue(std::exception* pex, const char* pszThread);70-void ParseString(const string& str, char c, vector<string>& v);71-string FormatMoney(int64 n, bool fPlus=false);72-bool ParseMoney(const string& str, int64& nRet);73+void ParseString(const std::string& str, char c, std::vector<std::string>& v);74+std::string FormatMoney(int64 n, bool fPlus=false);75+bool ParseMoney(const std::string& str, int64& nRet);76 bool ParseMoney(const char* pszIn, int64& nRet);77-vector<unsigned char> ParseHex(const char* psz);78-vector<unsigned char> ParseHex(const string& str);79+std::vector<unsigned char> ParseHex(const char* psz);80+std::vector<unsigned char> ParseHex(const std::string& str);81 void ParseParameters(int argc, char* argv[]);82 const char* wxGetTranslation(const char* psz);83 bool WildcardMatch(const char* psz, const char* mask);84-bool WildcardMatch(const string& str, const string& mask);85+bool WildcardMatch(const std::string& str, const std::string& mask);86 int GetFilesize(FILE* file);87 void GetDataDir(char* pszDirRet);88-string GetConfigFile();89-string GetPidFile();90-void CreatePidFile(string pidFile, pid_t pid);91-void ReadConfigFile(map<string, string>& mapSettingsRet, map<string, vector<string> >& mapMultiSettingsRet);92-#ifdef __WXMSW__93-string MyGetSpecialFolderPath(int nFolder, bool fCreate);94-#endif95-string GetDefaultDataDir();96-string GetDataDir();97+std::string GetConfigFile();98+std::string GetPidFile();99+void CreatePidFile(std::string pidFile, pid_t pid);100+void ReadConfigFile(std::map<std::string, std::string>& mapSettingsRet, std::map<std::string, std::vector<std::string> >& mapMultiSettingsRet);101+#ifdef __WXMSW__102+std::string MyGetSpecialFolderPath(int nFolder, bool fCreate);103+#endif104+std::string GetDefaultDataDir();105+std::string GetDataDir();106 void ShrinkDebugFile();107 int GetRandInt(int nMax);108 uint64 GetRand(uint64 nMax);109 int64 GetTime();110 int64 GetAdjustedTime();111 void AddTimeData(unsigned int ip, int64 nTime);112-string FormatFullVersion();113+std::string FormatFullVersion();114 115 116 117@@ -268,12 +289,12 @@118 119 120 121-inline string i64tostr(int64 n)122+inline std::string i64tostr(int64 n)123 {124 return strprintf("%"PRI64d, n);125 }126 127-inline string itostr(int n)128+inline std::string itostr(int n)129 {130 return strprintf("%d", n);131 }132@@ -287,7 +308,7 @@133 #endif134 }135 136-inline int64 atoi64(const string& str)137+inline int64 atoi64(const std::string& str)138 {139 #ifdef _MSC_VER140 return _atoi64(str.c_str());141@@ -296,7 +317,7 @@142 #endif143 }144 145-inline int atoi(const string& str)146+inline int atoi(const std::string& str)147 {148 return atoi(str.c_str());149 }150@@ -317,39 +338,39 @@151 }152 153 template<typename T>154-string HexStr(const T itbegin, const T itend, bool fSpaces=false)155+std::string HexStr(const T itbegin, const T itend, bool fSpaces=false)156 {157 if (itbegin == itend)158 return "";159 const unsigned char* pbegin = (const unsigned char*)&itbegin[0];160 const unsigned char* pend = pbegin + (itend - itbegin) * sizeof(itbegin[0]);161- string str;162+ std::string str;163 str.reserve((pend-pbegin) * (fSpaces ? 3 : 2));164 for (const unsigned char* p = pbegin; p != pend; p++)165 str += strprintf((fSpaces && p != pend-1 ? "%02x " : "%02x"), *p);166 return str;167 }168 169-inline string HexStr(const vector<unsigned char>& vch, bool fSpaces=false)170+inline std::string HexStr(const std::vector<unsigned char>& vch, bool fSpaces=false)171 {172 return HexStr(vch.begin(), vch.end(), fSpaces);173 }174 175 template<typename T>176-string HexNumStr(const T itbegin, const T itend, bool f0x=true)177+std::string HexNumStr(const T itbegin, const T itend, bool f0x=true)178 {179 if (itbegin == itend)180 return "";181 const unsigned char* pbegin = (const unsigned char*)&itbegin[0];182 const unsigned char* pend = pbegin + (itend - itbegin) * sizeof(itbegin[0]);183- string str = (f0x ? "0x" : "");184+ std::string str = (f0x ? "0x" : "");185 str.reserve(str.size() + (pend-pbegin) * 2);186 for (const unsigned char* p = pend-1; p >= pbegin; p--)187 str += strprintf("%02x", *p);188 return str;189 }190 191-inline string HexNumStr(const vector<unsigned char>& vch, bool f0x=true)192+inline std::string HexNumStr(const std::vector<unsigned char>& vch, bool f0x=true)193 {194 return HexNumStr(vch.begin(), vch.end(), f0x);195 }196@@ -360,7 +381,7 @@197 printf(pszFormat, HexStr(pbegin, pend, fSpaces).c_str());198 }199 200-inline void PrintHex(const vector<unsigned char>& vch, const char* pszFormat="%s", bool fSpaces=true)201+inline void PrintHex(const std::vector<unsigned char>& vch, const char* pszFormat="%s", bool fSpaces=true)202 {203 printf(pszFormat, HexStr(vch, fSpaces).c_str());204 }205@@ -380,11 +401,11 @@206 207 inline int64 GetTimeMillis()208 {209- return (posix_time::ptime(posix_time::microsec_clock::universal_time()) -210- posix_time::ptime(gregorian::date(1970,1,1))).total_milliseconds();211-}212-213-inline string DateTimeStrFormat(const char* pszFormat, int64 nTime)214+ return (boost::posix_time::ptime(boost::posix_time::microsec_clock::universal_time()) -215+ boost::posix_time::ptime(boost::gregorian::date(1970,1,1))).total_milliseconds();216+}217+218+inline std::string DateTimeStrFormat(const char* pszFormat, int64 nTime)219 {220 time_t n = nTime;221 struct tm* ptmTime = gmtime(&n);222@@ -409,21 +430,21 @@223 #endif224 }225 226-inline string GetArg(const string& strArg, const string& strDefault)227+inline std::string GetArg(const std::string& strArg, const std::string& strDefault)228 {229 if (mapArgs.count(strArg))230 return mapArgs[strArg];231 return strDefault;232 }233 234-inline int64 GetArg(const string& strArg, int64 nDefault)235+inline int64 GetArg(const std::string& strArg, int64 nDefault)236 {237 if (mapArgs.count(strArg))238 return atoi64(mapArgs[strArg]);239 return nDefault;240 }241 242-inline bool GetBoolArg(const string& strArg)243+inline bool GetBoolArg(const std::string& strArg)244 {245 if (mapArgs.count(strArg))246 {247@@ -538,7 +559,7 @@248 return Hash(ss.begin(), ss.end());249 }250 251-inline uint160 Hash160(const vector<unsigned char>& vch)252+inline uint160 Hash160(const std::vector<unsigned char>& vch)253 {254 uint256 hash1;255 SHA256(&vch[0], vch.size(), (unsigned char*)&hash1);256@@ -656,3 +677,5 @@257 return false;258 }259 260+#endif261+
