What changed
Bitcoin r202 → v0.3.20
Release commit message: Changed setup for mingw toolchain
Full source: r202. Previous diff: v0.3.19 → r202. Next: v0.3.20 → v0.3.21.
- build-msw.txt modified · +45 −55
- build-unix.txt modified · +8 −0
- db.cpp modified · +10 −8
- db.h modified · +1 −1
- init.cpp modified · +29 −11
- irc.cpp modified · +3 −1
- main.cpp modified · +171 −19
- main.h modified · +9 −30
- makefile.mingw modified · +13 −13
- makefile.vc modified · +17 −14
- net.cpp modified · +85 −62
- rpc.cpp modified · +299 −124
- serialize.h modified · +4 −1
- setup.nsi modified · +3 −8
- ui.cpp modified · +12 −5
- uibase.cpp modified · +0 −1
- util.cpp modified · +18 −13
- util.h modified · +1 −0
build-msw.txt (modified)
1--- r202/build-msw.txt2+++ v0.3.20/build-msw.txt3@@ -1,4 +1,4 @@4-Copyright (c) 2009-2010 Satoshi Nakamoto5+Copyright (c) 2009-2011 Bitcoin Developers6 Distributed under the MIT/X11 software license, see the accompanying7 file license.txt or http://www.opensource.org/licenses/mit-license.php.8 This product includes software developed by the OpenSSL Project for use in9@@ -11,23 +11,25 @@10 11 Compilers Supported12 -------------------13-MinGW GCC (recommended)14-http://tdm-gcc.tdragon.net/ has an easy installer. Go back a few versions15-for a little older gcc like gcc 4.4.?.16+MinGW GCC http://tdm-gcc.tdragon.net/17+ TDM-GCC with gcc 4.5.1 was used to build this release.18+MSYS 1.0.11 was also used (sh needed to compile some dependencies)19 20-MSVC 8.0 (2005) SP1 has been tested. Note: MSVC 7.0 and up have a habit of21-linking to runtime DLLs that are not installed on XP by default.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-2.9 \wxwidgets http://www.wxwidgets.org/downloads/34-OpenSSL \openssl http://www.openssl.org/source/35-Berkeley DB \db http://www.oracle.com/technology/software/products/berkeley-db/index.html36-Boost \boost http://www.boost.org/users/download/37+ default path download38+wxWidgets \wxwidgets-2.9.1-mgw http://www.wxwidgets.org/downloads/39+OpenSSL \openssl-1.0.0c-mgw http://www.openssl.org/source/40+Berkeley DB \db-4.7.25.NC-mgw http://www.oracle.com/technology/software/products/berkeley-db/index.html41+Boost \boost-1.43.0-mgw http://www.boost.org/users/download/42 43 Their licenses:44 wxWidgets LGPL 2.1 with very liberal exceptions45@@ -36,11 +38,10 @@46 Boost MIT-like license47 48 Versions used in this release:49-MinGW GCC 3.4.550-wxWidgets 2.9.051-OpenSSL 0.9.8k52+wxWidgets 2.9.153+OpenSSL 1.0.0c54 Berkeley DB 4.7.25.NC55-Boost 1.42.156+Boost 1.43.057 58 59 Notes60@@ -49,62 +50,51 @@61 uiproject.fbp. It generates uibase.cpp and uibase.h, which define base62 classes that do the rote work of constructing all the UI elements.63 64-The release is built with GCC and then "strip bitcoin.exe" to strip the debug65-symbols, which reduces the executable size by about 90%.66-67-68 wxWidgets69 ---------70-cd \wxwidgets\build\msw71-make -f makefile.gcc72- or73-nmake -f makefile.vc74-75+DOS shell:76+cd \wxWidgets-2.9.1-mgw\build\msw77+mingw32-make -f makefile.gcc78 79 OpenSSL80 -------81-If you want to exclude unused optional algorithms, a few patches are required.82-(instructions for OpenSSL v0.9.8k)83+MSYS shell:84+un-tar sources with MSYS 'tar xfz' to avoid issue with symlinks (OpenSSL ticket 2377)85+change 'MAKE' env. variable from 'C:\MinGW32\bin\mingw32-make.exe' to '/c/MinGW32/bin/mingw32-make.exe'86 87-Edit engines\e_gmp.c and engines\e_capi.c and add this #ifndef around88-the openssl/rsa.h include:89- #ifndef OPENSSL_NO_RSA90- #include <openssl/rsa.h>91- #endif92+cd /c/openssl-1.0.0c-mgw93+./config94+make95 96-Edit ms\mingw32.bat and replace the Configure line's parameters with this97-no-everything list. You have to put this in the batch file because batch98-files can't take more than nine command line parameters.99- 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-dh100+perl util/mkdef.pl 32 libeay enable-static-engine > libeay32.def101+dllwrap --dllname libeay32.dll --output-lib libeay32.a --def libeay32.def libcrypto.a -lws2_32 -lgdi32102 103-Also REM out the following line in ms\mingw32.bat after the mingw32-make104-line. The build fails after it's already finished building libeay32, which105-is all we care about, but the failure aborts the script before it runs106-dllwrap to generate libeay32.dll.107- REM if errorlevel 1 goto end108-109-Build110- cd \openssl111- ms\mingw32.bat112-113-If you're using MSVC, generate the .lib file114- lib /machine:i386 /def:ms\libeay32.def /out:out\libeay32.lib115-116+after that openssl libeay is in main source dir (openssl-1.0.0c-mgw)117 118 Berkeley DB119 -----------120-Using MinGW and MSYS:121-cd \db\build_unix122+MSYS shell:123+cd /c/db-4.7.25.NC-mgw/build_unix124 sh ../dist/configure --enable-mingw --enable-cxx125 make126 127 128 Boost129 -----130-download bjam.exe from131-http://sourceforge.net/project/showfiles.php?group_id=7586&package_id=72941132-cd \boost133+DOS prompt:134+downloaded boost jam 3.1.18135+cd \boost-1.43.0-mgw136 bjam toolset=gcc --build-type=complete stage137- or138-bjam toolset=msvc --build-type=complete stage139 140+Note:141+building with boost 1.45.0 failed because of boost ticket 4614, 4258142+builds fine with boost 1.43.0143+144+Bitcoin145+-------146+DOS prompt:147+cd \bitcoin148+mingw32-make bitcoin.exe bitcoind.exe -f makefile.mingw149+strip bitcoin.exe150+strip bitcoind.exe151+
build-unix.txt (modified)
1--- r202/build-unix.txt2+++ v0.3.20/build-unix.txt3@@ -8,6 +8,14 @@4 5 UNIX BUILD NOTES6 ================7+8+To Build9+--------10+11+make -f makefile.unix # Bitcoin with wxWidgets GUI12+ or13+make -f makefile.unix bitcoind # Headless bitcoin14+15 16 Dependencies17 ------------
db.cpp (modified)
1--- r202/db.cpp2+++ v0.3.20/db.cpp3@@ -592,9 +592,9 @@4 return Write(make_pair(string("acc"), strAccount), account);5 }6 7-bool CWalletDB::WriteAccountingEntry(const string& strAccount, const CAccountingEntry& acentry)8-{9- return Write(make_tuple(string("acentry"), strAccount, ++nAccountingEntryNumber), acentry);10+bool CWalletDB::WriteAccountingEntry(const CAccountingEntry& acentry)11+{12+ return Write(make_tuple(string("acentry"), acentry.strAccount, ++nAccountingEntryNumber), acentry);13 }14 15 int64 CWalletDB::GetAccountCreditDebit(const string& strAccount)16@@ -612,6 +612,8 @@17 void CWalletDB::ListAccountCreditDebit(const string& strAccount, list<CAccountingEntry>& entries)18 {19 int64 nCreditDebit = 0;20+21+ bool fAllAccounts = (strAccount == "*");22 23 Dbc* pcursor = GetCursor();24 if (!pcursor)25@@ -622,7 +624,7 @@26 // Read next record27 CDataStream ssKey;28 if (fFlags == DB_SET_RANGE)29- ssKey << make_tuple(string("acentry"), strAccount, uint64(0));30+ ssKey << make_tuple(string("acentry"), (fAllAccounts? string("") : strAccount), uint64(0));31 CDataStream ssValue;32 int ret = ReadAtCursor(pcursor, ssKey, ssValue, fFlags);33 fFlags = DB_NEXT;34@@ -639,18 +641,18 @@35 ssKey >> strType;36 if (strType != "acentry")37 break;38- string strAccountName;39- ssKey >> strAccountName;40- if (strAccountName != strAccount)41+ CAccountingEntry acentry;42+ ssKey >> acentry.strAccount;43+ if (!fAllAccounts && acentry.strAccount != strAccount)44 break;45 46- CAccountingEntry acentry;47 ssValue >> acentry;48 entries.push_back(acentry);49 }50 51 pcursor->close();52 }53+54 55 bool CWalletDB::LoadWallet()56 {
db.h (modified)
1--- r202/db.h2+++ v0.3.20/db.h3@@ -433,7 +433,7 @@4 5 bool ReadAccount(const string& strAccount, CAccount& account);6 bool WriteAccount(const string& strAccount, const CAccount& account);7- bool WriteAccountingEntry(const string& strAccount, const CAccountingEntry& acentry);8+ bool WriteAccountingEntry(const CAccountingEntry& acentry);9 int64 GetAccountCreditDebit(const string& strAccount);10 void ListAccountCreditDebit(const string& strAccount, list<CAccountingEntry>& acentries);11
init.cpp (modified)
1--- r202/init.cpp2+++ v0.3.20/init.cpp3@@ -158,7 +158,9 @@4 5 if (mapArgs.count("-?") || mapArgs.count("--help"))6 {7+ string beta = VERSION_IS_BETA ? _(" beta") : "";8 string strUsage = string() +9+ _("Bitcoin version") + " " + FormatVersion(VERSION) + pszSubVer + beta + "\n\n" +10 _("Usage:") + "\t\t\t\t\t\t\t\t\t\t\n" +11 " bitcoin [options] \t " + "\n" +12 " bitcoin [options] <command> [params]\t " + _("Send command to -server or bitcoind\n") +13@@ -173,23 +175,26 @@14 " -proxy=<ip:port> \t " + _("Connect through socks4 proxy\n") +15 " -addnode=<ip> \t " + _("Add a node to connect to\n") +16 " -connect=<ip> \t\t " + _("Connect only to the specified node\n") +17+ " -nolisten \t " + _("Don't accept connections from outside") +18 " -paytxfee=<amt> \t " + _("Fee per KB to add to transactions you send\n") +19 " -server \t\t " + _("Accept command line and JSON-RPC commands\n") +20 " -daemon \t\t " + _("Run in the background as a daemon and accept commands\n") +21 " -testnet \t\t " + _("Use the test network\n") +22 " -rpcuser=<user> \t " + _("Username for JSON-RPC connections\n") +23 " -rpcpassword=<pw>\t " + _("Password for JSON-RPC connections\n") +24- " -rpcport=<port> \t\t " + _("Listen for JSON-RPC connections on <port>\n") +25+ " -rpcport=<port> \t\t " + _("Listen for JSON-RPC connections on <port> (default: 8332)\n") +26 " -rpcallowip=<ip> \t\t " + _("Allow JSON-RPC connections from specified IP address\n") +27- " -rpcconnect=<ip> \t " + _("Send commands to node running on <ip>\n");28+ " -rpcconnect=<ip> \t " + _("Send commands to node running on <ip> (default: 127.0.0.1)\n") +29+ " -keypool=<n> \t " + _("Set key pool size to <n> (default: 100)\n") +30+ " -rescan \t " + _("Rescan the block chain for missing wallet transactions\n");31 32 #ifdef USE_SSL33 strUsage += string() +34 _("\nSSL options: (see the Bitcoin Wiki for SSL setup instructions)\n") +35- " -rpcssl=1 \t " + _("Use OpenSSL (https) for JSON-RPC connections\n") +36- " -rpcsslcertificatchainfile=<file.cert>\t " + _("Server certificate file (default: server.cert)\n") +37- " -rpcsslprivatekeyfile=<file.pem> \t " + _("Server private key (default: server.pem)\n") +38- " -rpcsslciphers=<ciphers> \t " + _("Acceptable ciphers (default: TLSv1+HIGH:!SSLv2:!aNULL:!eNULL:!AH:!3DES:@STRENGTH)\n");39+ " -rpcssl \t " + _("Use OpenSSL (https) for JSON-RPC connections\n") +40+ " -rpcsslcertificatechainfile=<file.cert>\t " + _("Server certificate file (default: server.cert)\n") +41+ " -rpcsslprivatekeyfile=<file.pem> \t " + _("Server private key (default: server.pem)\n") +42+ " -rpcsslciphers=<ciphers> \t " + _("Acceptable ciphers (default: TLSv1+HIGH:!SSLv2:!aNULL:!eNULL:!AH:!3DES:@STRENGTH)\n");43 #endif44 45 strUsage += string() +46@@ -208,9 +213,12 @@47 48 fDebug = GetBoolArg("-debug");49 50+ fPrintToConsole = GetBoolArg("-printtoconsole");51 fPrintToDebugger = GetBoolArg("-printtodebugger");52 53 fTestNet = GetBoolArg("-testnet");54+ 55+ fNoListen = GetBoolArg("-nolisten");56 57 if (fCommandLine)58 {59@@ -221,7 +229,7 @@60 if (!fDebug && !pszSetDataDir[0])61 ShrinkDebugFile();62 printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");63- printf("Bitcoin version %s%s beta\n", FormatVersion(VERSION).c_str(), pszSubVer);64+ printf("Bitcoin version %s%s%s\n", FormatVersion(VERSION).c_str(), pszSubVer, VERSION_IS_BETA ? _(" beta") : "");65 #ifdef GUI66 printf("OS version %s\n", ((string)wxGetOsDescription()).c_str());67 printf("System default language is %d %s\n", g_locale.GetSystemLanguage(), ((string)g_locale.GetSysName()).c_str());68@@ -290,10 +298,13 @@69 70 // Bind to the port early so we can tell if another instance is already running.71 string strErrors;72- if (!BindListenPort(strErrors))73- {74- wxMessageBox(strErrors, "Bitcoin");75- return false;76+ if (!fNoListen)77+ {78+ if (!BindListenPort(strErrors))79+ {80+ wxMessageBox(strErrors, "Bitcoin");81+ return false;82+ }83 }84 85 //86@@ -322,6 +333,13 @@87 if (!LoadWallet(fFirstRun))88 strErrors += _("Error loading wallet.dat \n");89 printf(" wallet %15"PRI64d"ms\n", GetTimeMillis() - nStart);90+91+ if (GetBoolArg("-rescan"))92+ {93+ nStart = GetTimeMillis();94+ ScanForWalletTransactions(pindexGenesisBlock);95+ printf(" rescan %15"PRI64d"ms\n", GetTimeMillis() - nStart);96+ }97 98 printf("Done loading\n");99
irc.cpp (modified)
1--- r202/irc.cpp2+++ v0.3.20/irc.cpp3@@ -257,8 +257,10 @@4 5 void ThreadIRCSeed2(void* parg)6 {7- if (mapArgs.count("-connect"))8+ /* Dont advertise on IRC if we don't allow incoming connections */9+ if (mapArgs.count("-connect") || fNoListen)10 return;11+12 if (GetBoolArg("-noirc"))13 return;14 printf("ThreadIRCSeed started\n");
main.cpp (modified)
1--- r202/main.cpp2+++ v0.3.20/main.cpp3@@ -187,6 +187,19 @@4 return true;5 }6 7+bool AddToWalletIfFromMe(const CTransaction& tx, const CBlock* pblock)8+{9+ if (tx.IsFromMe() || mapWallet.count(tx.GetHash()))10+ {11+ CWalletTx wtx(tx);12+ // Get merkle branch if transaction was found in a block13+ if (pblock)14+ wtx.SetMerkleBranch(pblock);15+ return AddToWallet(wtx);16+ }17+ return true;18+}19+20 bool EraseFromWallet(uint256 hash)21 {22 CRITICAL_BLOCK(cs_mapWallet)23@@ -394,6 +407,98 @@24 return nRequests;25 }26 27+void CWalletTx::GetAmounts(int64& nGenerated, list<pair<string, int64> >& listReceived,28+ list<pair<string, int64> >& listSent, int64& nFee, string& strSentAccount) const29+{30+ nGenerated = nFee = 0;31+ listReceived.clear();32+ listSent.clear();33+ strSentAccount = strFromAccount;34+35+ if (IsCoinBase())36+ {37+ if (GetDepthInMainChain() >= COINBASE_MATURITY)38+ nGenerated = GetCredit();39+ return;40+ }41+42+ // Compute fee:43+ int64 nDebit = GetDebit();44+ if (nDebit > 0) // debit>0 means we signed/sent this transaction45+ {46+ int64 nValueOut = GetValueOut();47+ nFee = nDebit - nValueOut;48+ }49+50+ // Sent/received. Standard client will never generate a send-to-multiple-recipients,51+ // but non-standard clients might (so return a list of address/amount pairs)52+ foreach(const CTxOut& txout, vout)53+ {54+ string address;55+ uint160 hash160;56+ vector<unsigned char> vchPubKey;57+ if (ExtractHash160(txout.scriptPubKey, hash160))58+ address = Hash160ToAddress(hash160);59+ else if (ExtractPubKey(txout.scriptPubKey, false, vchPubKey))60+ address = PubKeyToAddress(vchPubKey);61+ else62+ {63+ printf("CWalletTx::GetAmounts: Unknown transaction type found, txid %s\n",64+ this->GetHash().ToString().c_str());65+ address = " unknown ";66+ }67+68+ // Don't report 'change' txouts69+ if (nDebit > 0 && txout.IsChange())70+ continue;71+72+ if (nDebit > 0)73+ listSent.push_back(make_pair(address, txout.nValue));74+75+ if (txout.IsMine())76+ listReceived.push_back(make_pair(address, txout.nValue));77+ }78+79+}80+81+void CWalletTx::GetAccountAmounts(const string& strAccount, int64& nGenerated, int64& nReceived, 82+ int64& nSent, int64& nFee) const83+{84+ nGenerated = nReceived = nSent = nFee = 0;85+86+ int64 allGenerated, allFee;87+ allGenerated = allFee = 0;88+ string strSentAccount;89+ list<pair<string, int64> > listReceived;90+ list<pair<string, int64> > listSent;91+ GetAmounts(allGenerated, listReceived, listSent, allFee, strSentAccount);92+93+ if (strAccount == "")94+ nGenerated = allGenerated;95+ if (strAccount == strSentAccount)96+ {97+ foreach(const PAIRTYPE(string,int64)& s, listSent)98+ nSent += s.second;99+ nFee = allFee;100+ }101+ CRITICAL_BLOCK(cs_mapAddressBook)102+ {103+ foreach(const PAIRTYPE(string,int64)& r, listReceived)104+ {105+ if (mapAddressBook.count(r.first))106+ {107+ if (mapAddressBook[r.first] == strAccount)108+ {109+ nReceived += r.second;110+ }111+ }112+ else if (strAccount.empty())113+ {114+ nReceived += r.second;115+ }116+ }117+ }118+}119 120 121 122@@ -773,11 +878,50 @@123 return false;124 }125 126+int ScanForWalletTransactions(CBlockIndex* pindexStart)127+{128+ int ret = 0;129+130+ CBlockIndex* pindex = pindexStart;131+ CRITICAL_BLOCK(cs_mapWallet)132+ {133+ while (pindex)134+ {135+ CBlock block;136+ block.ReadFromDisk(pindex, true);137+ foreach(CTransaction& tx, block.vtx)138+ {139+ uint256 hash = tx.GetHash();140+ if (mapWallet.count(hash)) continue;141+ AddToWalletIfMine(tx, &block);142+ if (mapWallet.count(hash))143+ {144+ ++ret;145+ printf("Added missing RECEIVE %s\n", hash.ToString().c_str());146+ continue;147+ }148+ AddToWalletIfFromMe(tx, &block);149+ if (mapWallet.count(hash))150+ {151+ ++ret;152+ printf("Added missing SEND %s\n", hash.ToString().c_str());153+ continue;154+ }155+ }156+ pindex = pindex->pnext;157+ }158+ }159+ return ret;160+}161+162 void ReacceptWalletTransactions()163 {164 CTxDB txdb("r");165- CRITICAL_BLOCK(cs_mapWallet)166- {167+ bool fRepeat = true;168+ while (fRepeat) CRITICAL_BLOCK(cs_mapWallet)169+ {170+ fRepeat = false;171+ vector<CDiskTxPos> vMissingTx;172 foreach(PAIRTYPE(const uint256, CWalletTx)& item, mapWallet)173 {174 CWalletTx& wtx = item.second;175@@ -799,11 +943,14 @@176 {177 if (!txindex.vSpent[i].IsNull() && wtx.vout[i].IsMine())178 {179- printf("ReacceptWalletTransactions found spent coin %sbc %s\n", FormatMoney(wtx.GetCredit()).c_str(), wtx.GetHash().ToString().c_str());180 wtx.fSpent = true;181- wtx.WriteToDisk();182- break;183+ vMissingTx.push_back(txindex.vSpent[i]);184 }185+ }186+ if (wtx.fSpent)187+ {188+ printf("ReacceptWalletTransactions found spent coin %sbc %s\n", FormatMoney(wtx.GetCredit()).c_str(), wtx.GetHash().ToString().c_str());189+ wtx.WriteToDisk();190 }191 }192 }193@@ -813,6 +960,12 @@194 if (!wtx.IsCoinBase())195 wtx.AcceptWalletTransaction(txdb, false);196 }197+ }198+ if (!vMissingTx.empty())199+ {200+ // TODO: optimize this to scan just part of the block chain?201+ if (ScanForWalletTransactions(pindexGenesisBlock))202+ fRepeat = true; // Found missing transactions: re-do Reaccept.203 }204 }205 }206@@ -991,7 +1144,7 @@207 208 bool IsInitialBlockDownload()209 {210- if (pindexBest == NULL || (!fTestNet && nBestHeight < 74000))211+ if (pindexBest == NULL || (!fTestNet && nBestHeight < 105000))212 return true;213 static int64 nLastUpdate;214 static CBlockIndex* pindexLastBest;215@@ -1285,8 +1438,6 @@216 return true;217 }218 219-220-221 bool Reorganize(CTxDB& txdb, CBlockIndex* pindexNew)222 {223 printf("REORGANIZE\n");224@@ -1554,11 +1705,12 @@225 226 // Check that the block chain matches the known block chain up to a checkpoint227 if (!fTestNet)228- if ((nHeight == 11111 && hash != uint256("0x0000000069e244f73d78e8fd29ba2fd2ed618bd6fa2ee92559f542fdb26e7c1d")) ||229- (nHeight == 33333 && hash != uint256("0x000000002dd5588a74784eaa7ab0507a18ad16a236e7b1ce69f00d7ddfb5d0a6")) ||230- (nHeight == 68555 && hash != uint256("0x00000000001e1b4903550a0b96e9a9405c8a95f387162e4944e8d9fbe501cd6a")) ||231- (nHeight == 70567 && hash != uint256("0x00000000006a49b14bcf27462068f1264c961f11fa2e0eddd2be0791e1d4124a")) ||232- (nHeight == 74000 && hash != uint256("0x0000000000573993a3c9e41ce34471c079dcf5f52a0e824a81e7f953b8661a20")))233+ if ((nHeight == 11111 && hash != uint256("0x0000000069e244f73d78e8fd29ba2fd2ed618bd6fa2ee92559f542fdb26e7c1d")) ||234+ (nHeight == 33333 && hash != uint256("0x000000002dd5588a74784eaa7ab0507a18ad16a236e7b1ce69f00d7ddfb5d0a6")) ||235+ (nHeight == 68555 && hash != uint256("0x00000000001e1b4903550a0b96e9a9405c8a95f387162e4944e8d9fbe501cd6a")) ||236+ (nHeight == 70567 && hash != uint256("0x00000000006a49b14bcf27462068f1264c961f11fa2e0eddd2be0791e1d4124a")) ||237+ (nHeight == 74000 && hash != uint256("0x0000000000573993a3c9e41ce34471c079dcf5f52a0e824a81e7f953b8661a20")) ||238+ (nHeight == 105000 && hash != uint256("0x00000000000291ce28027faea320c8d2b054b2e0fe44a773f3eefb151d6bdc97")))239 return error("AcceptBlock() : rejected by checkpoint lockin at %d", nHeight);240 241 // Write block to history file242@@ -1575,7 +1727,7 @@243 if (hashBestChain == hash)244 CRITICAL_BLOCK(cs_vNodes)245 foreach(CNode* pnode, vNodes)246- if (nBestHeight > (pnode->nStartingHeight != -1 ? pnode->nStartingHeight - 2000 : 55000))247+ if (nBestHeight > (pnode->nStartingHeight != -1 ? pnode->nStartingHeight - 2000 : 105000))248 pnode->PushInventory(CInv(MSG_BLOCK, hash));249 250 return true;251@@ -1746,7 +1898,7 @@252 {253 if (fTestNet)254 {255- hashGenesisBlock = uint256("0x0000000224b1593e3ff16a0e3b61285bbc393a39f78c8aa48c456142671f7110");256+ hashGenesisBlock = uint256("0x00000007199508e34a9ff81e6ec0c477a4cccff2a4767a8eee39c11db367b008");257 bnProofOfWorkLimit = CBigNum(~uint256(0) >> 28);258 pchMessageStart[0] = 0xfa;259 pchMessageStart[1] = 0xbf;260@@ -1796,9 +1948,9 @@261 262 if (fTestNet)263 {264- block.nTime = 1279232055;265+ block.nTime = 1296688602;266 block.nBits = 0x1d07fff8;267- block.nNonce = 81622180;268+ block.nNonce = 384568319;269 }270 271 //// debug print272@@ -2976,7 +3128,7 @@273 "mov %%ecx, %1;" // ecx into c274 :"=r"(a),"=r"(c) /* output */275 :"r"(in) /* input */276- :"%eax","%ecx" /* clobbered register */277+ :"%eax","%ebx","%ecx","%edx" /* clobbered register */278 );279 aret = a;280 cret = c;281@@ -3379,7 +3531,7 @@282 SetThreadPriority(THREAD_PRIORITY_LOWEST);283 bool f4WaySSE2 = Detect128BitSSE2();284 if (mapArgs.count("-4way"))285- f4WaySSE2 = GetBoolArg(mapArgs["-4way"]);286+ f4WaySSE2 = GetBoolArg("-4way");287 288 // Each thread has its own key and counter289 CReserveKey reservekey;
main.h (modified)
1--- r202/main.h2+++ v0.3.20/main.h3@@ -69,6 +69,7 @@4 vector<unsigned char> GenerateNewKey();5 bool AddToWallet(const CWalletTx& wtxIn);6 void WalletUpdateSpent(const COutPoint& prevout);7+int ScanForWalletTransactions(CBlockIndex* pindexStart);8 void ReacceptWalletTransactions();9 bool LoadBlockIndex(bool fAllowNew=true);10 void PrintBlockTree();11@@ -873,36 +874,11 @@12 return nChangeCached;13 }14 15- void GetAccountAmounts(string strAccount, const set<CScript>& setPubKey,16- int64& nGenerated, int64& nReceived, int64& nSent, int64& nFee) const17- {18- nGenerated = nReceived = nSent = nFee = 0;19-20- // Generated blocks count to account ""21- if (IsCoinBase())22- {23- if (strAccount == "" && GetBlocksToMaturity() == 0)24- nGenerated = GetCredit();25- return;26- }27-28- // Received29- foreach(const CTxOut& txout, vout)30- if (setPubKey.count(txout.scriptPubKey))31- nReceived += txout.nValue;32-33- // Sent34- if (strFromAccount == strAccount)35- {36- int64 nDebit = GetDebit();37- if (nDebit > 0)38- {39- int64 nValueOut = GetValueOut();40- nFee = nDebit - nValueOut;41- nSent = nValueOut - GetChange();42- }43- }44- }45+ void GetAmounts(int64& nGenerated, list<pair<string /* address */, int64> >& listReceived,46+ list<pair<string /* address */, int64> >& listSent, int64& nFee, string& strSentAccount) const;47+48+ void GetAccountAmounts(const string& strAccount, int64& nGenerated, int64& nReceived, 49+ int64& nSent, int64& nFee) const;50 51 bool IsFromMe() const52 {53@@ -1695,6 +1671,7 @@54 class CAccountingEntry55 {56 public:57+ string strAccount;58 int64 nCreditDebit;59 int64 nTime;60 string strOtherAccount;61@@ -1709,6 +1686,7 @@62 {63 nCreditDebit = 0;64 nTime = 0;65+ strAccount.clear();66 strOtherAccount.clear();67 strComment.clear();68 }69@@ -1717,6 +1695,7 @@70 (71 if (!(nType & SER_GETHASH))72 READWRITE(nVersion);73+ // Note: strAccount is serialized as part of the key, not here.74 READWRITE(nCreditDebit);75 READWRITE(nTime);76 READWRITE(strOtherAccount);
makefile.mingw (modified)
1--- r202/makefile.mingw2+++ v0.3.20/makefile.mingw3@@ -4,26 +4,26 @@4 5 6 INCLUDEPATHS= \7- -I"/boost" \8- -I"/db/build_unix" \9- -I"/openssl/include" \10- -I"/wxwidgets/lib/gcc_lib/mswud" \11- -I"/wxwidgets/include"12+ -I"C:\boost-1.43.0-mgw" \13+ -I"C:\db-4.7.25.NC-mgw\build_unix" \14+ -I"C:\openssl-1.0.0c-mgw\include" \15+ -I"C:\wxWidgets-2.9.1-mgw\lib\gcc_lib\mswud" \16+ -I"C:\wxWidgets-2.9.1-mgw\include"17 18 LIBPATHS= \19- -L"/boost/stage/lib" \20- -L"/db/build_unix" \21- -L"/openssl/out" \22- -L"/wxwidgets/lib/gcc_lib"23+ -L"C:\boost-1.43.0-mgw\stage\lib" \24+ -L"C:\db-4.7.25.NC-mgw\build_unix" \25+ -L"C:\openssl-1.0.0c-mgw" \26+ -L"C:\wxWidgets-2.9.1-mgw\lib\gcc_lib"27 28 WXLIBS= \29 -l wxmsw29ud_html -l wxmsw29ud_core -l wxmsw29ud_adv -l wxbase29ud -l wxtiffd -l wxjpegd -l wxpngd -l wxzlibd30 31 LIBS= \32- -l libboost_system-mgw34-mt-d \33- -l libboost_filesystem-mgw34-mt-d \34- -l libboost_program_options-mgw34-mt-d \35- -l libboost_thread-mgw34-mt-d \36+ -l boost_system-mgw45-mt-s-1_43 \37+ -l boost_filesystem-mgw45-mt-s-1_43 \38+ -l boost_program_options-mgw45-mt-s-1_43 \39+ -l boost_thread-mgw45-mt-s-1_43 \40 -l db_cxx \41 -l eay32 \42 -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
makefile.vc (modified)
1--- r202/makefile.vc2+++ v0.3.20/makefile.vc3@@ -7,29 +7,32 @@4 /I"/boost" \5 /I"/db/build_windows" \6 /I"/openssl/include" \7- /I"/wxwidgets/lib/vc_lib/mswud" \8+ /I"/wxwidgets/lib/vc_lib/mswu" \9 /I"/wxwidgets/include"10 11 LIBPATHS= \12 /LIBPATH:"/boost/stage/lib" \13- /LIBPATH:"/db/build_windows/debug" \14- /LIBPATH:"/openssl/out" \15- /LIBPATH:"/wxwidgets/lib/vc_lib"16+ /LIBPATH:"/db/build_windows/Release" \17+ /LIBPATH:"/openssl/lib" \18+ /LIBPATH:"/wxwidgets/lib/vc_lib" \19+ /NODEFAULTLIB:libc.lib /NODEFAULTLIB:libcmt.lib \20+ /NODEFAULTLIB:libcd.lib /NODEFAULTLIB:libcmtd.lib \21+ /NODEFAULTLIB:msvcrtd.lib22 23-WXLIBS=wxmsw29ud_html.lib wxmsw29ud_core.lib wxmsw29ud_adv.lib wxbase29ud.lib wxtiffd.lib wxjpegd.lib wxpngd.lib wxzlibd.lib24+WXLIBS=wxmsw29u.lib wxtiff.lib wxjpeg.lib wxpng.lib wxzlib.lib25 26 LIBS= \27- libboost_system-vc80-mt-gd.lib \28- libboost_filesystem-vc80-mt-gd.lib \29- libboost_program_options-vc80-mt-gd.lib \30- libboost_thread-vc80-mt-gd.lib \31- libdb47sd.lib \32+ libboost_system-vc100-mt.lib \33+ libboost_filesystem-vc100-mt.lib \34+ libboost_program_options-vc100-mt.lib \35+ libboost_thread-vc100-mt.lib \36+ libdb47s.lib \37 libeay32.lib \38 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.lib39 40 DEFS=/DWIN32 /D__WXMSW__ /D_WINDOWS /DNOPCH41-DEBUGFLAGS=/Zi /D__WXDEBUG__42-CFLAGS=/c /nologo /MDd /EHsc /GR /Zm300 $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS)43+DEBUGFLAGS=/Os44+CFLAGS=/MD /c /nologo /EHsc /GR /Zm300 $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS)45 HEADERS=headers.h strlcpy.h serialize.h uint256.h util.h key.h bignum.h base58.h \46 script.h db.h net.h irc.h main.h rpc.h uibase.h ui.h noui.h init.h47 48@@ -82,7 +85,7 @@49 rc $(INCLUDEPATHS) $(DEFS) /Fo$@ %s50 51 bitcoin.exe: $(OBJS) obj\ui.obj obj\uibase.obj obj\ui.res52- link /nologo /DEBUG /SUBSYSTEM:WINDOWS /OUT:$@ $(LIBPATHS) $** $(WXLIBS) $(LIBS)53+ link /nologo /SUBSYSTEM:WINDOWS /OUT:$@ $(LIBPATHS) $** $(WXLIBS) $(LIBS)54 55 56 .cpp{obj\nogui}.obj:57@@ -105,7 +108,7 @@58 obj\nogui\init.obj: $(HEADERS)59 60 bitcoind.exe: $(OBJS:obj\=obj\nogui\) obj\ui.res61- link /nologo /DEBUG /OUT:$@ $(LIBPATHS) $** $(LIBS)62+ link /nologo /OUT:$@ $(LIBPATHS) $** $(LIBS)63 64 65 clean:
net.cpp (modified)
1--- r202/net.cpp2+++ v0.3.20/net.cpp3@@ -643,7 +643,9 @@4 FD_ZERO(&fdsetSend);5 FD_ZERO(&fdsetError);6 SOCKET hSocketMax = 0;7- FD_SET(hListenSocket, &fdsetRecv);8+9+ if(hListenSocket != INVALID_SOCKET)10+ FD_SET(hListenSocket, &fdsetRecv);11 hSocketMax = max(hSocketMax, hListenSocket);12 CRITICAL_BLOCK(cs_vNodes)13 {14@@ -680,18 +682,24 @@15 //16 // Accept new connections17 //18- if (FD_ISSET(hListenSocket, &fdsetRecv))19+ if (hListenSocket != INVALID_SOCKET && FD_ISSET(hListenSocket, &fdsetRecv))20 {21 struct sockaddr_in sockaddr;22 socklen_t len = sizeof(sockaddr);23 SOCKET hSocket = accept(hListenSocket, (struct sockaddr*)&sockaddr, &len);24 CAddress addr(sockaddr);25+ int nInbound = 0;26+27+ CRITICAL_BLOCK(cs_vNodes)28+ foreach(CNode* pnode, vNodes)29+ if (pnode->fInbound)30+ nInbound++;31 if (hSocket == INVALID_SOCKET)32 {33 if (WSAGetLastError() != WSAEWOULDBLOCK)34 printf("socket error accept failed: %d\n", WSAGetLastError());35 }36- else if (mapArgs.count("-maxconnections") && (int)vNodes.size() >= atoi(mapArgs["-maxconnections"]) - MAX_OUTBOUND_CONNECTIONS)37+ else if (nInbound >= GetArg("-maxconnections", 125) - MAX_OUTBOUND_CONNECTIONS)38 {39 closesocket(hSocket);40 }41@@ -733,31 +741,38 @@42 CDataStream& vRecv = pnode->vRecv;43 unsigned int nPos = vRecv.size();44 45- // typical socket buffer is 8K-64K46- char pchBuf[0x10000];47- int nBytes = recv(pnode->hSocket, pchBuf, sizeof(pchBuf), MSG_DONTWAIT);48- if (nBytes > 0)49- {50- vRecv.resize(nPos + nBytes);51- memcpy(&vRecv[nPos], pchBuf, nBytes);52- pnode->nLastRecv = GetTime();53- }54- else if (nBytes == 0)55- {56- // socket closed gracefully57+ if (nPos > 1000*GetArg("-maxreceivebuffer", 2*1000)) {58 if (!pnode->fDisconnect)59- printf("socket closed\n");60+ printf("socket recv flood control disconnect (%d bytes)\n", vRecv.size());61 pnode->CloseSocketDisconnect();62 }63- else if (nBytes < 0)64- {65- // error66- int nErr = WSAGetLastError();67- if (nErr != WSAEWOULDBLOCK && nErr != WSAEMSGSIZE && nErr != WSAEINTR && nErr != WSAEINPROGRESS)68+ else {69+ // typical socket buffer is 8K-64K70+ char pchBuf[0x10000];71+ int nBytes = recv(pnode->hSocket, pchBuf, sizeof(pchBuf), MSG_DONTWAIT);72+ if (nBytes > 0)73 {74+ vRecv.resize(nPos + nBytes);75+ memcpy(&vRecv[nPos], pchBuf, nBytes);76+ pnode->nLastRecv = GetTime();77+ }78+ else if (nBytes == 0)79+ {80+ // socket closed gracefully81 if (!pnode->fDisconnect)82- printf("socket recv error %d\n", nErr);83+ printf("socket closed\n");84 pnode->CloseSocketDisconnect();85+ }86+ else if (nBytes < 0)87+ {88+ // error89+ int nErr = WSAGetLastError();90+ if (nErr != WSAEWOULDBLOCK && nErr != WSAEMSGSIZE && nErr != WSAEINTR && nErr != WSAEINPROGRESS)91+ {92+ if (!pnode->fDisconnect)93+ printf("socket recv error %d\n", nErr);94+ pnode->CloseSocketDisconnect();95+ }96 }97 }98 }99@@ -791,6 +806,11 @@100 pnode->CloseSocketDisconnect();101 }102 }103+ if (vSend.size() > 1000*GetArg("-maxsendbuffer", 256)) {104+ if (!pnode->fDisconnect)105+ printf("socket send flood control disconnect (%d bytes)\n", vSend.size());106+ pnode->CloseSocketDisconnect();107+ }108 }109 }110 }111@@ -843,42 +863,46 @@112 113 unsigned int pnSeed[] =114 {115- // 2010/06116- 0x35218252, 0x9c9c9618, 0xda6bacad, 0xb9aca862, 0x97c235c6,117- 0x146f9562, 0xb67b9e4b, 0x87cf4bc0, 0xb83945d0, 0x984333ad,118- 0xbbeec555, 0x6f0eb440, 0xe0005318, 0x7797e460, 0xddc60fcc,119- 0xb3bbd24a, 0x1ac85746, 0x641846a6, 0x85ee1155, 0xbb2e7a4c,120- 0x9cb8514b, 0xfc342648, 0x62958fae, 0xd0a8c87a, 0xa800795b,121- 0xda8c814e, 0x256a0c80, 0x3f23ec63, 0xd565df43, 0x997d9044,122- 0xaa121448, 0xbed8688e, 0x59d09a5e, 0xb2931243, 0x3730ba18,123- 0xdd3462d0, 0x4e4d1448, 0x171df645, 0x84ee1155,124- 0x248ac445, 0x0e634444, 0x0ded1b63, 0x30c01e60,125- 0xa2b9a094, 0x29e4fd43, 0x9ce61b4c, 0xdae09744,126-127- // 2010/08128- 0x5ae6bf43, 0x460be257, 0x7245c0cf, 0x4e0f028d, 0x26501760, 0x38643255, 0x67094f4f, 0x480449b8,129- 0x16545143, 0x1f082e5a, 0xaa428018, 0xe411e793, 0x14c1f862, 0x2726105b, 0x9b33ea50, 0xeeef86ca,130- 0xe3210d44, 0x0dca8b63, 0x3f9dfb18, 0x860340ad, 0xf33ba17a, 0x9018375c, 0x1de4e353, 0x0fa52dcb,131- 0x89c4555b, 0x109cf37b, 0x28c55b40, 0x04c801ae, 0x275c1e80, 0x6f7f745d, 0x7a2a5653, 0xa28e26d8,132- 0xa4e65db2, 0x99a06580, 0xf253ba44, 0x82cf6ab8, 0x859c2e8e, 0xf71a815d, 0xc18f1454, 0x71c8a943,133- 0x90d24e18, 0x311789b2, 0x74aba645, 0xde0bbfc3, 0xad724fad, 0xbf1ae15e, 0xbaa6fb54, 0x06e4d145,134- 0x51528645, 0x72120cd4, 0xd4cfd145, 0x0a7afed8, 0x9b9a5fad, 0x9e9ff45e, 0x10128355, 0xd44e8646,135- 0x04a07b47, 0x5fc9d547, 0xe0491e45, 0xbac21b41, 0x7aa31bae, 0x10483c5f, 0x94a23055, 0x73d9dc47,136- 0x1a99c247, 0x822fe847, 0x7e57ba48, 0xb19ea843, 0xa60621b2, 0x778cf163, 0x125c6556, 0xf94ba44f,137- 0xa61a0948, 0x6c839e4b, 0x29af5348, 0x68d84845, 0x752b95c3, 0xcf0d4663, 0x08e11e56, 0x75109550,138- 0x5f24b94c, 0x42426d4d, 0xfbbc0a4c, 0x70a9a246, 0xda7837cb, 0xae2a986d, 0xe283c358, 0x0c7ca954,139- 0x8e9bde59, 0x61521760, 0x6884444c, 0xa194e548, 0x9b8809cc, 0x16e96a8f, 0x956ff859, 0xfad5e555,140- 0x0ea70c80, 0x5b4ce26d, 0x7984444c, 0x1080d24a, 0x22a686cf, 0x6bf8c2ad, 0xb0f7485f, 0x06b66e56,141- 0x668373bc, 0x75506279, 0x3868694e, 0x12a5954b, 0x3a8b62d1, 0xb74fcbad, 0xa7dc3360, 0xc070b359,142- 0xa2b87242, 0xc45cab7c, 0x69882050, 0x14a5464b, 0x386acad5, 0x80b85db2, 0x1f78a062, 0xc608c55b,143- 0x4257d543, 0x7636ad80, 0x4432d655, 0xb2114d4b, 0x32639bd9, 0xadd75db2, 0x9be5a362, 0x6831bc5e,144- 0xf7f77046, 0x8f35ba81, 0x09bb4e59, 0xd0fb6b4e, 0xc5daa445, 0x9c611618, 0x355dcc62, 0xf2cf435e,145- 0x31e72c46, 0xdd8a43ad, 0x171f9c5b, 0xb4c2e355, 0xbe8af945, 0x613d3942, 0xe6f9e863, 0x7a3d855f,146- 0xa66adc47, 0x261089b2, 0x5a27105b, 0x6c28105b, 0xdd247946, 0xe6c3a445, 0x43a1ec63, 0x99b4dd5f,147- 0xb6834347, 0x5e9649bc, 0xf9dd545d, 0x6ae4c15b, 0xa5318a47, 0x7984ec47, 0x93a73b63, 0x0c60195f,148- 0xa5c85e4b, 0xa0a36dc2, 0x0739a95e, 0x3d44c15b, 0xfb940f4b, 0xd67c9148, 0x614f9876, 0x0a241c5f,149- 0xad9da74c, 0x4459abc8, 0x12e71b5f, 0x1c534a5d, 0x8ff5fc50, 0x2ca8864b, 0xd894fd80, 0x82ab3160,150- 0x390d804e, 0x2cf310cc, 0x680dad80, 0x691be15e, 0x5a8f4652, 0xaad0784d, 0x0d2431ad,151+ 0x1ddb1032, 0x6242ce40, 0x52d6a445, 0x2dd7a445, 0x8a53cd47, 0x73263750, 0xda23c257, 0xecd4ed57,152+ 0x0a40ec59, 0x75dce160, 0x7df76791, 0x89370bad, 0xa4f214ad, 0x767700ae, 0x638b0418, 0x868a1018,153+ 0xcd9f332e, 0x0129653e, 0xcc92dc3e, 0x96671640, 0x56487e40, 0x5b66f440, 0xb1d01f41, 0xf1dc6041,154+ 0xc1d12b42, 0x86ba1243, 0x6be4df43, 0x6d4cef43, 0xd18e0644, 0x1ab0b344, 0x6584a345, 0xe7c1a445,155+ 0x58cea445, 0xc5daa445, 0x21dda445, 0x3d3b5346, 0x13e55347, 0x1080d24a, 0x8e611e4b, 0x81518e4b,156+ 0x6c839e4b, 0xe2ad0a4c, 0xfbbc0a4c, 0x7f5b6e4c, 0x7244224e, 0x1300554e, 0x20690652, 0x5a48b652,157+ 0x75c5c752, 0x4335cc54, 0x340fd154, 0x87c07455, 0x087b2b56, 0x8a133a57, 0xac23c257, 0x70374959,158+ 0xfb63d45b, 0xb9a1685c, 0x180d765c, 0x674f645d, 0x04d3495e, 0x1de44b5e, 0x4ee8a362, 0x0ded1b63,159+ 0xc1b04b6d, 0x8d921581, 0x97b7ea82, 0x1cf83a8e, 0x91490bad, 0x09dc75ae, 0x9a6d79ae, 0xa26d79ae,160+ 0x0fd08fae, 0x0f3e3fb2, 0x4f944fb2, 0xcca448b8, 0x3ecd6ab8, 0xa9d5a5bc, 0x8d0119c1, 0x045997d5,161+ 0xca019dd9, 0x0d526c4d, 0xabf1ba44, 0x66b1ab55, 0x1165f462, 0x3ed7cbad, 0xa38fae6e, 0x3bd2cbad,162+ 0xd36f0547, 0x20df7840, 0x7a337742, 0x549f8e4b, 0x9062365c, 0xd399f562, 0x2b5274a1, 0x8edfa153,163+ 0x3bffb347, 0x7074bf58, 0xb74fcbad, 0x5b5a795b, 0x02fa29ce, 0x5a6738d4, 0xe8a1d23e, 0xef98c445,164+ 0x4b0f494c, 0xa2bc1e56, 0x7694ad63, 0xa4a800c3, 0x05fda6cd, 0x9f22175e, 0x364a795b, 0x536285d5,165+ 0xac44c9d4, 0x0b06254d, 0x150c2fd4, 0x32a50dcc, 0xfd79ce48, 0xf15cfa53, 0x66c01e60, 0x6bc26661,166+ 0xc03b47ae, 0x4dda1b81, 0x3285a4c1, 0x883ca96d, 0x35d60a4c, 0xdae09744, 0x2e314d61, 0x84e247cf,167+ 0x6c814552, 0x3a1cc658, 0x98d8f382, 0xe584cb5b, 0x15e86057, 0x7b01504e, 0xd852dd48, 0x56382f56,168+ 0x0a5df454, 0xa0d18d18, 0x2e89b148, 0xa79c114c, 0xcbdcd054, 0x5523bc43, 0xa9832640, 0x8a066144,169+ 0x3894c3bc, 0xab76bf58, 0x6a018ac1, 0xfebf4f43, 0x2f26c658, 0x31102f4e, 0x85e929d5, 0x2a1c175e,170+ 0xfc6c2cd1, 0x27b04b6d, 0xdf024650, 0x161748b8, 0x28be6580, 0x57be6580, 0x1cee677a, 0xaa6bb742,171+ 0x9a53964b, 0x0a5a2d4d, 0x2434c658, 0x9a494f57, 0x1ebb0e48, 0xf610b85d, 0x077ecf44, 0x085128bc,172+ 0x5ba17a18, 0x27ca1b42, 0xf8a00b56, 0xfcd4c257, 0xcf2fc15e, 0xd897e052, 0x4cada04f, 0x2f35f6d5,173+ 0x382ce8c9, 0xe523984b, 0x3f946846, 0x60c8be43, 0x41da6257, 0xde0be142, 0xae8a544b, 0xeff0c254,174+ 0x1e0f795b, 0xaeb28890, 0xca16acd9, 0x1e47ddd8, 0x8c8c4829, 0xd27dc747, 0xd53b1663, 0x4096b163,175+ 0x9c8dd958, 0xcb12f860, 0x9e79305c, 0x40c1a445, 0x4a90c2bc, 0x2c3a464d, 0x2727f23c, 0x30b04b6d,176+ 0x59024cb8, 0xa091e6ad, 0x31b04b6d, 0xc29d46a6, 0x63934fb2, 0xd9224dbe, 0x9f5910d8, 0x7f530a6b,177+ 0x752e9c95, 0x65453548, 0xa484be46, 0xce5a1b59, 0x710e0718, 0x46a13d18, 0xdaaf5318, 0xc4a8ff53,178+ 0x87abaa52, 0xb764cf51, 0xb2025d4a, 0x6d351e41, 0xc035c33e, 0xa432c162, 0x61ef34ae, 0xd16fddbc,179+ 0x0870e8c1, 0x3070e8c1, 0x9c71e8c1, 0xa4992363, 0x85a1f663, 0x4184e559, 0x18d96ed8, 0x17b8dbd5,180+ 0x60e7cd18, 0xe5ee104c, 0xab17ac62, 0x1e786e1b, 0x5d23b762, 0xf2388fae, 0x88270360, 0x9e5b3d80,181+ 0x7da518b2, 0xb5613b45, 0x1ad41f3e, 0xd550854a, 0x8617e9a9, 0x925b229c, 0xf2e92542, 0x47af0544,182+ 0x73b5a843, 0xb9b7a0ad, 0x03a748d0, 0x0a6ff862, 0x6694df62, 0x3bfac948, 0x8e098f4f, 0x746916c3,183+ 0x02f38e4f, 0x40bb1243, 0x6a54d162, 0x6008414b, 0xa513794c, 0x514aa343, 0x63781747, 0xdbb6795b,184+ 0xed065058, 0x42d24b46, 0x1518794c, 0x9b271681, 0x73e4ffad, 0x0654784f, 0x438dc945, 0x641846a6,185+ 0x2d1b0944, 0x94b59148, 0x8d369558, 0xa5a97662, 0x8b705b42, 0xce9204ae, 0x8d584450, 0x2df61555,186+ 0xeebff943, 0x2e75fb4d, 0x3ef8fc57, 0x9921135e, 0x8e31042e, 0xb5afad43, 0x89ecedd1, 0x9cfcc047,187+ 0x8fcd0f4c, 0xbe49f5ad, 0x146a8d45, 0x98669ab8, 0x98d9175e, 0xd1a8e46d, 0x839a3ab8, 0x40a0016c,188+ 0x6d27c257, 0x977fffad, 0x7baa5d5d, 0x1213be43, 0xb167e5a9, 0x640fe8ca, 0xbc9ea655, 0x0f820a4c,189+ 0x0f097059, 0x69ac957c, 0x366d8453, 0xb1ba2844, 0x8857f081, 0x70b5be63, 0xc545454b, 0xaf36ded1,190+ 0xb5a4b052, 0x21f062d1, 0x72ab89b2, 0x74a45318, 0x8312e6bc, 0xb916965f, 0x8aa7c858, 0xfe7effad,191 };192 193 194@@ -957,8 +981,7 @@195 if (!pnode->fInbound)196 nOutbound++;197 int nMaxOutboundConnections = MAX_OUTBOUND_CONNECTIONS;198- if (mapArgs.count("-maxconnections"))199- nMaxOutboundConnections = min(nMaxOutboundConnections, atoi(mapArgs["-maxconnections"]));200+ nMaxOutboundConnections = min(nMaxOutboundConnections, (int)GetArg("-maxconnections", 125));201 if (nOutbound < nMaxOutboundConnections)202 break;203 Sleep(2000);204@@ -1007,7 +1030,7 @@205 {206 foreach(PAIRTYPE(const vector<unsigned char>, CAddress)& item, mapAddresses)207 {208- if (setSeed.count(item.second.ip))209+ if (setSeed.count(item.second.ip) && item.second.nTime != 0)210 {211 item.second.nTime = 0;212 CAddrDB().WriteAddress(item.second);213@@ -1344,7 +1367,7 @@214 #endif215 printf("addrLocalHost = %s\n", addrLocalHost.ToString().c_str());216 217- if (fUseProxy || mapArgs.count("-connect"))218+ if (fUseProxy || mapArgs.count("-connect") || fNoListen)219 {220 // Proxies can't take incoming connections221 addrLocalHost.ip = CAddress("0.0.0.0").ip;
rpc.cpp (modified)
1--- r202/rpc.cpp2+++ v0.3.20/rpc.cpp3@@ -80,11 +80,18 @@4 {5 entry.push_back(Pair("confirmations", wtx.GetDepthInMainChain()));6 entry.push_back(Pair("txid", wtx.GetHash().GetHex()));7+ entry.push_back(Pair("time", (boost::int64_t)wtx.GetTxTime()));8 foreach(const PAIRTYPE(string,string)& item, wtx.mapValue)9 entry.push_back(Pair(item.first, item.second));10 }11 12-13+string AccountFromValue(const Value& value)14+{15+ string strAccount = value.get_str();16+ if (strAccount == "*")17+ throw JSONRPCError(-11, "Invalid account name");18+ return strAccount;19+}20 21 22 23@@ -239,6 +246,8 @@24 CWalletDB().WriteSetting("fLimitProcessors", fLimitProcessors);25 if (nGenProcLimit != -1)26 CWalletDB().WriteSetting("nLimitProcessors", nLimitProcessors = nGenProcLimit);27+ if (nGenProcLimit == 0)28+ fGenerate = false;29 }30 31 GenerateBitcoins(fGenerate);32@@ -296,7 +305,7 @@33 // Parse the account first so we don't generate a key if there's an error34 string strAccount;35 if (params.size() > 0)36- strAccount = params[0].get_str();37+ strAccount = AccountFromValue(params[0]);38 39 // Generate a new key that is added to wallet40 string strAddress = PubKeyToAddress(GetKeyFromKeyPool());41@@ -306,15 +315,9 @@42 }43 44 45-Value getaccountaddress(const Array& params, bool fHelp)46-{47- if (fHelp || params.size() != 1)48- throw runtime_error(49- "getaccountaddress <account>\n"50- "Returns the current bitcoin address for receiving payments to this account.");51-52- // Parse the account first so we don't generate a key if there's an error53- string strAccount = params[0].get_str();54+string GetAccountAddress(string strAccount, bool bForceNew=false)55+{56+ string strAddress;57 58 CRITICAL_BLOCK(cs_mapWallet)59 {60@@ -341,7 +344,7 @@61 }62 63 // Generate a new key64- if (account.vchPubKey.empty())65+ if (account.vchPubKey.empty() || bForceNew)66 {67 account.vchPubKey = GetKeyFromKeyPool();68 string strAddress = PubKeyToAddress(account.vchPubKey);69@@ -350,9 +353,24 @@70 }71 72 walletdb.TxnCommit();73- return PubKeyToAddress(account.vchPubKey);74- }75-}76+ strAddress = PubKeyToAddress(account.vchPubKey);77+ }78+ return strAddress;79+}80+81+Value getaccountaddress(const Array& params, bool fHelp)82+{83+ if (fHelp || params.size() != 1)84+ throw runtime_error(85+ "getaccountaddress <account>\n"86+ "Returns the current bitcoin address for receiving payments to this account.");87+88+ // Parse the account first so we don't generate a key if there's an error89+ string strAccount = AccountFromValue(params[0]);90+91+ return GetAccountAddress(strAccount);92+}93+94 95 96 Value setaccount(const Array& params, bool fHelp)97@@ -365,7 +383,18 @@98 string strAddress = params[0].get_str();99 string strAccount;100 if (params.size() > 1)101- strAccount = params[1].get_str();102+ strAccount = AccountFromValue(params[1]);103+104+ // Detect when changing the account of an address that is the 'unused current key' of another account:105+ CRITICAL_BLOCK(cs_mapAddressBook)106+ {107+ if (mapAddressBook.count(strAddress))108+ {109+ string strOldAccount = mapAddressBook[strAddress];110+ if (strAddress == GetAccountAddress(strOldAccount))111+ GetAccountAddress(strOldAccount, true);112+ }113+ }114 115 SetAddressBookName(strAddress, strAccount);116 return Value::null;117@@ -399,7 +428,7 @@118 "getaddressesbyaccount <account>\n"119 "Returns the list of addresses for the given account.");120 121- string strAccount = params[0].get_str();122+ string strAccount = AccountFromValue(params[0]);123 124 // Find all addresses that have the given account125 Array ret;126@@ -436,7 +465,7 @@127 // Wallet comments128 CWalletTx wtx;129 if (params.size() > 2 && params[2].type() != null_type && !params[2].get_str().empty())130- wtx.mapValue["message"] = params[2].get_str();131+ wtx.mapValue["comment"] = params[2].get_str();132 if (params.size() > 3 && params[3].type() != null_type && !params[3].get_str().empty())133 wtx.mapValue["to"] = params[3].get_str();134 135@@ -522,7 +551,7 @@136 nMinDepth = params[1].get_int();137 138 // Get the set of pub keys that have the label139- string strAccount = params[0].get_str();140+ string strAccount = AccountFromValue(params[0]);141 set<CScript> setPubKey;142 GetAccountPubKeys(strAccount, setPubKey);143 144@@ -549,9 +578,6 @@145 146 int64 GetAccountBalance(CWalletDB& walletdb, const string& strAccount, int nMinDepth)147 {148- set<CScript> setPubKey;149- GetAccountPubKeys(strAccount, setPubKey);150-151 int64 nBalance = 0;152 CRITICAL_BLOCK(cs_mapWallet)153 {154@@ -563,7 +589,7 @@155 continue;156 157 int64 nGenerated, nReceived, nSent, nFee;158- wtx.GetAccountAmounts(strAccount, setPubKey, nGenerated, nReceived, nSent, nFee);159+ wtx.GetAccountAmounts(strAccount, nGenerated, nReceived, nSent, nFee);160 161 if (nReceived != 0 && wtx.GetDepthInMainChain() >= nMinDepth)162 nBalance += nReceived;163@@ -595,7 +621,37 @@164 if (params.size() == 0)165 return ((double)GetBalance() / (double)COIN);166 167- string strAccount = params[0].get_str();168+ if (params[0].get_str() == "*") {169+ // Calculate total balance a different way from GetBalance()170+ // (GetBalance() sums up all unspent TxOuts)171+ // getbalance and getbalance '*' should always return the same number.172+ int64 nBalance = 0;173+ vector<string> vAccounts;174+ for (map<uint256, CWalletTx>::iterator it = mapWallet.begin(); it != mapWallet.end(); ++it)175+ {176+ const CWalletTx& wtx = (*it).second;177+ int64 allGenerated, allFee;178+ allGenerated = allFee = 0;179+ string strSentAccount;180+ list<pair<string, int64> > listReceived;181+ list<pair<string, int64> > listSent;182+ wtx.GetAmounts(allGenerated, listReceived, listSent, allFee, strSentAccount);183+ foreach(const PAIRTYPE(string,int64)& r, listReceived)184+ {185+ nBalance += r.second;186+ if (!count(vAccounts.begin(), vAccounts.end(), r.first))187+ vAccounts.push_back(r.first);188+ }189+ foreach(const PAIRTYPE(string,int64)& r, listSent)190+ nBalance -= r.second;191+ nBalance -= allFee;192+ nBalance += allGenerated;193+ }194+ printf("Found %d accounts\n", vAccounts.size());195+ return (double)nBalance / (double)COIN;196+ }197+198+ string strAccount = AccountFromValue(params[0]);199 int nMinDepth = 1;200 if (params.size() > 1)201 nMinDepth = params[1].get_int();202@@ -613,8 +669,8 @@203 "move <fromaccount> <toaccount> <amount> [minconf=1] [comment]\n"204 "Move from one account in your wallet to another.");205 206- string strFrom = params[0].get_str();207- string strTo = params[1].get_str();208+ string strFrom = AccountFromValue(params[0]);209+ string strTo = AccountFromValue(params[1]);210 int64 nAmount = AmountFromValue(params[2]);211 int nMinDepth = 1;212 if (params.size() > 3)213@@ -647,19 +703,21 @@214 215 // Debit216 CAccountingEntry debit;217+ debit.strAccount = strFrom;218 debit.nCreditDebit = -nAmount;219 debit.nTime = nNow;220 debit.strOtherAccount = strTo;221 debit.strComment = strComment;222- walletdb.WriteAccountingEntry(strFrom, debit);223+ walletdb.WriteAccountingEntry(debit);224 225 // Credit226 CAccountingEntry credit;227+ credit.strAccount = strTo;228 credit.nCreditDebit = nAmount;229 credit.nTime = nNow;230 credit.strOtherAccount = strFrom;231 credit.strComment = strComment;232- walletdb.WriteAccountingEntry(strTo, credit);233+ walletdb.WriteAccountingEntry(credit);234 235 walletdb.TxnCommit();236 }237@@ -674,7 +732,7 @@238 "sendfrom <fromaccount> <tobitcoinaddress> <amount> [minconf=1] [comment] [comment-to]\n"239 "<amount> is a real and is rounded to the nearest 0.01");240 241- string strAccount = params[0].get_str();242+ string strAccount = AccountFromValue(params[0]);243 string strAddress = params[1].get_str();244 int64 nAmount = AmountFromValue(params[2]);245 int nMinDepth = 1;246@@ -684,7 +742,7 @@247 CWalletTx wtx;248 wtx.strFromAccount = strAccount;249 if (params.size() > 4 && params[4].type() != null_type && !params[4].get_str().empty())250- wtx.mapValue["message"] = params[4].get_str();251+ wtx.mapValue["comment"] = params[4].get_str();252 if (params.size() > 5 && params[5].type() != null_type && !params[5].get_str().empty())253 wtx.mapValue["to"] = params[5].get_str();254 255@@ -849,97 +907,200 @@256 return ListReceived(params, true);257 }258 259-void ListAccountTransactions(CWalletDB& walletdb, const string& strAccount, int nMinDepth, multimap<int64, Object>& ret)260-{261- set<CScript> setPubKey;262- GetAccountPubKeys(strAccount, setPubKey);263-264- CRITICAL_BLOCK(cs_mapWallet)265- {266- // Wallet: generate/send/receive transactions267- for (map<uint256, CWalletTx>::iterator it = mapWallet.begin(); it != mapWallet.end(); ++it)268- {269- const CWalletTx& wtx = (*it).second;270- if (!wtx.IsFinal())271- continue;272-273- int64 nGenerated, nReceived, nSent, nFee;274- wtx.GetAccountAmounts(strAccount, setPubKey, nGenerated, nReceived, nSent, nFee);275-276- // Generated blocks count to account ""277- if (nGenerated != 0)278+void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDepth, bool fLong, Array& ret)279+{280+ int64 nGenerated, nFee;281+ string strSentAccount;282+ list<pair<string, int64> > listReceived;283+ list<pair<string, int64> > listSent;284+ wtx.GetAmounts(nGenerated, listReceived, listSent, nFee, strSentAccount);285+286+ bool fAllAccounts = (strAccount == string("*"));287+288+ // Generated blocks assigned to account ""289+ if (nGenerated != 0 && (fAllAccounts || strAccount == ""))290+ {291+ Object entry;292+ entry.push_back(Pair("account", string("")));293+ entry.push_back(Pair("category", "generate"));294+ entry.push_back(Pair("amount", ValueFromAmount(nGenerated)));295+ if (fLong)296+ WalletTxToJSON(wtx, entry);297+ ret.push_back(entry);298+ }299+300+ // Sent301+ if ((!listSent.empty() || nFee != 0) && (fAllAccounts || strAccount == strSentAccount))302+ {303+ foreach(const PAIRTYPE(string, int64)& s, listSent)304+ {305+ Object entry;306+ entry.push_back(Pair("account", strSentAccount));307+ entry.push_back(Pair("address", s.first));308+ entry.push_back(Pair("category", "send"));309+ entry.push_back(Pair("amount", ValueFromAmount(-s.second)));310+ entry.push_back(Pair("fee", ValueFromAmount(-nFee)));311+ if (fLong)312+ WalletTxToJSON(wtx, entry);313+ ret.push_back(entry);314+ }315+ }316+317+ // Received318+ if (listReceived.size() > 0 && wtx.GetDepthInMainChain() >= nMinDepth)319+ CRITICAL_BLOCK(cs_mapAddressBook)320+ {321+ foreach(const PAIRTYPE(string, int64)& r, listReceived)322 {323- Object entry;324- entry.push_back(Pair("category", "generate"));325- entry.push_back(Pair("amount", ValueFromAmount(nGenerated)));326- WalletTxToJSON(wtx, entry);327- ret.insert(make_pair(wtx.GetTxTime(), entry));328+ string account;329+ if (mapAddressBook.count(r.first))330+ account = mapAddressBook[r.first];331+ if (fAllAccounts || (account == strAccount))332+ {333+ Object entry;334+ entry.push_back(Pair("account", account));335+ entry.push_back(Pair("address", r.first));336+ entry.push_back(Pair("category", "receive"));337+ entry.push_back(Pair("amount", ValueFromAmount(r.second)));338+ if (fLong)339+ WalletTxToJSON(wtx, entry);340+ ret.push_back(entry);341+ }342 }343-344- // Sent345- if (nSent != 0 || nFee != 0)346- {347- Object entry;348- entry.push_back(Pair("category", "send"));349- entry.push_back(Pair("amount", ValueFromAmount(-nSent)));350- entry.push_back(Pair("fee", ValueFromAmount(-nFee)));351- WalletTxToJSON(wtx, entry);352- ret.insert(make_pair(wtx.GetTxTime(), entry));353- }354-355- // Received356- if (nReceived != 0 && wtx.GetDepthInMainChain() >= nMinDepth)357- {358- Object entry;359- entry.push_back(Pair("category", "receive"));360- entry.push_back(Pair("amount", ValueFromAmount(nReceived)));361- WalletTxToJSON(wtx, entry);362- ret.insert(make_pair(wtx.GetTxTime(), entry));363- }364- }365-366- // Internal accounting entries367- list<CAccountingEntry> acentries;368- walletdb.ListAccountCreditDebit(strAccount, acentries);369- foreach (const CAccountingEntry& acentry, acentries)370- {371- Object entry;372- entry.push_back(Pair("category", "move"));373- entry.push_back(Pair("amount", ValueFromAmount(acentry.nCreditDebit)));374- entry.push_back(Pair("otheraccount", acentry.strOtherAccount));375- ret.insert(make_pair(acentry.nTime, entry));376- }377+ }378+379+}380+381+void AcentryToJSON(const CAccountingEntry& acentry, const string& strAccount, Array& ret)382+{383+ bool fAllAccounts = (strAccount == string("*"));384+385+ if (fAllAccounts || acentry.strAccount == strAccount)386+ {387+ Object entry;388+ entry.push_back(Pair("account", acentry.strAccount));389+ entry.push_back(Pair("category", "move"));390+ entry.push_back(Pair("time", (boost::int64_t)acentry.nTime));391+ entry.push_back(Pair("amount", ValueFromAmount(acentry.nCreditDebit)));392+ entry.push_back(Pair("otheraccount", acentry.strOtherAccount));393+ entry.push_back(Pair("comment", acentry.strComment));394+ ret.push_back(entry);395 }396 }397 398 Value listtransactions(const Array& params, bool fHelp)399 {400- if (fHelp || params.size() < 1 || params.size() > 2)401- throw runtime_error(402- "listtransactions <account> [count=10]\n"403+ if (fHelp || params.size() > 2)404+ throw runtime_error(405+ "listtransactions [account] [count=10]\n"406 "Returns up to [count] most recent transactions for account <account>.");407 408- string strAccount = params[0].get_str();409+ string strAccount = "*";410+ if (params.size() > 0)411+ strAccount = params[0].get_str();412 int nCount = 10;413 if (params.size() > 1)414 nCount = params[1].get_int();415 416+ Array ret;417 CWalletDB walletdb;418- multimap<int64, Object> mapByTime; // keys are transaction time419- ListAccountTransactions(walletdb, strAccount, 0, mapByTime);420-421- // Return only last nCount items:422- int nToErase = mapByTime.size()-nCount;423- if (nToErase > 0)424- {425- multimap<int64, Object>::iterator end = mapByTime.begin();426- std::advance(end, nToErase);427- mapByTime.erase(mapByTime.begin(), end);428- }429-430- Array ret;431- foreach(const PAIRTYPE(int64, Object)& item, mapByTime)432- ret.push_back(item.second);433+434+ CRITICAL_BLOCK(cs_mapWallet)435+ {436+ // Firs: get all CWalletTx and CAccountingEntry into a sorted-by-time multimap:437+ typedef pair<CWalletTx*, CAccountingEntry*> TxPair;438+ typedef multimap<int64, TxPair > TxItems;439+ TxItems txByTime;440+441+ for (map<uint256, CWalletTx>::iterator it = mapWallet.begin(); it != mapWallet.end(); ++it)442+ {443+ CWalletTx* wtx = &((*it).second);444+ txByTime.insert(make_pair(wtx->GetTxTime(), TxPair(wtx, (CAccountingEntry*)0)));445+ }446+ list<CAccountingEntry> acentries;447+ walletdb.ListAccountCreditDebit(strAccount, acentries);448+ foreach(CAccountingEntry& entry, acentries)449+ {450+ txByTime.insert(make_pair(entry.nTime, TxPair((CWalletTx*)0, &entry)));451+ }452+453+ // Now: iterate backwards until we have nCount items to return:454+ for (TxItems::reverse_iterator it = txByTime.rbegin(); it != txByTime.rend(); ++it)455+ {456+ CWalletTx *const pwtx = (*it).second.first;457+ if (pwtx != 0)458+ ListTransactions(*pwtx, strAccount, 0, true, ret);459+ CAccountingEntry *const pacentry = (*it).second.second;460+ if (pacentry != 0)461+ AcentryToJSON(*pacentry, strAccount, ret);462+463+ if (ret.size() >= nCount) break;464+ }465+ // ret is now newest to oldest466+ }467+ 468+ // Make sure we return only last nCount items (sends-to-self might give us an extra):469+ if (ret.size() > nCount)470+ {471+ Array::iterator last = ret.begin();472+ std::advance(last, nCount);473+ ret.erase(last, ret.end());474+ }475+ std::reverse(ret.begin(), ret.end()); // oldest to newest476+477+ return ret;478+}479+480+Value listaccounts(const Array& params, bool fHelp)481+{482+ if (fHelp || params.size() > 1)483+ throw runtime_error(484+ "listaccounts [minconf=1]\n"485+ "Returns Object that has account names as keys, account balances as values.");486+487+ int nMinDepth = 1;488+ if (params.size() > 0)489+ nMinDepth = params[0].get_int();490+491+ map<string, int64> mapAccountBalances;492+ CRITICAL_BLOCK(cs_mapWallet)493+ CRITICAL_BLOCK(cs_mapAddressBook)494+ {495+ foreach(const PAIRTYPE(string, string)& entry, mapAddressBook)496+ mapAccountBalances[entry.second] = 0;497+498+ for (map<uint256, CWalletTx>::iterator it = mapWallet.begin(); it != mapWallet.end(); ++it)499+ {500+ const CWalletTx& wtx = (*it).second;501+ int64 nGenerated, nFee;502+ string strSentAccount;503+ list<pair<string, int64> > listReceived;504+ list<pair<string, int64> > listSent;505+ wtx.GetAmounts(nGenerated, listReceived, listSent, nFee, strSentAccount);506+ mapAccountBalances[strSentAccount] -= nFee;507+ foreach(const PAIRTYPE(string, int64)& s, listSent)508+ mapAccountBalances[strSentAccount] -= s.second;509+ if (wtx.GetDepthInMainChain() >= nMinDepth)510+ {511+ mapAccountBalances[""] += nGenerated;512+ foreach(const PAIRTYPE(string, int64)& r, listReceived)513+ if (mapAddressBook.count(r.first))514+ mapAccountBalances[mapAddressBook[r.first]] += r.second;515+ else516+ mapAccountBalances[""] += r.second;517+ }518+ }519+ }520+521+ list<CAccountingEntry> acentries;522+ CWalletDB().ListAccountCreditDebit("*", acentries);523+ foreach(const CAccountingEntry& entry, acentries)524+ mapAccountBalances[entry.strAccount] += entry.nCreditDebit;525+526+ Object ret;527+ foreach(const PAIRTYPE(string, int64)& accountBalance, mapAccountBalances) {528+ ret.push_back(Pair(accountBalance.first, ValueFromAmount(accountBalance.second)));529+ }530 return ret;531 }532 533@@ -957,7 +1118,7 @@534 CRITICAL_BLOCK(cs_mapWallet)535 {536 if (!mapWallet.count(hash))537- throw JSONRPCError(-5, "Invalid transaction id");538+ throw JSONRPCError(-5, "Invalid or non-wallet transaction id");539 const CWalletTx& wtx = mapWallet[hash];540 541 int64 nCredit = wtx.GetCredit();542@@ -968,7 +1129,12 @@543 entry.push_back(Pair("amount", ValueFromAmount(nNet - nFee)));544 if (wtx.IsFromMe())545 entry.push_back(Pair("fee", ValueFromAmount(nFee)));546+547 WalletTxToJSON(mapWallet[hash], entry);548+549+ Array details;550+ ListTransactions(mapWallet[hash], "*", 0, false, details);551+ entry.push_back(Pair("details", details));552 }553 554 return entry;555@@ -1175,6 +1341,7 @@556 make_pair("gettransaction", &gettransaction),557 make_pair("listtransactions", &listtransactions),558 make_pair("getwork", &getwork),559+ make_pair("listaccounts", &listaccounts),560 };561 map<string, rpcfn_type> mapCallTable(pCallTable, pCallTable + sizeof(pCallTable)/sizeof(pCallTable[0]));562 563@@ -1247,7 +1414,7 @@564 "Server: bitcoin-json-rpc\r\n"565 "WWW-Authenticate: Basic realm=\"jsonrpc\"\r\n"566 "Content-Type: text/html\r\n"567- "Content-Length: 311\r\n"568+ "Content-Length: 296\r\n"569 "\r\n"570 "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"\r\n"571 "\"http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd\">\r\n"572@@ -1421,6 +1588,17 @@573 return write_string(Value(reply), false) + "\n";574 }575 576+void ErrorReply(std::ostream& stream, const Object& objError, const Value& id)577+{578+ // Send error reply from json-rpc error object579+ int nStatus = 500;580+ int code = find_value(objError, "code").get_int();581+ if (code == -32600) nStatus = 400;582+ else if (code == -32601) nStatus = 404;583+ string strReply = JSONRPCReply(Value::null, objError, id);584+ stream << HTTPReply(nStatus, strReply) << std::flush;585+}586+587 bool ClientAllowed(const string& strAddress)588 {589 if (strAddress == asio::ip::address_v4::loopback().to_string())590@@ -1581,10 +1759,16 @@591 if (!ClientAllowed(peer.address().to_string()))592 continue;593 594- // Receive request595 map<string, string> mapHeaders;596 string strRequest;597- ReadHTTP(stream, mapHeaders, strRequest);598+599+ boost::thread api_caller(ReadHTTP, boost::ref(stream), boost::ref(mapHeaders), boost::ref(strRequest));600+ if (!api_caller.timed_join(boost::posix_time::seconds(GetArg("-rpctimeout", 30))))601+ { // Timed out:602+ acceptor.cancel();603+ printf("ThreadRPCServer ReadHTTP timeout\n");604+ continue;605+ }606 607 // Check authorization608 if (mapHeaders.count("Authorization") == 0)609@@ -1656,26 +1840,16 @@610 }611 catch (std::exception& e)612 {613- // Send error reply from method614- string strReply = JSONRPCReply(Value::null, JSONRPCError(-1, e.what()), id);615- stream << HTTPReply(500, strReply) << std::flush;616+ ErrorReply(stream, JSONRPCError(-1, e.what()), id);617 }618 }619 catch (Object& objError)620 {621- // Send error reply from json-rpc error object622- int nStatus = 500;623- int code = find_value(objError, "code").get_int();624- if (code == -32600) nStatus = 400;625- else if (code == -32601) nStatus = 404;626- string strReply = JSONRPCReply(Value::null, objError, id);627- stream << HTTPReply(nStatus, strReply) << std::flush;628+ ErrorReply(stream, objError, id);629 }630 catch (std::exception& e)631 {632- // Send error reply from other json-rpc parsing errors633- string strReply = JSONRPCReply(Value::null, JSONRPCError(-32700, e.what()), id);634- stream << HTTPReply(500, strReply) << std::flush;635+ ErrorReply(stream, JSONRPCError(-32700, e.what()), id);636 }637 }638 }639@@ -1812,6 +1986,7 @@640 if (strMethod == "sendfrom" && n > 2) ConvertTo<double>(params[2]);641 if (strMethod == "sendfrom" && n > 3) ConvertTo<boost::int64_t>(params[3]);642 if (strMethod == "listtransactions" && n > 1) ConvertTo<boost::int64_t>(params[1]);643+ if (strMethod == "listaccounts" && n > 0) ConvertTo<boost::int64_t>(params[0]);644 645 // Execute646 Object reply = CallRPC(strMethod, params);
serialize.h (modified)
1--- r202/serialize.h2+++ v0.3.20/serialize.h3@@ -25,8 +25,9 @@4 class CAutoFile;5 static const unsigned int MAX_SIZE = 0x02000000;6 7-static const int VERSION = 31901;8+static const int VERSION = 32001;9 static const char* pszSubVer = "";10+static const bool VERSION_IS_BETA = true;11 12 13 14@@ -762,6 +763,8 @@15 typedef typename base::value_type value_type;16 secure_allocator() throw() {}17 secure_allocator(const secure_allocator& a) throw() : base(a) {}18+ template <typename U>19+ secure_allocator(const secure_allocator<U>& a) throw() : base(a) {}20 ~secure_allocator() throw() {}21 template<typename _Other> struct rebind22 { typedef secure_allocator<_Other> other; };
setup.nsi (modified)
1--- r202/setup.nsi2+++ v0.3.20/setup.nsi3@@ -1,13 +1,10 @@4-# Auto-generated by EclipseNSIS Script Wizard5-# 3.10.2009 19:00:286-7 Name Bitcoin8 9 RequestExecutionLevel highest10 11 # General Symbol Definitions12 !define REGKEY "SOFTWARE\$(^Name)"13-!define VERSION 0.3.1914+!define VERSION 0.3.2015 !define COMPANY "Bitcoin project"16 !define URL http://www.bitcoin.org/17 18@@ -42,12 +39,12 @@19 !insertmacro MUI_LANGUAGE English20 21 # Installer attributes22-OutFile bitcoin-0.3.19-win32-setup.exe23+OutFile bitcoin-0.3.20-win32-setup.exe24 InstallDir $PROGRAMFILES\Bitcoin25 CRCCheck on26 XPStyle on27 ShowInstDetails show28-VIProductVersion 0.3.19.029+VIProductVersion 0.3.20.030 VIAddVersionKey ProductName Bitcoin31 VIAddVersionKey ProductVersion "${VERSION}"32 VIAddVersionKey CompanyName "${COMPANY}"33@@ -64,7 +61,6 @@34 SetOverwrite on35 File bitcoin.exe36 File libeay32.dll37- File mingwm10.dll38 File license.txt39 File readme.txt40 SetOutPath $INSTDIR\daemon41@@ -113,7 +109,6 @@42 Section /o -un.Main UNSEC000043 Delete /REBOOTOK $INSTDIR\bitcoin.exe44 Delete /REBOOTOK $INSTDIR\libeay32.dll45- Delete /REBOOTOK $INSTDIR\mingwm10.dll46 Delete /REBOOTOK $INSTDIR\license.txt47 Delete /REBOOTOK $INSTDIR\readme.txt48 RMDir /r /REBOOTOK $INSTDIR\daemon
ui.cpp (modified)
1--- r202/ui.cpp2+++ v0.3.20/ui.cpp3@@ -746,6 +746,12 @@4 strDescription += " - ";5 strDescription += mapValue["message"];6 }7+ else if (!mapValue["comment"].empty())8+ {9+ if (!strDescription.empty())10+ strDescription += " - ";11+ strDescription += mapValue["comment"];12+ }13 14 int64 nValue = txout.nValue;15 if (nTxFee > 0)16@@ -1405,6 +1411,8 @@17 //18 if (!wtx.mapValue["message"].empty())19 strHTML += string() + "<br><b>" + _("Message:") + "</b><br>" + HtmlEscape(wtx.mapValue["message"], true) + "<br>";20+ if (!wtx.mapValue["comment"].empty())21+ strHTML += string() + "<br><b>" + _("Comment:") + "</b><br>" + HtmlEscape(wtx.mapValue["comment"], true) + "<br>";22 23 if (wtx.IsCoinBase())24 strHTML += string() + "<br>" + _("Generated coins must wait 120 blocks before they can be spent. When you generated this block, it was broadcast to the network to be added to the block chain. If it fails to get into the chain, it will change to \"not accepted\" and not be spendable. This may occasionally happen if another node generates a block within a few seconds of yours.") + "<br>";25@@ -1458,8 +1466,7 @@26 27 void CTxDetailsDialog::OnButtonOK(wxCommandEvent& event)28 {29- Close();30- //Destroy();31+ EndModal(false);32 }33 34 35@@ -1728,12 +1735,12 @@36 void COptionsDialog::OnButtonOK(wxCommandEvent& event)37 {38 OnButtonApply(event);39- Close();40+ EndModal(false);41 }42 43 void COptionsDialog::OnButtonCancel(wxCommandEvent& event)44 {45- Close();46+ EndModal(false);47 }48 49 void COptionsDialog::OnButtonApply(wxCommandEvent& event)50@@ -1820,7 +1827,7 @@51 52 void CAboutDialog::OnButtonOK(wxCommandEvent& event)53 {54- Close();55+ EndModal(false);56 }57 58
uibase.cpp (modified)
1--- r202/uibase.cpp2+++ v0.3.20/uibase.cpp3@@ -61,7 +61,6 @@4 m_toolBar->Realize();5 6 m_statusBar = this->CreateStatusBar( 1, wxST_SIZEGRIP, wxID_ANY );7- m_statusBar->SetBackgroundColour( wxColour( 240, 240, 240 ) );8 9 wxBoxSizer* bSizer2;10 bSizer2 = new wxBoxSizer( wxVERTICAL );
util.cpp (modified)
1--- r202/util.cpp2+++ v0.3.20/util.cpp3@@ -17,7 +17,7 @@4 bool fCommandLine = false;5 string strMiscWarning;6 bool fTestNet = false;7-8+bool fNoListen = false;9 10 11 12@@ -165,7 +165,7 @@13 GetDataDir(pszFile);14 strlcat(pszFile, "/debug.log", sizeof(pszFile));15 fileout = fopen(pszFile, "a");16- setbuf(fileout, NULL); // unbuffered17+ if (fileout) setbuf(fileout, NULL); // unbuffered18 }19 if (fileout)20 {21@@ -810,19 +810,24 @@22 else23 {24 nTimeOffset = 0;25- // If nobody else has the same time as us, give a warning26- bool fMatch = false;27- foreach(int64 nOffset, vTimeOffsets)28- if (nOffset != 0 && abs64(nOffset) < 5 * 60)29- fMatch = true;30+31 static bool fDone;32- if (!fMatch && !fDone)33+ if (!fDone)34 {35- fDone = true;36- string strMessage = _("Warning: Please check that your computer's date and time are correct. If your clock is wrong Bitcoin will not work properly.");37- strMiscWarning = strMessage;38- printf("*** %s\n", strMessage.c_str());39- boost::thread(boost::bind(ThreadSafeMessageBox, strMessage+" ", string("Bitcoin"), wxOK | wxICON_EXCLAMATION, (wxWindow*)NULL, -1, -1));40+ // If nobody has a time different than ours but within 5 minutes of ours, give a warning41+ bool fMatch = false;42+ foreach(int64 nOffset, vTimeOffsets)43+ if (nOffset != 0 && abs64(nOffset) < 5 * 60)44+ fMatch = true;45+46+ if (!fMatch)47+ {48+ fDone = true;49+ string strMessage = _("Warning: Please check that your computer's date and time are correct. If your clock is wrong Bitcoin will not work properly.");50+ strMiscWarning = strMessage;51+ printf("*** %s\n", strMessage.c_str());52+ boost::thread(boost::bind(ThreadSafeMessageBox, strMessage+" ", string("Bitcoin"), wxOK | wxICON_EXCLAMATION, (wxWindow*)NULL, -1, -1));53+ }54 }55 }56 foreach(int64 n, vTimeOffsets)
util.h (modified)
1--- r202/util.h2+++ v0.3.20/util.h3@@ -146,6 +146,7 @@4 extern bool fCommandLine;5 extern string strMiscWarning;6 extern bool fTestNet;7+extern bool fNoListen;8 9 void RandAddSeed();10 void RandAddSeedPerfmon();
