What changed
Bitcoin v0.3.14 → v0.3.15
Release commit message: -- version 0.3.15 release
Previous diff: v0.3.13 → v0.3.14. Next: v0.3.15 → v0.3.17.
- build-msw.txt modified · +2 −3
- db.cpp modified · +14 −5
- db.h modified · +2 −0
- headers.h modified · +1 −0
- init.cpp modified · +2 −1
- irc.cpp modified · +25 −12
- main.cpp modified · +186 −34
- main.h modified · +26 −4
- net.cpp modified · +3 −21
- net.h modified · +7 −13
- rpc.cpp modified · +21 −6
- serialize.h modified · +1 −1
- setup.nsi modified · +3 −3
- ui.cpp modified · +70 −61
build-msw.txt (modified)
1--- v0.3.14/build-msw.txt2+++ v0.3.15/build-msw.txt3@@ -63,8 +63,7 @@4 5 OpenSSL6 -------7-Bitcoin does not use any encryption. If you want to do a no-everything8-build of OpenSSL to exclude encryption routines, a few patches are required.9+If you want to exclude unused optional algorithms, a few patches are required.10 (instructions for OpenSSL v0.9.8k)11 12 Edit engines\e_gmp.c and engines\e_capi.c and add this #ifndef around13@@ -88,7 +87,7 @@14 cd \openssl15 ms\mingw32.bat16 17-If you want to use it with MSVC, generate the .lib file18+If you're using MSVC, generate the .lib file19 lib /machine:i386 /def:ms\libeay32.def /out:out\libeay32.lib20 21
db.cpp (modified)
1--- v0.3.14/db.cpp2+++ v0.3.15/db.cpp3@@ -503,6 +503,11 @@4 return Write(make_pair(string("addr"), addr.GetKey()), addr);5 }6 7+bool CAddrDB::EraseAddress(const CAddress& addr)8+{9+ return Erase(make_pair(string("addr"), addr.GetKey()));10+}11+12 bool CAddrDB::LoadAddresses()13 {14 CRITICAL_BLOCK(cs_mapAddresses)15@@ -554,11 +559,6 @@16 pcursor->close();17 18 printf("Loaded %d addresses\n", mapAddresses.size());19-20- // Fix for possible bug that manifests in mapAddresses.count in irc.cpp,21- // just need to call count here and it doesn't happen there. The bug was the22- // pack pragma in irc.cpp and has been fixed, but I'm not in a hurry to delete this.23- mapAddresses.count(vector<unsigned char>(18));24 }25 26 return true;27@@ -909,3 +909,12 @@28 return keypool.vchPubKey;29 }30 31+int64 CWalletDB::GetOldestKeyPoolTime()32+{33+ int64 nIndex = 0;34+ CKeyPool keypool;35+ ReserveKeyFromKeyPool(nIndex, keypool);36+ ReturnKey(nIndex);37+ return keypool.nTime;38+}39+
db.h (modified)
1--- v0.3.14/db.h2+++ v0.3.15/db.h3@@ -298,6 +298,7 @@4 void operator=(const CAddrDB&);5 public:6 bool WriteAddress(const CAddress& addr);7+ bool EraseAddress(const CAddress& addr);8 bool LoadAddresses();9 };10 11@@ -432,6 +433,7 @@12 friend class CReserveKey;13 public:14 vector<unsigned char> GetKeyFromKeyPool();15+ int64 GetOldestKeyPoolTime();16 };17 18 bool LoadWallet(bool& fFirstRunRet);
headers.h (modified)
1--- v0.3.14/headers.h2+++ v0.3.15/headers.h3@@ -43,6 +43,7 @@4 #include <db_cxx.h>5 #include <stdio.h>6 #include <stdlib.h>7+#include <time.h>8 #include <math.h>9 #include <limits.h>10 #include <float.h>
init.cpp (modified)
1--- v0.3.14/init.cpp2+++ v0.3.15/init.cpp3@@ -173,6 +173,7 @@4 " -proxy=<ip:port> \t " + _("Connect through socks4 proxy\n") +5 " -addnode=<ip> \t " + _("Add a node to connect to\n") +6 " -connect=<ip> \t\t " + _("Connect only to the specified node\n") +7+ " -paytxfee=<amt> \t " + _("Fee per KB to add to transactions you send\n") +8 " -server \t\t " + _("Accept command line and JSON-RPC commands\n") +9 " -daemon \t\t " + _("Run in the background as a daemon and accept commands\n") +10 " -testnet \t\t " + _("Use the test network\n") +11@@ -413,7 +414,7 @@12 wxMessageBox(_("Invalid amount for -paytxfee=<amount>"), "Bitcoin");13 return false;14 }15- if (nTransactionFee > 1 * COIN)16+ if (nTransactionFee > 0.25 * COIN)17 wxMessageBox(_("Warning: -paytxfee is set very high. This is the transaction fee you will pay if you send a transaction."), "Bitcoin", wxOK | wxICON_EXCLAMATION);18 }19
irc.cpp (modified)
1--- v0.3.14/irc.cpp2+++ v0.3.15/irc.cpp3@@ -84,18 +84,31 @@4 }5 else if (nBytes <= 0)6 {7+ if (fShutdown)8+ return false;9+ if (nBytes < 0)10+ {11+ int nErr = WSAGetLastError();12+ if (nErr == WSAEMSGSIZE)13+ continue;14+ if (nErr == WSAEWOULDBLOCK || nErr == WSAEINTR || nErr == WSAEINPROGRESS)15+ {16+ Sleep(10);17+ continue;18+ }19+ }20 if (!strLine.empty())21 return true;22- // socket closed23- printf("IRC socket closed\n");24- return false;25- }26- else27- {28- // socket error29- int nErr = WSAGetLastError();30- if (nErr != WSAEMSGSIZE && nErr != WSAEINTR && nErr != WSAEINPROGRESS)31- {32+ if (nBytes == 0)33+ {34+ // socket closed35+ printf("IRC socket closed\n");36+ return false;37+ }38+ else39+ {40+ // socket error41+ int nErr = WSAGetLastError();42 printf("IRC recv failed: %d\n", nErr);43 return false;44 }45@@ -293,8 +306,8 @@46 CAddress addr;47 if (DecodeAddress(pszName, addr))48 {49- addr.nTime = GetAdjustedTime() - 51 * 60;50- if (AddAddress(addr))51+ addr.nTime = GetAdjustedTime();52+ if (AddAddress(addr, 51 * 60))53 printf("IRC got new address\n");54 nGotIRCAddresses++;55 }
main.cpp (modified)
1--- v0.3.14/main.cpp2+++ v0.3.15/main.cpp3@@ -276,6 +276,34 @@4 //5 // CTransaction6 //7+8+bool CTransaction::ReadFromDisk(CTxDB& txdb, COutPoint prevout, CTxIndex& txindexRet)9+{10+ SetNull();11+ if (!txdb.ReadTxIndex(prevout.hash, txindexRet))12+ return false;13+ if (!ReadFromDisk(txindexRet.pos))14+ return false;15+ if (prevout.n >= vout.size())16+ {17+ SetNull();18+ return false;19+ }20+ return true;21+}22+23+bool CTransaction::ReadFromDisk(CTxDB& txdb, COutPoint prevout)24+{25+ CTxIndex txindex;26+ return ReadFromDisk(txdb, prevout, txindex);27+}28+29+bool CTransaction::ReadFromDisk(COutPoint prevout)30+{31+ CTxDB txdb("r");32+ CTxIndex txindex;33+ return ReadFromDisk(txdb, prevout, txindex);34+}35 36 bool CTxIn::IsMine() const37 {38@@ -929,7 +957,7 @@39 40 bool IsInitialBlockDownload()41 {42- if (pindexBest == NULL)43+ if (pindexBest == NULL || (!fTestNet && nBestHeight < 74000))44 return true;45 static int64 nLastUpdate;46 static CBlockIndex* pindexLastBest;47@@ -2172,6 +2200,24 @@48 if (pfrom->nVersion < 209)49 pfrom->vRecv.SetVersion(min(pfrom->nVersion, VERSION));50 51+ if (!pfrom->fInbound)52+ {53+ // Advertise our address54+ if (addrLocalHost.IsRoutable() && !fUseProxy)55+ {56+ CAddress addr(addrLocalHost);57+ addr.nTime = GetAdjustedTime();58+ pfrom->PushAddress(addr);59+ }60+61+ // Get recent addresses62+ if (pfrom->nVersion >= 31402 || mapAddresses.size() < 1000)63+ {64+ pfrom->PushMessage("getaddr");65+ pfrom->fGetAddr = true;66+ }67+ }68+69 // Ask the first connected node for block updates70 static int nAskedForBlocks;71 if (!pfrom->fClient && (nAskedForBlocks < 1 || vNodes.size() <= 1))72@@ -2208,14 +2254,18 @@73 {74 vector<CAddress> vAddr;75 vRecv >> vAddr;76- if (pfrom->nVersion < 200) // don't want addresses from 0.1.577+78+ // Don't want addr from older versions unless seeding79+ if (pfrom->nVersion < 209)80 return true;81- if (pfrom->nVersion < 209 && mapAddresses.size() > 1000) // don't want addr from 0.2.0 unless seeding82+ if (pfrom->nVersion < 31402 && mapAddresses.size() > 1000)83 return true;84 if (vAddr.size() > 1000)85 return error("message addr size() = %d", vAddr.size());86 87 // Store the new addresses88+ int64 nNow = GetAdjustedTime();89+ int64 nSince = nNow - 10 * 60;90 foreach(CAddress& addr, vAddr)91 {92 if (fShutdown)93@@ -2223,12 +2273,11 @@94 // ignore IPv6 for now, since it isn't implemented anyway95 if (!addr.IsIPv4())96 continue;97- addr.nTime = GetAdjustedTime() - 2 * 60 * 60;98- if (pfrom->fGetAddr || vAddr.size() > 10)99- addr.nTime -= 5 * 24 * 60 * 60;100- AddAddress(addr);101+ if (addr.nTime <= 100000000 || addr.nTime > nNow + 10 * 60)102+ addr.nTime = nNow - 5 * 24 * 60 * 60;103+ AddAddress(addr, 2 * 60 * 60);104 pfrom->AddAddressKnown(addr);105- if (!pfrom->fGetAddr && vAddr.size() <= 10 && addr.IsRoutable())106+ if (addr.nTime > nSince && !pfrom->fGetAddr && vAddr.size() <= 10 && addr.IsRoutable())107 {108 // Relay to a limited number of other nodes109 CRITICAL_BLOCK(cs_vNodes)110@@ -2243,6 +2292,8 @@111 multimap<uint256, CNode*> mapMix;112 foreach(CNode* pnode, vNodes)113 {114+ if (pnode->nVersion < 31402)115+ continue;116 unsigned int nPointer;117 memcpy(&nPointer, &pnode, sizeof(nPointer));118 uint256 hashKey = hashRand ^ nPointer;119@@ -2610,9 +2661,12 @@120 if (pto->nLastSend && GetTime() - pto->nLastSend > 30 * 60 && pto->vSend.empty())121 pto->PushMessage("ping");122 123+ // Resend wallet transactions that haven't gotten in a block yet124+ ResendWalletTransactions();125+126 // Address refresh broadcast127 static int64 nLastRebroadcast;128- if (GetTime() - nLastRebroadcast > 24 * 60 * 60) // every 24 hours129+ if (GetTime() - nLastRebroadcast > 24 * 60 * 60)130 {131 nLastRebroadcast = GetTime();132 CRITICAL_BLOCK(cs_vNodes)133@@ -2624,13 +2678,42 @@134 135 // Rebroadcast our address136 if (addrLocalHost.IsRoutable() && !fUseProxy)137- pnode->PushAddress(addrLocalHost);138+ {139+ CAddress addr(addrLocalHost);140+ addr.nTime = GetAdjustedTime();141+ pnode->PushAddress(addr);142+ }143 }144 }145 }146 147- // Resend wallet transactions that haven't gotten in a block yet148- ResendWalletTransactions();149+ // Clear out old addresses periodically so it's not too much work at once150+ static int64 nLastClear;151+ if (nLastClear == 0)152+ nLastClear = GetTime();153+ if (GetTime() - nLastClear > 10 * 60 && vNodes.size() >= 3)154+ {155+ nLastClear = GetTime();156+ CRITICAL_BLOCK(cs_mapAddresses)157+ {158+ CAddrDB addrdb;159+ int64 nSince = GetAdjustedTime() - 14 * 24 * 60 * 60;160+ for (map<vector<unsigned char>, CAddress>::iterator mi = mapAddresses.begin();161+ mi != mapAddresses.end();)162+ {163+ const CAddress& addr = (*mi).second;164+ if (addr.nTime < nSince)165+ {166+ if (mapAddresses.size() < 1000 || GetTime() > nLastClear + 20)167+ break;168+ addrdb.EraseAddress(addr);169+ mapAddresses.erase(mi++);170+ }171+ else172+ mi++;173+ }174+ }175+ }176 177 178 //179@@ -2827,7 +2910,7 @@180 "mov %2, %%eax; " // in into eax181 "cpuid;"182 "mov %%eax, %0;" // eax into a183- "mov %%ecx, %1;" // eax into c184+ "mov %%ecx, %1;" // ecx into c185 :"=r"(a),"=r"(c) /* output */186 :"r"(in) /* input */187 :"%eax","%ecx" /* clobbered register */188@@ -3013,42 +3096,97 @@189 CRITICAL_BLOCK(cs_mapTransactions)190 {191 CTxDB txdb("r");192+193+ // Priority order to process transactions194+ multimap<double, CTransaction*> mapPriority;195+ for (map<uint256, CTransaction>::iterator mi = mapTransactions.begin(); mi != mapTransactions.end(); ++mi)196+ {197+ CTransaction& tx = (*mi).second;198+ if (tx.IsCoinBase() || !tx.IsFinal())199+ continue;200+201+ double dPriority = 0;202+ foreach(const CTxIn& txin, tx.vin)203+ {204+ // Read prev transaction205+ CTransaction txPrev;206+ CTxIndex txindex;207+ if (!txPrev.ReadFromDisk(txdb, txin.prevout, txindex))208+ continue;209+ int64 nValueIn = txPrev.vout[txin.prevout.n].nValue;210+211+ // Read block header212+ int nConf = 0;213+ CBlock block;214+ if (block.ReadFromDisk(txindex.pos.nFile, txindex.pos.nBlockPos, false))215+ {216+ map<uint256, CBlockIndex*>::iterator it = mapBlockIndex.find(block.GetHash());217+ if (it != mapBlockIndex.end())218+ {219+ CBlockIndex* pindex = (*it).second;220+ if (pindex->IsInMainChain())221+ nConf = 1 + nBestHeight - pindex->nHeight;222+ }223+ }224+225+ dPriority += (double)nValueIn * nConf;226+227+ if (fDebug && mapArgs.count("-printpriority"))228+ printf("priority nValueIn=%-12I64d nConf=%-5d dPriority=%-20.1f\n", nValueIn, nConf, dPriority);229+ }230+231+ // Priority is sum(valuein * age) / txsize232+ dPriority /= ::GetSerializeSize(tx, SER_NETWORK);233+234+ mapPriority.insert(make_pair(-dPriority, &(*mi).second));235+236+ if (fDebug && mapArgs.count("-printpriority"))237+ printf("priority %-20.1f %s\n%s\n", dPriority, tx.GetHash().ToString().substr(0,10).c_str(), tx.ToString().c_str());238+ }239+240+ // Collect transactions into block241 map<uint256, CTxIndex> mapTestPool;242- vector<char> vfAlreadyAdded(mapTransactions.size());243 uint64 nBlockSize = 1000;244 int nBlockSigOps = 100;245 bool fFoundSomething = true;246 while (fFoundSomething)247 {248 fFoundSomething = false;249- unsigned int n = 0;250- for (map<uint256, CTransaction>::iterator mi = mapTransactions.begin(); mi != mapTransactions.end(); ++mi, ++n)251+ for (multimap<double, CTransaction*>::iterator mi = mapPriority.begin(); mi != mapPriority.end();)252 {253- if (vfAlreadyAdded[n])254- continue;255- CTransaction& tx = (*mi).second;256- if (tx.IsCoinBase() || !tx.IsFinal())257- continue;258+ CTransaction& tx = *(*mi).second;259 unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK);260 if (nBlockSize + nTxSize >= MAX_BLOCK_SIZE_GEN)261+ {262+ mapPriority.erase(mi++);263 continue;264+ }265 int nTxSigOps = tx.GetSigOpCount();266 if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS)267+ {268+ mapPriority.erase(mi++);269 continue;270+ }271 272 // Transaction fee based on block size273 int64 nMinFee = tx.GetMinFee(nBlockSize);274 275+ // Connecting can fail due to dependency on other memory pool transactions276+ // that aren't in the block yet, so keep trying in later passes277 map<uint256, CTxIndex> mapTestPoolTmp(mapTestPool);278 if (!tx.ConnectInputs(txdb, mapTestPoolTmp, CDiskTxPos(1,1,1), pindexPrev, nFees, false, true, nMinFee))279+ {280+ mi++;281 continue;282+ }283 swap(mapTestPool, mapTestPoolTmp);284 285+ // Added286 pblock->vtx.push_back(tx);287 nBlockSize += nTxSize;288 nBlockSigOps += nTxSigOps;289- vfAlreadyAdded[n] = true;290 fFoundSomething = true;291+ mapPriority.erase(mi++);292 }293 }294 }295@@ -3262,7 +3400,7 @@296 }297 298 299-bool SelectCoins(int64 nTargetValue, set<CWalletTx*>& setCoinsRet)300+bool SelectCoinsMinConf(int64 nTargetValue, int nConfMine, int nConfTheirs, set<CWalletTx*>& setCoinsRet)301 {302 setCoinsRet.clear();303 304@@ -3284,6 +3422,11 @@305 {306 if (!pcoin->IsFinal() || pcoin->fSpent || !pcoin->IsConfirmed())307 continue;308+309+ int nDepth = pcoin->GetDepthInMainChain();310+ if (nDepth < (pcoin->IsFromMe() ? nConfMine : nConfTheirs))311+ continue;312+313 int64 n = pcoin->GetCredit();314 if (n <= 0)315 continue;316@@ -3368,19 +3511,25 @@317 return true;318 }319 320-321-322-323-bool CreateTransaction(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew, CReserveKey& reservekey, int64& nFeeRequiredRet)324-{325- nFeeRequiredRet = 0;326+bool SelectCoins(int64 nTargetValue, set<CWalletTx*>& setCoinsRet)327+{328+ return (SelectCoinsMinConf(nTargetValue, 1, 6, setCoinsRet) ||329+ SelectCoinsMinConf(nTargetValue, 1, 1, setCoinsRet) ||330+ SelectCoinsMinConf(nTargetValue, 0, 1, setCoinsRet));331+}332+333+334+335+336+bool CreateTransaction(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew, CReserveKey& reservekey, int64& nFeeRet)337+{338 CRITICAL_BLOCK(cs_main)339 {340 // txdb must be opened before the mapWallet lock341 CTxDB txdb("r");342 CRITICAL_BLOCK(cs_mapWallet)343 {344- int64 nFee = nTransactionFee;345+ nFeeRet = nTransactionFee;346 loop347 {348 wtxNew.vin.clear();349@@ -3389,7 +3538,7 @@350 if (nValue < 0)351 return false;352 int64 nValueOut = nValue;353- int64 nTotalValue = nValue + nFee;354+ int64 nTotalValue = nValue + nFeeRet;355 356 // Choose coins to use357 set<CWalletTx*> setCoins;358@@ -3449,13 +3598,16 @@359 return false;360 361 // Limit size362- if (::GetSerializeSize(*(CTransaction*)&wtxNew, SER_NETWORK) >= MAX_BLOCK_SIZE_GEN/5)363+ unsigned int nBytes = ::GetSerializeSize(*(CTransaction*)&wtxNew, SER_NETWORK);364+ if (nBytes >= MAX_BLOCK_SIZE_GEN/5)365 return false;366 367 // Check that enough fee is included368- if (nFee < wtxNew.GetMinFee())369+ int64 nPayFee = nTransactionFee * (1 + (int64)nBytes / 1000);370+ int64 nMinFee = wtxNew.GetMinFee();371+ if (nFeeRet < max(nPayFee, nMinFee))372 {373- nFee = nFeeRequiredRet = wtxNew.GetMinFee();374+ nFeeRet = max(nPayFee, nMinFee);375 continue;376 }377
main.h (modified)
1--- v0.3.14/main.h2+++ v0.3.15/main.h3@@ -76,7 +76,7 @@4 bool ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv);5 bool SendMessages(CNode* pto, bool fSendTrickle);6 int64 GetBalance();7-bool CreateTransaction(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew, CReserveKey& reservekey, int64& nFeeRequiredRet);8+bool CreateTransaction(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew, CReserveKey& reservekey, int64& nFeeRet);9 bool CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey);10 bool BroadcastTransaction(CWalletTx& wtxNew);11 string SendMoney(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew, bool fAskFee=false);12@@ -487,6 +487,11 @@13 return false;14 }15 16+ bool IsFromMe() const17+ {18+ return (GetDebit() > 0);19+ }20+21 int64 GetDebit() const22 {23 int64 nDebit = 0;24@@ -579,7 +584,6 @@25 }26 return true;27 }28-29 30 friend bool operator==(const CTransaction& a, const CTransaction& b)31 {32@@ -617,6 +621,9 @@33 }34 35 36+ bool ReadFromDisk(CTxDB& txdb, COutPoint prevout, CTxIndex& txindexRet);37+ bool ReadFromDisk(CTxDB& txdb, COutPoint prevout);38+ bool ReadFromDisk(COutPoint prevout);39 bool DisconnectInputs(CTxDB& txdb);40 bool ConnectInputs(CTxDB& txdb, map<uint256, CTxIndex>& mapTestPool, CDiskTxPos posThisTx,41 CBlockIndex* pindexBlock, int64& nFees, bool fBlock, bool fMiner, int64 nMinFee=0);42@@ -787,8 +794,23 @@43 return nCreditCached;44 }45 46+ bool IsFromMe() const47+ {48+ return (GetDebit() > 0);49+ }50+51 bool IsConfirmed() const52 {53+ // Quick answer in most cases54+ if (!IsFinal())55+ return false;56+ if (GetDepthInMainChain() >= 1)57+ return true;58+ if (!IsFromMe()) // using wtx's cached debit59+ return false;60+61+ // If no confirmations but it's from us, we can still62+ // consider it confirmed if all dependencies are confirmed63 map<uint256, const CMerkleTx*> mapPrev;64 vector<const CMerkleTx*> vWorkQueue;65 vWorkQueue.reserve(vtxPrev.size()+1);66@@ -801,7 +823,7 @@67 return false;68 if (ptx->GetDepthInMainChain() >= 1)69 return true;70- if (ptx->GetDebit() <= 0)71+ if (!ptx->IsFromMe())72 return false;73 74 if (mapPrev.empty())75@@ -1654,7 +1676,7 @@76 bool Cancels(const CAlert& alert) const77 {78 if (!IsInEffect())79- false;80+ return false; // this was a no-op before 3140381 return (alert.nID <= nCancel || setCancel.count(alert.nID));82 }83
net.cpp (modified)
1--- v0.3.14/net.cpp2+++ v0.3.15/net.cpp3@@ -144,7 +144,7 @@4 }5 }6 closesocket(hSocket);7- if (strLine.find("<"))8+ if (strLine.find("<") != -1)9 strLine = strLine.substr(0, strLine.find("<"));10 strLine = strLine.substr(strspn(strLine.c_str(), " \t\n\r"));11 while (strLine.size() > 0 && isspace(strLine[strLine.size()-1]))12@@ -224,12 +224,13 @@13 14 15 16-bool AddAddress(CAddress addr)17+bool AddAddress(CAddress addr, int64 nTimePenalty)18 {19 if (!addr.IsRoutable())20 return false;21 if (addr.ip == addrLocalHost.ip)22 return false;23+ addr.nTime = max((int64)0, (int64)addr.nTime - nTimePenalty);24 CRITICAL_BLOCK(cs_mapAddresses)25 {26 map<vector<unsigned char>, CAddress>::iterator it = mapAddresses.find(addr.GetKey());27@@ -1073,25 +1074,6 @@28 return false;29 pnode->fNetworkNode = true;30 31- if (addrLocalHost.IsRoutable() && !fUseProxy)32- {33- // Advertise our address34- vector<CAddress> vAddr;35- vAddr.push_back(addrLocalHost);36- pnode->PushMessage("addr", vAddr);37- }38-39- // Get as many addresses as we can40- pnode->PushMessage("getaddr");41- pnode->fGetAddr = true; // don't relay the results of the getaddr42-43- ////// should the one on the receiving end do this too?44- // Subscribe our local subscription list45- const unsigned int nHops = 0;46- for (unsigned int nChannel = 0; nChannel < pnodeLocalHost->vfSubscribe.size(); nChannel++)47- if (pnodeLocalHost->vfSubscribe[nChannel])48- pnode->PushMessage("subscribe", nChannel, nHops);49-50 return true;51 }52
net.h (modified)
1--- v0.3.14/net.h2+++ v0.3.15/net.h3@@ -24,7 +24,7 @@4 5 bool ConnectSocket(const CAddress& addrConnect, SOCKET& hSocketRet);6 bool GetMyExternalIP(unsigned int& ipRet);7-bool AddAddress(CAddress addr);8+bool AddAddress(CAddress addr, int64 nTimePenalty=0);9 void AddressCurrentlyConnected(const CAddress& addr);10 CNode* FindNode(unsigned int ip);11 CNode* ConnectNode(CAddress addrConnect, int64 nTimeout=0);12@@ -139,7 +139,7 @@13 unsigned int ip;14 unsigned short port;15 16- // disk only17+ // disk and network only18 unsigned int nTime;19 20 // memory only21@@ -186,7 +186,7 @@22 memcpy(pchReserved, pchIPv4, sizeof(pchReserved));23 ip = INADDR_NONE;24 port = GetDefaultPort();25- nTime = GetAdjustedTime();26+ nTime = 100000000;27 nLastTry = 0;28 }29 30@@ -218,11 +218,12 @@31 32 IMPLEMENT_SERIALIZE33 (34+ if (fRead)35+ const_cast<CAddress*>(this)->Init();36 if (nType & SER_DISK)37- {38 READWRITE(nVersion);39+ if ((nType & SER_DISK) || (nVersion >= 31402 && !(nType & SER_GETHASH)))40 READWRITE(nTime);41- }42 READWRITE(nServices);43 READWRITE(FLATDATA(pchReserved)); // for IPv644 READWRITE(ip);45@@ -415,7 +416,7 @@46 const char* GetCommand() const47 {48 if (!IsKnownType())49- throw std::out_of_range(strprintf("CInv::GetCommand() : type=% unknown type", type));50+ throw std::out_of_range(strprintf("CInv::GetCommand() : type=%d unknown type", type));51 return ppszTypeName[type];52 }53 54@@ -732,13 +733,6 @@55 AbortMessage();56 }57 58- const char* GetMessageCommand() const59- {60- if (nHeaderStart == -1)61- return "";62- return &vSend[nHeaderStart] + offsetof(CMessageHeader, pchCommand);63- }64-65 66 67
rpc.cpp (modified)
1--- v0.3.14/rpc.cpp2+++ v0.3.15/rpc.cpp3@@ -261,6 +261,9 @@4 obj.push_back(Pair("genproclimit", (int)(fLimitProcessors ? nLimitProcessors : -1)));5 obj.push_back(Pair("difficulty", (double)GetDifficulty()));6 obj.push_back(Pair("hashespersec", gethashespersec(params, false)));7+ obj.push_back(Pair("testnet", fTestNet));8+ obj.push_back(Pair("keypoololdest", (boost::int64_t)CWalletDB().GetOldestKeyPoolTime()));9+ obj.push_back(Pair("paytxfee", (double)nTransactionFee / (double)COIN));10 obj.push_back(Pair("errors", GetWarnings("statusbar")));11 return obj;12 }13@@ -653,6 +656,7 @@14 15 return Value::null;16 }17+18 19 Value validateaddress(const Array& params, bool fHelp)20 {21@@ -767,12 +771,22 @@22 return s.str();23 }24 25+string rfc1123Time()26+{27+ char buffer[32];28+ time_t now;29+ time(&now);30+ struct tm* now_gmt = gmtime(&now);31+ strftime(buffer, sizeof(buffer), "%a, %d %b %Y %H:%M:%S %Z", now_gmt);32+ return string(buffer);33+}34+35 string HTTPReply(int nStatus, const string& strMsg)36 {37 if (nStatus == 401)38- return "HTTP/1.0 401 Authorization Required\r\n"39- "Server: HTTPd/1.0\r\n"40- "Date: Sat, 08 Jul 2006 12:04:08 GMT\r\n"41+ return strprintf("HTTP/1.0 401 Authorization Required\r\n"42+ "Date: %s\r\n"43+ "Server: bitcoin-json-rpc\r\n"44 "WWW-Authenticate: Basic realm=\"jsonrpc\"\r\n"45 "Content-Type: text/html\r\n"46 "Content-Length: 311\r\n"47@@ -785,7 +799,7 @@48 "<META HTTP-EQUIV='Content-Type' CONTENT='text/html; charset=ISO-8859-1'>\r\n"49 "</HEAD>\r\n"50 "<BODY><H1>401 Unauthorized.</H1></BODY>\r\n"51- "</HTML>\r\n";52+ "</HTML>\r\n", rfc1123Time().c_str());53 string strStatus;54 if (nStatus == 200) strStatus = "OK";55 else if (nStatus == 400) strStatus = "Bad Request";56@@ -793,15 +807,16 @@57 else if (nStatus == 500) strStatus = "Internal Server Error";58 return strprintf(59 "HTTP/1.1 %d %s\r\n"60+ "Date: %s\r\n"61 "Connection: close\r\n"62 "Content-Length: %d\r\n"63 "Content-Type: application/json\r\n"64- "Date: Sat, 08 Jul 2006 12:04:08 GMT\r\n"65- "Server: json-rpc/1.0\r\n"66+ "Server: bitcoin-json-rpc/1.0\r\n"67 "\r\n"68 "%s",69 nStatus,70 strStatus.c_str(),71+ rfc1123Time().c_str(),72 strMsg.size(),73 strMsg.c_str());74 }
serialize.h (modified)
1--- v0.3.14/serialize.h2+++ v0.3.15/serialize.h3@@ -22,7 +22,7 @@4 class CAutoFile;5 static const unsigned int MAX_SIZE = 0x02000000;6 7-static const int VERSION = 31400;8+static const int VERSION = 31500;9 static const char* pszSubVer = "";10 11
setup.nsi (modified)
1--- v0.3.14/setup.nsi2+++ v0.3.15/setup.nsi3@@ -7,7 +7,7 @@4 5 # General Symbol Definitions6 !define REGKEY "SOFTWARE\$(^Name)"7-!define VERSION 0.3.148+!define VERSION 0.3.159 !define COMPANY "Bitcoin project"10 !define URL http://www.bitcoin.org/11 12@@ -42,12 +42,12 @@13 !insertmacro MUI_LANGUAGE English14 15 # Installer attributes16-OutFile bitcoin-0.3.14-win32-setup.exe17+OutFile bitcoin-0.3.15-win32-setup.exe18 InstallDir $PROGRAMFILES\Bitcoin19 CRCCheck on20 XPStyle on21 ShowInstDetails show22-VIProductVersion 0.3.14.023+VIProductVersion 0.3.15.024 VIAddVersionKey ProductName Bitcoin25 VIAddVersionKey ProductVersion "${VERSION}"26 VIAddVersionKey CompanyName "${COMPANY}"
ui.cpp (modified)
1--- v0.3.14/ui.cpp2+++ v0.3.15/ui.cpp3@@ -196,7 +196,7 @@4 5 bool ThreadSafeAskFee(int64 nFeeRequired, const string& strCaption, wxWindow* parent)6 {7- if (nFeeRequired < CENT || fDaemon)8+ if (nFeeRequired < CENT || nFeeRequired <= nTransactionFee || fDaemon)9 return true;10 string strMessage = strprintf(11 _("This transaction is over the size limit. You can still send it for a fee of %s, "12@@ -1929,69 +1929,78 @@13 14 void CSendDialog::OnButtonSend(wxCommandEvent& event)15 {16- CWalletTx wtx;17- string strAddress = (string)m_textCtrlAddress->GetValue();18-19- // Parse amount20- int64 nValue = 0;21- if (!ParseMoney(m_textCtrlAmount->GetValue(), nValue) || nValue <= 0)22- {23- wxMessageBox(_("Error in amount "), _("Send Coins"));24- return;25- }26- if (nValue > GetBalance())27- {28- wxMessageBox(_("Amount exceeds your balance "), _("Send Coins"));29- return;30- }31- if (nValue + nTransactionFee > GetBalance())32- {33- wxMessageBox(string(_("Total exceeds your balance when the ")) + FormatMoney(nTransactionFee) + _(" transaction fee is included "), _("Send Coins"));34- return;35- }36-37- // Parse bitcoin address38- uint160 hash160;39- bool fBitcoinAddress = AddressToHash160(strAddress, hash160);40-41- if (fBitcoinAddress)42- {43- // Send to bitcoin address44- CScript scriptPubKey;45- scriptPubKey << OP_DUP << OP_HASH160 << hash160 << OP_EQUALVERIFY << OP_CHECKSIG;46-47- string strError = SendMoney(scriptPubKey, nValue, wtx, true);48- if (strError == "")49- wxMessageBox(_("Payment sent "), _("Sending..."));50- else if (strError != "ABORTED")51- wxMessageBox(strError + " ", _("Sending..."));52- }53- else54- {55- // Parse IP address56- CAddress addr(strAddress);57- if (!addr.IsValid())58- {59- wxMessageBox(_("Invalid address "), _("Send Coins"));60+ static CCriticalSection cs_sendlock;61+ TRY_CRITICAL_BLOCK(cs_sendlock)62+ {63+ CWalletTx wtx;64+ string strAddress = (string)m_textCtrlAddress->GetValue();65+66+ // Parse amount67+ int64 nValue = 0;68+ if (!ParseMoney(m_textCtrlAmount->GetValue(), nValue) || nValue <= 0)69+ {70+ wxMessageBox(_("Error in amount "), _("Send Coins"));71 return;72 }73-74- // Message75- wtx.mapValue["to"] = strAddress;76- wtx.mapValue["from"] = m_textCtrlFrom->GetValue();77- wtx.mapValue["message"] = m_textCtrlMessage->GetValue();78-79- // Send to IP address80- CSendingDialog* pdialog = new CSendingDialog(this, addr, nValue, wtx);81- if (!pdialog->ShowModal())82+ if (nValue > GetBalance())83+ {84+ wxMessageBox(_("Amount exceeds your balance "), _("Send Coins"));85 return;86- }87-88- CRITICAL_BLOCK(cs_mapAddressBook)89- if (!mapAddressBook.count(strAddress))90- SetAddressBookName(strAddress, "");91-92- EndModal(true);93+ }94+ if (nValue + nTransactionFee > GetBalance())95+ {96+ wxMessageBox(string(_("Total exceeds your balance when the ")) + FormatMoney(nTransactionFee) + _(" transaction fee is included "), _("Send Coins"));97+ return;98+ }99+100+ // Parse bitcoin address101+ uint160 hash160;102+ bool fBitcoinAddress = AddressToHash160(strAddress, hash160);103+104+ if (fBitcoinAddress)105+ {106+ // Send to bitcoin address107+ CScript scriptPubKey;108+ scriptPubKey << OP_DUP << OP_HASH160 << hash160 << OP_EQUALVERIFY << OP_CHECKSIG;109+110+ string strError = SendMoney(scriptPubKey, nValue, wtx, true);111+ if (strError == "")112+ wxMessageBox(_("Payment sent "), _("Sending..."));113+ else if (strError == "ABORTED")114+ return; // leave send dialog open115+ else116+ {117+ wxMessageBox(strError + " ", _("Sending..."));118+ EndModal(false);119+ }120+ }121+ else122+ {123+ // Parse IP address124+ CAddress addr(strAddress);125+ if (!addr.IsValid())126+ {127+ wxMessageBox(_("Invalid address "), _("Send Coins"));128+ return;129+ }130+131+ // Message132+ wtx.mapValue["to"] = strAddress;133+ wtx.mapValue["from"] = m_textCtrlFrom->GetValue();134+ wtx.mapValue["message"] = m_textCtrlMessage->GetValue();135+136+ // Send to IP address137+ CSendingDialog* pdialog = new CSendingDialog(this, addr, nValue, wtx);138+ if (!pdialog->ShowModal())139+ return;140+ }141+142+ CRITICAL_BLOCK(cs_mapAddressBook)143+ if (!mapAddressBook.count(strAddress))144+ SetAddressBookName(strAddress, "");145+146+ EndModal(true);147+ }148 }149 150 void CSendDialog::OnButtonCancel(wxCommandEvent& event)
