Research
Timechain
Search Donate
Sponsors
Cake Wallet, private Bitcoin and Monero walletSideShift.ai, no-signup crypto exchangeOrangeRock, non-custodial bitcoin spot and perps tradingBraiins Hashpower, buy and sell Bitcoin hashrateeCash.com
What changed

Bitcoin v0.3.8 → v0.3.10

17 files · +776 · −172 · 08fee7520 · 2010-08-15 · s_nakamoto

Release commit message: makefile.unix to build with option to enable tcatm's 4-way SSE2 SHA-256 with -4way switch on Linux -- version 0.3.10 release

v0.3.10. Previous diff: v0.3.7 → v0.3.8. Next: v0.3.10 → v0.3.12.

build-unix.txt (modified)

1--- v0.3.8/build-unix.txt2+++ v0.3.10/build-unix.txt3@@ -64,11 +64,18 @@4 ldconfig5 6 7+Berkeley DB8+-----------9+You need Berkeley DB 4.7.  Don't use 4.8, the database/log0000* files10+are incompatible.  If you have to build Berkeley DB yourself:11+../dist/configure --enable-cxx12+make13+14+15 Boost16 -----17-If you want to build Boost yourself,18-cd /usr/local/boost_1_40_019-su20+If you need to build Boost yourself:21+sudo su22 ./bootstrap.sh23 ./bjam install24 

headers.h (modified)

1--- v0.3.8/headers.h2+++ v0.3.10/headers.h3@@ -18,6 +18,14 @@4 #define _WIN32_IE 0x04005 #define WIN32_LEAN_AND_MEAN 16 #define __STDC_LIMIT_MACROS // to enable UINT64_MAX from stdint.h7+#if (defined(__unix__) || defined(unix)) && !defined(USG)8+#include <sys/param.h>  // to get BSD define9+#endif10+#ifdef __WXMAC_OSX__11+#ifndef BSD12+#define BSD 113+#endif14+#endif15 #ifdef GUI16 #include <wx/wx.h>17 #include <wx/stdpaths.h>18@@ -25,12 +33,6 @@19 #include <wx/utils.h>20 #include <wx/clipbrd.h>21 #include <wx/taskbar.h>22-#else23-#ifdef __WXMAC_OSX__24-#define __WXMAC__ 125-#define __WXOSX__ 126-#define __BSD__ 127-#endif28 #endif29 #include <openssl/buffer.h>30 #include <openssl/ecdsa.h>31@@ -98,7 +100,7 @@32 #include <ifaddrs.h>33 #include <fcntl.h>34 #endif35-#ifdef __BSD__36+#ifdef BSD37 #include <netinet/in.h>38 #endif39 

init.cpp (modified)

1--- v0.3.8/init.cpp2+++ v0.3.10/init.cpp3@@ -137,7 +137,10 @@4     ParseParameters(argc, argv);5 6     if (mapArgs.count("-datadir"))7-        strlcpy(pszSetDataDir, mapArgs["-datadir"].c_str(), sizeof(pszSetDataDir));8+    {9+        filesystem::path pathDataDir = filesystem::system_complete(mapArgs["-datadir"]);10+        strlcpy(pszSetDataDir, pathDataDir.string().c_str(), sizeof(pszSetDataDir));11+    }12 13     ReadConfigFile(mapArgs, mapMultiArgs); // Must be done after processing datadir14 15@@ -147,8 +150,8 @@16           _("Usage:") + "\t\t\t\t\t\t\t\t\t\t\n" +17             "  bitcoin [options]                   \t  " + "\n" +18             "  bitcoin [options] <command> [params]\t  " + _("Send command to -server or bitcoind\n") +19-            "  bitcoin [options] <command> -?      \t\t  " + _("Get help for a command\n") +20-            "  bitcoin help                        \t\t\t  " + _("List commands\n") +21+            "  bitcoin [options] help              \t\t  " + _("List commands\n") +22+            "  bitcoin [options] help <command>    \t\t  " + _("Get help for a command\n") +23           _("Options:\n") +24             "  -conf=<file>    \t  " + _("Specify configuration file (default: bitcoin.conf)\n") +25             "  -gen            \t  " + _("Generate coins\n") +26@@ -363,6 +366,17 @@27         }28     }29 30+    if (mapArgs.count("-paytxfee"))31+    {32+        if (!ParseMoney(mapArgs["-paytxfee"], nTransactionFee))33+        {34+            wxMessageBox(_("Invalid amount for -paytxfee=<amount>"), "Bitcoin");35+            return false;36+        }37+        if (nTransactionFee > 1 * COIN)38+            wxMessageBox(_("Warning: -paytxfee is set very high.  This is the transaction fee you will pay if you send a transaction."), "Bitcoin");39+    }40+41     //42     // Create the main window and start the node43     //44@@ -382,7 +396,7 @@45     if (mapArgs.count("-server") || fDaemon)46         CreateThread(ThreadRPCServer, NULL);47 48-#ifdef GUI49+#if defined(__WXMSW__) && defined(GUI)50     if (fFirstRun)51         SetStartOnSystemStartup(true);52 #endif

main.cpp (modified)

1--- v0.3.8/main.cpp2+++ v0.3.10/main.cpp3@@ -52,6 +52,9 @@4 CCriticalSection cs_mapAddressBook;5 6 vector<unsigned char> vchDefaultKey;7+8+double dHashesPerSec;9+int64 nHPSTimerStart;10 11 // Settings12 int fGenerateBitcoins = false;13@@ -535,7 +538,7 @@14     // Check against previous transactions15     map<uint256, CTxIndex> mapUnused;16     int64 nFees = 0;17-    if (fCheckInputs && !ConnectInputs(txdb, mapUnused, CDiskTxPos(1,1,1), 0, nFees, false, false))18+    if (fCheckInputs && !ConnectInputs(txdb, mapUnused, CDiskTxPos(1,1,1), pindexBest, nFees, false, false))19     {20         if (pfMissingInputs)21             *pfMissingInputs = true;22@@ -741,7 +744,7 @@23     if (GetTime() < nNextTime)24         return;25     bool fFirst = (nNextTime == 0);26-    nNextTime = GetTime() + GetRand(120 * 60);27+    nNextTime = GetTime() + GetRand(30 * 60);28     if (fFirst)29         return;30 31@@ -757,7 +760,7 @@32             CWalletTx& wtx = item.second;33             // Don't rebroadcast until it's had plenty of time that34             // it should have gotten in already by now.35-            if (nTimeBestReceived - wtx.nTimeReceived > 60 * 60)36+            if (nTimeBestReceived - (int64)wtx.nTimeReceived > 5 * 60)37                 mapSorted.insert(make_pair(wtx.nTimeReceived, &wtx));38         }39         foreach(PAIRTYPE(const unsigned int, CWalletTx*)& item, mapSorted)40@@ -885,7 +888,7 @@41     printf("Lockdown:  current best=%s  height=%d  work=%s\n", hashBestChain.ToString().substr(0,22).c_str(), nBestHeight, bnBestChainWork.ToString().c_str());42     printf("Lockdown: IsLockdown()=%d\n", (IsLockdown() ? 1 : 0));43     if (IsLockdown())44-        printf("Lockdown: WARNING: Displayed transactions may not be correct!  You may need to upgrade.\n");45+        printf("Lockdown: WARNING: Displayed transactions may not be correct!  You may need to upgrade, or other nodes may need to upgrade.\n");46 }47 48 49@@ -928,7 +931,8 @@50 }51 52 53-bool CTransaction::ConnectInputs(CTxDB& txdb, map<uint256, CTxIndex>& mapTestPool, CDiskTxPos posThisTx, int nHeight, int64& nFees, bool fBlock, bool fMiner, int64 nMinFee)54+bool CTransaction::ConnectInputs(CTxDB& txdb, map<uint256, CTxIndex>& mapTestPool, CDiskTxPos posThisTx,55+                                 CBlockIndex* pindexBlock, int64& nFees, bool fBlock, bool fMiner, int64 nMinFee)56 {57     // Take over previous transactions' spent pointers58     if (!IsCoinBase())59@@ -980,9 +984,9 @@60 61             // If prev is coinbase, check that it's matured62             if (txPrev.IsCoinBase())63-                for (CBlockIndex* pindex = pindexBest; pindex && nBestHeight - pindex->nHeight < COINBASE_MATURITY-1; pindex = pindex->pprev)64+                for (CBlockIndex* pindex = pindexBlock; pindex && pindexBlock->nHeight - pindex->nHeight < COINBASE_MATURITY; pindex = pindex->pprev)65                     if (pindex->nBlockPos == txindex.pos.nBlockPos && pindex->nFile == txindex.pos.nFile)66-                        return error("ConnectInputs() : tried to spend coinbase at depth %d", nBestHeight - pindex->nHeight);67+                        return error("ConnectInputs() : tried to spend coinbase at depth %d", pindexBlock->nHeight - pindex->nHeight);68 69             // Verify signature70             if (!VerifySignature(txPrev, *this, i))71@@ -1002,6 +1006,14 @@72                 mapTestPool[prevout.hash] = txindex;73 74             nValueIn += txPrev.vout[prevout.n].nValue;75+76+            // Check for negative or overflow input values77+            if (txPrev.vout[prevout.n].nValue < 0)78+                return error("ConnectInputs() : txin.nValue negative");79+            if (txPrev.vout[prevout.n].nValue > MAX_MONEY)80+                return error("ConnectInputs() : txin.nValue too high");81+            if (nValueIn > MAX_MONEY)82+                return error("ConnectInputs() : txin total too high");83         }84 85         // Tally transaction fees86@@ -1016,7 +1028,7 @@87     if (fBlock)88     {89         // Add transaction to disk index90-        if (!txdb.AddTxIndex(*this, posThisTx, nHeight))91+        if (!txdb.AddTxIndex(*this, posThisTx, pindexBlock->nHeight))92             return error("ConnectInputs() : AddTxPos failed");93     }94     else if (fMiner)95@@ -1105,7 +1117,7 @@96         CDiskTxPos posThisTx(pindex->nFile, pindex->nBlockPos, nTxPos);97         nTxPos += ::GetSerializeSize(tx, SER_DISK);98 99-        if (!tx.ConnectInputs(txdb, mapUnused, posThisTx, pindex->nHeight, nFees, true, false))100+        if (!tx.ConnectInputs(txdb, mapUnused, posThisTx, pindex, nFees, true, false))101             return false;102     }103 104@@ -1376,14 +1388,21 @@105         return error("AcceptBlock() : incorrect proof of work");106 107     // Check that the block chain matches the known block chain up to a checkpoint108-    if (pindexPrev->nHeight+1 == 11111 && hash != uint256("0x0000000069e244f73d78e8fd29ba2fd2ed618bd6fa2ee92559f542fdb26e7c1d"))109-        return error("AcceptBlock() : rejected by checkpoint lockin at 11111");110-    if (pindexPrev->nHeight+1 == 33333 && hash != uint256("0x000000002dd5588a74784eaa7ab0507a18ad16a236e7b1ce69f00d7ddfb5d0a6"))111-        return error("AcceptBlock() : rejected by checkpoint lockin at 33333");112-    if (pindexPrev->nHeight+1 == 68555 && hash != uint256("0x00000000001e1b4903550a0b96e9a9405c8a95f387162e4944e8d9fbe501cd6a"))113-        return error("AcceptBlock() : rejected by checkpoint lockin at 68555");114-    if (pindexPrev->nHeight+1 == 70567 && hash != uint256("0x00000000006a49b14bcf27462068f1264c961f11fa2e0eddd2be0791e1d4124a"))115-        return error("AcceptBlock() : rejected by checkpoint lockin at 70567");116+    if ((pindexPrev->nHeight+1 == 11111 && hash != uint256("0x0000000069e244f73d78e8fd29ba2fd2ed618bd6fa2ee92559f542fdb26e7c1d")) ||117+        (pindexPrev->nHeight+1 == 33333 && hash != uint256("0x000000002dd5588a74784eaa7ab0507a18ad16a236e7b1ce69f00d7ddfb5d0a6")) ||118+        (pindexPrev->nHeight+1 == 68555 && hash != uint256("0x00000000001e1b4903550a0b96e9a9405c8a95f387162e4944e8d9fbe501cd6a")) ||119+        (pindexPrev->nHeight+1 == 70567 && hash != uint256("0x00000000006a49b14bcf27462068f1264c961f11fa2e0eddd2be0791e1d4124a")) ||120+        (pindexPrev->nHeight+1 == 74000 && hash != uint256("0x0000000000573993a3c9e41ce34471c079dcf5f52a0e824a81e7f953b8661a20")))121+        return error("AcceptBlock() : rejected by checkpoint lockin at %d", pindexPrev->nHeight+1);122+123+    // Scanback checkpoint lockin124+    for (CBlockIndex* pindex = pindexPrev; pindex->nHeight >= 74000; pindex = pindex->pprev)125+    {126+        if (pindex->nHeight == 74000 && pindex->GetBlockHash() != uint256("0x0000000000573993a3c9e41ce34471c079dcf5f52a0e824a81e7f953b8661a20"))127+            return error("AcceptBlock() : rejected by scanback lockin at %d", pindex->nHeight);128+        if (pindex->nHeight == 74638 && pindex->GetBlockHash() == uint256("0x0000000000790ab3f22ec756ad43b6ab569abf0bddeb97c67a6f7b1470a7ec1c"))129+            return error("AcceptBlock() : rejected by scanback lockin at %d", pindex->nHeight);130+    }131 132     // Write block to history file133     if (!CheckDiskSpace(::GetSerializeSize(*this, SER_DISK)))134@@ -2221,7 +2240,7 @@135         // This includes all nodes that are currently online,136         // since they rebroadcast an addr every 24 hours137         pfrom->vAddrToSend.clear();138-        int64 nSince = GetAdjustedTime() - 24 * 60 * 60; // in the last 24 hours139+        int64 nSince = GetAdjustedTime() - 12 * 60 * 60; // in the last 12 hours140         CRITICAL_BLOCK(cs_mapAddresses)141         {142             unsigned int nSize = mapAddresses.size();143@@ -2542,6 +2561,9 @@144         PrintException(NULL, "ThreadBitcoinMiner()");145     }146     UIThreadCall(bind(CalledSetStatusBar, "", 0));147+    nHPSTimerStart = 0;148+    if (vnThreadsRunning[3] == 0)149+        dHashesPerSec = 0;150     printf("ThreadBitcoinMiner exiting, %d threads remaining\n", vnThreadsRunning[3]);151 }152 153@@ -2571,6 +2593,8 @@154     CryptoPP::SHA256::Transform((CryptoPP::word32*)pstate, (CryptoPP::word32*)pinput);155 }156 157+static const int NPAR = 32;158+extern void Double_BlockSHA256(const void* pin, void* pout, const void* pinit, unsigned int hash[8][NPAR], const void* init2);159 160 161 162@@ -2652,7 +2676,7 @@163                     int64 nMinFee = tx.GetMinFee(nBlockSize);164 165                     map<uint256, CTxIndex> mapTestPoolTmp(mapTestPool);166-                    if (!tx.ConnectInputs(txdb, mapTestPoolTmp, CDiskTxPos(1,1,1), 0, nFees, false, true, nMinFee))167+                    if (!tx.ConnectInputs(txdb, mapTestPoolTmp, CDiskTxPos(1,1,1), pindexPrev, nFees, false, true, nMinFee))168                         continue;169                     swap(mapTestPool, mapTestPoolTmp);170 171@@ -2713,14 +2737,40 @@172         //173         // Search174         //175+        bool f4WaySSE2 = mapArgs.count("-4way");176         int64 nStart = GetTime();177         uint256 hashTarget = CBigNum().SetCompact(pblock->nBits).getuint256();178         uint256 hashbuf[2];179         uint256& hash = *alignup<16>(hashbuf);180         loop181         {182-            SHA256Transform(&tmp.hash1, (char*)&tmp.block + 64, &midstate);183-            SHA256Transform(&hash, &tmp.hash1, pSHA256InitState);184+#ifdef FOURWAYSSE2185+            if (f4WaySSE2)186+            {187+                // tcatm's 4-way SSE2 SHA-256188+                tmp.block.nNonce += NPAR;189+                unsigned int thashbuf[9][NPAR];190+                unsigned int (&thash)[9][NPAR] = *alignup<16>(&thashbuf);191+                Double_BlockSHA256((char*)&tmp.block + 64, &tmp.hash1, &midstate, thash, pSHA256InitState);192+                ((unsigned short*)&hash)[14] = 0xffff;193+                for (int j = 0; j < NPAR; j++)194+                {195+                    if (thash[7][j] == 0)196+                    {197+                        for (int i = 0; i < sizeof(hash)/4; i++)198+                            ((unsigned int*)&hash)[i] = thash[i][j];199+                        pblock->nNonce = ByteReverse(tmp.block.nNonce + j);200+                    }201+                }202+            }203+            else204+#endif205+            {206+                // Crypto++ SHA-256207+                tmp.block.nNonce++;208+                SHA256Transform(&tmp.hash1, (char*)&tmp.block + 64, &midstate);209+                SHA256Transform(&hash, &tmp.hash1, pSHA256InitState);210+            }211 212             if (((unsigned short*)&hash)[14] == 0)213             {214@@ -2730,7 +2780,10 @@215 216                 if (hash <= hashTarget)217                 {218-                    pblock->nNonce = ByteReverse(tmp.block.nNonce);219+#ifdef FOURWAYSSE2220+                    if (!f4WaySSE2)221+#endif222+                        pblock->nNonce = ByteReverse(tmp.block.nNonce);223                     assert(hash == pblock->GetHash());224 225                         //// debug print226@@ -2768,25 +2821,28 @@227 228             // Update nTime every few seconds229             const unsigned int nMask = 0xffff;230-            if ((++tmp.block.nNonce & nMask) == 0)231+            const int nHashesPerCycle = (nMask+1);232+            if ((tmp.block.nNonce & nMask) == 0)233             {234                 // Meter hashes/sec235-                static int64 nTimerStart;236-                static int nHashCounter;237-                if (nTimerStart == 0)238-                    nTimerStart = GetTimeMillis();239+                static int nCycleCounter;240+                if (nHPSTimerStart == 0)241+                {242+                    nHPSTimerStart = GetTimeMillis();243+                    nCycleCounter = 0;244+                }245                 else246-                    nHashCounter++;247-                if (GetTimeMillis() - nTimerStart > 4000)248+                    nCycleCounter++;249+                if (GetTimeMillis() - nHPSTimerStart > 4000)250                 {251                     static CCriticalSection cs;252                     CRITICAL_BLOCK(cs)253                     {254-                        if (GetTimeMillis() - nTimerStart > 4000)255+                        if (GetTimeMillis() - nHPSTimerStart > 4000)256                         {257-                            double dHashesPerSec = 1000.0 * (nMask+1) * nHashCounter / (GetTimeMillis() - nTimerStart);258-                            nTimerStart = GetTimeMillis();259-                            nHashCounter = 0;260+                            dHashesPerSec = 1000.0 * nHashesPerCycle * nCycleCounter / (GetTimeMillis() - nHPSTimerStart);261+                            nHPSTimerStart = GetTimeMillis();262+                            nCycleCounter = 0;263                             string strStatus = strprintf("    %.0f khash/s", dHashesPerSec/1000.0);264                             UIThreadCall(bind(CalledSetStatusBar, strStatus, 0));265                             static int64 nLogTime;

main.h (modified)

1--- v0.3.8/main.h2+++ v0.3.10/main.h3@@ -18,6 +18,7 @@4 static const unsigned int MAX_BLOCK_SIZE = 1000000;5 static const int64 COIN = 100000000;6 static const int64 CENT = 1000000;7+static const int64 MAX_MONEY = 21000000 * COIN;8 static const int COINBASE_MATURITY = 100;9 10 static const CBigNum bnProofOfWorkLimit(~uint256(0) >> 32);11@@ -42,6 +43,8 @@12 extern map<string, string> mapAddressBook;13 extern CCriticalSection cs_mapAddressBook;14 extern vector<unsigned char> vchDefaultKey;15+extern double dHashesPerSec;16+extern int64 nHPSTimerStart;17 18 // Settings19 extern int fGenerateBitcoins;20@@ -469,10 +472,18 @@21         if (vin.empty() || vout.empty())22             return error("CTransaction::CheckTransaction() : vin or vout empty");23 24-        // Check for negative values25+        // Check for negative or overflow output values26+        int64 nValueOut = 0;27         foreach(const CTxOut& txout, vout)28+        {29             if (txout.nValue < 0)30                 return error("CTransaction::CheckTransaction() : txout.nValue negative");31+            if (txout.nValue > MAX_MONEY)32+                return error("CTransaction::CheckTransaction() : txout.nValue too high");33+            nValueOut += txout.nValue;34+            if (nValueOut > MAX_MONEY)35+                return error("CTransaction::CheckTransaction() : txout total too high");36+        }37 38         if (IsCoinBase())39         {40@@ -611,7 +622,8 @@41 42 43     bool DisconnectInputs(CTxDB& txdb);44-    bool ConnectInputs(CTxDB& txdb, map<uint256, CTxIndex>& mapTestPool, CDiskTxPos posThisTx, int nHeight, int64& nFees, bool fBlock, bool fMiner, int64 nMinFee=0);45+    bool ConnectInputs(CTxDB& txdb, map<uint256, CTxIndex>& mapTestPool, CDiskTxPos posThisTx,46+                       CBlockIndex* pindexBlock, int64& nFees, bool fBlock, bool fMiner, int64 nMinFee=0);47     bool ClientConnectInputs();48 49     bool AcceptTransaction(CTxDB& txdb, bool fCheckInputs=true, bool* pfMissingInputs=NULL);

makefile.mingw (modified)

1--- v0.3.8/makefile.mingw2+++ v0.3.10/makefile.mingw3@@ -54,7 +54,7 @@4 	g++ -c $(CFLAGS) -DGUI -o $@ $<5 6 cryptopp/obj/%.o: cryptopp/%.cpp7-	g++ -c $(CFLAGS) -O3 -DCRYPTOPP_X86_ASM_AVAILABLE -DCRYPTOPP_DISABLE_SSE2 -o $@ $<8+	g++ -c $(CFLAGS) -O3 -DCRYPTOPP_X86_ASM_AVAILABLE -o $@ $<9 10 obj/ui_res.o: ui.rc  rc/bitcoin.ico rc/check.ico rc/send16.bmp rc/send16mask.bmp rc/send16masknoshadow.bmp rc/send20.bmp rc/send20mask.bmp rc/addressbook16.bmp rc/addressbook16mask.bmp rc/addressbook20.bmp rc/addressbook20mask.bmp11 	windres $(DEFS) $(INCLUDEPATHS) -o $@ -i $<

makefile.osx (modified)

1--- v0.3.8/makefile.osx2+++ v0.3.10/makefile.osx3@@ -5,6 +5,7 @@4 # Mac OS X makefile for bitcoin5 # Laszlo Hanyecz (solar@heliacal.net)6 7+CXX=llvm-g++8 DEPSDIR=/Users/macosuser/bitcoin/deps9 10 INCLUDEPATHS= \11@@ -27,7 +28,7 @@12 13 DEBUGFLAGS=-g -DwxDEBUG_LEVEL=014 # ppc doesn't work because we don't support big-endian15-CFLAGS=-mmacosx-version-min=10.5 -arch i386 -arch x86_64 -O2 -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS)16+CFLAGS=-mmacosx-version-min=10.5 -arch i386 -arch x86_64 -O3 -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS)17 HEADERS=headers.h strlcpy.h serialize.h uint256.h util.h key.h bignum.h base58.h \18     script.h db.h net.h irc.h main.h rpc.h uibase.h ui.h noui.h init.h19 20@@ -48,23 +49,25 @@21 22 23 obj/%.o: %.cpp $(HEADERS)24-	g++ -c $(CFLAGS) -DGUI -o $@ $<25+	$(CXX) -c $(CFLAGS) -DGUI -o $@ $<26 27 cryptopp/obj/%.o: cryptopp/%.cpp28-	g++ -c $(CFLAGS) -O3 -DCRYPTOPP_DISABLE_ASM -o $@ $<29+	$(CXX) -c $(CFLAGS) -O3 -DCRYPTOPP_DISABLE_ASM -o $@ $<30 31 bitcoin: $(OBJS) obj/ui.o obj/uibase.o32-	g++ $(CFLAGS) -o $@ $(LIBPATHS) $^ $(WXLIBS) $(LIBS)33+	$(CXX) $(CFLAGS) -o $@ $(LIBPATHS) $^ $(WXLIBS) $(LIBS)34 35 36 obj/nogui/%.o: %.cpp $(HEADERS)37-	g++ -c $(CFLAGS) -o $@ $<38+	$(CXX) -c $(CFLAGS) -o $@ $<39 40 bitcoind: $(OBJS:obj/%=obj/nogui/%)41-	g++ $(CFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS)42+	$(CXX) $(CFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS)43 44 45 clean:46+	-rm -f bitcoin bitcoind47 	-rm -f obj/*.o48 	-rm -f obj/nogui/*.o49+	-rm -f cryptopp/obj/*.o50 

makefile.unix (modified)

1--- v0.3.8/makefile.unix2+++ v0.3.10/makefile.unix3@@ -25,7 +25,7 @@4  -Wl,-Bdynamic \5    -l gthread-2.06 7-DEFS=-D__WXGTK__ -DNOPCH8+DEFS=-D__WXGTK__ -DNOPCH -DFOURWAYSSE29 DEBUGFLAGS=-g -D__WXDEBUG__10 CFLAGS=-O2 -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS)11 HEADERS=headers.h strlcpy.h serialize.h uint256.h util.h key.h bignum.h base58.h \12@@ -51,16 +51,19 @@13 	g++ -c $(CFLAGS) -DGUI -o $@ $<14 15 cryptopp/obj/%.o: cryptopp/%.cpp16-	g++ -c $(CFLAGS) -O3 -DCRYPTOPP_DISABLE_SSE2 -o $@ $<17+	g++ -c $(CFLAGS) -O3 -o $@ $<18 19-bitcoin: $(OBJS) obj/ui.o obj/uibase.o20+obj/sha256.o: sha256.cpp21+	g++ -c $(CFLAGS) -msse2 -O3 -o $@ $<22+23+bitcoin: $(OBJS) obj/ui.o obj/uibase.o obj/sha256.o24 	g++ $(CFLAGS) -o $@ $^ $(WXLIBS) $(LIBS)25 26 27 obj/nogui/%.o: %.cpp $(HEADERS)28 	g++ -c $(CFLAGS) -o $@ $<29 30-bitcoind: $(OBJS:obj/%=obj/nogui/%)31+bitcoind: $(OBJS:obj/%=obj/nogui/%) obj/sha256.o32 	g++ $(CFLAGS) -o $@ $^ $(LIBS)33 34 

net.cpp (modified)

1--- v0.3.8/net.cpp2+++ v0.3.10/net.cpp3@@ -3,6 +3,8 @@4 // file license.txt or http://www.opensource.org/licenses/mit-license.php.5 6 #include "headers.h"7+8+static const int MAX_OUTBOUND_CONNECTIONS = 8;9 10 void ThreadMessageHandler2(void* parg);11 void ThreadSocketHandler2(void* parg);12@@ -64,7 +66,7 @@13     SOCKET hSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);14     if (hSocket == INVALID_SOCKET)15         return false;16-#if defined(__BSD__) || defined(__WXMAC_OSX__)17+#ifdef BSD18     int set = 1;19     setsockopt(hSocket, SOL_SOCKET, SO_NOSIGPIPE, (void*)&set, sizeof(int));20 #endif21@@ -652,6 +654,10 @@22             {23                 if (WSAGetLastError() != WSAEWOULDBLOCK)24                     printf("socket error accept failed: %d\n", WSAGetLastError());25+            }26+            else if (mapArgs.count("-maxconnections") && (int)vNodes.size() >= atoi(mapArgs["-maxconnections"]) - MAX_OUTBOUND_CONNECTIONS)27+            {28+                closesocket(hSocket);29             }30             else31             {32@@ -802,6 +808,7 @@33 34 unsigned int pnSeed[] =35 {36+    // 2010/0637     0x35218252, 0x9c9c9618, 0xda6bacad, 0xb9aca862, 0x97c235c6,38     0x146f9562, 0xb67b9e4b, 0x87cf4bc0, 0xb83945d0, 0x984333ad,39     0xbbeec555, 0x6f0eb440, 0xe0005318, 0x7797e460, 0xddc60fcc,40@@ -812,6 +819,31 @@41     0xdd3462d0, 0x4e4d1448, 0x171df645, 0x84ee1155,42     0x248ac445, 0x0e634444, 0x0ded1b63, 0x30c01e60,43     0xa2b9a094, 0x29e4fd43, 0x9ce61b4c, 0xdae09744,44+45+    // 2010/0846+    0x5ae6bf43, 0x460be257, 0x7245c0cf, 0x4e0f028d, 0x26501760, 0x38643255, 0x67094f4f, 0x480449b8,47+    0x16545143, 0x1f082e5a, 0xaa428018, 0xe411e793, 0x14c1f862, 0x2726105b, 0x9b33ea50, 0xeeef86ca,48+    0xe3210d44, 0x0dca8b63, 0x3f9dfb18, 0x860340ad, 0xf33ba17a, 0x9018375c, 0x1de4e353, 0x0fa52dcb,49+    0x89c4555b, 0x109cf37b, 0x28c55b40, 0x04c801ae, 0x275c1e80, 0x6f7f745d, 0x7a2a5653, 0xa28e26d8,50+    0xa4e65db2, 0x99a06580, 0xf253ba44, 0x82cf6ab8, 0x859c2e8e, 0xf71a815d, 0xc18f1454, 0x71c8a943,51+    0x90d24e18, 0x311789b2, 0x74aba645, 0xde0bbfc3, 0xad724fad, 0xbf1ae15e, 0xbaa6fb54, 0x06e4d145,52+    0x51528645, 0x72120cd4, 0xd4cfd145, 0x0a7afed8, 0x9b9a5fad, 0x9e9ff45e, 0x10128355, 0xd44e8646,53+    0x04a07b47, 0x5fc9d547, 0xe0491e45, 0xbac21b41, 0x7aa31bae, 0x10483c5f, 0x94a23055, 0x73d9dc47,54+    0x1a99c247, 0x822fe847, 0x7e57ba48, 0xb19ea843, 0xa60621b2, 0x778cf163, 0x125c6556, 0xf94ba44f,55+    0xa61a0948, 0x6c839e4b, 0x29af5348, 0x68d84845, 0x752b95c3, 0xcf0d4663, 0x08e11e56, 0x75109550,56+    0x5f24b94c, 0x42426d4d, 0xfbbc0a4c, 0x70a9a246, 0xda7837cb, 0xae2a986d, 0xe283c358, 0x0c7ca954,57+    0x8e9bde59, 0x61521760, 0x6884444c, 0xa194e548, 0x9b8809cc, 0x16e96a8f, 0x956ff859, 0xfad5e555,58+    0x0ea70c80, 0x5b4ce26d, 0x7984444c, 0x1080d24a, 0x22a686cf, 0x6bf8c2ad, 0xb0f7485f, 0x06b66e56,59+    0x668373bc, 0x75506279, 0x3868694e, 0x12a5954b, 0x3a8b62d1, 0xb74fcbad, 0xa7dc3360, 0xc070b359,60+    0xa2b87242, 0xc45cab7c, 0x69882050, 0x14a5464b, 0x386acad5, 0x80b85db2, 0x1f78a062, 0xc608c55b,61+    0x4257d543, 0x7636ad80, 0x4432d655, 0xb2114d4b, 0x32639bd9, 0xadd75db2, 0x9be5a362, 0x6831bc5e,62+    0xf7f77046, 0x8f35ba81, 0x09bb4e59, 0xd0fb6b4e, 0xc5daa445, 0x9c611618, 0x355dcc62, 0xf2cf435e,63+    0x31e72c46, 0xdd8a43ad, 0x171f9c5b, 0xb4c2e355, 0xbe8af945, 0x613d3942, 0xe6f9e863, 0x7a3d855f,64+    0xa66adc47, 0x261089b2, 0x5a27105b, 0x6c28105b, 0xdd247946, 0xe6c3a445, 0x43a1ec63, 0x99b4dd5f,65+    0xb6834347, 0x5e9649bc, 0xf9dd545d, 0x6ae4c15b, 0xa5318a47, 0x7984ec47, 0x93a73b63, 0x0c60195f,66+    0xa5c85e4b, 0xa0a36dc2, 0x0739a95e, 0x3d44c15b, 0xfb940f4b, 0xd67c9148, 0x614f9876, 0x0a241c5f,67+    0xad9da74c, 0x4459abc8, 0x12e71b5f, 0x1c534a5d, 0x8ff5fc50, 0x2ca8864b, 0xd894fd80, 0x82ab3160,68+    0x390d804e, 0x2cf310cc, 0x680dad80, 0x691be15e, 0x5a8f4652, 0xaad0784d, 0x0d2431ad,69 };70 71 72@@ -879,12 +911,21 @@73     int64 nStart = GetTime();74     loop75     {76-        // Wait77+        // Limit outbound connections78         vnThreadsRunning[1]--;79         Sleep(500);80-        const int nMaxConnections = 8;81-        while (vNodes.size() >= nMaxConnections)82-        {83+        loop84+        {85+            int nOutbound = 0;86+            CRITICAL_BLOCK(cs_vNodes)87+                foreach(CNode* pnode, vNodes)88+                    if (!pnode->fInbound)89+                        nOutbound++;90+            int nMaxOutboundConnections = MAX_OUTBOUND_CONNECTIONS;91+            if (mapArgs.count("-maxconnections"))92+                nMaxOutboundConnections = min(nMaxOutboundConnections, atoi(mapArgs["-maxconnections"]));93+            if (nOutbound < nMaxOutboundConnections)94+                break;95             Sleep(2000);96             if (fShutdown)97                 return;98@@ -948,18 +989,19 @@99         CAddress addrConnect;100         int64 nBest = INT64_MIN;101 102-        // Do this here so we don't have to critsect vNodes inside mapAddresses critsect103+        // Only connect to one address per a.b.?.? range.104+        // Do this here so we don't have to critsect vNodes inside mapAddresses critsect.105         set<unsigned int> setConnected;106         CRITICAL_BLOCK(cs_vNodes)107             foreach(CNode* pnode, vNodes)108-                setConnected.insert(pnode->addr.ip);109+                setConnected.insert(pnode->addr.ip & 0x0000ffff);110 111         CRITICAL_BLOCK(cs_mapAddresses)112         {113             foreach(const PAIRTYPE(vector<unsigned char>, CAddress)& item, mapAddresses)114             {115                 const CAddress& addr = item.second;116-                if (!addr.IsIPv4() || !addr.IsValid() || setConnected.count(addr.ip))117+                if (!addr.IsIPv4() || !addr.IsValid() || setConnected.count(addr.ip & 0x0000ffff))118                     continue;119                 int64 nSinceLastSeen = GetAdjustedTime() - addr.nTime;120                 int64 nSinceLastTry = GetAdjustedTime() - addr.nLastTry;121@@ -1163,7 +1205,7 @@122         return false;123     }124 125-#if defined(__BSD__) || defined(__WXMAC_OSX__)126+#ifdef BSD127     // Different way of disabling SIGPIPE on BSD128     setsockopt(hListenSocket, SOL_SOCKET, SO_NOSIGPIPE, (void*)&nOne, sizeof(int));129 #endif

rpc.cpp (modified)

1--- v0.3.8/rpc.cpp2+++ v0.3.10/rpc.cpp3@@ -56,10 +56,14 @@4 5 Value help(const Array& params, bool fHelp)6 {7-    if (fHelp || params.size() != 0)8-        throw runtime_error(9-            "help\n"10-            "List commands.");11+    if (fHelp || params.size() > 1)12+        throw runtime_error(13+            "help [command]\n"14+            "List commands, or get help for a command.");15+16+    string strCommand;17+    if (params.size() > 0)18+        strCommand = params[0].get_str();19 20     string strRet;21     set<rpcfn_type> setDone;22@@ -70,6 +74,8 @@23         if (strMethod == "getamountreceived" ||24             strMethod == "getallreceived")25             continue;26+        if (strCommand != "" && strMethod != strCommand)27+            continue;28         try29         {30             Array params;31@@ -81,11 +87,14 @@32         {33             // Help text is returned in an exception34             string strHelp = string(e.what());35-            if (strHelp.find('\n') != -1)36-                strHelp = strHelp.substr(0, strHelp.find('\n'));37+            if (strCommand == "")38+                if (strHelp.find('\n') != -1)39+                    strHelp = strHelp.substr(0, strHelp.find('\n'));40             strRet += strHelp + "\n";41         }42     }43+    if (strRet == "")44+        strRet = strprintf("help: unknown command: %s\n", strCommand.c_str());45     strRet = strRet.substr(0,strRet.size()-1);46     return strRet;47 }48@@ -208,13 +217,28 @@49 }50 51 52+Value gethashespersec(const Array& params, bool fHelp)53+{54+    if (fHelp || params.size() != 0)55+        throw runtime_error(56+            "gethashespersec\n"57+            "Returns a recent hashes per second performance measurement while generating.");58+59+    if (GetTimeMillis() - nHPSTimerStart > 8000)60+        return (boost::int64_t)0;61+    return (boost::int64_t)dHashesPerSec;62+}63+64+65 Value getinfo(const Array& params, bool fHelp)66 {67     if (fHelp || params.size() != 0)68         throw runtime_error(69-            "getinfo");70+            "getinfo\n"71+            "Returns an object containing various state info.");72 73     Object obj;74+    obj.push_back(Pair("version",       (int)VERSION));75     obj.push_back(Pair("balance",       (double)GetBalance() / (double)COIN));76     obj.push_back(Pair("blocks",        (int)nBestHeight + 1));77     obj.push_back(Pair("connections",   (int)vNodes.size()));78@@ -222,6 +246,7 @@79     obj.push_back(Pair("generate",      (bool)fGenerateBitcoins));80     obj.push_back(Pair("genproclimit",  (int)(fLimitProcessors ? nLimitProcessors : -1)));81     obj.push_back(Pair("difficulty",    (double)GetDifficulty()));82+    obj.push_back(Pair("hashespersec",  gethashespersec(params, false)));83     return obj;84 }85 86@@ -456,6 +481,7 @@87 88     return (double)nAmount / (double)COIN;89 }90+91 92 93 struct tallyitem94@@ -626,6 +652,7 @@95     make_pair("getbalance",            &getbalance),96     make_pair("getgenerate",           &getgenerate),97     make_pair("setgenerate",           &setgenerate),98+    make_pair("gethashespersec",       &gethashespersec),99     make_pair("getinfo",               &getinfo),100     make_pair("getnewaddress",         &getnewaddress),101     make_pair("setlabel",              &setlabel),102@@ -947,8 +974,8 @@103                 printf("ThreadRPCServer method=%s\n", strMethod.c_str());104 105                 // Observe lockdown106-                if (IsLockdown() && strMethod != "help" && strMethod != "stop" && strMethod != "getgenerate" && strMethod != "setgenerate")107-                    throw runtime_error("WARNING: Displayed transactions may not be correct!  You may need to upgrade.");108+                if (IsLockdown() && !mapArgs.count("-overridesafety") && strMethod != "help" && strMethod != "stop" && strMethod != "getgenerate" && strMethod != "setgenerate")109+                    throw runtime_error("WARNING: Displayed transactions may not be correct!  You may need to upgrade, or other nodes may need to upgrade.");110 111                 // Execute112                 map<string, rpcfn_type>::iterator mi = mapCallTable.find(strMethod);113@@ -1059,57 +1086,37 @@114             argv++;115         }116 117-        // Check that the method exists118+        // Method119         if (argc < 2)120             throw runtime_error("too few parameters");121         string strMethod = argv[1];122-        if (!mapCallTable.count(strMethod))123-            throw runtime_error(strprintf("unknown command: %s", strMethod.c_str()));124-125-        Value result;126-        if (argc == 3 && strcmp(argv[2], "-?") == 0)127-        {128-            // Call help locally, help text is returned in an exception129-            try130-            {131-                map<string, rpcfn_type>::iterator mi = mapCallTable.find(strMethod);132-                Array params;133-                (*(*mi).second)(params, true);134-            }135-            catch (std::exception& e)136-            {137-                result = e.what();138-            }139-        }140-        else141-        {142-            // Parameters default to strings143-            Array params;144-            for (int i = 2; i < argc; i++)145-                params.push_back(argv[i]);146-            int n = params.size();147-148-            //149-            // Special case non-string parameter types150-            //151-            if (strMethod == "setgenerate"            && n > 0) ConvertTo<bool>(params[0]);152-            if (strMethod == "setgenerate"            && n > 1) ConvertTo<boost::int64_t>(params[1]);153-            if (strMethod == "sendtoaddress"          && n > 1) ConvertTo<double>(params[1]);154-            if (strMethod == "listtransactions"       && n > 0) ConvertTo<boost::int64_t>(params[0]);155-            if (strMethod == "listtransactions"       && n > 1) ConvertTo<bool>(params[1]);156-            if (strMethod == "getamountreceived"      && n > 1) ConvertTo<boost::int64_t>(params[1]); // deprecated157-            if (strMethod == "getreceivedbyaddress"   && n > 1) ConvertTo<boost::int64_t>(params[1]);158-            if (strMethod == "getreceivedbylabel"     && n > 1) ConvertTo<boost::int64_t>(params[1]);159-            if (strMethod == "getallreceived"         && n > 0) ConvertTo<boost::int64_t>(params[0]); // deprecated160-            if (strMethod == "getallreceived"         && n > 1) ConvertTo<bool>(params[1]);161-            if (strMethod == "listreceivedbyaddress"  && n > 0) ConvertTo<boost::int64_t>(params[0]);162-            if (strMethod == "listreceivedbyaddress"  && n > 1) ConvertTo<bool>(params[1]);163-            if (strMethod == "listreceivedbylabel"    && n > 0) ConvertTo<boost::int64_t>(params[0]);164-            if (strMethod == "listreceivedbylabel"    && n > 1) ConvertTo<bool>(params[1]);165-166-            // Execute167-            result = CallRPC(strMethod, params);168-        }169+170+        // Parameters default to strings171+        Array params;172+        for (int i = 2; i < argc; i++)173+            params.push_back(argv[i]);174+        int n = params.size();175+176+        //177+        // Special case non-string parameter types178+        //179+        if (strMethod == "setgenerate"            && n > 0) ConvertTo<bool>(params[0]);180+        if (strMethod == "setgenerate"            && n > 1) ConvertTo<boost::int64_t>(params[1]);181+        if (strMethod == "sendtoaddress"          && n > 1) ConvertTo<double>(params[1]);182+        if (strMethod == "listtransactions"       && n > 0) ConvertTo<boost::int64_t>(params[0]);183+        if (strMethod == "listtransactions"       && n > 1) ConvertTo<bool>(params[1]);184+        if (strMethod == "getamountreceived"      && n > 1) ConvertTo<boost::int64_t>(params[1]); // deprecated185+        if (strMethod == "getreceivedbyaddress"   && n > 1) ConvertTo<boost::int64_t>(params[1]);186+        if (strMethod == "getreceivedbylabel"     && n > 1) ConvertTo<boost::int64_t>(params[1]);187+        if (strMethod == "getallreceived"         && n > 0) ConvertTo<boost::int64_t>(params[0]); // deprecated188+        if (strMethod == "getallreceived"         && n > 1) ConvertTo<bool>(params[1]);189+        if (strMethod == "listreceivedbyaddress"  && n > 0) ConvertTo<boost::int64_t>(params[0]);190+        if (strMethod == "listreceivedbyaddress"  && n > 1) ConvertTo<bool>(params[1]);191+        if (strMethod == "listreceivedbylabel"    && n > 0) ConvertTo<boost::int64_t>(params[0]);192+        if (strMethod == "listreceivedbylabel"    && n > 1) ConvertTo<bool>(params[1]);193+194+        // Execute195+        Value result = CallRPC(strMethod, params);196 197         // Print result198         string strResult = (result.type() == str_type ? result.get_str() : write_string(result, true));

script.cpp (modified)

1--- v0.3.8/script.cpp2+++ v0.3.10/script.cpp3@@ -16,12 +16,30 @@4 static const CBigNum bnOne(1);5 static const CBigNum bnFalse(0);6 static const CBigNum bnTrue(1);7-static const size_t nMaxNumSize = 258;8-9+static const size_t nMaxNumSize = 4;10+11+12+CBigNum CastToBigNum(const valtype& vch)13+{14+    if (vch.size() > nMaxNumSize)15+        throw runtime_error("CastToBigNum() : overflow");16+    // Get rid of extra leading zeros17+    return CBigNum(CBigNum(vch).getvch());18+}19 20 bool CastToBool(const valtype& vch)21 {22-    return (CBigNum(vch) != bnZero);23+    for (int i = 0; i < vch.size(); i++)24+    {25+        if (vch[i] != 0)26+        {27+            // Can be negative zero28+            if (i == vch.size()-1 && vch[i] == 0x80)29+                return false;30+            return true;31+        }32+    }33+    return false;34 }35 36 void MakeSameSize(valtype& vch1, valtype& vch2)37@@ -68,9 +86,26 @@38             valtype vchPushValue;39             if (!script.GetOp(pc, opcode, vchPushValue))40                 return false;41-            if (vchPushValue.size() > 5000)42+            if (vchPushValue.size() > 520)43                 return false;44             if (opcode > OP_16 && nOpCount++ > 200)45+                return false;46+47+            if (opcode == OP_CAT ||48+                opcode == OP_SUBSTR ||49+                opcode == OP_LEFT ||50+                opcode == OP_RIGHT ||51+                opcode == OP_INVERT ||52+                opcode == OP_AND ||53+                opcode == OP_OR ||54+                opcode == OP_XOR ||55+                opcode == OP_2MUL ||56+                opcode == OP_2DIV ||57+                opcode == OP_MUL ||58+                opcode == OP_DIV ||59+                opcode == OP_MOD ||60+                opcode == OP_LSHIFT ||61+                opcode == OP_RSHIFT)62                 return false;63 64             if (fExec && opcode <= OP_PUSHDATA4)65@@ -332,7 +367,7 @@66                     // (xn ... x2 x1 x0 n - ... x2 x1 x0 xn)67                     if (stack.size() < 2)68                         return false;69-                    int n = CBigNum(stacktop(-1)).getint();70+                    int n = CastToBigNum(stacktop(-1)).getint();71                     stack.pop_back();72                     if (n < 0 || n >= stack.size())73                         return false;74@@ -387,7 +422,7 @@75                     valtype& vch2 = stacktop(-1);76                     vch1.insert(vch1.end(), vch2.begin(), vch2.end());77                     stack.pop_back();78-                    if (stacktop(-1).size() > 5000)79+                    if (stacktop(-1).size() > 520)80                         return false;81                 }82                 break;83@@ -398,8 +433,8 @@84                     if (stack.size() < 3)85                         return false;86                     valtype& vch = stacktop(-3);87-                    int nBegin = CBigNum(stacktop(-2)).getint();88-                    int nEnd = nBegin + CBigNum(stacktop(-1)).getint();89+                    int nBegin = CastToBigNum(stacktop(-2)).getint();90+                    int nEnd = nBegin + CastToBigNum(stacktop(-1)).getint();91                     if (nBegin < 0 || nEnd < nBegin)92                         return false;93                     if (nBegin > vch.size())94@@ -420,7 +455,7 @@95                     if (stack.size() < 2)96                         return false;97                     valtype& vch = stacktop(-2);98-                    int nSize = CBigNum(stacktop(-1)).getint();99+                    int nSize = CastToBigNum(stacktop(-1)).getint();100                     if (nSize < 0)101                         return false;102                     if (nSize > vch.size())103@@ -531,9 +566,7 @@104                     // (in -- out)105                     if (stack.size() < 1)106                         return false;107-                    if (stacktop(-1).size() > nMaxNumSize)108-                        return false;109-                    CBigNum bn(stacktop(-1));110+                    CBigNum bn = CastToBigNum(stacktop(-1));111                     switch (opcode)112                     {113                     case OP_1ADD:       bn += bnOne; break;114@@ -572,11 +605,8 @@115                     // (x1 x2 -- out)116                     if (stack.size() < 2)117                         return false;118-                    if (stacktop(-2).size() > nMaxNumSize ||119-                        stacktop(-1).size() > nMaxNumSize)120-                        return false;121-                    CBigNum bn1(stacktop(-2));122-                    CBigNum bn2(stacktop(-1));123+                    CBigNum bn1 = CastToBigNum(stacktop(-2));124+                    CBigNum bn2 = CastToBigNum(stacktop(-1));125                     CBigNum bn;126                     switch (opcode)127                     {128@@ -646,13 +676,9 @@129                     // (x min max -- out)130                     if (stack.size() < 3)131                         return false;132-                    if (stacktop(-3).size() > nMaxNumSize ||133-                        stacktop(-2).size() > nMaxNumSize ||134-                        stacktop(-1).size() > nMaxNumSize)135-                        return false;136-                    CBigNum bn1(stacktop(-3));137-                    CBigNum bn2(stacktop(-2));138-                    CBigNum bn3(stacktop(-1));139+                    CBigNum bn1 = CastToBigNum(stacktop(-3));140+                    CBigNum bn2 = CastToBigNum(stacktop(-2));141+                    CBigNum bn3 = CastToBigNum(stacktop(-1));142                     bool fValue = (bn2 <= bn1 && bn1 < bn3);143                     stack.pop_back();144                     stack.pop_back();145@@ -748,7 +774,7 @@146                     if (stack.size() < i)147                         return false;148 149-                    int nKeysCount = CBigNum(stacktop(-i)).getint();150+                    int nKeysCount = CastToBigNum(stacktop(-i)).getint();151                     if (nKeysCount < 0)152                         return false;153                     int ikey = ++i;154@@ -756,7 +782,7 @@155                     if (stack.size() < i)156                         return false;157 158-                    int nSigsCount = CBigNum(stacktop(-i)).getint();159+                    int nSigsCount = CastToBigNum(stacktop(-i)).getint();160                     if (nSigsCount < 0 || nSigsCount > nKeysCount)161                         return false;162                     int isig = ++i;

serialize.h (modified)

1--- v0.3.8/serialize.h2+++ v0.3.10/serialize.h3@@ -19,8 +19,8 @@4 class CDataStream;5 class CAutoFile;6 7-static const int VERSION = 308;8-static const char* pszSubVer = "";9+static const int VERSION = 310;10+static const char* pszSubVer = ".1";11 12 13 

setup.nsi (modified)

1--- v0.3.8/setup.nsi2+++ v0.3.10/setup.nsi3@@ -7,7 +7,7 @@4 5 # General Symbol Definitions6 !define REGKEY "SOFTWARE\$(^Name)"7-!define VERSION 0.3.88+!define VERSION 0.3.109 !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.8-win32-setup.exe17+OutFile bitcoin-0.3.10-win32-setup.exe18 InstallDir $PROGRAMFILES\Bitcoin19 CRCCheck on20 XPStyle on21 ShowInstDetails show22-VIProductVersion 0.3.8.023+VIProductVersion 0.3.10.024 VIAddVersionKey ProductName Bitcoin25 VIAddVersionKey ProductVersion "${VERSION}"26 VIAddVersionKey CompanyName "${COMPANY}"

sha256.cpp (added)

1--- /dev/null2+++ v0.3.10/sha256.cpp3@@ -1 +1,420 @@4-5+// Copyright (c) 2010 Satoshi Nakamoto6+// Distributed under the MIT/X11 software license, see the accompanying7+// file license.txt or http://www.opensource.org/licenses/mit-license.php.8+9+#include <string.h>10+#include <assert.h>11+12+#include <xmmintrin.h>13+#include <stdint.h>14+#include <stdio.h>15+16+#define NPAR 3217+18+static const unsigned int sha256_consts[] = {19+    0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, /*  0 */20+    0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,21+    0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, /*  8 */22+    0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,23+    0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, /* 16 */24+    0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,25+    0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, /* 24 */26+    0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,27+    0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, /* 32 */28+    0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,29+    0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, /* 40 */30+    0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,31+    0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, /* 48 */32+    0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,33+    0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, /* 56 */34+    0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f235+};36+37+38+static inline __m128i Ch(const __m128i b, const __m128i c, const __m128i d) {39+    return (b & c) ^ (~b & d);40+}41+42+static inline __m128i Maj(const __m128i b, const __m128i c, const __m128i d) {43+    return (b & c) ^ (b & d) ^ (c & d);44+}45+46+static inline __m128i ROTR(__m128i x, const int n) {47+    return _mm_srli_epi32(x, n) | _mm_slli_epi32(x, 32 - n);48+}49+50+static inline __m128i SHR(__m128i x, const int n) {51+    return _mm_srli_epi32(x, n);52+}53+54+/* SHA256 Functions */55+#define BIGSIGMA0_256(x)    (ROTR((x), 2) ^ ROTR((x), 13) ^ ROTR((x), 22))56+#define BIGSIGMA1_256(x)    (ROTR((x), 6) ^ ROTR((x), 11) ^ ROTR((x), 25))57+#define SIGMA0_256(x)       (ROTR((x), 7) ^ ROTR((x), 18) ^ SHR((x), 3))58+#define SIGMA1_256(x)       (ROTR((x), 17) ^ ROTR((x), 19) ^ SHR((x), 10))59+60+static inline unsigned int store32(const __m128i x, int i) {61+    union { unsigned int ret[4]; __m128i x; } box;62+    box.x = x;63+    return box.ret[i];64+}65+66+static inline void store_epi32(const __m128i x, unsigned int *x0, unsigned int *x1, unsigned int *x2, unsigned int *x3) {67+    union { unsigned int ret[4]; __m128i x; } box;68+    box.x = x;69+    *x0 = box.ret[3]; *x1 = box.ret[2]; *x2 = box.ret[1]; *x3 = box.ret[0];70+}71+72+#define add4(x0, x1, x2, x3) _mm_add_epi32(_mm_add_epi32(_mm_add_epi32(x0, x1), x2), x3)73+#define add5(x0, x1, x2, x3, x4) _mm_add_epi32(add4(x0, x1, x2, x3), x4)74+75+#define SHA256ROUND(a, b, c, d, e, f, g, h, i, w)                       \76+    T1 = add5(h, BIGSIGMA1_256(e), Ch(e, f, g), _mm_set1_epi32(sha256_consts[i]), w);   \77+d = _mm_add_epi32(d, T1);                                           \78+h = _mm_add_epi32(T1, _mm_add_epi32(BIGSIGMA0_256(a), Maj(a, b, c)));79+80+static inline void dumpreg(__m128i x, char *msg) {81+    union { unsigned int ret[4]; __m128i x; } box;82+    box.x = x ;83+    printf("%s %08x %08x %08x %08x\n", msg, box.ret[0], box.ret[1], box.ret[2], box.ret[3]);84+}85+86+#if 187+#define dumpstate(i) printf("%s: %08x %08x %08x %08x %08x %08x %08x %08x %08x\n", \88+        __func__, store32(w0, i), store32(a, i), store32(b, i), store32(c, i), store32(d, i), store32(e, i), store32(f, i), store32(g, i), store32(h, i));89+#else90+#define dumpstate()91+#endif92+void Double_BlockSHA256(const void* pin, void* pad, const void *pre, unsigned int thash[9][NPAR], const void *init)93+{94+    unsigned int* In = (unsigned int*)pin;95+    unsigned int* Pad = (unsigned int*)pad;96+    unsigned int* hPre = (unsigned int*)pre;97+    unsigned int* hInit = (unsigned int*)init;98+    unsigned int i, j, k;99+100+    /* vectors used in calculation */101+    __m128i w0, w1, w2, w3, w4, w5, w6, w7;102+    __m128i w8, w9, w10, w11, w12, w13, w14, w15;103+    __m128i T1;104+    __m128i a, b, c, d, e, f, g, h;105+    __m128i nonce;106+107+    /* nonce offset for vector */108+    __m128i offset = _mm_set_epi32(0x00000003, 0x00000002, 0x00000001, 0x00000000);109+110+111+    for(k = 0; k<NPAR; k+=4) {112+        w0 = _mm_set1_epi32(In[0]);113+        w1 = _mm_set1_epi32(In[1]);114+        w2 = _mm_set1_epi32(In[2]);115+        //w3 = _mm_set1_epi32(In[3]); nonce will be later hacked into the hash116+        w4 = _mm_set1_epi32(In[4]);117+        w5 = _mm_set1_epi32(In[5]);118+        w6 = _mm_set1_epi32(In[6]);119+        w7 = _mm_set1_epi32(In[7]);120+        w8 = _mm_set1_epi32(In[8]);121+        w9 = _mm_set1_epi32(In[9]);122+        w10 = _mm_set1_epi32(In[10]);123+        w11 = _mm_set1_epi32(In[11]);124+        w12 = _mm_set1_epi32(In[12]);125+        w13 = _mm_set1_epi32(In[13]);126+        w14 = _mm_set1_epi32(In[14]);127+        w15 = _mm_set1_epi32(In[15]);128+129+        /* hack nonce into lowest byte of w3 */130+        nonce = _mm_set1_epi32(In[3]);131+        nonce = _mm_add_epi32(nonce, offset);132+        nonce = _mm_add_epi32(nonce, _mm_set1_epi32(k));133+        w3 = nonce;134+135+        a = _mm_set1_epi32(hPre[0]);136+        b = _mm_set1_epi32(hPre[1]);137+        c = _mm_set1_epi32(hPre[2]);138+        d = _mm_set1_epi32(hPre[3]);139+        e = _mm_set1_epi32(hPre[4]);140+        f = _mm_set1_epi32(hPre[5]);141+        g = _mm_set1_epi32(hPre[6]);142+        h = _mm_set1_epi32(hPre[7]);143+144+        SHA256ROUND(a, b, c, d, e, f, g, h, 0, w0);145+        SHA256ROUND(h, a, b, c, d, e, f, g, 1, w1);146+        SHA256ROUND(g, h, a, b, c, d, e, f, 2, w2);147+        SHA256ROUND(f, g, h, a, b, c, d, e, 3, w3);148+        SHA256ROUND(e, f, g, h, a, b, c, d, 4, w4);149+        SHA256ROUND(d, e, f, g, h, a, b, c, 5, w5);150+        SHA256ROUND(c, d, e, f, g, h, a, b, 6, w6);151+        SHA256ROUND(b, c, d, e, f, g, h, a, 7, w7);152+        SHA256ROUND(a, b, c, d, e, f, g, h, 8, w8);153+        SHA256ROUND(h, a, b, c, d, e, f, g, 9, w9);154+        SHA256ROUND(g, h, a, b, c, d, e, f, 10, w10);155+        SHA256ROUND(f, g, h, a, b, c, d, e, 11, w11);156+        SHA256ROUND(e, f, g, h, a, b, c, d, 12, w12);157+        SHA256ROUND(d, e, f, g, h, a, b, c, 13, w13);158+        SHA256ROUND(c, d, e, f, g, h, a, b, 14, w14);159+        SHA256ROUND(b, c, d, e, f, g, h, a, 15, w15);160+161+        w0 = add4(SIGMA1_256(w14), w9, SIGMA0_256(w1), w0);162+        SHA256ROUND(a, b, c, d, e, f, g, h, 16, w0);163+        w1 = add4(SIGMA1_256(w15), w10, SIGMA0_256(w2), w1);164+        SHA256ROUND(h, a, b, c, d, e, f, g, 17, w1);165+        w2 = add4(SIGMA1_256(w0), w11, SIGMA0_256(w3), w2);166+        SHA256ROUND(g, h, a, b, c, d, e, f, 18, w2);167+        w3 = add4(SIGMA1_256(w1), w12, SIGMA0_256(w4), w3);168+        SHA256ROUND(f, g, h, a, b, c, d, e, 19, w3);169+        w4 = add4(SIGMA1_256(w2), w13, SIGMA0_256(w5), w4);170+        SHA256ROUND(e, f, g, h, a, b, c, d, 20, w4);171+        w5 = add4(SIGMA1_256(w3), w14, SIGMA0_256(w6), w5);172+        SHA256ROUND(d, e, f, g, h, a, b, c, 21, w5);173+        w6 = add4(SIGMA1_256(w4), w15, SIGMA0_256(w7), w6);174+        SHA256ROUND(c, d, e, f, g, h, a, b, 22, w6);175+        w7 = add4(SIGMA1_256(w5), w0, SIGMA0_256(w8), w7);176+        SHA256ROUND(b, c, d, e, f, g, h, a, 23, w7);177+        w8 = add4(SIGMA1_256(w6), w1, SIGMA0_256(w9), w8);178+        SHA256ROUND(a, b, c, d, e, f, g, h, 24, w8);179+        w9 = add4(SIGMA1_256(w7), w2, SIGMA0_256(w10), w9);180+        SHA256ROUND(h, a, b, c, d, e, f, g, 25, w9);181+        w10 = add4(SIGMA1_256(w8), w3, SIGMA0_256(w11), w10);182+        SHA256ROUND(g, h, a, b, c, d, e, f, 26, w10);183+        w11 = add4(SIGMA1_256(w9), w4, SIGMA0_256(w12), w11);184+        SHA256ROUND(f, g, h, a, b, c, d, e, 27, w11);185+        w12 = add4(SIGMA1_256(w10), w5, SIGMA0_256(w13), w12);186+        SHA256ROUND(e, f, g, h, a, b, c, d, 28, w12);187+        w13 = add4(SIGMA1_256(w11), w6, SIGMA0_256(w14), w13);188+        SHA256ROUND(d, e, f, g, h, a, b, c, 29, w13);189+        w14 = add4(SIGMA1_256(w12), w7, SIGMA0_256(w15), w14);190+        SHA256ROUND(c, d, e, f, g, h, a, b, 30, w14);191+        w15 = add4(SIGMA1_256(w13), w8, SIGMA0_256(w0), w15);192+        SHA256ROUND(b, c, d, e, f, g, h, a, 31, w15);193+194+        w0 = add4(SIGMA1_256(w14), w9, SIGMA0_256(w1), w0);195+        SHA256ROUND(a, b, c, d, e, f, g, h, 32, w0);196+        w1 = add4(SIGMA1_256(w15), w10, SIGMA0_256(w2), w1);197+        SHA256ROUND(h, a, b, c, d, e, f, g, 33, w1);198+        w2 = add4(SIGMA1_256(w0), w11, SIGMA0_256(w3), w2);199+        SHA256ROUND(g, h, a, b, c, d, e, f, 34, w2);200+        w3 = add4(SIGMA1_256(w1), w12, SIGMA0_256(w4), w3);201+        SHA256ROUND(f, g, h, a, b, c, d, e, 35, w3);202+        w4 = add4(SIGMA1_256(w2), w13, SIGMA0_256(w5), w4);203+        SHA256ROUND(e, f, g, h, a, b, c, d, 36, w4);204+        w5 = add4(SIGMA1_256(w3), w14, SIGMA0_256(w6), w5);205+        SHA256ROUND(d, e, f, g, h, a, b, c, 37, w5);206+        w6 = add4(SIGMA1_256(w4), w15, SIGMA0_256(w7), w6);207+        SHA256ROUND(c, d, e, f, g, h, a, b, 38, w6);208+        w7 = add4(SIGMA1_256(w5), w0, SIGMA0_256(w8), w7);209+        SHA256ROUND(b, c, d, e, f, g, h, a, 39, w7);210+        w8 = add4(SIGMA1_256(w6), w1, SIGMA0_256(w9), w8);211+        SHA256ROUND(a, b, c, d, e, f, g, h, 40, w8);212+        w9 = add4(SIGMA1_256(w7), w2, SIGMA0_256(w10), w9);213+        SHA256ROUND(h, a, b, c, d, e, f, g, 41, w9);214+        w10 = add4(SIGMA1_256(w8), w3, SIGMA0_256(w11), w10);215+        SHA256ROUND(g, h, a, b, c, d, e, f, 42, w10);216+        w11 = add4(SIGMA1_256(w9), w4, SIGMA0_256(w12), w11);217+        SHA256ROUND(f, g, h, a, b, c, d, e, 43, w11);218+        w12 = add4(SIGMA1_256(w10), w5, SIGMA0_256(w13), w12);219+        SHA256ROUND(e, f, g, h, a, b, c, d, 44, w12);220+        w13 = add4(SIGMA1_256(w11), w6, SIGMA0_256(w14), w13);221+        SHA256ROUND(d, e, f, g, h, a, b, c, 45, w13);222+        w14 = add4(SIGMA1_256(w12), w7, SIGMA0_256(w15), w14);223+        SHA256ROUND(c, d, e, f, g, h, a, b, 46, w14);224+        w15 = add4(SIGMA1_256(w13), w8, SIGMA0_256(w0), w15);225+        SHA256ROUND(b, c, d, e, f, g, h, a, 47, w15);226+227+        w0 = add4(SIGMA1_256(w14), w9, SIGMA0_256(w1), w0);228+        SHA256ROUND(a, b, c, d, e, f, g, h, 48, w0);229+        w1 = add4(SIGMA1_256(w15), w10, SIGMA0_256(w2), w1);230+        SHA256ROUND(h, a, b, c, d, e, f, g, 49, w1);231+        w2 = add4(SIGMA1_256(w0), w11, SIGMA0_256(w3), w2);232+        SHA256ROUND(g, h, a, b, c, d, e, f, 50, w2);233+        w3 = add4(SIGMA1_256(w1), w12, SIGMA0_256(w4), w3);234+        SHA256ROUND(f, g, h, a, b, c, d, e, 51, w3);235+        w4 = add4(SIGMA1_256(w2), w13, SIGMA0_256(w5), w4);236+        SHA256ROUND(e, f, g, h, a, b, c, d, 52, w4);237+        w5 = add4(SIGMA1_256(w3), w14, SIGMA0_256(w6), w5);238+        SHA256ROUND(d, e, f, g, h, a, b, c, 53, w5);239+        w6 = add4(SIGMA1_256(w4), w15, SIGMA0_256(w7), w6);240+        SHA256ROUND(c, d, e, f, g, h, a, b, 54, w6);241+        w7 = add4(SIGMA1_256(w5), w0, SIGMA0_256(w8), w7);242+        SHA256ROUND(b, c, d, e, f, g, h, a, 55, w7);243+        w8 = add4(SIGMA1_256(w6), w1, SIGMA0_256(w9), w8);244+        SHA256ROUND(a, b, c, d, e, f, g, h, 56, w8);245+        w9 = add4(SIGMA1_256(w7), w2, SIGMA0_256(w10), w9);246+        SHA256ROUND(h, a, b, c, d, e, f, g, 57, w9);247+        w10 = add4(SIGMA1_256(w8), w3, SIGMA0_256(w11), w10);248+        SHA256ROUND(g, h, a, b, c, d, e, f, 58, w10);249+        w11 = add4(SIGMA1_256(w9), w4, SIGMA0_256(w12), w11);250+        SHA256ROUND(f, g, h, a, b, c, d, e, 59, w11);251+        w12 = add4(SIGMA1_256(w10), w5, SIGMA0_256(w13), w12);252+        SHA256ROUND(e, f, g, h, a, b, c, d, 60, w12);253+        w13 = add4(SIGMA1_256(w11), w6, SIGMA0_256(w14), w13);254+        SHA256ROUND(d, e, f, g, h, a, b, c, 61, w13);255+        w14 = add4(SIGMA1_256(w12), w7, SIGMA0_256(w15), w14);256+        SHA256ROUND(c, d, e, f, g, h, a, b, 62, w14);257+        w15 = add4(SIGMA1_256(w13), w8, SIGMA0_256(w0), w15);258+        SHA256ROUND(b, c, d, e, f, g, h, a, 63, w15);259+260+#define store_load(x, i, dest) \261+        T1 = _mm_set1_epi32((hPre)[i]); \262+        dest = _mm_add_epi32(T1, x);263+264+        store_load(a, 0, w0);265+        store_load(b, 1, w1);266+        store_load(c, 2, w2);267+        store_load(d, 3, w3);268+        store_load(e, 4, w4);269+        store_load(f, 5, w5);270+        store_load(g, 6, w6);271+        store_load(h, 7, w7);272+273+        w8 = _mm_set1_epi32(Pad[8]);274+        w9 = _mm_set1_epi32(Pad[9]);275+        w10 = _mm_set1_epi32(Pad[10]);276+        w11 = _mm_set1_epi32(Pad[11]);277+        w12 = _mm_set1_epi32(Pad[12]);278+        w13 = _mm_set1_epi32(Pad[13]);279+        w14 = _mm_set1_epi32(Pad[14]);280+        w15 = _mm_set1_epi32(Pad[15]);281+282+        a = _mm_set1_epi32(hInit[0]);283+        b = _mm_set1_epi32(hInit[1]);284+        c = _mm_set1_epi32(hInit[2]);285+        d = _mm_set1_epi32(hInit[3]);286+        e = _mm_set1_epi32(hInit[4]);287+        f = _mm_set1_epi32(hInit[5]);288+        g = _mm_set1_epi32(hInit[6]);289+        h = _mm_set1_epi32(hInit[7]);290+291+        SHA256ROUND(a, b, c, d, e, f, g, h, 0, w0);292+        SHA256ROUND(h, a, b, c, d, e, f, g, 1, w1);293+        SHA256ROUND(g, h, a, b, c, d, e, f, 2, w2);294+        SHA256ROUND(f, g, h, a, b, c, d, e, 3, w3);295+        SHA256ROUND(e, f, g, h, a, b, c, d, 4, w4);296+        SHA256ROUND(d, e, f, g, h, a, b, c, 5, w5);297+        SHA256ROUND(c, d, e, f, g, h, a, b, 6, w6);298+        SHA256ROUND(b, c, d, e, f, g, h, a, 7, w7);299+        SHA256ROUND(a, b, c, d, e, f, g, h, 8, w8);300+        SHA256ROUND(h, a, b, c, d, e, f, g, 9, w9);301+        SHA256ROUND(g, h, a, b, c, d, e, f, 10, w10);302+        SHA256ROUND(f, g, h, a, b, c, d, e, 11, w11);303+        SHA256ROUND(e, f, g, h, a, b, c, d, 12, w12);304+        SHA256ROUND(d, e, f, g, h, a, b, c, 13, w13);305+        SHA256ROUND(c, d, e, f, g, h, a, b, 14, w14);306+        SHA256ROUND(b, c, d, e, f, g, h, a, 15, w15);307+308+        w0 = add4(SIGMA1_256(w14), w9, SIGMA0_256(w1), w0);309+        SHA256ROUND(a, b, c, d, e, f, g, h, 16, w0);310+        w1 = add4(SIGMA1_256(w15), w10, SIGMA0_256(w2), w1);311+        SHA256ROUND(h, a, b, c, d, e, f, g, 17, w1);312+        w2 = add4(SIGMA1_256(w0), w11, SIGMA0_256(w3), w2);313+        SHA256ROUND(g, h, a, b, c, d, e, f, 18, w2);314+        w3 = add4(SIGMA1_256(w1), w12, SIGMA0_256(w4), w3);315+        SHA256ROUND(f, g, h, a, b, c, d, e, 19, w3);316+        w4 = add4(SIGMA1_256(w2), w13, SIGMA0_256(w5), w4);317+        SHA256ROUND(e, f, g, h, a, b, c, d, 20, w4);318+        w5 = add4(SIGMA1_256(w3), w14, SIGMA0_256(w6), w5);319+        SHA256ROUND(d, e, f, g, h, a, b, c, 21, w5);320+        w6 = add4(SIGMA1_256(w4), w15, SIGMA0_256(w7), w6);321+        SHA256ROUND(c, d, e, f, g, h, a, b, 22, w6);322+        w7 = add4(SIGMA1_256(w5), w0, SIGMA0_256(w8), w7);323+        SHA256ROUND(b, c, d, e, f, g, h, a, 23, w7);324+        w8 = add4(SIGMA1_256(w6), w1, SIGMA0_256(w9), w8);325+        SHA256ROUND(a, b, c, d, e, f, g, h, 24, w8);326+        w9 = add4(SIGMA1_256(w7), w2, SIGMA0_256(w10), w9);327+        SHA256ROUND(h, a, b, c, d, e, f, g, 25, w9);328+        w10 = add4(SIGMA1_256(w8), w3, SIGMA0_256(w11), w10);329+        SHA256ROUND(g, h, a, b, c, d, e, f, 26, w10);330+        w11 = add4(SIGMA1_256(w9), w4, SIGMA0_256(w12), w11);331+        SHA256ROUND(f, g, h, a, b, c, d, e, 27, w11);332+        w12 = add4(SIGMA1_256(w10), w5, SIGMA0_256(w13), w12);333+        SHA256ROUND(e, f, g, h, a, b, c, d, 28, w12);334+        w13 = add4(SIGMA1_256(w11), w6, SIGMA0_256(w14), w13);335+        SHA256ROUND(d, e, f, g, h, a, b, c, 29, w13);336+        w14 = add4(SIGMA1_256(w12), w7, SIGMA0_256(w15), w14);337+        SHA256ROUND(c, d, e, f, g, h, a, b, 30, w14);338+        w15 = add4(SIGMA1_256(w13), w8, SIGMA0_256(w0), w15);339+        SHA256ROUND(b, c, d, e, f, g, h, a, 31, w15);340+341+        w0 = add4(SIGMA1_256(w14), w9, SIGMA0_256(w1), w0);342+        SHA256ROUND(a, b, c, d, e, f, g, h, 32, w0);343+        w1 = add4(SIGMA1_256(w15), w10, SIGMA0_256(w2), w1);344+        SHA256ROUND(h, a, b, c, d, e, f, g, 33, w1);345+        w2 = add4(SIGMA1_256(w0), w11, SIGMA0_256(w3), w2);346+        SHA256ROUND(g, h, a, b, c, d, e, f, 34, w2);347+        w3 = add4(SIGMA1_256(w1), w12, SIGMA0_256(w4), w3);348+        SHA256ROUND(f, g, h, a, b, c, d, e, 35, w3);349+        w4 = add4(SIGMA1_256(w2), w13, SIGMA0_256(w5), w4);350+        SHA256ROUND(e, f, g, h, a, b, c, d, 36, w4);351+        w5 = add4(SIGMA1_256(w3), w14, SIGMA0_256(w6), w5);352+        SHA256ROUND(d, e, f, g, h, a, b, c, 37, w5);353+        w6 = add4(SIGMA1_256(w4), w15, SIGMA0_256(w7), w6);354+        SHA256ROUND(c, d, e, f, g, h, a, b, 38, w6);355+        w7 = add4(SIGMA1_256(w5), w0, SIGMA0_256(w8), w7);356+        SHA256ROUND(b, c, d, e, f, g, h, a, 39, w7);357+        w8 = add4(SIGMA1_256(w6), w1, SIGMA0_256(w9), w8);358+        SHA256ROUND(a, b, c, d, e, f, g, h, 40, w8);359+        w9 = add4(SIGMA1_256(w7), w2, SIGMA0_256(w10), w9);360+        SHA256ROUND(h, a, b, c, d, e, f, g, 41, w9);361+        w10 = add4(SIGMA1_256(w8), w3, SIGMA0_256(w11), w10);362+        SHA256ROUND(g, h, a, b, c, d, e, f, 42, w10);363+        w11 = add4(SIGMA1_256(w9), w4, SIGMA0_256(w12), w11);364+        SHA256ROUND(f, g, h, a, b, c, d, e, 43, w11);365+        w12 = add4(SIGMA1_256(w10), w5, SIGMA0_256(w13), w12);366+        SHA256ROUND(e, f, g, h, a, b, c, d, 44, w12);367+        w13 = add4(SIGMA1_256(w11), w6, SIGMA0_256(w14), w13);368+        SHA256ROUND(d, e, f, g, h, a, b, c, 45, w13);369+        w14 = add4(SIGMA1_256(w12), w7, SIGMA0_256(w15), w14);370+        SHA256ROUND(c, d, e, f, g, h, a, b, 46, w14);371+        w15 = add4(SIGMA1_256(w13), w8, SIGMA0_256(w0), w15);372+        SHA256ROUND(b, c, d, e, f, g, h, a, 47, w15);373+374+        w0 = add4(SIGMA1_256(w14), w9, SIGMA0_256(w1), w0);375+        SHA256ROUND(a, b, c, d, e, f, g, h, 48, w0);376+        w1 = add4(SIGMA1_256(w15), w10, SIGMA0_256(w2), w1);377+        SHA256ROUND(h, a, b, c, d, e, f, g, 49, w1);378+        w2 = add4(SIGMA1_256(w0), w11, SIGMA0_256(w3), w2);379+        SHA256ROUND(g, h, a, b, c, d, e, f, 50, w2);380+        w3 = add4(SIGMA1_256(w1), w12, SIGMA0_256(w4), w3);381+        SHA256ROUND(f, g, h, a, b, c, d, e, 51, w3);382+        w4 = add4(SIGMA1_256(w2), w13, SIGMA0_256(w5), w4);383+        SHA256ROUND(e, f, g, h, a, b, c, d, 52, w4);384+        w5 = add4(SIGMA1_256(w3), w14, SIGMA0_256(w6), w5);385+        SHA256ROUND(d, e, f, g, h, a, b, c, 53, w5);386+        w6 = add4(SIGMA1_256(w4), w15, SIGMA0_256(w7), w6);387+        SHA256ROUND(c, d, e, f, g, h, a, b, 54, w6);388+        w7 = add4(SIGMA1_256(w5), w0, SIGMA0_256(w8), w7);389+        SHA256ROUND(b, c, d, e, f, g, h, a, 55, w7);390+        w8 = add4(SIGMA1_256(w6), w1, SIGMA0_256(w9), w8);391+        SHA256ROUND(a, b, c, d, e, f, g, h, 56, w8);392+        w9 = add4(SIGMA1_256(w7), w2, SIGMA0_256(w10), w9);393+        SHA256ROUND(h, a, b, c, d, e, f, g, 57, w9);394+        w10 = add4(SIGMA1_256(w8), w3, SIGMA0_256(w11), w10);395+        SHA256ROUND(g, h, a, b, c, d, e, f, 58, w10);396+        w11 = add4(SIGMA1_256(w9), w4, SIGMA0_256(w12), w11);397+        SHA256ROUND(f, g, h, a, b, c, d, e, 59, w11);398+        w12 = add4(SIGMA1_256(w10), w5, SIGMA0_256(w13), w12);399+        SHA256ROUND(e, f, g, h, a, b, c, d, 60, w12);400+        w13 = add4(SIGMA1_256(w11), w6, SIGMA0_256(w14), w13);401+        SHA256ROUND(d, e, f, g, h, a, b, c, 61, w13);402+        w14 = add4(SIGMA1_256(w12), w7, SIGMA0_256(w15), w14);403+        SHA256ROUND(c, d, e, f, g, h, a, b, 62, w14);404+        w15 = add4(SIGMA1_256(w13), w8, SIGMA0_256(w0), w15);405+        SHA256ROUND(b, c, d, e, f, g, h, a, 63, w15);406+407+        /* store resulsts directly in thash */408+#define store_2(x,i)  \409+        w0 = _mm_set1_epi32(hInit[i]); \410+        *(__m128i *)&(thash)[i][0+k] = _mm_add_epi32(w0, x);411+412+        store_2(a, 0);413+        store_2(b, 1);414+        store_2(c, 2);415+        store_2(d, 3);416+        store_2(e, 4);417+        store_2(f, 5);418+        store_2(g, 6);419+        store_2(h, 7);420+        *(__m128i *)&(thash)[8][0+k] = nonce;421+    }422+423+}424+

ui.cpp (modified)

1--- v0.3.8/ui.cpp2+++ v0.3.10/ui.cpp3@@ -388,7 +388,7 @@4         fClosedToTray = true;5     Show(!fClosedToTray);6     ptaskbaricon->Show(fMinimizeToTray || fClosedToTray);7-#ifdef __WXGTK__8+#if defined(__WXGTK__) || defined(__WXMAC_OSX__)9     }10 #endif11 }12@@ -515,7 +515,7 @@13 {14     string strOut;15     bool fOneSpace = false;16-    foreach(int c, strIn)17+    foreach(unsigned char c, strIn)18     {19         if (isspace(c))20         {21@@ -640,7 +640,7 @@22                         {23                             //strDescription += _("Received payment to ");24                             //strDescription += _("Received with address ");25-                            strDescription += _("From: unknown, Received with: ");26+                            strDescription += _("Received with: ");27                             string strAddress = PubKeyToAddress(vchPubKey);28                             map<string, string>::iterator mi = mapAddressBook.find(strAddress);29                             if (mi != mapAddressBook.end() && !(*mi).second.empty())30@@ -1015,7 +1015,7 @@31     // Update status bar32     static bool fPrevLockdown;33     if (IsLockdown())34-        m_statusBar->SetStatusText(string("    ") + _("WARNING: Displayed transactions may not be correct!  You may need to upgrade."), 0);35+        m_statusBar->SetStatusText(string("    ") + _("WARNING: Displayed transactions may not be correct!  You may need to upgrade, or other nodes may need to upgrade."), 0);36     else if (fPrevLockdown)37         m_statusBar->SetStatusText("", 0);38     fPrevLockdown = IsLockdown();39@@ -1559,6 +1559,11 @@40     }41     else42     {43+        char pszExePath[MAX_PATH+1];44+        memset(pszExePath, 0, sizeof(pszExePath));45+        if (readlink("/proc/self/exe", pszExePath, sizeof(pszExePath)-1) == -1)46+            return;47+48         boost::filesystem::create_directories(GetAutostartDir());49 50         boost::filesystem::ofstream optionFile(GetAutostartFilePath(), ios_base::out|ios_base::trunc);51@@ -1568,9 +1573,6 @@52             return;53         }54         // Write a bitcoin.desktop file to the autostart directory:55-        char pszExePath[MAX_PATH+1];56-        memset(pszExePath, 0, sizeof(pszExePath));57-        readlink("/proc/self/exe", pszExePath, sizeof(pszExePath)-1);58         optionFile << "[Desktop Entry]\n";59         optionFile << "Type=Application\n";60         optionFile << "Name=Bitcoin\n";61@@ -1858,7 +1860,7 @@62     {63         strFromSave    = m_textCtrlFrom->GetValue();64         strMessageSave = m_textCtrlMessage->GetValue();65-        m_textCtrlFrom->SetValue(_("Will appear as \"From: Unknown\""));66+        m_textCtrlFrom->SetValue(_("n/a"));67         m_textCtrlMessage->SetValue(_("Can't include a message when sending to a Bitcoin address"));68     }69     else if (fEnable && !fEnabledPrev)

util.cpp (modified)

1--- v0.3.8/util.cpp2+++ v0.3.10/util.cpp3@@ -14,6 +14,14 @@4 bool fShutdown = false;5 bool fDaemon = false;6 bool fCommandLine = false;7+8+9+10+11+12+// Workaround for "multiple definition of `_tls_used'"13+// http://svn.boost.org/trac/boost/ticket/425814+extern "C" void tss_cleanup_implemented() { }15 16 17 

util.h (modified)

1--- v0.3.8/util.h2+++ v0.3.10/util.h3@@ -430,8 +430,9 @@4 template<typename T1>5 inline uint256 Hash(const T1 pbegin, const T1 pend)6 {7+    static unsigned char pblank[1];8     uint256 hash1;9-    SHA256((unsigned char*)&pbegin[0], (pend - pbegin) * sizeof(pbegin[0]), (unsigned char*)&hash1);10+    SHA256((pbegin == pend ? pblank : (unsigned char*)&pbegin[0]), (pend - pbegin) * sizeof(pbegin[0]), (unsigned char*)&hash1);11     uint256 hash2;12     SHA256((unsigned char*)&hash1, sizeof(hash1), (unsigned char*)&hash2);13     return hash2;14@@ -441,11 +442,12 @@15 inline uint256 Hash(const T1 p1begin, const T1 p1end,16                     const T2 p2begin, const T2 p2end)17 {18+    static unsigned char pblank[1];19     uint256 hash1;20     SHA256_CTX ctx;21     SHA256_Init(&ctx);22-    SHA256_Update(&ctx, (unsigned char*)&p1begin[0], (p1end - p1begin) * sizeof(p1begin[0]));23-    SHA256_Update(&ctx, (unsigned char*)&p2begin[0], (p2end - p2begin) * sizeof(p2begin[0]));24+    SHA256_Update(&ctx, (p1begin == p1end ? pblank : (unsigned char*)&p1begin[0]), (p1end - p1begin) * sizeof(p1begin[0]));25+    SHA256_Update(&ctx, (p2begin == p2end ? pblank : (unsigned char*)&p2begin[0]), (p2end - p2begin) * sizeof(p2begin[0]));26     SHA256_Final((unsigned char*)&hash1, &ctx);27     uint256 hash2;28     SHA256((unsigned char*)&hash1, sizeof(hash1), (unsigned char*)&hash2);29@@ -457,12 +459,13 @@30                     const T2 p2begin, const T2 p2end,31                     const T3 p3begin, const T3 p3end)32 {33+    static unsigned char pblank[1];34     uint256 hash1;35     SHA256_CTX ctx;36     SHA256_Init(&ctx);37-    SHA256_Update(&ctx, (unsigned char*)&p1begin[0], (p1end - p1begin) * sizeof(p1begin[0]));38-    SHA256_Update(&ctx, (unsigned char*)&p2begin[0], (p2end - p2begin) * sizeof(p2begin[0]));39-    SHA256_Update(&ctx, (unsigned char*)&p3begin[0], (p3end - p3begin) * sizeof(p3begin[0]));40+    SHA256_Update(&ctx, (p1begin == p1end ? pblank : (unsigned char*)&p1begin[0]), (p1end - p1begin) * sizeof(p1begin[0]));41+    SHA256_Update(&ctx, (p2begin == p2end ? pblank : (unsigned char*)&p2begin[0]), (p2end - p2begin) * sizeof(p2begin[0]));42+    SHA256_Update(&ctx, (p3begin == p3end ? pblank : (unsigned char*)&p3begin[0]), (p3end - p3begin) * sizeof(p3begin[0]));43     SHA256_Final((unsigned char*)&hash1, &ctx);44     uint256 hash2;45     SHA256((unsigned char*)&hash1, sizeof(hash1), (unsigned char*)&hash2);
0:000:00