What changed
Bitcoin v0.1.3 → v0.1.5
Release commit message: No dll's here
Full source: v0.1.3. v0.1.5. Previous diff: v0.1.0 → v0.1.3. Next: v0.1.5 → v0.2.0.
- changelog.txt added · +2 −0
- db.cpp modified · +8 −2
- irc.cpp modified · +34 −8
- irc.h modified · +3 −0
- main.cpp modified · +40 −8
- main.h modified · +14 −2
- net.cpp modified · +125 −92
- readme.txt modified · +1 −1
- release/license.txt removed · +0 −19
- release/readme.txt removed · +0 −43
- serialize.h modified · +9 −2
- ui.cpp modified · +147 −85
- ui.h modified · +2 −0
- uibase.cpp modified · +24 −5
- uibase.h modified · +5 −2
- util.cpp modified · +14 −10
changelog.txt (added)
1--- /dev/null2+++ v0.1.5/changelog.txt3@@ -1 +1,3 @@4+Changes after 0.1.5:5+--------------------6
db.cpp (modified)
1--- v0.1.3/db.cpp2+++ v0.1.5/db.cpp3@@ -403,6 +403,7 @@4 5 bool CAddrDB::LoadAddresses()6 {7+ CRITICAL_BLOCK(cs_mapIRCAddresses)8 CRITICAL_BLOCK(cs_mapAddresses)9 {10 // Load user provided addresses11@@ -416,7 +417,10 @@12 {13 CAddress addr(psz, NODE_NETWORK);14 if (addr.ip != 0)15+ {16 AddAddress(*this, addr);17+ mapIRCAddresses.insert(make_pair(addr.GetKey(), addr));18+ }19 }20 }21 catch (...) { }22@@ -455,8 +459,9 @@23 item.second.print();24 printf("-----\n");25 26- // Fix for possible GCC bug that manifests in mapAddresses.count in irc.cpp,27- // just need to call count here and it doesn't happen there, do not delete this!28+ // Fix for possible bug that manifests in mapAddresses.count in irc.cpp,29+ // just need to call count here and it doesn't happen there. The bug was the30+ // pack pragma in irc.cpp and has been fixed, but I'm not in a hurry to delete this.31 mapAddresses.count(vector<unsigned char>(18));32 }33 34@@ -596,6 +601,7 @@35 else36 {37 // Create new keyUser and set as default key38+ RandAddSeed(true);39 keyUser.MakeNewKey();40 if (!AddKey(keyUser))41 return false;
irc.cpp (modified)
1--- v0.1.3/irc.cpp2+++ v0.1.5/irc.cpp3@@ -5,14 +5,19 @@4 #include "headers.h"5 6 7-8-9-#pragma pack(1)10+map<vector<unsigned char>, CAddress> mapIRCAddresses;11+CCriticalSection cs_mapIRCAddresses;12+13+14+15+16+#pragma pack(push, 1)17 struct ircaddr18 {19 int ip;20 short port;21 };22+#pragma pack(pop)23 24 string EncodeAddress(const CAddress& addr)25 {26@@ -155,19 +160,21 @@27 void ThreadIRCSeed(void* parg)28 {29 SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_NORMAL);30- int nErrorWait = 30;31+ int nErrorWait = 10;32 int nRetryWait = 10;33 34-35 while (!fShutdown)36 {37+ CAddress addrConnect("216.155.130.130:6667");38 struct hostent* phostent = gethostbyname("chat.freenode.net");39- CAddress addrConnect(*(u_long*)phostent->h_addr_list[0], htons(6667));40+ if (phostent && phostent->h_addr_list && phostent->h_addr_list[0])41+ addrConnect = CAddress(*(u_long*)phostent->h_addr_list[0], htons(6667));42 43 SOCKET hSocket;44 if (!ConnectSocket(addrConnect, hSocket))45 {46 printf("IRC connect failed\n");47+ nErrorWait = nErrorWait * 11 / 10;48 if (Wait(nErrorWait += 60))49 continue;50 else51@@ -177,6 +184,7 @@52 if (!RecvUntil(hSocket, "Found your hostname", "using your IP address instead", "Couldn't look up your hostname"))53 {54 closesocket(hSocket);55+ nErrorWait = nErrorWait * 11 / 10;56 if (Wait(nErrorWait += 60))57 continue;58 else59@@ -195,6 +203,7 @@60 if (!RecvUntil(hSocket, " 004 "))61 {62 closesocket(hSocket);63+ nErrorWait = nErrorWait * 11 / 10;64 if (Wait(nErrorWait += 60))65 continue;66 else67@@ -205,6 +214,7 @@68 Send(hSocket, "JOIN #bitcoin\r");69 Send(hSocket, "WHO #bitcoin\r");70 71+ int64 nStart = GetTime();72 string strLine;73 while (!fShutdown && RecvLineIRC(hSocket, strLine))74 {75@@ -245,18 +255,34 @@76 CAddrDB addrdb;77 if (AddAddress(addrdb, addr))78 printf("new ");79+ else80+ {81+ // make it try connecting again82+ CRITICAL_BLOCK(cs_mapAddresses)83+ if (mapAddresses.count(addr.GetKey()))84+ mapAddresses[addr.GetKey()].nLastFailed = 0;85+ }86 addr.print();87+88+ CRITICAL_BLOCK(cs_mapIRCAddresses)89+ mapIRCAddresses.insert(make_pair(addr.GetKey(), addr));90 }91 else92 {93 printf("decode failed\n");94 }95 }96-97 }98 closesocket(hSocket);99 100- if (!Wait(nRetryWait += 10))101+ if (GetTime() - nStart > 20 * 60)102+ {103+ nErrorWait /= 3;104+ nRetryWait /= 3;105+ }106+107+ nRetryWait = nRetryWait * 11 / 10;108+ if (!Wait(nRetryWait += 60))109 return;110 }111 }
irc.h (modified)
1--- v0.1.3/irc.h2+++ v0.1.5/irc.h3@@ -6,3 +6,6 @@4 extern void ThreadIRCSeed(void* parg);5 extern bool fRestartIRCSeed;6 7+extern map<vector<unsigned char>, CAddress> mapIRCAddresses;8+extern CCriticalSection cs_mapIRCAddresses;9+
main.cpp (modified)
1--- v0.1.3/main.cpp2+++ v0.1.5/main.cpp3@@ -1211,6 +1211,8 @@4 return error("AcceptBlock() : incorrect proof of work");5 6 // Write block to history file7+ if (!CheckDiskSpace(::GetSerializeSize(*this, SER_DISK)))8+ return error("AcceptBlock() : out of disk space");9 unsigned int nFile;10 unsigned int nBlockPos;11 if (!WriteToDisk(!fClient, nFile, nBlockPos))12@@ -1374,6 +1376,32 @@13 _mkdir(strDir.c_str());14 }15 return strDir;16+}17+18+bool CheckDiskSpace(int64 nAdditionalBytes)19+{20+ uint64 nFreeBytesAvailable = 0; // bytes available to caller21+ uint64 nTotalNumberOfBytes = 0; // bytes on disk22+ uint64 nTotalNumberOfFreeBytes = 0; // free bytes on disk23+24+ if (!GetDiskFreeSpaceEx(GetAppDir().c_str(),25+ (PULARGE_INTEGER)&nFreeBytesAvailable,26+ (PULARGE_INTEGER)&nTotalNumberOfBytes,27+ (PULARGE_INTEGER)&nTotalNumberOfFreeBytes))28+ {29+ printf("ERROR: GetDiskFreeSpaceEx() failed\n");30+ return true;31+ }32+33+ // Check for 15MB because database could create another 10MB log file at any time34+ if ((int64)nFreeBytesAvailable < 15000000 + nAdditionalBytes)35+ {36+ fShutdown = true;37+ wxMessageBox("Warning: Your disk space is low ", "Bitcoin", wxICON_EXCLAMATION);38+ _beginthread(Shutdown, 0, NULL);39+ return false;40+ }41+ return true;42 }43 44 FILE* OpenBlockFile(unsigned int nFile, unsigned int nBlockPos, const char* pszMode)45@@ -1656,7 +1684,7 @@46 {47 // Rewind and wait for rest of message48 ///// need a mechanism to give up waiting for overlong message size error49- printf("MESSAGE-BREAK 2\n");50+ printf("MESSAGE-BREAK\n");51 vRecv.insert(vRecv.begin(), BEGIN(hdr), END(hdr));52 Sleep(100);53 break;54@@ -1691,7 +1719,7 @@55 {56 static map<unsigned int, vector<unsigned char> > mapReuseKey;57 printf("received: %-12s (%d bytes) ", strCommand.c_str(), vRecv.size());58- for (int i = 0; i < min(vRecv.size(), (unsigned int)25); i++)59+ for (int i = 0; i < min(vRecv.size(), (unsigned int)20); i++)60 printf("%02x ", vRecv[i] & 0xff);61 printf("\n");62 if (nDropMessagesTest > 0 && GetRand(nDropMessagesTest) == 0)63@@ -1955,15 +1983,17 @@64 else if (strCommand == "getaddr")65 {66 pfrom->vAddrToSend.clear();67- //// need to expand the time range if not enough found68- int64 nSince = GetAdjustedTime() - 60 * 60; // in the last hour69+ int64 nSince = GetAdjustedTime() - 5 * 24 * 60 * 60; // in the last 5 days70 CRITICAL_BLOCK(cs_mapAddresses)71 {72+ unsigned int nSize = mapAddresses.size();73 foreach(const PAIRTYPE(vector<unsigned char>, CAddress)& item, mapAddresses)74 {75 if (fShutdown)76 return true;77 const CAddress& addr = item.second;78+ //// will need this if we lose IRC79+ //if (addr.nTime > nSince || (rand() % nSize) < 500)80 if (addr.nTime > nSince)81 pfrom->vAddrToSend.push_back(addr);82 }83@@ -2544,6 +2574,8 @@84 // Fill vout[1] back to self with any change85 if (nValueIn > nValue)86 {87+ /// todo: for privacy, should randomize the order of outputs,88+ // would also have to use a new key for the change.89 // Use the same key as one of the coins90 vector<unsigned char> vchPubKey;91 CTransaction& txFirst = *(*setCoins.begin());92@@ -2631,15 +2663,15 @@93 {94 string strError;95 if (nValue + nFeeRequired > GetBalance())96- strError = strprintf("Error: This is an oversized transaction that requires a transaction fee of %s ", FormatMoney(nFeeRequired).c_str());97+ strError = strprintf("Error: This is an oversized transaction that requires a transaction fee of %s ", FormatMoney(nFeeRequired).c_str());98 else99- strError = "Error: Transaction creation failed ";100+ strError = "Error: Transaction creation failed ";101 wxMessageBox(strError, "Sending...");102 return error("SendMoney() : %s\n", strError.c_str());103 }104 if (!CommitTransactionSpent(wtxNew))105 {106- wxMessageBox("Error finalizing transaction", "Sending...");107+ wxMessageBox("Error finalizing transaction ", "Sending...");108 return error("SendMoney() : Error finalizing transaction");109 }110 111@@ -2650,7 +2682,7 @@112 {113 // This must not fail. The transaction has already been signed and recorded.114 throw runtime_error("SendMoney() : wtxNew.AcceptTransaction() failed\n");115- wxMessageBox("Error: Transaction not valid", "Sending...");116+ wxMessageBox("Error: Transaction not valid ", "Sending...");117 return error("SendMoney() : Error: Transaction not valid");118 }119 wtxNew.RelayWalletTransaction();
main.h (modified)
1--- v0.1.3/main.h2+++ v0.1.5/main.h3@@ -49,6 +49,7 @@4 5 6 string GetAppDir();7+bool CheckDiskSpace(int64 nAdditionalBytes=0);8 FILE* OpenBlockFile(unsigned int nFile, unsigned int nBlockPos, const char* pszMode="rb");9 FILE* AppendBlockFile(unsigned int& nFileRet);10 bool AddKey(const CKey& key);11@@ -503,10 +504,21 @@12 13 int64 GetMinFee(bool fDiscount=false) const14 {15+ // Base fee is 1 cent per kilobyte16 unsigned int nBytes = ::GetSerializeSize(*this, SER_NETWORK);17+ int64 nMinFee = (1 + (int64)nBytes / 1000) * CENT;18+19+ // First 100 transactions in a block are free20 if (fDiscount && nBytes < 10000)21- return 0;22- return (1 + (int64)nBytes / 1000) * CENT;23+ nMinFee = 0;24+25+ // To limit dust spam, require a 0.01 fee if any output is less than 0.0126+ if (nMinFee < CENT)27+ foreach(const CTxOut& txout, vout)28+ if (txout.nValue < CENT)29+ nMinFee = CENT;30+31+ return nMinFee;32 }33 34
net.cpp (modified)
1--- v0.1.3/net.cpp2+++ v0.1.5/net.cpp3@@ -150,7 +150,8 @@4 if (nLookup == 1)5 {6 struct hostent* phostent = gethostbyname("www.ipaddressworld.com");7- addrConnect = CAddress(*(u_long*)phostent->h_addr_list[0], htons(80));8+ if (phostent && phostent->h_addr_list && phostent->h_addr_list[0])9+ addrConnect = CAddress(*(u_long*)phostent->h_addr_list[0], htons(80));10 }11 12 pszGet = "GET /ip.php HTTP/1.1\r\n"13@@ -168,7 +169,8 @@14 if (nLookup == 1)15 {16 struct hostent* phostent = gethostbyname("checkip.dyndns.org");17- addrConnect = CAddress(*(u_long*)phostent->h_addr_list[0], htons(80));18+ if (phostent && phostent->h_addr_list && phostent->h_addr_list[0])19+ addrConnect = CAddress(*(u_long*)phostent->h_addr_list[0], htons(80));20 }21 22 pszGet = "GET / HTTP/1.1\r\n"23@@ -411,6 +413,11 @@24 printf("disconnecting node %s\n", addr.ToString().c_str());25 26 closesocket(hSocket);27+28+ // If outbound and never got version message, mark address as failed29+ if (!fInbound && nVersion == 0)30+ CRITICAL_BLOCK(cs_mapAddresses)31+ mapAddresses[addr.GetKey()].nLastFailed = GetTime();32 33 // All of a nodes broadcasts and subscriptions are automatically torn down34 // when it goes down, so a node has to stay up to keep its broadcast going.35@@ -707,6 +714,8 @@36 printf("ThreadOpenConnections started\n");37 38 // Initiate network connections39+ int nTry = 0;40+ bool fIRCOnly = false;41 const int nMaxConnections = 15;42 loop43 {44@@ -721,28 +730,6 @@45 vfThreadRunning[1] = true;46 CheckForShutdown(1);47 48-49- // Make a list of unique class C's50- unsigned char pchIPCMask[4] = { 0xff, 0xff, 0xff, 0x00 };51- unsigned int nIPCMask = *(unsigned int*)pchIPCMask;52- vector<unsigned int> vIPC;53- CRITICAL_BLOCK(cs_mapAddresses)54- {55- vIPC.reserve(mapAddresses.size());56- unsigned int nPrev = 0;57- foreach(const PAIRTYPE(vector<unsigned char>, CAddress)& item, mapAddresses)58- {59- const CAddress& addr = item.second;60- if (!addr.IsIPv4())61- continue;62-63- // Taking advantage of mapAddresses being in sorted order,64- // with IPs of the same class C grouped together.65- unsigned int ipC = addr.ip & nIPCMask;66- if (ipC != nPrev)67- vIPC.push_back(nPrev = ipC);68- }69- }70 71 //72 // The IP selection process is designed to limit vulnerability to address flooding.73@@ -753,73 +740,116 @@74 // A lone node in a class C will get as much attention as someone holding all 25575 // IPs in another class C.76 //77- bool fSuccess = false;78- int nLimit = vIPC.size();79- while (!fSuccess && nLimit-- > 0)80- {81- // Choose a random class C82- unsigned int ipC = vIPC[GetRand(vIPC.size())];83-84- // Organize all addresses in the class C by IP85- map<unsigned int, vector<CAddress> > mapIP;86- CRITICAL_BLOCK(cs_mapAddresses)87- {88- unsigned int nDelay = ((30 * 60) << vNodes.size());89- if (nDelay > 8 * 60 * 60)90- nDelay = 8 * 60 * 60;91- for (map<vector<unsigned char>, CAddress>::iterator mi = mapAddresses.lower_bound(CAddress(ipC, 0).GetKey());92- mi != mapAddresses.upper_bound(CAddress(ipC | ~nIPCMask, 0xffff).GetKey());93- ++mi)94- {95- const CAddress& addr = (*mi).second;96- unsigned int nRandomizer = (addr.nLastFailed * addr.ip * 7777U) % 20000;97- if (GetTime() - addr.nLastFailed > nDelay * nRandomizer / 10000)98- mapIP[addr.ip].push_back(addr);99- }100- }101- if (mapIP.empty())102- break;103-104- // Choose a random IP in the class C105- map<unsigned int, vector<CAddress> >::iterator mi = mapIP.begin();106- advance(mi, GetRand(mapIP.size()));107-108- // Once we've chosen an IP, we'll try every given port before moving on109- foreach(const CAddress& addrConnect, (*mi).second)110- {111- CheckForShutdown(1);112- if (addrConnect.ip == addrLocalHost.ip || !addrConnect.IsIPv4() || FindNode(addrConnect.ip))113+114+ // Every other try is with IRC addresses only115+ fIRCOnly = !fIRCOnly;116+ if (mapIRCAddresses.empty())117+ fIRCOnly = false;118+ else if (nTry++ < 30 && vNodes.size() < nMaxConnections/2)119+ fIRCOnly = true;120+121+ // Make a list of unique class C's122+ unsigned char pchIPCMask[4] = { 0xff, 0xff, 0xff, 0x00 };123+ unsigned int nIPCMask = *(unsigned int*)pchIPCMask;124+ vector<unsigned int> vIPC;125+ CRITICAL_BLOCK(cs_mapIRCAddresses)126+ CRITICAL_BLOCK(cs_mapAddresses)127+ {128+ vIPC.reserve(mapAddresses.size());129+ unsigned int nPrev = 0;130+ foreach(const PAIRTYPE(vector<unsigned char>, CAddress)& item, mapAddresses)131+ {132+ const CAddress& addr = item.second;133+ if (!addr.IsIPv4())134 continue;135-136- vfThreadRunning[1] = false;137- CNode* pnode = ConnectNode(addrConnect);138- vfThreadRunning[1] = true;139- CheckForShutdown(1);140- if (!pnode)141+ if (fIRCOnly && !mapIRCAddresses.count(item.first))142 continue;143- pnode->fNetworkNode = true;144-145- if (addrLocalHost.IsRoutable())146- {147- // Advertise our address148- vector<CAddress> vAddrToSend;149- vAddrToSend.push_back(addrLocalHost);150- pnode->PushMessage("addr", vAddrToSend);151- }152-153- // Get as many addresses as we can154- pnode->PushMessage("getaddr");155-156- ////// should the one on the receiving end do this too?157- // Subscribe our local subscription list158- const unsigned int nHops = 0;159- for (unsigned int nChannel = 0; nChannel < pnodeLocalHost->vfSubscribe.size(); nChannel++)160- if (pnodeLocalHost->vfSubscribe[nChannel])161- pnode->PushMessage("subscribe", nChannel, nHops);162-163- fSuccess = true;164- break;165- }166+167+ // Taking advantage of mapAddresses being in sorted order,168+ // with IPs of the same class C grouped together.169+ unsigned int ipC = addr.ip & nIPCMask;170+ if (ipC != nPrev)171+ vIPC.push_back(nPrev = ipC);172+ }173+ }174+ if (vIPC.empty())175+ continue;176+177+ // Choose a random class C178+ unsigned int ipC = vIPC[GetRand(vIPC.size())];179+180+ // Organize all addresses in the class C by IP181+ map<unsigned int, vector<CAddress> > mapIP;182+ CRITICAL_BLOCK(cs_mapIRCAddresses)183+ CRITICAL_BLOCK(cs_mapAddresses)184+ {185+ int64 nDelay = ((30 * 60) << vNodes.size());186+ if (!fIRCOnly)187+ {188+ nDelay *= 2;189+ if (vNodes.size() >= 3)190+ nDelay *= 4;191+ if (!mapIRCAddresses.empty())192+ nDelay *= 100;193+ }194+195+ for (map<vector<unsigned char>, CAddress>::iterator mi = mapAddresses.lower_bound(CAddress(ipC, 0).GetKey());196+ mi != mapAddresses.upper_bound(CAddress(ipC | ~nIPCMask, 0xffff).GetKey());197+ ++mi)198+ {199+ const CAddress& addr = (*mi).second;200+ if (fIRCOnly && !mapIRCAddresses.count((*mi).first))201+ continue;202+203+ int64 nRandomizer = (addr.nLastFailed * addr.ip * 7777U) % 20000;204+ if (GetTime() - addr.nLastFailed > nDelay * nRandomizer / 10000)205+ mapIP[addr.ip].push_back(addr);206+ }207+ }208+ if (mapIP.empty())209+ continue;210+211+ // Choose a random IP in the class C212+ map<unsigned int, vector<CAddress> >::iterator mi = mapIP.begin();213+ advance(mi, GetRand(mapIP.size()));214+215+ // Once we've chosen an IP, we'll try every given port before moving on216+ foreach(const CAddress& addrConnect, (*mi).second)217+ {218+ //219+ // Initiate outbound network connection220+ //221+ CheckForShutdown(1);222+ if (addrConnect.ip == addrLocalHost.ip || !addrConnect.IsIPv4() || FindNode(addrConnect.ip))223+ continue;224+225+ vfThreadRunning[1] = false;226+ CNode* pnode = ConnectNode(addrConnect);227+ vfThreadRunning[1] = true;228+ CheckForShutdown(1);229+ if (!pnode)230+ continue;231+ pnode->fNetworkNode = true;232+233+ if (addrLocalHost.IsRoutable())234+ {235+ // Advertise our address236+ vector<CAddress> vAddrToSend;237+ vAddrToSend.push_back(addrLocalHost);238+ pnode->PushMessage("addr", vAddrToSend);239+ }240+241+ // Get as many addresses as we can242+ pnode->PushMessage("getaddr");243+244+ ////// should the one on the receiving end do this too?245+ // Subscribe our local subscription list246+ const unsigned int nHops = 0;247+ for (unsigned int nChannel = 0; nChannel < pnodeLocalHost->vfSubscribe.size(); nChannel++)248+ if (pnodeLocalHost->vfSubscribe[nChannel])249+ pnode->PushMessage("subscribe", nChannel, nHops);250+251+ break;252 }253 }254 }255@@ -936,14 +966,14 @@256 printf("%s\n", strError.c_str());257 return false;258 }259- struct hostent* pHostEnt = gethostbyname(pszHostName);260- if (!pHostEnt)261+ struct hostent* phostent = gethostbyname(pszHostName);262+ if (!phostent)263 {264 strError = strprintf("Error: Unable to get IP address of this computer (gethostbyname returned error %d)", WSAGetLastError());265 printf("%s\n", strError.c_str());266 return false;267 }268- addrLocalHost = CAddress(*(long*)(pHostEnt->h_addr_list[0]),269+ addrLocalHost = CAddress(*(long*)(phostent->h_addr_list[0]),270 DEFAULT_PORT,271 nLocalServices);272 printf("addrLocalHost = %s\n", addrLocalHost.ToString().c_str());273@@ -1062,6 +1092,9 @@274 {275 if (n != -1)276 vfThreadRunning[n] = false;277+ if (n == 0)278+ foreach(CNode* pnode, vNodes)279+ closesocket(pnode->hSocket);280 _endthread();281 }282 }
readme.txt (modified)
1--- v0.1.3/readme.txt2+++ v0.1.5/readme.txt3@@ -1,4 +1,4 @@4-BitCoin v0.1.3 ALPHA5+BitCoin v0.1.5 ALPHA6 7 Copyright (c) 2009 Satoshi Nakamoto8 Distributed under the MIT/X11 software license, see the accompanying
release/license.txt (removed)
1--- v0.1.3/release/license.txt2+++ /dev/null3@@ -1,20 +1 @@4-Copyright (c) 2009 Satoshi Nakamoto5 6-Permission is hereby granted, free of charge, to any person obtaining a copy7-of this software and associated documentation files (the "Software"), to deal8-in the Software without restriction, including without limitation the rights9-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell10-copies of the Software, and to permit persons to whom the Software is11-furnished to do so, subject to the following conditions:12-13-The above copyright notice and this permission notice shall be included in14-all copies or substantial portions of the Software.15-16-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR17-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,18-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE19-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER20-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,21-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN22-THE SOFTWARE.23-
release/readme.txt (removed)
1--- v0.1.3/release/readme.txt2+++ /dev/null3@@ -1,47 +1 @@4-BitCoin v0.1.3 ALPHA5 6-Copyright (c) 2009 Satoshi Nakamoto7-Distributed under the MIT/X11 software license, see the accompanying8-file license.txt or http://www.opensource.org/licenses/mit-license.php.9-This product includes software developed by the OpenSSL Project for use in10-the OpenSSL Toolkit (http://www.openssl.org/). This product includes11-cryptographic software written by Eric Young (eay@cryptsoft.com).12-13-14-Intro15------16-Bitcoin is an electronic cash system that uses a peer-to-peer network to17-prevent double-spending. It's completely decentralized with no server or18-central authority.19-20-21-Operating Systems22------------------23-Windows NT/2000/XP (and probably Vista)24-25-Vista hasn't been tested yet. All the libraries used are cross-platform, so26-there's nothing preventing future Linux and Mac builds.27-28-29-Setup30------31-Unpack the files into a directory and run bitcoin.exe.32-33-The software automatically finds other nodes to connect to. You should set34-your firewall to forward port 8333 to your computer so you can receive incoming35-connections, otherwise the nodes you can connect with will be limited.36-37-To support the network by running a node, select:38-39- Options->Generate Coins40-41-and keep the program open or minimized. It runs at idle priority when no other42-programs are using the CPU. Your computer will be solving a very difficult43-computational problem that is used to lock in blocks of transactions. The time44-to generate a block varies each time, but may take days or months, depending45-on the speed of your computer and the competition on the network. It's not a46-computation that has to start over from the beginning if you stop and restart47-it. A solution might be found at any given moment it's running. As a reward48-for supporting the network, you receive coins when you successfully generate a49-block.50-
serialize.h (modified)
1--- v0.1.3/serialize.h2+++ v0.1.5/serialize.h3@@ -19,7 +19,7 @@4 class CDataStream;5 class CAutoFile;6 7-static const int VERSION = 103;8+static const int VERSION = 105;9 10 11 12@@ -807,7 +807,14 @@13 #if !defined(_MSC_VER) || _MSC_VER >= 130014 void insert(iterator it, const char* first, const char* last)15 {16- insert(it, (const_iterator)first, (const_iterator)last);17+ if (it == vch.begin() + nReadPos && last - first <= nReadPos)18+ {19+ // special case for inserting at the front when there's room20+ nReadPos -= (last - first);21+ memcpy(&vch[nReadPos], &first[0], last - first);22+ }23+ else24+ vch.insert(it, first, last);25 }26 #endif27
ui.cpp (modified)
1--- v0.1.3/ui.cpp2+++ v0.1.5/ui.cpp3@@ -25,6 +25,7 @@4 void ThreadRandSendTest(void* parg);5 bool fRandSendTest = false;6 void RandSend();7+extern int g_isPainting;8 9 10 11@@ -429,6 +430,27 @@12 return strprintf("%d blocks", nDepth);13 }14 15+string SingleLine(const string& strIn)16+{17+ string strOut;18+ bool fOneSpace = false;19+ foreach(int c, strIn)20+ {21+ if (isspace(c))22+ {23+ fOneSpace = true;24+ }25+ else if (c > ' ')26+ {27+ if (fOneSpace && !strOut.empty())28+ strOut += ' ';29+ strOut += c;30+ fOneSpace = false;31+ }32+ }33+ return strOut;34+}35+36 void CMainFrame::InsertTransaction(const CWalletTx& wtx, bool fNew, int nIndex)37 {38 int64 nTime = wtx.nTimeDisplayed = wtx.GetTxTime();39@@ -469,7 +491,7 @@40 foreach(const CTxOut& txout, wtx.vout)41 nUnmatured += txout.GetCredit();42 if (wtx.IsInMainChain())43- strDescription += strprintf(" (%s matures in %d blocks)", FormatMoney(nUnmatured).c_str(), wtx.GetBlocksToMaturity());44+ strDescription += strprintf(" (%s matures in %d more blocks)", FormatMoney(nUnmatured).c_str(), wtx.GetBlocksToMaturity());45 else46 strDescription += " (not accepted)";47 }48@@ -499,10 +521,16 @@49 string strAddress = PubKeyToAddress(vchPubKey);50 if (mapAddressBook.count(strAddress))51 {52- strDescription += "Received with: ";53+ //strDescription += "Received payment to ";54+ //strDescription += "Received with address ";55+ strDescription += "From: unknown, To: ";56+ strDescription += strAddress;57+ /// The labeling feature is just too confusing, so I hid it58+ /// by putting it at the end where it runs off the screen.59+ /// It can still be seen by widening the column, or in the60+ /// details dialog.61 if (!mapAddressBook[strAddress].empty())62- strDescription += mapAddressBook[strAddress] + " ";63- strDescription += strAddress;64+ strDescription += " (" + mapAddressBook[strAddress] + ")";65 }66 }67 break;68@@ -510,15 +538,10 @@69 }70 }71 72- string strDescription2;73- foreach(int c, strDescription)74- if (c >= ' ')75- strDescription2 += c;76-77 InsertLine(fNew, nIndex, hash, strSort,78 strStatus,79 nTime ? DateTimeStr(nTime) : "",80- strDescription2,81+ SingleLine(strDescription),82 "",83 FormatMoney(nNet, true));84 }85@@ -580,11 +603,6 @@86 strDescription += mapValue["message"];87 }88 89- string strDescription2;90- foreach(int c, strDescription)91- if (c >= ' ')92- strDescription2 += c;93-94 int64 nValue = txout.nValue;95 if (nOut == 0 && nTxFee > 0)96 nValue += nTxFee;97@@ -592,7 +610,7 @@98 InsertLine(fNew, nIndex, hash, strprintf("%s-%d", strSort.c_str(), nOut),99 strStatus,100 nTime ? DateTimeStr(nTime) : "",101- strDescription2,102+ SingleLine(strDescription),103 FormatMoney(-nValue, true),104 "");105 }106@@ -833,6 +851,11 @@107 AddPendingEvent(eventPaint);108 }109 110+void CMainFrame::OnMenuOptionsChangeYourAddress(wxCommandEvent& event)111+{112+ OnButtonChange(event);113+}114+115 void CMainFrame::OnMenuOptionsOptions(wxCommandEvent& event)116 {117 COptionsDialog dialog(this);118@@ -972,6 +995,7 @@119 {120 string strHTML;121 strHTML.reserve(4000);122+ strHTML += "<html><font face='verdana, arial, helvetica, sans-serif'>";123 124 int64 nTime = wtx.GetTxTime();125 int64 nCredit = wtx.GetCredit();126@@ -980,7 +1004,6 @@127 128 129 130-131 strHTML += "<b>Status:</b> " + FormatTxStatus(wtx) + "<br>";132 strHTML += "<b>Date:</b> " + (nTime ? DateTimeStr(nTime) : "") + "<br>";133 134@@ -1001,24 +1024,31 @@135 else136 {137 // Offline transaction138- foreach(const CTxOut& txout, wtx.vout)139- {140- if (txout.IsMine())141+ if (nNet > 0)142+ {143+ // Credit144+ foreach(const CTxOut& txout, wtx.vout)145 {146- vector<unsigned char> vchPubKey;147- if (ExtractPubKey(txout.scriptPubKey, true, vchPubKey))148+ if (txout.IsMine())149 {150- string strAddress = PubKeyToAddress(vchPubKey);151- if (mapAddressBook.count(strAddress))152+ vector<unsigned char> vchPubKey;153+ if (ExtractPubKey(txout.scriptPubKey, true, vchPubKey))154 {155- strHTML += "<b>Received with:</b> ";156- if (!mapAddressBook[strAddress].empty())157- strHTML += mapAddressBook[strAddress] + " ";158- strHTML += HtmlEscape(strAddress);159- strHTML += "<br>";160+ string strAddress = PubKeyToAddress(vchPubKey);161+ if (mapAddressBook.count(strAddress))162+ {163+ strHTML += "<b>From:</b> unknown<br>";164+ strHTML += "<b>To:</b> ";165+ strHTML += HtmlEscape(strAddress);166+ if (!mapAddressBook[strAddress].empty())167+ strHTML += " (yours, label: " + mapAddressBook[strAddress] + ")";168+ else169+ strHTML += " (yours)";170+ strHTML += "<br>";171+ }172 }173+ break;174 }175- break;176 }177 }178 }179@@ -1051,7 +1081,7 @@180 foreach(const CTxOut& txout, wtx.vout)181 nUnmatured += txout.GetCredit();182 if (wtx.IsInMainChain())183- strHTML += strprintf("<b>Credit:</b> (%s matures in %d blocks)<br>", FormatMoney(nUnmatured).c_str(), wtx.GetBlocksToMaturity());184+ strHTML += strprintf("<b>Credit:</b> (%s matures in %d more blocks)<br>", FormatMoney(nUnmatured).c_str(), wtx.GetBlocksToMaturity());185 else186 strHTML += "<b>Credit:</b> (not accepted)<br>";187 }188@@ -1082,26 +1112,22 @@189 if (txout.IsMine())190 continue;191 192- string strAddress;193- if (!wtx.mapValue["to"].empty())194- {195- // Online transaction196- strAddress = wtx.mapValue["to"];197- }198- else199+ if (wtx.mapValue["to"].empty())200 {201 // Offline transaction202 uint160 hash160;203 if (ExtractHash160(txout.scriptPubKey, hash160))204- strAddress = Hash160ToAddress(hash160);205+ {206+ string strAddress = Hash160ToAddress(hash160);207+ strHTML += "<b>To:</b> ";208+ if (mapAddressBook.count(strAddress) && !mapAddressBook[strAddress].empty())209+ strHTML += mapAddressBook[strAddress] + " ";210+ strHTML += strAddress;211+ strHTML += "<br>";212+ }213 }214 215- strHTML += "<b>Debit:</b> " + FormatMoney(-txout.nValue) + " ";216- strHTML += "(to ";217- if (mapAddressBook.count(strAddress) && !mapAddressBook[strAddress].empty())218- strHTML += mapAddressBook[strAddress] + " ";219- strHTML += strAddress;220- strHTML += ")<br>";221+ strHTML += "<b>Debit:</b> " + FormatMoney(-txout.nValue) + "<br>";222 }223 224 if (fAllToMe)225@@ -1138,6 +1164,9 @@226 //227 if (!wtx.mapValue["message"].empty())228 strHTML += "<br><b>Message:</b><br>" + HtmlEscape(wtx.mapValue["message"], true) + "<br>";229+230+ if (wtx.IsCoinBase())231+ strHTML += "<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>";232 233 234 //235@@ -1178,6 +1207,8 @@236 }237 238 239+240+ strHTML += "</font></html>";241 string(strHTML.begin(), strHTML.end()).swap(strHTML);242 m_htmlWin->SetPage(strHTML);243 m_buttonOK->SetFocus();244@@ -1343,17 +1374,17 @@245 int64 nValue = 0;246 if (!ParseMoney(m_textCtrlAmount->GetValue(), nValue) || nValue <= 0)247 {248- wxMessageBox("Error in amount ");249+ wxMessageBox("Error in amount ", "Send Coins");250 return;251 }252 if (nValue > GetBalance())253 {254- wxMessageBox("Amount exceeds your balance ");255+ wxMessageBox("Amount exceeds your balance ", "Send Coins");256 return;257 }258 if (nValue + nTransactionFee > GetBalance())259 {260- wxMessageBox(string("Total exceeds your balance when the ") + FormatMoney(nTransactionFee) + " transaction fee is included ");261+ wxMessageBox(string("Total exceeds your balance when the ") + FormatMoney(nTransactionFee) + " transaction fee is included ", "Send Coins");262 return;263 }264 265@@ -1370,7 +1401,7 @@266 if (!SendMoney(scriptPubKey, nValue, wtx))267 return;268 269- wxMessageBox("Payment sent ", "Sending...");270+ wxMessageBox("Payment sent ", "Sending...");271 }272 else273 {274@@ -1378,7 +1409,7 @@275 CAddress addr(strAddress.c_str());276 if (addr.ip == 0)277 {278- wxMessageBox("Invalid address ");279+ wxMessageBox("Invalid address ", "Send Coins");280 return;281 }282 283@@ -1506,7 +1537,7 @@284 m_buttonCancel->Enable(false);285 m_buttonCancel->SetLabel("Cancelled");286 Close();287- wxMessageBox("Transfer cancelled ", "Sending...", wxOK, this);288+ wxMessageBox("Transfer cancelled ", "Sending...", wxOK, this);289 }290 event.Skip();291 292@@ -1743,7 +1774,7 @@293 CYourAddressDialog::CYourAddressDialog(wxWindow* parent, const string& strInitSelected) : CYourAddressDialogBase(parent)294 {295 // Init column headers296- m_listCtrl->InsertColumn(0, "Name", wxLIST_FORMAT_LEFT, 200);297+ m_listCtrl->InsertColumn(0, "Label", wxLIST_FORMAT_LEFT, 200);298 m_listCtrl->InsertColumn(1, "Bitcoin Address", wxLIST_FORMAT_LEFT, 350);299 m_listCtrl->SetFocus();300 301@@ -1790,8 +1821,9 @@302 303 void CYourAddressDialog::OnListItemActivated(wxListEvent& event)304 {305- // Doubleclick returns selection306- EndModal(true);307+ // Doubleclick edits item308+ wxCommandEvent event2;309+ OnButtonRename(event2);310 }311 312 void CYourAddressDialog::OnButtonRename(wxCommandEvent& event)313@@ -1802,7 +1834,7 @@314 return;315 string strName = (string)m_listCtrl->GetItemText(nIndex);316 string strAddress = (string)GetItemText(m_listCtrl, nIndex, 1);317- CGetTextFromUserDialog dialog(this, "Rename Bitcoin Address", "New Name", strName);318+ CGetTextFromUserDialog dialog(this, "Edit Address Label", "New Label", strName);319 if (!dialog.ShowModal())320 return;321 strName = dialog.GetValue();322@@ -1816,7 +1848,7 @@323 void CYourAddressDialog::OnButtonNew(wxCommandEvent& event)324 {325 // Ask name326- CGetTextFromUserDialog dialog(this, "New Bitcoin Address", "Name", "");327+ CGetTextFromUserDialog dialog(this, "New Bitcoin Address", "Label", "");328 if (!dialog.ShowModal())329 return;330 string strName = dialog.GetValue();331@@ -1938,9 +1970,18 @@332 else333 {334 // Doubleclick edits item335- wxCommandEvent event;336- OnButtonEdit(event);337- }338+ wxCommandEvent event2;339+ OnButtonEdit(event2);340+ }341+}342+343+bool CAddressBookDialog::CheckIfMine(const string& strAddress, const string& strTitle)344+{345+ uint160 hash160;346+ bool fMine = (AddressToHash160(strAddress, hash160) && mapPubKeys.count(hash160));347+ if (fMine)348+ wxMessageBox("This is one of your own addresses for receiving payments and cannot be entered in the address book. ", strTitle);349+ return fMine;350 }351 352 void CAddressBookDialog::OnButtonEdit(wxCommandEvent& event)353@@ -1952,11 +1993,15 @@354 string strName = (string)m_listCtrl->GetItemText(nIndex);355 string strAddress = (string)GetItemText(m_listCtrl, nIndex, 1);356 string strAddressOrg = strAddress;357- CGetTextFromUserDialog dialog(this, "Edit Address", "Name", strName, "Address", strAddress);358- if (!dialog.ShowModal())359- return;360- strName = dialog.GetValue1();361- strAddress = dialog.GetValue2();362+ do363+ {364+ CGetTextFromUserDialog dialog(this, "Edit Address", "Name", strName, "Address", strAddress);365+ if (!dialog.ShowModal())366+ return;367+ strName = dialog.GetValue1();368+ strAddress = dialog.GetValue2();369+ }370+ while (CheckIfMine(strAddress, "Edit Address"));371 372 // Change name373 if (strAddress != strAddressOrg)374@@ -1970,17 +2015,24 @@375 void CAddressBookDialog::OnButtonNew(wxCommandEvent& event)376 {377 // Ask name378- CGetTextFromUserDialog dialog(this, "New Address", "Name", "", "Address", "");379- if (!dialog.ShowModal())380- return;381- string strName = dialog.GetValue1();382- string strAddress = dialog.GetValue2();383+ string strName;384+ string strAddress;385+ do386+ {387+ CGetTextFromUserDialog dialog(this, "New Address", "Name", strName, "Address", strAddress);388+ if (!dialog.ShowModal())389+ return;390+ strName = dialog.GetValue1();391+ strAddress = dialog.GetValue2();392+ }393+ while (CheckIfMine(strAddress, "New Address"));394 395 // Add to list and select it396 SetAddressBookName(strAddress, strName);397 int nIndex = InsertLine(m_listCtrl, strName, strAddress);398 SetSelection(m_listCtrl, nIndex);399 m_listCtrl->SetFocus();400+ pframeMain->RefreshListCtrl();401 }402 403 void CAddressBookDialog::OnButtonDelete(wxCommandEvent& event)404@@ -2293,7 +2345,7 @@405 product.vchPubKeyFrom = keyUser.GetPubKey();406 if (!keyUser.Sign(product.GetSigHash(), product.vchSig))407 {408- wxMessageBox("Error digitally signing the product ");409+ wxMessageBox("Error digitally signing the product ");410 return;411 }412 413@@ -2307,14 +2359,14 @@414 // Sign the summary product415 if (!keyUser.Sign(product.GetSigHash(), product.vchSig))416 {417- wxMessageBox("Error digitally signing the product ");418+ wxMessageBox("Error digitally signing the product ");419 return;420 }421 422 // Verify423 if (!product.CheckProduct())424 {425- wxMessageBox("Errors found in product ");426+ wxMessageBox("Errors found in product ");427 return;428 }429 430@@ -2768,7 +2820,7 @@431 {432 if (m_choiceStars->GetSelection() == -1)433 {434- wxMessageBox("Please select a rating ");435+ wxMessageBox("Please select a rating ");436 return;437 }438 439@@ -2779,14 +2831,14 @@440 review.vchPubKeyFrom = keyUser.GetPubKey();441 if (!keyUser.Sign(review.GetSigHash(), review.vchSig))442 {443- wxMessageBox("Unable to digitally sign the review ");444+ wxMessageBox("Unable to digitally sign the review ");445 return;446 }447 448 // Broadcast449 if (!review.AcceptReview())450 {451- wxMessageBox("Save failed ");452+ wxMessageBox("Save failed ");453 return;454 }455 RelayMessage(CInv(MSG_REVIEW, review.GetHash()), review);456@@ -2889,10 +2941,14 @@457 _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);458 _CrtSetReportFile(_CRT_WARN, CreateFile("NUL", GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0));459 #endif460+#ifdef __WXDEBUG__461+ // Disable malfunctioning wxWidgets debug assertion462+ g_isPainting = 10000;463+#endif464 465 //// debug print466 printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");467- printf("Bitcoin CMyApp::OnInit()\n");468+ printf("Bitcoin version %d, Windows version %08x\n", VERSION, GetVersion());469 470 //471 // Limit to single instance per user472@@ -3000,7 +3056,7 @@473 474 if (!strErrors.empty())475 {476- wxMessageBox(strErrors);477+ wxMessageBox(strErrors, "Bitcoin");478 OnExit();479 return false;480 }481@@ -3033,8 +3089,14 @@482 pframeMain = new CMainFrame(NULL);483 pframeMain->Show();484 485+ if (!CheckDiskSpace())486+ {487+ OnExit();488+ return false;489+ }490+491 if (!StartNode(strErrors))492- wxMessageBox(strErrors);493+ wxMessageBox(strErrors, "Bitcoin");494 495 if (fGenerateBitcoins)496 if (_beginthread(ThreadBitcoinMiner, 0, NULL) == -1)497@@ -3133,7 +3195,7 @@498 499 void CMyApp::OnFatalException()500 {501- wxMessageBox("Program has crashed and will terminate. ", "", wxOK | wxICON_ERROR);502+ wxMessageBox("Program has crashed and will terminate. ", "Bitcoin", wxOK | wxICON_ERROR);503 }504 505 506@@ -3162,7 +3224,7 @@507 uint160 hash160;508 if (!AddressToHash160(strAddress, hash160))509 {510- wxMessageBox(strprintf("ThreadRandSendTest: Bitcoin address '%s' not valid ", strAddress.c_str()));511+ wxMessageBox(strprintf("ThreadRandSendTest: Bitcoin address '%s' not valid ", strAddress.c_str()));512 return;513 }514 515@@ -3181,7 +3243,7 @@516 int64 nValue = (GetRand(9) + 1) * 100 * CENT;517 if (GetBalance() < nValue)518 {519- wxMessageBox("Out of money ");520+ wxMessageBox("Out of money ");521 return;522 }523 nValue += (nRep % 100) * CENT;524@@ -3217,13 +3279,13 @@525 int64 nValue = (GetRand(999) + 1) * CENT;526 if (GetBalance() < nValue)527 {528- wxMessageBox("Out of money ");529+ wxMessageBox("Out of money ");530 return;531 }532 533 // Send to IP address534 CSendingDialog* pdialog = new CSendingDialog(pframeMain, addr, nValue, wtx);535 if (!pdialog->Show())536- wxMessageBox("ShowModal Failed ");537-}538-539+ wxMessageBox("ShowModal Failed ");540+}541+
ui.h (modified)
1--- v0.1.3/ui.h2+++ v0.1.5/ui.h3@@ -45,6 +45,7 @@4 void OnPaintListCtrl(wxPaintEvent& event);5 void OnMenuFileExit(wxCommandEvent& event);6 void OnMenuOptionsGenerate(wxCommandEvent& event);7+ void OnMenuOptionsChangeYourAddress(wxCommandEvent& event);8 void OnMenuOptionsOptions(wxCommandEvent& event);9 void OnMenuHelpAbout(wxCommandEvent& event);10 void OnButtonSend(wxCommandEvent& event);11@@ -233,6 +234,7 @@12 // Custom13 bool fSending;14 wxString GetAddress();15+ bool CheckIfMine(const string& strAddress, const string& strTitle);16 };17 18
uibase.cpp (modified)
1--- v0.1.3/uibase.cpp2+++ v0.1.5/uibase.cpp3@@ -33,6 +33,10 @@4 m_menuOptionsGenerateBitcoins = new wxMenuItem(m_menuOptions, wxID_OPTIONSGENERATEBITCOINS, wxString(wxT("&Generate Coins")) , wxEmptyString, wxITEM_CHECK);5 m_menuOptions->Append(m_menuOptionsGenerateBitcoins);6 7+ wxMenuItem* m_menuChangeYourAddress;8+ m_menuChangeYourAddress = new wxMenuItem(m_menuOptions, wxID_ANY, wxString(wxT("&Change Your Address...")) , wxEmptyString, wxITEM_NORMAL);9+ m_menuOptions->Append(m_menuChangeYourAddress);10+11 wxMenuItem* m_menuOptionsOptions;12 m_menuOptionsOptions = new wxMenuItem(m_menuOptions, wxID_ANY, wxString(wxT("&Options...")) , wxEmptyString, wxITEM_NORMAL);13 m_menuOptions->Append(m_menuOptionsOptions);14@@ -82,6 +86,8 @@15 bSizer85->Add(m_buttonCopy, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5);16 17 m_button91 = new wxButton(this, wxID_BUTTONCHANGE, wxT("C&hange..."), wxDefaultPosition, wxDefaultSize, 0);18+ m_button91->Hide();19+20 bSizer85->Add(m_button91, 0, wxRIGHT, 5);21 22 23@@ -103,7 +109,7 @@24 m_staticTextBalance = new wxStaticText(m_panel14, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(120,15), wxALIGN_RIGHT|wxST_NO_AUTORESIZE);25 m_staticTextBalance->Wrap(-1);26 m_staticTextBalance->SetFont(wxFont(8, 70, 90, 90, false, wxEmptyString));27- m_staticTextBalance->SetBackgroundColour(wxColour(240, 240, 240));28+ m_staticTextBalance->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));29 30 bSizer66->Add(m_staticTextBalance, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);31 32@@ -223,6 +229,7 @@33 this->Connect(wxEVT_PAINT, wxPaintEventHandler(CMainFrameBase::OnPaint));34 this->Connect(m_menuFileExit->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(CMainFrameBase::OnMenuFileExit));35 this->Connect(m_menuOptionsGenerateBitcoins->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(CMainFrameBase::OnMenuOptionsGenerate));36+ this->Connect(m_menuChangeYourAddress->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(CMainFrameBase::OnMenuOptionsChangeYourAddress));37 this->Connect(m_menuOptionsOptions->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(CMainFrameBase::OnMenuOptionsOptions));38 this->Connect(m_menuHelpAbout->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(CMainFrameBase::OnMenuHelpAbout));39 this->Connect(wxID_BUTTONSEND, wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler(CMainFrameBase::OnButtonSend));40@@ -273,6 +280,7 @@41 this->Disconnect(wxEVT_PAINT, wxPaintEventHandler(CMainFrameBase::OnPaint));42 this->Disconnect(wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(CMainFrameBase::OnMenuFileExit));43 this->Disconnect(wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(CMainFrameBase::OnMenuOptionsGenerate));44+ this->Disconnect(wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(CMainFrameBase::OnMenuOptionsChangeYourAddress));45 this->Disconnect(wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(CMainFrameBase::OnMenuOptionsOptions));46 this->Disconnect(wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(CMainFrameBase::OnMenuHelpAbout));47 this->Disconnect(wxID_BUTTONSEND, wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler(CMainFrameBase::OnButtonSend));48@@ -492,7 +500,7 @@49 50 fgSizer1->Add(0, 0, 0, wxEXPAND, 5);51 52- m_staticText14 = new wxStaticText(this, wxID_ANY, wxT("Enter the recipient's IP address (e.g. 123.45.6.7) for online transfer with comments and confirmation, \nor bitcoin address (e.g. 1NS17iag9jJgTHD1VXjvLCEnZuQ3rJED9L) if recipient is not online."), wxDefaultPosition, wxDefaultSize, 0);53+ m_staticText14 = new wxStaticText(this, wxID_ANY, wxT("Enter the recipient's IP address (e.g. 123.45.6.7) for online transfer with comments and confirmation, \nor Bitcoin address (e.g. 1NS17iag9jJgTHD1VXjvLCEnZuQ3rJED9L) if recipient is not online."), wxDefaultPosition, wxDefaultSize, 0);54 m_staticText14->Wrap(-1);55 fgSizer1->Add(m_staticText14, 0, wxTOP|wxRIGHT|wxLEFT, 5);56 57@@ -538,13 +546,23 @@58 59 m_staticText20 = new wxStaticText(this, wxID_ANY, wxT("T&ransfer:"), wxDefaultPosition, wxSize(-1,-1), wxALIGN_RIGHT);60 m_staticText20->Wrap(-1);61+ m_staticText20->Hide();62+63 fgSizer1->Add(m_staticText20, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxTOP|wxBOTTOM|wxLEFT, 5);64 65 wxString m_choiceTransferTypeChoices[] = { wxT(" Standard") };66 int m_choiceTransferTypeNChoices = sizeof(m_choiceTransferTypeChoices) / sizeof(wxString);67 m_choiceTransferType = new wxChoice(this, wxID_CHOICETRANSFERTYPE, wxDefaultPosition, wxDefaultSize, m_choiceTransferTypeNChoices, m_choiceTransferTypeChoices, 0);68 m_choiceTransferType->SetSelection(0);69+ m_choiceTransferType->Hide();70+71 fgSizer1->Add(m_choiceTransferType, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);72+73+74+ fgSizer1->Add(0, 3, 0, wxEXPAND, 5);75+76+77+ fgSizer1->Add(0, 0, 0, wxEXPAND, 5);78 79 bSizer21->Add(fgSizer1, 0, wxEXPAND|wxLEFT, 5);80 81@@ -696,8 +714,8 @@82 83 bSizer68->Add(0, 5, 0, wxEXPAND, 5);84 85- m_staticText45 = new wxStaticText(this, wxID_ANY, wxT("These are your Bitcoin addresses for receiving payments.\nYou may want to give a different one to each sender so you can keep track of who is paying you."), wxDefaultPosition, wxDefaultSize, 0);86- m_staticText45->Wrap(600);87+ m_staticText45 = new wxStaticText(this, wxID_ANY, wxT("These are your Bitcoin addresses for receiving payments. You may want to give a different one to each sender so you can keep track of who is paying you. The highlighted address is displayed in the main window."), wxDefaultPosition, wxDefaultSize, 0);88+ m_staticText45->Wrap(590);89 bSizer68->Add(m_staticText45, 0, wxALL, 5);90 91 m_listCtrl = new wxListCtrl(this, wxID_LISTCTRL, wxDefaultPosition, wxDefaultSize, wxLC_NO_SORT_HEADER|wxLC_REPORT|wxLC_SORT_ASCENDING);92@@ -709,7 +727,7 @@93 94 bSizer69->Add(0, 0, 1, wxEXPAND, 5);95 96- m_buttonRename = new wxButton(this, wxID_BUTTONRENAME, wxT("&Rename..."), wxDefaultPosition, wxDefaultSize, 0);97+ m_buttonRename = new wxButton(this, wxID_BUTTONRENAME, wxT("&Edit..."), wxDefaultPosition, wxDefaultSize, 0);98 m_buttonRename->SetMinSize(wxSize(85,25));99 100 bSizer69->Add(m_buttonRename, 0, wxALL, 5);101@@ -730,6 +748,7 @@102 bSizer69->Add(m_buttonOK, 0, wxALL, 5);103 104 m_buttonCancel = new wxButton(this, wxID_CANCEL, wxT("Cancel"), wxDefaultPosition, wxSize(-1,-1), 0);105+ m_buttonCancel->Hide();106 m_buttonCancel->SetMinSize(wxSize(85,25));107 108 bSizer69->Add(m_buttonCancel, 0, wxALL, 5);
uibase.h (modified)
1--- v0.1.3/uibase.h2+++ v0.1.5/uibase.h3@@ -134,6 +134,7 @@4 virtual void OnPaint(wxPaintEvent& event){ event.Skip(); }5 virtual void OnMenuFileExit(wxCommandEvent& event){ event.Skip(); }6 virtual void OnMenuOptionsGenerate(wxCommandEvent& event){ event.Skip(); }7+ virtual void OnMenuOptionsChangeYourAddress(wxCommandEvent& event){ event.Skip(); }8 virtual void OnMenuOptionsOptions(wxCommandEvent& event){ event.Skip(); }9 virtual void OnMenuHelpAbout(wxCommandEvent& event){ event.Skip(); }10 virtual void OnButtonSend(wxCommandEvent& event){ event.Skip(); }11@@ -260,6 +261,8 @@12 wxTextCtrl* m_textCtrlAmount;13 wxStaticText* m_staticText20;14 wxChoice* m_choiceTransferType;15+16+17 wxStaticText* m_staticTextFrom;18 wxTextCtrl* m_textCtrlFrom;19 wxStaticText* m_staticTextMessage;20@@ -279,7 +282,7 @@21 22 23 public:24- CSendDialogBase(wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Send Coins"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize(675,338), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER);25+ CSendDialogBase(wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Send Coins"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize(675,312), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER);26 ~CSendDialogBase();27 28 };29@@ -342,7 +345,7 @@30 31 32 public:33- CYourAddressDialogBase(wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Your Bitcoin Address"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize(610,390), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER);34+ CYourAddressDialogBase(wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Your Bitcoin Addresses"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize(610,390), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER);35 ~CYourAddressDialogBase();36 37 };
util.cpp (modified)
1--- v0.1.3/util.cpp2+++ v0.1.5/util.cpp3@@ -235,12 +235,12 @@4 if (*p == '.')5 {6 p++;7- if (!isdigit(p[0]) || !isdigit(p[1]))8- return false;9- nCents = atoi64(p);10- if (nCents < 0 || nCents > 99)11- return false;12- p += 2;13+ if (isdigit(*p))14+ {15+ nCents = 10 * (*p++ - '0');16+ if (isdigit(*p))17+ nCents += (*p++ - '0');18+ }19 break;20 }21 if (isspace(*p))22@@ -252,13 +252,17 @@23 for (; *p; p++)24 if (!isspace(*p))25 return false;26- if (strWhole.size() > 17)27+ if (strWhole.size() > 14)28+ return false;29+ if (nCents < 0 || nCents > 99)30 return false;31 int64 nWhole = atoi64(strWhole);32- int64 nValue = nWhole * 100 + nCents;33- if (nValue / 100 != nWhole)34+ int64 nPreValue = nWhole * 100 + nCents;35+ int64 nValue = nPreValue * CENT;36+ if (nValue / CENT != nPreValue)37 return false;38- nValue *= CENT;39+ if (nValue / COIN != nWhole)40+ return false;41 nRet = nValue;42 return true;43 }
