diff options
-rw-r--r-- | .gitignore | 3 | ||||
-rw-r--r-- | build-msw.txt | 100 | ||||
-rw-r--r-- | build-unix.txt | 4 | ||||
-rw-r--r-- | db.cpp | 2 | ||||
-rw-r--r-- | init.cpp | 2 | ||||
-rw-r--r-- | main.cpp | 6 | ||||
-rw-r--r-- | makefile.mingw | 26 | ||||
-rw-r--r-- | makefile.unix | 31 | ||||
-rw-r--r-- | makefile.vc | 31 | ||||
-rw-r--r-- | net.cpp | 146 | ||||
-rw-r--r-- | rpc.cpp | 32 | ||||
-rw-r--r-- | serialize.h | 4 | ||||
-rw-r--r-- | setup.nsi | 11 | ||||
-rw-r--r-- | ui.cpp | 36 | ||||
-rw-r--r-- | ui.h | 1 | ||||
-rw-r--r-- | uibase.cpp | 44 | ||||
-rw-r--r-- | uiproject.fbp | 2 | ||||
-rw-r--r-- | util.cpp | 40 |
18 files changed, 230 insertions, 291 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..1990117cfd --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +*.exe +bitcoin +bitcoind diff --git a/build-msw.txt b/build-msw.txt index 3082f69414..deba805d52 100644 --- a/build-msw.txt +++ b/build-msw.txt @@ -1,4 +1,4 @@ -Copyright (c) 2009-2010 Satoshi Nakamoto +Copyright (c) 2009-2011 Bitcoin Developers Distributed under the MIT/X11 software license, see the accompanying file license.txt or http://www.opensource.org/licenses/mit-license.php. This product includes software developed by the OpenSSL Project for use in @@ -11,23 +11,25 @@ WINDOWS BUILD NOTES Compilers Supported ------------------- -MinGW GCC (recommended) -http://tdm-gcc.tdragon.net/ has an easy installer. Go back a few versions -for a little older gcc like gcc 4.4.?. +MinGW GCC http://tdm-gcc.tdragon.net/ + TDM-GCC with gcc 4.5.1 was used to build this release. +MSYS 1.0.11 was also used (sh needed to compile some dependencies) -MSVC 8.0 (2005) SP1 has been tested. Note: MSVC 7.0 and up have a habit of -linking to runtime DLLs that are not installed on XP by default. + +Candidate releases were built with MSVC 10.0 (2010), but +compiling with Visual C++ caused rendering artifacts when +bitcoin was run. Dependencies ------------ Libraries you need to download separately and build: - default path download -wxWidgets-2.9 \wxwidgets http://www.wxwidgets.org/downloads/ -OpenSSL \openssl http://www.openssl.org/source/ -Berkeley DB \db http://www.oracle.com/technology/software/products/berkeley-db/index.html -Boost \boost http://www.boost.org/users/download/ + default path download +wxWidgets \wxwidgets-2.9.1-mgw http://www.wxwidgets.org/downloads/ +OpenSSL \openssl-1.0.0c-mgw http://www.openssl.org/source/ +Berkeley DB \db-4.7.25.NC-mgw http://www.oracle.com/technology/software/products/berkeley-db/index.html +Boost \boost-1.43.0-mgw http://www.boost.org/users/download/ Their licenses: wxWidgets LGPL 2.1 with very liberal exceptions @@ -36,11 +38,10 @@ Berkeley DB New BSD license with additional requirement that linked software Boost MIT-like license Versions used in this release: -MinGW GCC 3.4.5 -wxWidgets 2.9.0 -OpenSSL 0.9.8k +wxWidgets 2.9.1 +OpenSSL 1.0.0c Berkeley DB 4.7.25.NC -Boost 1.42.1 +Boost 1.43.0 Notes @@ -49,61 +50,50 @@ The UI layout is edited with wxFormBuilder. The project file is uiproject.fbp. It generates uibase.cpp and uibase.h, which define base classes that do the rote work of constructing all the UI elements. -The release is built with GCC and then "strip bitcoin.exe" to strip the debug -symbols, which reduces the executable size by about 90%. - - wxWidgets --------- -cd \wxwidgets\build\msw -make -f makefile.gcc - or -nmake -f makefile.vc - +DOS shell: +cd \wxWidgets-2.9.1-mgw\build\msw +mingw32-make -f makefile.gcc OpenSSL ------- -If you want to exclude unused optional algorithms, a few patches are required. -(instructions for OpenSSL v0.9.8k) - -Edit engines\e_gmp.c and engines\e_capi.c and add this #ifndef around -the openssl/rsa.h include: - #ifndef OPENSSL_NO_RSA - #include <openssl/rsa.h> - #endif - -Edit ms\mingw32.bat and replace the Configure line's parameters with this -no-everything list. You have to put this in the batch file because batch -files can't take more than nine command line parameters. - perl Configure mingw threads no-rc2 no-rc4 no-rc5 no-idea no-des no-bf no-cast no-aes no-camellia no-seed no-rsa no-dh +MSYS shell: +un-tar sources with MSYS 'tar xfz' to avoid issue with symlinks (OpenSSL ticket 2377) +change 'MAKE' env. variable from 'C:\MinGW32\bin\mingw32-make.exe' to '/c/MinGW32/bin/mingw32-make.exe' -Also REM out the following line in ms\mingw32.bat after the mingw32-make -line. The build fails after it's already finished building libeay32, which -is all we care about, but the failure aborts the script before it runs -dllwrap to generate libeay32.dll. - REM if errorlevel 1 goto end - -Build - cd \openssl - ms\mingw32.bat +cd /c/openssl-1.0.0c-mgw +./config +make -If you're using MSVC, generate the .lib file - lib /machine:i386 /def:ms\libeay32.def /out:out\libeay32.lib +perl util/mkdef.pl 32 libeay enable-static-engine > libeay32.def +dllwrap --dllname libeay32.dll --output-lib libeay32.a --def libeay32.def libcrypto.a -lws2_32 -lgdi32 +after that openssl libeay is in main source dir (openssl-1.0.0c-mgw) Berkeley DB ----------- -Using MinGW and MSYS: -cd \db\build_unix +MSYS shell: +cd /c/db-4.7.25.NC-mgw/build_unix sh ../dist/configure --enable-mingw --enable-cxx make Boost ----- -download bjam.exe from -http://sourceforge.net/project/showfiles.php?group_id=7586&package_id=72941 -cd \boost +DOS prompt: +downloaded boost jam 3.1.18 +cd \boost-1.43.0-mgw bjam toolset=gcc --build-type=complete stage - or -bjam toolset=msvc --build-type=complete stage + +Note: +building with boost 1.45.0 failed because of boost ticket 4614, 4258 +builds fine with boost 1.43.0 + +Bitcoin +------- +DOS prompt: +cd \bitcoin +mingw32-make bitcoin.exe bitcoind.exe -f makefile.mingw +strip bitcoin.exe +strip bitcoind.exe diff --git a/build-unix.txt b/build-unix.txt index 25c4db2557..27a4570665 100644 --- a/build-unix.txt +++ b/build-unix.txt @@ -29,8 +29,8 @@ or Boost 1.37: sudo apt-get install libboost1.37-dev If using Boost 1.37, append -mt to the boost libraries in the makefile. -We're using wxWidgets 2.9.0, which uses UTF-8. Don't try 2.8, it won't work. -The build hasn't been updated to work with wxWidgets 2.9.1 yet. +Requires wxWidgets 2.9.0 or greater, which uses UTF-8. Don't try 2.8, it +won't work. You need to download wxWidgets from http://www.wxwidgets.org/downloads/ and build it yourself. See the build instructions and configure parameters @@ -843,7 +843,7 @@ bool LoadWallet(bool& fFirstRunRet) keyUser.MakeNewKey(); if (!AddKey(keyUser)) return false; - if (!SetAddressBookName(PubKeyToAddress(keyUser.GetPubKey()), "Your Address")) + if (!SetAddressBookName(PubKeyToAddress(keyUser.GetPubKey()), "")) return false; CWalletDB().WriteDefaultKey(keyUser.GetPubKey()); } @@ -175,7 +175,7 @@ bool AppInit2(int argc, char* argv[]) " -proxy=<ip:port> \t " + _("Connect through socks4 proxy\n") + " -addnode=<ip> \t " + _("Add a node to connect to\n") + " -connect=<ip> \t\t " + _("Connect only to the specified node\n") + - " -nolisten \t " + _("Don't accept connections from outside") + + " -nolisten \t " + _("Don't accept connections from outside\n") + " -paytxfee=<amt> \t " + _("Fee per KB to add to transactions you send\n") + " -server \t\t " + _("Accept command line and JSON-RPC commands\n") + " -daemon \t\t " + _("Run in the background as a daemon and accept commands\n") + @@ -1898,7 +1898,7 @@ bool LoadBlockIndex(bool fAllowNew) { if (fTestNet) { - hashGenesisBlock = uint256("0x0000000224b1593e3ff16a0e3b61285bbc393a39f78c8aa48c456142671f7110"); + hashGenesisBlock = uint256("0x00000007199508e34a9ff81e6ec0c477a4cccff2a4767a8eee39c11db367b008"); bnProofOfWorkLimit = CBigNum(~uint256(0) >> 28); pchMessageStart[0] = 0xfa; pchMessageStart[1] = 0xbf; @@ -1948,9 +1948,9 @@ bool LoadBlockIndex(bool fAllowNew) if (fTestNet) { - block.nTime = 1279232055; + block.nTime = 1296688602; block.nBits = 0x1d07fff8; - block.nNonce = 81622180; + block.nNonce = 384568319; } //// debug print diff --git a/makefile.mingw b/makefile.mingw index 9140c23ec5..6b849f93f6 100644 --- a/makefile.mingw +++ b/makefile.mingw @@ -4,26 +4,26 @@ INCLUDEPATHS= \ - -I"/boost" \ - -I"/db/build_unix" \ - -I"/openssl/include" \ - -I"/wxwidgets/lib/gcc_lib/mswud" \ - -I"/wxwidgets/include" + -I"C:\boost-1.43.0-mgw" \ + -I"C:\db-4.7.25.NC-mgw\build_unix" \ + -I"C:\openssl-1.0.0c-mgw\include" \ + -I"C:\wxWidgets-2.9.1-mgw\lib\gcc_lib\mswud" \ + -I"C:\wxWidgets-2.9.1-mgw\include" LIBPATHS= \ - -L"/boost/stage/lib" \ - -L"/db/build_unix" \ - -L"/openssl/out" \ - -L"/wxwidgets/lib/gcc_lib" + -L"C:\boost-1.43.0-mgw\stage\lib" \ + -L"C:\db-4.7.25.NC-mgw\build_unix" \ + -L"C:\openssl-1.0.0c-mgw" \ + -L"C:\wxWidgets-2.9.1-mgw\lib\gcc_lib" WXLIBS= \ -l wxmsw29ud_html -l wxmsw29ud_core -l wxmsw29ud_adv -l wxbase29ud -l wxtiffd -l wxjpegd -l wxpngd -l wxzlibd LIBS= \ - -l libboost_system-mgw34-mt-d \ - -l libboost_filesystem-mgw34-mt-d \ - -l libboost_program_options-mgw34-mt-d \ - -l libboost_thread-mgw34-mt-d \ + -l boost_system-mgw45-mt-s-1_43 \ + -l boost_filesystem-mgw45-mt-s-1_43 \ + -l boost_program_options-mgw45-mt-s-1_43 \ + -l boost_thread-mgw45-mt-s-1_43 \ -l db_cxx \ -l eay32 \ -l kernel32 -l user32 -l gdi32 -l comdlg32 -l winspool -l winmm -l shell32 -l comctl32 -l ole32 -l oleaut32 -l uuid -l rpcrt4 -l advapi32 -l ws2_32 -l shlwapi diff --git a/makefile.unix b/makefile.unix index 9573a560f6..d306f746d3 100644 --- a/makefile.unix +++ b/makefile.unix @@ -2,18 +2,11 @@ # Distributed under the MIT/X11 software license, see the accompanying # file license.txt or http://www.opensource.org/licenses/mit-license.php. +CXX=g++ -INCLUDEPATHS= \ - -I"/usr/local/include/wx-2.9" \ - -I"/usr/local/lib/wx/include/gtk2-unicode-debug-static-2.9" +WXINCLUDEPATHS=$(shell wx-config --cxxflags) -# for wxWidgets 2.9.1, add -l Xxf86vm -WXLIBS= \ - -Wl,-Bstatic \ - -l wx_gtk2ud-2.9 \ - -Wl,-Bdynamic \ - -l gtk-x11-2.0 \ - -l SM +WXLIBS=$(shell wx-config --libs) # for boost 1.37, add -mt to the boost libraries LIBS= \ @@ -30,9 +23,9 @@ LIBS= \ -l z \ -l dl -DEFS=-D__WXGTK__ -DNOPCH -DFOURWAYSSE2 -DUSE_SSL +DEFS=-DNOPCH -DFOURWAYSSE2 -DUSE_SSL DEBUGFLAGS=-g -D__WXDEBUG__ -CFLAGS=-O2 -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS) +CXXFLAGS=-O2 -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(DEFS) HEADERS=headers.h strlcpy.h serialize.h uint256.h util.h key.h bignum.h base58.h \ script.h db.h net.h irc.h main.h rpc.h uibase.h ui.h noui.h init.h @@ -53,23 +46,23 @@ all: bitcoin obj/%.o: %.cpp $(HEADERS) - g++ -c $(CFLAGS) -DGUI -o $@ $< + $(CXX) -c $(CXXFLAGS) $(WXINCLUDEPATHS) -DGUI -o $@ $< cryptopp/obj/%.o: cryptopp/%.cpp - g++ -c $(CFLAGS) -O3 -o $@ $< + $(CXX) -c $(CXXFLAGS) -O3 -o $@ $< obj/sha256.o: sha256.cpp - g++ -c $(CFLAGS) -msse2 -O3 -march=amdfam10 -o $@ $< + $(CXX) -c $(CXXFLAGS) -msse2 -O3 -march=amdfam10 -o $@ $< bitcoin: $(OBJS) obj/ui.o obj/uibase.o obj/sha256.o - g++ $(CFLAGS) -o $@ $^ $(WXLIBS) $(LIBS) + $(CXX) $(CXXFLAGS) -o $@ $^ $(WXLIBS) $(LIBS) obj/nogui/%.o: %.cpp $(HEADERS) - g++ -c $(CFLAGS) -o $@ $< + $(CXX) -c $(CXXFLAGS) -o $@ $< bitcoind: $(OBJS:obj/%=obj/nogui/%) obj/sha256.o - g++ $(CFLAGS) -o $@ $^ $(LIBS) + $(CXX) $(CXXFLAGS) -o $@ $^ $(LIBS) clean: @@ -77,3 +70,5 @@ clean: -rm -f obj/nogui/*.o -rm -f cryptopp/obj/*.o -rm -f headers.h.gch + -rm -f bitcoin + -rm -f bitcoind diff --git a/makefile.vc b/makefile.vc index ee65f85990..18ced0236e 100644 --- a/makefile.vc +++ b/makefile.vc @@ -7,29 +7,32 @@ INCLUDEPATHS= \ /I"/boost" \ /I"/db/build_windows" \ /I"/openssl/include" \ - /I"/wxwidgets/lib/vc_lib/mswud" \ + /I"/wxwidgets/lib/vc_lib/mswu" \ /I"/wxwidgets/include" LIBPATHS= \ /LIBPATH:"/boost/stage/lib" \ - /LIBPATH:"/db/build_windows/debug" \ - /LIBPATH:"/openssl/out" \ - /LIBPATH:"/wxwidgets/lib/vc_lib" + /LIBPATH:"/db/build_windows/Release" \ + /LIBPATH:"/openssl/lib" \ + /LIBPATH:"/wxwidgets/lib/vc_lib" \ + /NODEFAULTLIB:libc.lib /NODEFAULTLIB:libcmt.lib \ + /NODEFAULTLIB:libcd.lib /NODEFAULTLIB:libcmtd.lib \ + /NODEFAULTLIB:msvcrtd.lib -WXLIBS=wxmsw29ud_html.lib wxmsw29ud_core.lib wxmsw29ud_adv.lib wxbase29ud.lib wxtiffd.lib wxjpegd.lib wxpngd.lib wxzlibd.lib +WXLIBS=wxmsw29u.lib wxtiff.lib wxjpeg.lib wxpng.lib wxzlib.lib LIBS= \ - libboost_system-vc80-mt-gd.lib \ - libboost_filesystem-vc80-mt-gd.lib \ - libboost_program_options-vc80-mt-gd.lib \ - libboost_thread-vc80-mt-gd.lib \ - libdb47sd.lib \ + libboost_system-vc100-mt.lib \ + libboost_filesystem-vc100-mt.lib \ + libboost_program_options-vc100-mt.lib \ + libboost_thread-vc100-mt.lib \ + libdb47s.lib \ libeay32.lib \ kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib ws2_32.lib shlwapi.lib DEFS=/DWIN32 /D__WXMSW__ /D_WINDOWS /DNOPCH -DEBUGFLAGS=/Zi /D__WXDEBUG__ -CFLAGS=/c /nologo /MDd /EHsc /GR /Zm300 $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS) +DEBUGFLAGS=/Os +CFLAGS=/MD /c /nologo /EHsc /GR /Zm300 $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS) HEADERS=headers.h strlcpy.h serialize.h uint256.h util.h key.h bignum.h base58.h \ script.h db.h net.h irc.h main.h rpc.h uibase.h ui.h noui.h init.h @@ -82,7 +85,7 @@ obj\ui.res: ui.rc rc/bitcoin.ico rc/check.ico rc/send16.bmp rc/send16mask.bmp r rc $(INCLUDEPATHS) $(DEFS) /Fo$@ %s bitcoin.exe: $(OBJS) obj\ui.obj obj\uibase.obj obj\ui.res - link /nologo /DEBUG /SUBSYSTEM:WINDOWS /OUT:$@ $(LIBPATHS) $** $(WXLIBS) $(LIBS) + link /nologo /SUBSYSTEM:WINDOWS /OUT:$@ $(LIBPATHS) $** $(WXLIBS) $(LIBS) .cpp{obj\nogui}.obj: @@ -105,7 +108,7 @@ obj\nogui\rpc.obj: $(HEADERS) obj\nogui\init.obj: $(HEADERS) bitcoind.exe: $(OBJS:obj\=obj\nogui\) obj\ui.res - link /nologo /DEBUG /OUT:$@ $(LIBPATHS) $** $(LIBS) + link /nologo /OUT:$@ $(LIBPATHS) $** $(LIBS) clean: @@ -688,25 +688,18 @@ void ThreadSocketHandler2(void* parg) socklen_t len = sizeof(sockaddr); SOCKET hSocket = accept(hListenSocket, (struct sockaddr*)&sockaddr, &len); CAddress addr(sockaddr); - bool fLimitConnections = false; int nInbound = 0; - if (mapArgs.count("-maxconnections")) - fLimitConnections = true; - - if (fLimitConnections) - { - CRITICAL_BLOCK(cs_vNodes) - foreach(CNode* pnode, vNodes) - if (pnode->fInbound) - nInbound++; - } + CRITICAL_BLOCK(cs_vNodes) + foreach(CNode* pnode, vNodes) + if (pnode->fInbound) + nInbound++; if (hSocket == INVALID_SOCKET) { if (WSAGetLastError() != WSAEWOULDBLOCK) printf("socket error accept failed: %d\n", WSAGetLastError()); } - else if (fLimitConnections && nInbound >= atoi(mapArgs["-maxconnections"]) - MAX_OUTBOUND_CONNECTIONS) + else if (nInbound >= GetArg("-maxconnections", 125) - MAX_OUTBOUND_CONNECTIONS) { closesocket(hSocket); } @@ -748,32 +741,39 @@ void ThreadSocketHandler2(void* parg) CDataStream& vRecv = pnode->vRecv; unsigned int nPos = vRecv.size(); - // typical socket buffer is 8K-64K - char pchBuf[0x10000]; - int nBytes = recv(pnode->hSocket, pchBuf, sizeof(pchBuf), MSG_DONTWAIT); - if (nBytes > 0) - { - vRecv.resize(nPos + nBytes); - memcpy(&vRecv[nPos], pchBuf, nBytes); - pnode->nLastRecv = GetTime(); - } - else if (nBytes == 0) - { - // socket closed gracefully + if (nPos > 1000*GetArg("-maxreceivebuffer", 10*1000)) { if (!pnode->fDisconnect) - printf("socket closed\n"); + printf("socket recv flood control disconnect (%d bytes)\n", vRecv.size()); pnode->CloseSocketDisconnect(); } - else if (nBytes < 0) - { - // error - int nErr = WSAGetLastError(); - if (nErr != WSAEWOULDBLOCK && nErr != WSAEMSGSIZE && nErr != WSAEINTR && nErr != WSAEINPROGRESS) + else { + // typical socket buffer is 8K-64K + char pchBuf[0x10000]; + int nBytes = recv(pnode->hSocket, pchBuf, sizeof(pchBuf), MSG_DONTWAIT); + if (nBytes > 0) + { + vRecv.resize(nPos + nBytes); + memcpy(&vRecv[nPos], pchBuf, nBytes); + pnode->nLastRecv = GetTime(); + } + else if (nBytes == 0) { + // socket closed gracefully if (!pnode->fDisconnect) - printf("socket recv error %d\n", nErr); + printf("socket closed\n"); pnode->CloseSocketDisconnect(); } + else if (nBytes < 0) + { + // error + int nErr = WSAGetLastError(); + if (nErr != WSAEWOULDBLOCK && nErr != WSAEMSGSIZE && nErr != WSAEINTR && nErr != WSAEINPROGRESS) + { + if (!pnode->fDisconnect) + printf("socket recv error %d\n", nErr); + pnode->CloseSocketDisconnect(); + } + } } } } @@ -806,6 +806,11 @@ void ThreadSocketHandler2(void* parg) pnode->CloseSocketDisconnect(); } } + if (vSend.size() > 1000*GetArg("-maxsendbuffer", 10*1000)) { + if (!pnode->fDisconnect) + printf("socket send flood control disconnect (%d bytes)\n", vSend.size()); + pnode->CloseSocketDisconnect(); + } } } } @@ -858,42 +863,46 @@ void ThreadSocketHandler2(void* parg) unsigned int pnSeed[] = { - // 2010/06 - 0x35218252, 0x9c9c9618, 0xda6bacad, 0xb9aca862, 0x97c235c6, - 0x146f9562, 0xb67b9e4b, 0x87cf4bc0, 0xb83945d0, 0x984333ad, - 0xbbeec555, 0x6f0eb440, 0xe0005318, 0x7797e460, 0xddc60fcc, - 0xb3bbd24a, 0x1ac85746, 0x641846a6, 0x85ee1155, 0xbb2e7a4c, - 0x9cb8514b, 0xfc342648, 0x62958fae, 0xd0a8c87a, 0xa800795b, - 0xda8c814e, 0x256a0c80, 0x3f23ec63, 0xd565df43, 0x997d9044, - 0xaa121448, 0xbed8688e, 0x59d09a5e, 0xb2931243, 0x3730ba18, - 0xdd3462d0, 0x4e4d1448, 0x171df645, 0x84ee1155, - 0x248ac445, 0x0e634444, 0x0ded1b63, 0x30c01e60, - 0xa2b9a094, 0x29e4fd43, 0x9ce61b4c, 0xdae09744, - - // 2010/08 - 0x5ae6bf43, 0x460be257, 0x7245c0cf, 0x4e0f028d, 0x26501760, 0x38643255, 0x67094f4f, 0x480449b8, - 0x16545143, 0x1f082e5a, 0xaa428018, 0xe411e793, 0x14c1f862, 0x2726105b, 0x9b33ea50, 0xeeef86ca, - 0xe3210d44, 0x0dca8b63, 0x3f9dfb18, 0x860340ad, 0xf33ba17a, 0x9018375c, 0x1de4e353, 0x0fa52dcb, - 0x89c4555b, 0x109cf37b, 0x28c55b40, 0x04c801ae, 0x275c1e80, 0x6f7f745d, 0x7a2a5653, 0xa28e26d8, - 0xa4e65db2, 0x99a06580, 0xf253ba44, 0x82cf6ab8, 0x859c2e8e, 0xf71a815d, 0xc18f1454, 0x71c8a943, - 0x90d24e18, 0x311789b2, 0x74aba645, 0xde0bbfc3, 0xad724fad, 0xbf1ae15e, 0xbaa6fb54, 0x06e4d145, - 0x51528645, 0x72120cd4, 0xd4cfd145, 0x0a7afed8, 0x9b9a5fad, 0x9e9ff45e, 0x10128355, 0xd44e8646, - 0x04a07b47, 0x5fc9d547, 0xe0491e45, 0xbac21b41, 0x7aa31bae, 0x10483c5f, 0x94a23055, 0x73d9dc47, - 0x1a99c247, 0x822fe847, 0x7e57ba48, 0xb19ea843, 0xa60621b2, 0x778cf163, 0x125c6556, 0xf94ba44f, - 0xa61a0948, 0x6c839e4b, 0x29af5348, 0x68d84845, 0x752b95c3, 0xcf0d4663, 0x08e11e56, 0x75109550, - 0x5f24b94c, 0x42426d4d, 0xfbbc0a4c, 0x70a9a246, 0xda7837cb, 0xae2a986d, 0xe283c358, 0x0c7ca954, - 0x8e9bde59, 0x61521760, 0x6884444c, 0xa194e548, 0x9b8809cc, 0x16e96a8f, 0x956ff859, 0xfad5e555, - 0x0ea70c80, 0x5b4ce26d, 0x7984444c, 0x1080d24a, 0x22a686cf, 0x6bf8c2ad, 0xb0f7485f, 0x06b66e56, - 0x668373bc, 0x75506279, 0x3868694e, 0x12a5954b, 0x3a8b62d1, 0xb74fcbad, 0xa7dc3360, 0xc070b359, - 0xa2b87242, 0xc45cab7c, 0x69882050, 0x14a5464b, 0x386acad5, 0x80b85db2, 0x1f78a062, 0xc608c55b, - 0x4257d543, 0x7636ad80, 0x4432d655, 0xb2114d4b, 0x32639bd9, 0xadd75db2, 0x9be5a362, 0x6831bc5e, - 0xf7f77046, 0x8f35ba81, 0x09bb4e59, 0xd0fb6b4e, 0xc5daa445, 0x9c611618, 0x355dcc62, 0xf2cf435e, - 0x31e72c46, 0xdd8a43ad, 0x171f9c5b, 0xb4c2e355, 0xbe8af945, 0x613d3942, 0xe6f9e863, 0x7a3d855f, - 0xa66adc47, 0x261089b2, 0x5a27105b, 0x6c28105b, 0xdd247946, 0xe6c3a445, 0x43a1ec63, 0x99b4dd5f, - 0xb6834347, 0x5e9649bc, 0xf9dd545d, 0x6ae4c15b, 0xa5318a47, 0x7984ec47, 0x93a73b63, 0x0c60195f, - 0xa5c85e4b, 0xa0a36dc2, 0x0739a95e, 0x3d44c15b, 0xfb940f4b, 0xd67c9148, 0x614f9876, 0x0a241c5f, - 0xad9da74c, 0x4459abc8, 0x12e71b5f, 0x1c534a5d, 0x8ff5fc50, 0x2ca8864b, 0xd894fd80, 0x82ab3160, - 0x390d804e, 0x2cf310cc, 0x680dad80, 0x691be15e, 0x5a8f4652, 0xaad0784d, 0x0d2431ad, + 0x1ddb1032, 0x6242ce40, 0x52d6a445, 0x2dd7a445, 0x8a53cd47, 0x73263750, 0xda23c257, 0xecd4ed57, + 0x0a40ec59, 0x75dce160, 0x7df76791, 0x89370bad, 0xa4f214ad, 0x767700ae, 0x638b0418, 0x868a1018, + 0xcd9f332e, 0x0129653e, 0xcc92dc3e, 0x96671640, 0x56487e40, 0x5b66f440, 0xb1d01f41, 0xf1dc6041, + 0xc1d12b42, 0x86ba1243, 0x6be4df43, 0x6d4cef43, 0xd18e0644, 0x1ab0b344, 0x6584a345, 0xe7c1a445, + 0x58cea445, 0xc5daa445, 0x21dda445, 0x3d3b5346, 0x13e55347, 0x1080d24a, 0x8e611e4b, 0x81518e4b, + 0x6c839e4b, 0xe2ad0a4c, 0xfbbc0a4c, 0x7f5b6e4c, 0x7244224e, 0x1300554e, 0x20690652, 0x5a48b652, + 0x75c5c752, 0x4335cc54, 0x340fd154, 0x87c07455, 0x087b2b56, 0x8a133a57, 0xac23c257, 0x70374959, + 0xfb63d45b, 0xb9a1685c, 0x180d765c, 0x674f645d, 0x04d3495e, 0x1de44b5e, 0x4ee8a362, 0x0ded1b63, + 0xc1b04b6d, 0x8d921581, 0x97b7ea82, 0x1cf83a8e, 0x91490bad, 0x09dc75ae, 0x9a6d79ae, 0xa26d79ae, + 0x0fd08fae, 0x0f3e3fb2, 0x4f944fb2, 0xcca448b8, 0x3ecd6ab8, 0xa9d5a5bc, 0x8d0119c1, 0x045997d5, + 0xca019dd9, 0x0d526c4d, 0xabf1ba44, 0x66b1ab55, 0x1165f462, 0x3ed7cbad, 0xa38fae6e, 0x3bd2cbad, + 0xd36f0547, 0x20df7840, 0x7a337742, 0x549f8e4b, 0x9062365c, 0xd399f562, 0x2b5274a1, 0x8edfa153, + 0x3bffb347, 0x7074bf58, 0xb74fcbad, 0x5b5a795b, 0x02fa29ce, 0x5a6738d4, 0xe8a1d23e, 0xef98c445, + 0x4b0f494c, 0xa2bc1e56, 0x7694ad63, 0xa4a800c3, 0x05fda6cd, 0x9f22175e, 0x364a795b, 0x536285d5, + 0xac44c9d4, 0x0b06254d, 0x150c2fd4, 0x32a50dcc, 0xfd79ce48, 0xf15cfa53, 0x66c01e60, 0x6bc26661, + 0xc03b47ae, 0x4dda1b81, 0x3285a4c1, 0x883ca96d, 0x35d60a4c, 0xdae09744, 0x2e314d61, 0x84e247cf, + 0x6c814552, 0x3a1cc658, 0x98d8f382, 0xe584cb5b, 0x15e86057, 0x7b01504e, 0xd852dd48, 0x56382f56, + 0x0a5df454, 0xa0d18d18, 0x2e89b148, 0xa79c114c, 0xcbdcd054, 0x5523bc43, 0xa9832640, 0x8a066144, + 0x3894c3bc, 0xab76bf58, 0x6a018ac1, 0xfebf4f43, 0x2f26c658, 0x31102f4e, 0x85e929d5, 0x2a1c175e, + 0xfc6c2cd1, 0x27b04b6d, 0xdf024650, 0x161748b8, 0x28be6580, 0x57be6580, 0x1cee677a, 0xaa6bb742, + 0x9a53964b, 0x0a5a2d4d, 0x2434c658, 0x9a494f57, 0x1ebb0e48, 0xf610b85d, 0x077ecf44, 0x085128bc, + 0x5ba17a18, 0x27ca1b42, 0xf8a00b56, 0xfcd4c257, 0xcf2fc15e, 0xd897e052, 0x4cada04f, 0x2f35f6d5, + 0x382ce8c9, 0xe523984b, 0x3f946846, 0x60c8be43, 0x41da6257, 0xde0be142, 0xae8a544b, 0xeff0c254, + 0x1e0f795b, 0xaeb28890, 0xca16acd9, 0x1e47ddd8, 0x8c8c4829, 0xd27dc747, 0xd53b1663, 0x4096b163, + 0x9c8dd958, 0xcb12f860, 0x9e79305c, 0x40c1a445, 0x4a90c2bc, 0x2c3a464d, 0x2727f23c, 0x30b04b6d, + 0x59024cb8, 0xa091e6ad, 0x31b04b6d, 0xc29d46a6, 0x63934fb2, 0xd9224dbe, 0x9f5910d8, 0x7f530a6b, + 0x752e9c95, 0x65453548, 0xa484be46, 0xce5a1b59, 0x710e0718, 0x46a13d18, 0xdaaf5318, 0xc4a8ff53, + 0x87abaa52, 0xb764cf51, 0xb2025d4a, 0x6d351e41, 0xc035c33e, 0xa432c162, 0x61ef34ae, 0xd16fddbc, + 0x0870e8c1, 0x3070e8c1, 0x9c71e8c1, 0xa4992363, 0x85a1f663, 0x4184e559, 0x18d96ed8, 0x17b8dbd5, + 0x60e7cd18, 0xe5ee104c, 0xab17ac62, 0x1e786e1b, 0x5d23b762, 0xf2388fae, 0x88270360, 0x9e5b3d80, + 0x7da518b2, 0xb5613b45, 0x1ad41f3e, 0xd550854a, 0x8617e9a9, 0x925b229c, 0xf2e92542, 0x47af0544, + 0x73b5a843, 0xb9b7a0ad, 0x03a748d0, 0x0a6ff862, 0x6694df62, 0x3bfac948, 0x8e098f4f, 0x746916c3, + 0x02f38e4f, 0x40bb1243, 0x6a54d162, 0x6008414b, 0xa513794c, 0x514aa343, 0x63781747, 0xdbb6795b, + 0xed065058, 0x42d24b46, 0x1518794c, 0x9b271681, 0x73e4ffad, 0x0654784f, 0x438dc945, 0x641846a6, + 0x2d1b0944, 0x94b59148, 0x8d369558, 0xa5a97662, 0x8b705b42, 0xce9204ae, 0x8d584450, 0x2df61555, + 0xeebff943, 0x2e75fb4d, 0x3ef8fc57, 0x9921135e, 0x8e31042e, 0xb5afad43, 0x89ecedd1, 0x9cfcc047, + 0x8fcd0f4c, 0xbe49f5ad, 0x146a8d45, 0x98669ab8, 0x98d9175e, 0xd1a8e46d, 0x839a3ab8, 0x40a0016c, + 0x6d27c257, 0x977fffad, 0x7baa5d5d, 0x1213be43, 0xb167e5a9, 0x640fe8ca, 0xbc9ea655, 0x0f820a4c, + 0x0f097059, 0x69ac957c, 0x366d8453, 0xb1ba2844, 0x8857f081, 0x70b5be63, 0xc545454b, 0xaf36ded1, + 0xb5a4b052, 0x21f062d1, 0x72ab89b2, 0x74a45318, 0x8312e6bc, 0xb916965f, 0x8aa7c858, 0xfe7effad, }; @@ -972,8 +981,7 @@ void ThreadOpenConnections2(void* parg) if (!pnode->fInbound) nOutbound++; int nMaxOutboundConnections = MAX_OUTBOUND_CONNECTIONS; - if (mapArgs.count("-maxconnections")) - nMaxOutboundConnections = min(nMaxOutboundConnections, atoi(mapArgs["-maxconnections"])); + nMaxOutboundConnections = min(nMaxOutboundConnections, (int)GetArg("-maxconnections", 125)); if (nOutbound < nMaxOutboundConnections) break; Sleep(2000); @@ -65,7 +65,7 @@ int64 AmountFromValue(const Value& value) double dAmount = value.get_real(); if (dAmount <= 0.0 || dAmount > 21000000.0) throw JSONRPCError(-3, "Invalid amount"); - int64 nAmount = roundint64(dAmount * 100.00) * CENT; + int64 nAmount = roundint64(dAmount * COIN); if (!MoneyRange(nAmount)) throw JSONRPCError(-3, "Invalid amount"); return nAmount; @@ -277,7 +277,7 @@ Value getinfo(const Array& params, bool fHelp) Object obj; obj.push_back(Pair("version", (int)VERSION)); - obj.push_back(Pair("balance", (double)GetBalance() / (double)COIN)); + obj.push_back(Pair("balance", ValueFromAmount(GetBalance()))); obj.push_back(Pair("blocks", (int)nBestHeight)); obj.push_back(Pair("connections", (int)vNodes.size())); obj.push_back(Pair("proxy", (fUseProxy ? addrProxy.ToStringIPPort() : string()))); @@ -287,7 +287,7 @@ Value getinfo(const Array& params, bool fHelp) obj.push_back(Pair("hashespersec", gethashespersec(params, false))); obj.push_back(Pair("testnet", fTestNet)); obj.push_back(Pair("keypoololdest", (boost::int64_t)GetOldestKeyPoolTime())); - obj.push_back(Pair("paytxfee", (double)nTransactionFee / (double)COIN)); + obj.push_back(Pair("paytxfee", ValueFromAmount(nTransactionFee))); obj.push_back(Pair("errors", GetWarnings("statusbar"))); return obj; } @@ -381,6 +381,12 @@ Value setaccount(const Array& params, bool fHelp) "Sets the account associated with the given address."); string strAddress = params[0].get_str(); + uint160 hash160; + bool isValid = AddressToHash160(strAddress, hash160); + if (!isValid) + throw JSONRPCError(-5, "Invalid bitcoin address"); + + string strAccount; if (params.size() > 1) strAccount = AccountFromValue(params[1]); @@ -513,7 +519,7 @@ Value getreceivedbyaddress(const Array& params, bool fHelp) } } - return (double)nAmount / (double)COIN; + return ValueFromAmount(nAmount); } @@ -619,7 +625,7 @@ Value getbalance(const Array& params, bool fHelp) "If [account] is specified, returns the balance in the account."); if (params.size() == 0) - return ((double)GetBalance() / (double)COIN); + return ValueFromAmount(GetBalance()); if (params[0].get_str() == "*") { // Calculate total balance a different way from GetBalance() @@ -648,7 +654,7 @@ Value getbalance(const Array& params, bool fHelp) nBalance += allGenerated; } printf("Found %d accounts\n", vAccounts.size()); - return (double)nBalance / (double)COIN; + return ValueFromAmount(nBalance); } string strAccount = AccountFromValue(params[0]); @@ -658,7 +664,7 @@ Value getbalance(const Array& params, bool fHelp) int64 nBalance = GetAccountBalance(strAccount, nMinDepth); - return (double)nBalance / (double)COIN; + return ValueFromAmount(nBalance); } @@ -851,7 +857,7 @@ Value ListReceived(const Array& params, bool fByAccounts) obj.push_back(Pair("address", strAddress)); obj.push_back(Pair("account", strAccount)); obj.push_back(Pair("label", strAccount)); // deprecated - obj.push_back(Pair("amount", (double)nAmount / (double)COIN)); + obj.push_back(Pair("amount", ValueFromAmount(nAmount))); obj.push_back(Pair("confirmations", (nConf == INT_MAX ? 0 : nConf))); ret.push_back(obj); } @@ -867,7 +873,7 @@ Value ListReceived(const Array& params, bool fByAccounts) Object obj; obj.push_back(Pair("account", (*it).first)); obj.push_back(Pair("label", (*it).first)); // deprecated - obj.push_back(Pair("amount", (double)nAmount / (double)COIN)); + obj.push_back(Pair("amount", ValueFromAmount(nAmount))); obj.push_back(Pair("confirmations", (nConf == INT_MAX ? 0 : nConf))); ret.push_back(obj); } @@ -1015,13 +1021,13 @@ Value listtransactions(const Array& params, bool fHelp) for (map<uint256, CWalletTx>::iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) { CWalletTx* wtx = &((*it).second); - txByTime.insert(make_pair(wtx->GetTxTime(), TxPair(wtx, 0))); + txByTime.insert(make_pair(wtx->GetTxTime(), TxPair(wtx, (CAccountingEntry*)0))); } list<CAccountingEntry> acentries; walletdb.ListAccountCreditDebit(strAccount, acentries); foreach(CAccountingEntry& entry, acentries) { - txByTime.insert(make_pair(entry.nTime, TxPair(0, &entry))); + txByTime.insert(make_pair(entry.nTime, TxPair((CWalletTx*)0, &entry))); } // Now: iterate backwards until we have nCount items to return: @@ -1710,6 +1716,8 @@ void ThreadRPCServer2(void* parg) ip::tcp::endpoint endpoint(bindAddress, GetArg("-rpcport", 8332)); ip::tcp::acceptor acceptor(io_service, endpoint); + acceptor.set_option(boost::asio::ip::tcp::acceptor::reuse_address(true)); + #ifdef USE_SSL ssl::context context(io_service, ssl::context::sslv23); if (fUseSSL) @@ -1762,7 +1770,7 @@ void ThreadRPCServer2(void* parg) map<string, string> mapHeaders; string strRequest; - boost::thread api_caller(ReadHTTP, ref(stream), ref(mapHeaders), ref(strRequest)); + boost::thread api_caller(ReadHTTP, boost::ref(stream), boost::ref(mapHeaders), boost::ref(strRequest)); if (!api_caller.timed_join(boost::posix_time::seconds(GetArg("-rpctimeout", 30)))) { // Timed out: acceptor.cancel(); diff --git a/serialize.h b/serialize.h index 45dec955dd..383c987864 100644 --- a/serialize.h +++ b/serialize.h @@ -25,7 +25,7 @@ class CDataStream; class CAutoFile; static const unsigned int MAX_SIZE = 0x02000000; -static const int VERSION = 32000; +static const int VERSION = 32100; static const char* pszSubVer = ""; static const bool VERSION_IS_BETA = true; @@ -763,6 +763,8 @@ struct secure_allocator : public std::allocator<T> typedef typename base::value_type value_type; secure_allocator() throw() {} secure_allocator(const secure_allocator& a) throw() : base(a) {} + template <typename U> + secure_allocator(const secure_allocator<U>& a) throw() : base(a) {} ~secure_allocator() throw() {} template<typename _Other> struct rebind { typedef secure_allocator<_Other> other; }; @@ -1,13 +1,10 @@ -# Auto-generated by EclipseNSIS Script Wizard
-# 3.10.2009 19:00:28
-
Name Bitcoin
RequestExecutionLevel highest
# General Symbol Definitions
!define REGKEY "SOFTWARE\$(^Name)"
-!define VERSION 0.3.19
+!define VERSION 0.3.20
!define COMPANY "Bitcoin project"
!define URL http://www.bitcoin.org/
@@ -42,12 +39,12 @@ Var StartMenuGroup !insertmacro MUI_LANGUAGE English
# Installer attributes
-OutFile bitcoin-0.3.19-win32-setup.exe
+OutFile bitcoin-0.3.20-win32-setup.exe
InstallDir $PROGRAMFILES\Bitcoin
CRCCheck on
XPStyle on
ShowInstDetails show
-VIProductVersion 0.3.19.0
+VIProductVersion 0.3.20.0
VIAddVersionKey ProductName Bitcoin
VIAddVersionKey ProductVersion "${VERSION}"
VIAddVersionKey CompanyName "${COMPANY}"
@@ -64,7 +61,6 @@ Section -Main SEC0000 SetOverwrite on
File bitcoin.exe
File libeay32.dll
- File mingwm10.dll
File license.txt
File readme.txt
SetOutPath $INSTDIR\daemon
@@ -113,7 +109,6 @@ done${UNSECTION_ID}: Section /o -un.Main UNSEC0000
Delete /REBOOTOK $INSTDIR\bitcoin.exe
Delete /REBOOTOK $INSTDIR\libeay32.dll
- Delete /REBOOTOK $INSTDIR\mingwm10.dll
Delete /REBOOTOK $INSTDIR\license.txt
Delete /REBOOTOK $INSTDIR\readme.txt
RMDir /r /REBOOTOK $INSTDIR\daemon
@@ -1854,7 +1854,7 @@ CSendDialog::CSendDialog(wxWindow* parent, const wxString& strAddress) : CSendDi if (fontTmp.GetPointSize() > 9); fontTmp.SetPointSize(9); m_staticTextInstructions->SetFont(fontTmp); - SetSize(725, 380); + SetSize(725, 180); #endif // Set Icon @@ -1862,44 +1862,12 @@ CSendDialog::CSendDialog(wxWindow* parent, const wxString& strAddress) : CSendDi iconSend.CopyFromBitmap(wxBitmap(send16noshadow_xpm)); SetIcon(iconSend); - wxCommandEvent event; - OnTextAddress(event); - // Fixup the tab order m_buttonPaste->MoveAfterInTabOrder(m_buttonCancel); m_buttonAddress->MoveAfterInTabOrder(m_buttonPaste); this->Layout(); } -void CSendDialog::OnTextAddress(wxCommandEvent& event) -{ - // Check mark - event.Skip(); - bool fBitcoinAddress = IsValidBitcoinAddress(m_textCtrlAddress->GetValue()); - m_bitmapCheckMark->Show(fBitcoinAddress); - - // Grey out message if bitcoin address - bool fEnable = !fBitcoinAddress; - m_staticTextFrom->Enable(fEnable); - m_textCtrlFrom->Enable(fEnable); - m_staticTextMessage->Enable(fEnable); - m_textCtrlMessage->Enable(fEnable); - m_textCtrlMessage->SetBackgroundColour(wxSystemSettings::GetColour(fEnable ? wxSYS_COLOUR_WINDOW : wxSYS_COLOUR_BTNFACE)); - if (!fEnable && fEnabledPrev) - { - strFromSave = m_textCtrlFrom->GetValue(); - strMessageSave = m_textCtrlMessage->GetValue(); - m_textCtrlFrom->SetValue(_("n/a")); - m_textCtrlMessage->SetValue(_("Can't include a message when sending to a Bitcoin address")); - } - else if (fEnable && !fEnabledPrev) - { - m_textCtrlFrom->SetValue(strFromSave); - m_textCtrlMessage->SetValue(strMessageSave); - } - fEnabledPrev = fEnable; -} - void CSendDialog::OnKillFocusAmount(wxFocusEvent& event) { // Reformat the amount @@ -1993,8 +1961,6 @@ void CSendDialog::OnButtonSend(wxCommandEvent& event) // Message wtx.mapValue["to"] = strAddress; - wtx.mapValue["from"] = m_textCtrlFrom->GetValue(); - wtx.mapValue["message"] = m_textCtrlMessage->GetValue(); // Send to IP address CSendingDialog* pdialog = new CSendingDialog(this, addr, nValue, wtx); @@ -166,7 +166,6 @@ class CSendDialog : public CSendDialogBase protected: // Event handlers void OnKeyDown(wxKeyEvent& event) { HandleCtrlA(event); } - void OnTextAddress(wxCommandEvent& event); void OnKillFocusAmount(wxFocusEvent& event); void OnButtonAddressBook(wxCommandEvent& event); void OnButtonPaste(wxCommandEvent& event); diff --git a/uibase.cpp b/uibase.cpp index a421e776e3..d806230dee 100644 --- a/uibase.cpp +++ b/uibase.cpp @@ -550,7 +550,7 @@ CAboutDialogBase::CAboutDialogBase( wxWindow* parent, wxWindowID id, const wxStr bSizer631->Add( 0, 4, 0, wxEXPAND, 5 ); - m_staticTextMain = new wxStaticText( this, wxID_ANY, _("Copyright (c) 2009-2010 Bitcoin Developers\n\nThis is experimental software.\n\nDistributed under the MIT/X11 software license, see the accompanying file \nlicense.txt or http://www.opensource.org/licenses/mit-license.php.\n\nThis product includes software developed by the OpenSSL Project for use in the \nOpenSSL Toolkit (http://www.openssl.org/) and cryptographic software written by \nEric Young (eay@cryptsoft.com)."), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticTextMain = new wxStaticText( this, wxID_ANY, _("Copyright (c) 2009-2011 Bitcoin Developers\n\nThis is experimental software.\n\nDistributed under the MIT/X11 software license, see the accompanying file \nlicense.txt or http://www.opensource.org/licenses/mit-license.php.\n\nThis product includes software developed by the OpenSSL Project for use in the \nOpenSSL Toolkit (http://www.openssl.org/) and cryptographic software written by \nEric Young (eay@cryptsoft.com)."), wxDefaultPosition, wxDefaultSize, 0 ); m_staticTextMain->Wrap( -1 ); bSizer631->Add( m_staticTextMain, 0, wxALL, 5 ); @@ -606,7 +606,7 @@ CSendDialogBase::CSendDialogBase( wxWindow* parent, wxWindowID id, const wxStrin fgSizer1->Add( 0, 0, 0, wxEXPAND, 5 ); - m_staticTextInstructions = new wxStaticText( this, wxID_ANY, _("Enter a Bitcoin address (e.g. 1NS17iag9jJgTHD1VXjvLCEnZuQ3rJED9L) or IP address (e.g. 123.45.6.7)"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticTextInstructions = new wxStaticText( this, wxID_ANY, _("Enter a Bitcoin address (e.g. 1NS17iag9jJgTHD1VXjvLCEnZuQ3rJDE9L)"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticTextInstructions->Wrap( -1 ); fgSizer1->Add( m_staticTextInstructions, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); @@ -677,40 +677,6 @@ CSendDialogBase::CSendDialogBase( wxWindow* parent, wxWindowID id, const wxStrin bSizer21->Add( fgSizer1, 0, wxEXPAND|wxLEFT, 5 ); - wxBoxSizer* bSizer672; - bSizer672 = new wxBoxSizer( wxHORIZONTAL ); - - wxBoxSizer* bSizer681; - bSizer681 = new wxBoxSizer( wxVERTICAL ); - - m_staticTextFrom = new wxStaticText( this, wxID_ANY, _("&From:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticTextFrom->Wrap( -1 ); - bSizer681->Add( m_staticTextFrom, 0, wxBOTTOM|wxLEFT, 5 ); - - m_textCtrlFrom = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1,-1 ), 0 ); - bSizer681->Add( m_textCtrlFrom, 0, wxLEFT|wxEXPAND, 5 ); - - bSizer672->Add( bSizer681, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - - bSizer21->Add( bSizer672, 0, wxEXPAND, 5 ); - - wxBoxSizer* bSizer67; - bSizer67 = new wxBoxSizer( wxHORIZONTAL ); - - wxBoxSizer* bSizer68; - bSizer68 = new wxBoxSizer( wxVERTICAL ); - - m_staticTextMessage = new wxStaticText( this, wxID_ANY, _("&Message:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticTextMessage->Wrap( -1 ); - bSizer68->Add( m_staticTextMessage, 0, wxTOP|wxBOTTOM|wxLEFT, 5 ); - - m_textCtrlMessage = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE ); - bSizer68->Add( m_textCtrlMessage, 1, wxEXPAND|wxLEFT, 5 ); - - bSizer67->Add( bSizer68, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - - bSizer21->Add( bSizer67, 1, wxEXPAND, 5 ); - wxBoxSizer* bSizer23; bSizer23 = new wxBoxSizer( wxHORIZONTAL ); @@ -732,13 +698,10 @@ CSendDialogBase::CSendDialogBase( wxWindow* parent, wxWindowID id, const wxStrin // Connect Events m_textCtrlAddress->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CSendDialogBase::OnKeyDown ), NULL, this ); - m_textCtrlAddress->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( CSendDialogBase::OnTextAddress ), NULL, this ); m_buttonPaste->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CSendDialogBase::OnButtonPaste ), NULL, this ); m_buttonAddress->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CSendDialogBase::OnButtonAddressBook ), NULL, this ); m_textCtrlAmount->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CSendDialogBase::OnKeyDown ), NULL, this ); m_textCtrlAmount->Connect( wxEVT_KILL_FOCUS, wxFocusEventHandler( CSendDialogBase::OnKillFocusAmount ), NULL, this ); - m_textCtrlFrom->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CSendDialogBase::OnKeyDown ), NULL, this ); - m_textCtrlMessage->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CSendDialogBase::OnKeyDown ), NULL, this ); m_buttonSend->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CSendDialogBase::OnButtonSend ), NULL, this ); m_buttonCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CSendDialogBase::OnButtonCancel ), NULL, this ); } @@ -747,13 +710,10 @@ CSendDialogBase::~CSendDialogBase() { // Disconnect Events m_textCtrlAddress->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CSendDialogBase::OnKeyDown ), NULL, this ); - m_textCtrlAddress->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( CSendDialogBase::OnTextAddress ), NULL, this ); m_buttonPaste->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CSendDialogBase::OnButtonPaste ), NULL, this ); m_buttonAddress->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CSendDialogBase::OnButtonAddressBook ), NULL, this ); m_textCtrlAmount->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CSendDialogBase::OnKeyDown ), NULL, this ); m_textCtrlAmount->Disconnect( wxEVT_KILL_FOCUS, wxFocusEventHandler( CSendDialogBase::OnKillFocusAmount ), NULL, this ); - m_textCtrlFrom->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CSendDialogBase::OnKeyDown ), NULL, this ); - m_textCtrlMessage->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CSendDialogBase::OnKeyDown ), NULL, this ); m_buttonSend->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CSendDialogBase::OnButtonSend ), NULL, this ); m_buttonCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CSendDialogBase::OnButtonCancel ), NULL, this ); } diff --git a/uiproject.fbp b/uiproject.fbp index bf01732ea8..f9f653184b 100644 --- a/uiproject.fbp +++ b/uiproject.fbp @@ -3140,7 +3140,7 @@ <property name="font"></property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
- <property name="label">Copyright (c) 2009-2010 Bitcoin Developers

This is experimental software.

Distributed under the MIT/X11 software license, see the accompanying file 
license.txt or http://www.opensource.org/licenses/mit-license.php.

This product includes software developed by the OpenSSL Project for use in the 
OpenSSL Toolkit (http://www.openssl.org/) and cryptographic software written by 
Eric Young (eay@cryptsoft.com).</property>
+ <property name="label">Copyright (c) 2009-2011 Bitcoin Developers

This is experimental software.

Distributed under the MIT/X11 software license, see the accompanying file 
license.txt or http://www.opensource.org/licenses/mit-license.php.

This product includes software developed by the OpenSSL Project for use in the 
OpenSSL Toolkit (http://www.openssl.org/) and cryptographic software written by 
Eric Young (eay@cryptsoft.com).</property>
<property name="maximum_size"></property>
<property name="minimum_size"></property>
<property name="name">m_staticTextMain</property>
@@ -313,9 +313,23 @@ void ParseString(const string& str, char c, vector<string>& v) string FormatMoney(int64 n, bool fPlus) { - n /= CENT; - string str = strprintf("%"PRI64d".%02"PRI64d, (n > 0 ? n : -n)/100, (n > 0 ? n : -n)%100); - for (int i = 6; i < str.size(); i += 4) + // Note: not using straight sprintf here because we do NOT want + // localized number formatting. + int64 n_abs = (n > 0 ? n : -n); + int64 quotient = n_abs/COIN; + int64 remainder = n_abs%COIN; + string str = strprintf("%"PRI64d".%08"PRI64d, quotient, remainder); + + // Right-trim excess 0's before the decimal point: + int nTrim = 0; + for (int i = str.size()-1; (str[i] == '0' && isdigit(str[i-2])); --i) + ++nTrim; + if (nTrim) + str.erase(str.size()-nTrim, nTrim); + + // Insert thousands-separators: + size_t point = str.find("."); + for (int i = (str.size()-point)+3; i < str.size(); i += 4) if (isdigit(str[str.size() - i - 1])) str.insert(str.size() - i, 1, ','); if (n < 0) @@ -334,7 +348,7 @@ bool ParseMoney(const string& str, int64& nRet) bool ParseMoney(const char* pszIn, int64& nRet) { string strWhole; - int64 nCents = 0; + int64 nUnits = 0; const char* p = pszIn; while (isspace(*p)) p++; @@ -345,11 +359,11 @@ bool ParseMoney(const char* pszIn, int64& nRet) if (*p == '.') { p++; - if (isdigit(*p)) + int64 nMult = CENT*10; + while (isdigit(*p) && (nMult > 0)) { - nCents = 10 * (*p++ - '0'); - if (isdigit(*p)) - nCents += (*p++ - '0'); + nUnits += nMult * (*p++ - '0'); + nMult /= 10; } break; } @@ -364,15 +378,11 @@ bool ParseMoney(const char* pszIn, int64& nRet) return false; if (strWhole.size() > 14) return false; - if (nCents < 0 || nCents > 99) + if (nUnits < 0 || nUnits > COIN) return false; int64 nWhole = atoi64(strWhole); - int64 nPreValue = nWhole * 100 + nCents; - int64 nValue = nPreValue * CENT; - if (nValue / CENT != nPreValue) - return false; - if (nValue / COIN != nWhole) - return false; + int64 nValue = nWhole*COIN + nUnits; + nRet = nValue; return true; } |