The sad state of Bitcoin code

Thursday, 21 January, Year 8 d.Tr. | Author: Mircea Popescu

There's been discussion on this topic for many years now, and a solid consensus in the Republic on the matter. Yet it never ceases to shock and disturb :

mircea_popescu unsigned char pchSig[10000]; // Can anyone explain why 10`000 ? Enough with the magic numbers already. << for the fucking record.
mircea_popescu WHO CODES LIKE THIS
copypaste I'll take a guess, seems like it's a signature, and 10k bytes is the expected length. But that seems insanely long. Perhaps it's some intermediary for a signature, and the final return will be chopped to say something sane like 64, 128
asciilifeform This kind of thing is pestilentially common in 1) microshit 2) folks who grew up on it. 'I'll leave a massive space on the stack so not to overflow because I can't count and also can't trust myself to put it in heap and remember to free()'

mircea_popescu Fuck that shit. Security through "Bill Gates should be enough to anally satisfy everyone".
copypaste (2) is surprisingly common. I've even seen "security patches" where the patch was to make the stack bigger, even though the stack was the right size to begin with. "So as not to overflow".
asciilifeform I worked with a fella like that. 'If I make it what I think is the right size, it crashes!111'. I often wonder, do these folks also have two-metre-wide toilet in the house, so as to not miss ?i A garage big enough for a boeing, so as to not hit the walls ? Part of the reason why software suxx is that the system appears to be quite forgiving of this kind of intellectual sloth. 'What's an extra 10kB'. Forgives, and forgives, until we have a bitcoind that wants a GB/week of RAM.

mircea_popescu Motherfucker.
mircea_popescu SPACE ALLIGNMENT!!!1 who! why! jesus.
mircea_popescu WHO DOES THESE THINGS
asciilifeform The heathens, who lack emacs ? And others, who edit their shit, who end up forced to use spaces to maintain the width ? Idiocy is ~contagious~. I'd happily see the whole shebang reformatted, but this would destroy v-ability And is in fact something lusers are famous for doing - recall the folks which the 'comment commits' and 'formatting fixes' who munge entire projects ?

mircea_popescu Fuck that, im making a proper file. The diff looks like the end of the fucking world, but hey.
asciilifeform mircea_popescu: argh this is painful

mircea_popescu I know ;/
asciilifeform You realize, this is likely the biggest patch so far, and almost all of it is whitespace-munging.

mircea_popescu Look, I can't use fucking space allignment. For one thing on some systems I need it 2 space and on others 4. Not to even go into all the semantic degradation when you go from 2 separators to just 1.
asciilifeform If you must do this, the right way is to separate the two. 1 patch for the meat, another where just munge. Because the latter can be machine-checked, at least in theory.

mircea_popescu Well, honestly, this wasn't intended as a release candidate, more like a commentary item
asciilifeform Ok.

mircea_popescu For your convenience ima make one with spaces unmunged, 1 sec.
asciilifeform Ty. I might actually have the stamina to read that one. FWIW i've deliberately refrained from munging whitespace or even fixing the asinine { } convention used in trb just to minimize touched-line countii. Because reading patches is serious work, I personally do not even have all that much time and energy these days, and other folks less still. I try to conserve it.

mircea_popescu Yes, conserve. On the other hand, the unknown unknowns : how many people currently simply CAN NOT help because of this ?
asciilifeform Because of whitespace ?

mircea_popescu Bullshit like you know, avoiding the word cunt because it might make it impossible for some developers to contribute isn't worth the time of day. But spaces for tabs is a fucking disability.
mircea_popescu asciilifeform tu quoque ffs! Just five minutes ago, you got to see what it does.
asciilifeform The spaces thing is just one in 10,001 sad things in a Jupiter-sized ball of sad that is trb.

mircea_popescu In honesty, without any exaggeration, I would estimate the barrier to contribution that whitespace-for-tab puts in front of me is actually larger than the barrier blindness put in front of chetty. No joking. And I can't be the only one.

Fixing the whitespace issue is perhaps progressing on its path, meanwhile let us see the other thing.

grep -rc '[0-9]*' .
./uint256.h:750
./wallet.h:645
./crypter.h:96
./obj/.gitignore:2
./obj/nogui/.gitignore:2
./obj/test/.gitignore:2
./net.cpp:1352
./main.h:1353
./wallet.cpp:1413
./script.h:701
./keystore.h:138
./db.h:485
./base58.h:318
./net.h:696
./json/json_spirit_writer_template.h:248
./json/LICENSE.txt:24
./json/json_spirit_utils.h:61
./json/json_spirit_writer.h:50
./json/json_spirit_writer.cpp:95
./json/json_spirit_reader.cpp:137
./json/json_spirit_stream_reader.h:70
./json/json_spirit_reader.h:62
./json/json_spirit_value.cpp:8
./json/json_spirit_value.h:534
./json/json_spirit.h:18
./json/json_spirit_reader_template.h:612
./json/json_spirit_error_position.h:54
./strlcpy.h:86
./noui.h:74
./main.cpp:2966
./bitcoinrpc.h:7
./db.cpp:1064
./util.cpp:1039
./init.h:14
./checkpoints.cpp:59
./protocol.h:149
./keystore.cpp:181
./bignum.h:538
./util.h:657
./checkpoints.h:29
./crypter.cpp:129
./headers.h:66
./init.cpp:472
./test/transaction_tests.cpp:25
./test/test_bitcoin.cpp:23
./test/uint160_tests.cpp:18
./test/README:21
./test/Checkpoints_tests.cpp:34
./test/DoS_tests.cpp:118
./test/util_tests.cpp:233
./test/miner_tests.cpp:35
./test/base64_tests.cpp:20
./test/base58_tests.cpp:87
./test/uint256_tests.cpp:18
./test/script_tests.cpp:173
./obj-test/.gitignore:2
./script.cpp:1203
./makefile.unix:144
./bitcoinrpc.cpp:2500
./key.h:406
./serialize.h:1326

That's some 23`842 instances in total, which is outrageous - but then again, the search was very greedy. Everything shows up (this is a good thing) : years, uint64 declarations, everything. Looking through the output (you're cordially invited to do exactly the same), here's the (perhaps not exhaustive) list of unjustified (and unjustifiable!) magic numbers in the code :


./uint256.h-
./uint256.h:inline int Testuint256AdHoc(std::vector vArg)
./uint256.h-{
./uint256.h: uint256 g(0);
./uint256.h-
--
./uint256.h-
./uint256.h: uint256 a(7);
./uint256.h: printf("a=7\n");
./uint256.h- printf("%s\n", a.ToString().c_str());
./uint256.h-
./uint256.h: uint256 b;
./uint256.h- printf("b undefined\n");
./uint256.h- printf("%s\n", b.ToString().c_str());
./uint256.h: int c = 3;
./uint256.h-
./uint256.h- a = c;
./uint256.h: a.pn[3] = 15;
./uint256.h- printf("%s\n", a.ToString().c_str());
./uint256.h: uint256 k(c);
./uint256.h-
./uint256.h: a = 5;
./uint256.h: a.pn[3] = 15;
./uint256.h- printf("%s\n", a.ToString().c_str());
./uint256.h: b = 1;
./uint256.h: b <<= 52;
./uint256.h-
--
./uint256.h-
./uint256.h: a ^= 0x500;
./uint256.h-
--
./uint256.h-
./uint256.h: a = a | b | (uint256)0x1000;
./uint256.h-
--
./uint256.h-
./uint256.h: a = 0xfffffffe;
./uint256.h: a.pn[4] = 9;
./uint256.h-
--
./uint256.h- printf("%s\n", a.ToString().c_str());
./uint256.h: uint256 d = a--;
./uint256.h- printf("%s\n", d.ToString().c_str());
--
./uint256.h- printf("%s\n", d.ToString().c_str());
./uint256.h: for (int i = uint256::WIDTH-1; i >= 0; i--) printf("%08x", d.pn[i]); printf("\n");
./uint256.h-
./uint256.h: uint256 neg = d;
./uint256.h- neg = ~neg;
--
./uint256.h-
./uint256.h: uint256 e = uint256("0xABCDEF123abcdef12345678909832180000011111111");
./uint256.h- printf("\n");
--
./uint256.h- printf("\n");
./uint256.h: uint256 x1 = uint256("0xABCDEF123abcdef12345678909832180000011111111");
./uint256.h: uint256 x2;
./uint256.h: printf("%s\n", x1.ToString().c_str());
./uint256.h: for (int i = 0; i < 270; i += 4)
./uint256.h- {
./uint256.h: x2 = x1 << i;
./uint256.h: printf("%s\n", x2.ToString().c_str());
./uint256.h- }
--
./uint256.h- printf("\n");
./uint256.h: printf("%s\n", x1.ToString().c_str());
./uint256.h: for (int i = 0; i < 270; i += 4)
./uint256.h- {
./uint256.h: x2 = x1;
./uint256.h: x2 >>= i;
./uint256.h: printf("%s\n", x2.ToString().c_str());
./uint256.h- }
--
./uint256.h-
./uint256.h: for (int i = 0; i < 100; i++)
./uint256.h- {
./uint256.h: uint256 k = (~uint256(0) >> i);
./uint256.h- printf("%s\n", k.ToString().c_str());
--
./uint256.h-
./uint256.h: for (int i = 0; i < 100; i++)
./uint256.h- {
./uint256.h: uint256 k = (~uint256(0) << i);
./uint256.h- printf("%s\n", k.ToString().c_str());
--
./uint256.h-
./uint256.h: return (0);
./uint256.h-}
--
./crypter.h-
./crypter.h:const unsigned int WALLET_CRYPTO_KEY_SIZE = 32;
./crypter.h:const unsigned int WALLET_CRYPTO_SALT_SIZE = 8;
./crypter.h-
--
./crypter.h- {
./crypter.h: // 25000 rounds is just under 0.1 seconds on a 1.86 GHz Pentium M
./crypter.h- // ie slightly lower than the lowest hardware we need bother supporting
./crypter.h: nDeriveIterations = 25000;
./crypter.h: nDerivationMethod = 0;
./crypter.h: vchOtherDerivationParameters = std::vector(0);
./crypter.h- }
--
./net.cpp-
./net.cpp:static const int MAX_OUTBOUND_CONNECTIONS = 8;
./net.cpp-
./net.cpp:void ThreadMessageHandler2(void* parg);
./net.cpp:void ThreadSocketHandler2(void* parg);
./net.cpp:void ThreadOpenConnections2(void* parg);
./net.cpp-bool OpenNetworkConnection(const CAddress& addrConnect);
--
./net.cpp-bool fClient = false;
./net.cpp:uint64 nLocalServices = (fClient ? 0 : NODE_NETWORK);
./net.cpp:CAddress addrLocalHost("0.0.0.0", 0, nLocalServices);
./net.cpp-static CNode* pnodeLocalHost = NULL;
./net.cpp:uint64 nLocalHostNonce = 0;
./net.cpp:array vnThreadsRunning;
./net.cpp-static SOCKET hListenSocket = INVALID_SOCKET;
--
./net.cpp-int fUseProxy = false;
./net.cpp:int nConnectTimeout = 5000;
./net.cpp:CAddress addrProxy("127.0.0.1",9050);
./net.cpp-
--
./net.cpp- struct timeval timeout;
./net.cpp: timeout.tv_sec = nTimeout / 1000;
./net.cpp: timeout.tv_usec = (nTimeout % 1000) * 1000;
./net.cpp-
--
./net.cpp- printf("proxy connecting %s\n", addrConnect.ToString().c_str());
./net.cpp: char pszSocks4IP[] = "\4\1\0\0\0\0\0\0user";
./net.cpp: memcpy(pszSocks4IP + 2, &addrConnect.port, 2);
./net.cpp: memcpy(pszSocks4IP + 4, &addrConnect.ip, 4);
./net.cpp: char* pszSocks4 = pszSocks4IP;
./net.cpp: int nSize = sizeof(pszSocks4IP);
./net.cpp-
./net.cpp: int ret = send(hSocket, pszSocks4, nSize, MSG_NOSIGNAL);
./net.cpp- if (ret != nSize)
--
./net.cpp- }
./net.cpp: char pchRet[8];
./net.cpp: if (recv(hSocket, pchRet, 8, 0) != 8)
./net.cpp- {
--
./net.cpp- }
./net.cpp: if (pchRet[1] != 0x5a)
./net.cpp- {
./net.cpp- closesocket(hSocket);
./net.cpp: if (pchRet[1] != 0x5b)
./net.cpp: printf("ERROR: Proxy returned error %d\n", pchRet[1]);
./net.cpp- return false;
--
./net.cpp- vaddr.clear();
./net.cpp: if (pszName[0] == 0)
./net.cpp- return false;
./net.cpp- int port = portDefault;
./net.cpp: char psz[256];
./net.cpp- char *pszHost = psz;
--
./net.cpp- {
./net.cpp: char* pszColon = strrchr(psz+1,':');
./net.cpp- char *pszPortEnd = NULL;
./net.cpp: int portParsed = pszColon ? strtoul(pszColon+1, &pszPortEnd, 10) : 0;
./net.cpp: if (pszColon && pszPortEnd && pszPortEnd[0] == 0)
./net.cpp- {
./net.cpp: if (psz[0] == '[' && pszColon[-1] == ']')
./net.cpp- {
./net.cpp: // Future: enable IPv6 colon-notation inside []
./net.cpp: pszHost = psz+1;
./net.cpp: pszColon[-1] = 0;
./net.cpp- }
./net.cpp- else
./net.cpp: pszColon[0] = 0;
./net.cpp- port = portParsed;
./net.cpp: if (port < 0 || port > USHRT_MAX)
./net.cpp- port = USHRT_MAX;
--
./net.cpp- }
./net.cpp: bool fCurrentlyOnline = (GetAdjustedTime() - addr.nTime < 24 * 60 * 60);
./net.cpp: int64 nUpdateInterval = (fCurrentlyOnline ? 60 * 60 : 24 * 60 * 60);
./net.cpp- if (addrFound.nTime < addr.nTime - nUpdateInterval)
--
./net.cpp- // CRITICAL_BLOCK:
./net.cpp: // Thread 1: begin db transaction (locks inside-db-mutex)
./net.cpp- // then AddAddress (locks cs_mapAddresses)
./net.cpp: // Thread 2: AddAddress (locks cs_mapAddresses)
./net.cpp- // ... then db operation hangs waiting for inside-db-mutex
--
./net.cpp- {
./net.cpp: int64 nUpdateInterval = 20 * 60;
./net.cpp- if (paddrFound->nTime < GetAdjustedTime() - nUpdateInterval)
--
./net.cpp-// The subscription system uses a meet-in-the-middle strategy.
./net.cpp:// With 100,000 nodes, if senders broadcast to 1000 random nodes and receivers
./net.cpp:// subscribe to 1000 random nodes, 99.995% (1 - 0.99^1000) of messages will get through.
./net.cpp-//
--
./net.cpp- /// debug print
./net.cpp: printf("trying connection %s lastseen=%.1fhrs lasttry=%.1fhrs\n",
./net.cpp- addrConnect.ToString().c_str(),
./net.cpp: (double)(addrConnect.nTime - GetAdjustedTime())/3600.0,
./net.cpp: (double)(addrConnect.nLastTry - GetAdjustedTime())/3600.0);
./net.cpp-
--
./net.cpp- nMisbehavior += howmuch;
./net.cpp: if (nMisbehavior >= GetArg("-banscore", 100))
./net.cpp- {
./net.cpp: int64 banTime = GetTime()+GetArg("-bantime", 60*60*24); // Default 24-hour ban
./net.cpp- CRITICAL_BLOCK(cs_setBanned)
--
./net.cpp- // hold in disconnected pool until all refs are released
./net.cpp: pnode->nReleaseTime = max(pnode->nReleaseTime, GetTime() + 15 * 60);
./net.cpp- if (pnode->fNetworkNode || pnode->fInbound)
--
./net.cpp- struct timeval timeout;
./net.cpp: timeout.tv_sec = 0;
./net.cpp: timeout.tv_usec = 50000; // frequency to poll pnode->vSend
./net.cpp-
--
./net.cpp- FD_ZERO(&fdsetError);
./net.cpp: Sleep(timeout.tv_usec/1000);
./net.cpp- }
--
./net.cpp- }
./net.cpp: else if (nInbound >= GetArg("-maxconnections", 125) - MAX_OUTBOUND_CONNECTIONS)
./net.cpp- {
--
./net.cpp- else {
./net.cpp: // typical socket buffer is 8K-64K
./net.cpp: char pchBuf[0x10000];
./net.cpp- int nBytes = recv(pnode->hSocket, pchBuf, sizeof(pchBuf), MSG_DONTWAIT);
./net.cpp: if (nBytes > 0)
./net.cpp- {
--
./net.cpp- pnode->nLastSendEmpty = GetTime();
./net.cpp: if (GetTime() - pnode->nTimeConnected > 60)
./net.cpp- {
./net.cpp: if (pnode->nLastRecv == 0 || pnode->nLastSend == 0)
./net.cpp- {
./net.cpp: printf("socket no message in first 60 seconds, %d %d\n", pnode->nLastRecv != 0, pnode->nLastSend != 0);
./net.cpp- pnode->fDisconnect = true;
./net.cpp- }
./net.cpp: else if (GetTime() - pnode->nLastSend > 90*60 && GetTime() - pnode->nLastSendEmpty > 90*60)
./net.cpp- {
--
./net.cpp- }
./net.cpp: else if (GetTime() - pnode->nLastRecv > 90*60)
./net.cpp- {
--
./net.cpp-
./net.cpp: Sleep(10);
./net.cpp- }
--
./net.cpp- OpenNetworkConnection(addr);
./net.cpp: for (int i = 0; i < 10 && i < nLoop; i++)
./net.cpp- {
./net.cpp: Sleep(500);
./net.cpp- if (fShutdown)
--
./net.cpp- OpenNetworkConnection(addr);
./net.cpp: Sleep(500);
./net.cpp- if (fShutdown)
--
./net.cpp- // Initiate network connections
./net.cpp: int64 nStart = GetTime();
./net.cpp- loop
./net.cpp- {
./net.cpp: vnThreadsRunning[1]--;
./net.cpp: Sleep(500);
./net.cpp: vnThreadsRunning[1]++;
./net.cpp- if (fShutdown)
--
./net.cpp- int nMaxOutboundConnections = MAX_OUTBOUND_CONNECTIONS;
./net.cpp: nMaxOutboundConnections = min(nMaxOutboundConnections, (int)GetArg("-maxconnections", 125));
./net.cpp- if (nOutbound < nMaxOutboundConnections)
./net.cpp- break;
./net.cpp: vnThreadsRunning[1]--;
./net.cpp: Sleep(2000);
./net.cpp: vnThreadsRunning[1]++;
./net.cpp- if (fShutdown)
--
./net.cpp- BOOST_FOREACH(CNode* pnode, vNodes)
./net.cpp: setConnected.insert(pnode->addr.ip & 0x0000ffff);
./net.cpp-
./net.cpp: int64 nANow = GetAdjustedTime();
./net.cpp-
--
./net.cpp- const CAddress& addr = item.second;
./net.cpp: if (!addr.IsIPv4() || !addr.IsValid() || setConnected.count(addr.ip & 0x0000ffff))
./net.cpp- continue;
./net.cpp: int64 nSinceLastSeen = nANow - addr.nTime;
./net.cpp: int64 nSinceLastTry = nANow - addr.nLastTry;
./net.cpp-
./net.cpp- // Randomize the order in a deterministic way, putting the standard port first
./net.cpp: int64 nRandomizer = (uint64)(nStart * 4951 + addr.nLastTry * 9567851 + addr.ip * 7789) % (2 * 60 * 60);
./net.cpp- if (addr.port != htons(GetDefaultPort()))
./net.cpp: nRandomizer += 2 * 60 * 60;
./net.cpp-
./net.cpp- // Last seen Base retry frequency
./net.cpp: // <1 hour 10 min
./net.cpp: // 1 hour 1 hour
./net.cpp: // 4 hours 2 hours
./net.cpp: // 24 hours 5 hours
./net.cpp: // 48 hours 7 hours
./net.cpp: // 7 days 13 hours
./net.cpp: // 30 days 27 hours
./net.cpp: // 90 days 46 hours
./net.cpp: // 365 days 93 hours
./net.cpp: int64 nDelay = (int64)(3600.0 * sqrt(fabs( (double)nSinceLastSeen) / 3600.0) + nRandomizer);
./net.cpp-
./net.cpp- // Fast reconnect for one hour after last seen
./net.cpp: if (nSinceLastSeen < 60 * 60)
./net.cpp: nDelay = 10 * 60;
./net.cpp-
--
./net.cpp- // Only try the old stuff if we don't have enough connections
./net.cpp: if (vNodes.size() >= 8 && nSinceLastSeen > 24 * 60 * 60)
./net.cpp- continue;
--
./net.cpp- // last seen and time since last tried.
./net.cpp: int64 nScore = min(nSinceLastTry, (int64)24 * 60 * 60) - nSinceLastSeen - nRandomizer;
./net.cpp- if (nScore > nBest)
--
./net.cpp- // we're sleeping, but we must always check fShutdown after doing this.
./net.cpp: vnThreadsRunning[2]--;
./net.cpp: Sleep(100);
./net.cpp- if (fRequestShutdown)
./net.cpp- Shutdown(NULL);
./net.cpp: vnThreadsRunning[2]++;
./net.cpp- if (fShutdown)
--
./net.cpp- if (pnodeLocalHost == NULL)
./net.cpp: pnodeLocalHost = new CNode(INVALID_SOCKET, CAddress("127.0.0.1", 0, nLocalServices));
./net.cpp-
--
./net.cpp- if (ifa->ifa_addr == NULL) continue;
./net.cpp: if ( (ifa->ifa_flags & IFF_UP) == 0) continue;
./net.cpp: if (strcmp(ifa->ifa_name, "lo") == 0) continue;
./net.cpp: if (strcmp(ifa->ifa_name, "lo0") == 0) continue;
./net.cpp: char pszIP[100];
./net.cpp- if (ifa->ifa_addr->sa_family == AF_INET)
./net.cpp- {
./net.cpp: struct sockaddr_in* s4 = (struct sockaddr_in*)(ifa->ifa_addr);
./net.cpp: if (inet_ntop(ifa->ifa_addr->sa_family, (void*)&(s4->sin_addr), pszIP, sizeof(pszIP)) != NULL)
./net.cpp: printf("ipv4 %s: %s\n", ifa->ifa_name, pszIP);
./net.cpp-
./net.cpp: // Take the first IP that isn't loopback 127.x.x.x
./net.cpp: CAddress addr(*(unsigned int*)&s4->sin_addr, GetListenPort(), nLocalServices);
./net.cpp: if (addr.IsValid() && addr.GetByte(3) != 127)
./net.cpp- {
--
./net.cpp- nTransactionsUpdated++;
./net.cpp: int64 nStart = GetTime();
./net.cpp: while (vnThreadsRunning[0] > 0 || vnThreadsRunning[1] > 0 || vnThreadsRunning[2] > 0 || vnThreadsRunning[3] > 0 || vnThreadsRunning[4] > 0
./net.cpp- )
./net.cpp- {
./net.cpp: if (GetTime() - nStart > 20)
./net.cpp- break;
./net.cpp: Sleep(20);
./net.cpp- }
./net.cpp: if (vnThreadsRunning[0] > 0) printf("ThreadSocketHandler still running\n");
./net.cpp: if (vnThreadsRunning[1] > 0) printf("ThreadOpenConnections still running\n");
./net.cpp: if (vnThreadsRunning[2] > 0) printf("ThreadMessageHandler still running\n");
./net.cpp: if (vnThreadsRunning[3] > 0) printf("ThreadBitcoinMiner still running\n");
./net.cpp: if (vnThreadsRunning[4] > 0) printf("ThreadRPCServer still running\n");
./net.cpp: while (vnThreadsRunning[2] > 0 || vnThreadsRunning[4] > 0)
./net.cpp: Sleep(20);
./net.cpp: Sleep(50);
./net.cpp-
--
./main.h-
./main.h:static const unsigned int MAX_BLOCK_SIZE = 1000000; ( (O hello!))
./main.h:static const unsigned int MAX_BLOCK_SIZE_GEN = MAX_BLOCK_SIZE/2;
./main.h:static const int MAX_BLOCK_SIGOPS = MAX_BLOCK_SIZE/50;
./main.h:static const int64 COIN = 100000000;
./main.h:static const int64 CENT = 1000000;
./main.h:static const int64 MIN_TX_FEE = 50000;
./main.h:static const int64 MIN_RELAY_TX_FEE = 10000;
./main.h:static const int64 MAX_MONEY = 21000000 * COIN;
./main.h:inline bool MoneyRange(int64 nValue) { return (nValue >= 0 && nValue <= MAX_MONEY); }
./main.h:static const int COINBASE_MATURITY = 100;
./main.h-// Threshold for nLockTime: below this value it is interpreted as block number, otherwise as UNIX timestamp.
./main.h:static const int LOCKTIME_THRESHOLD = 500000000; // Tue Nov 5 00:53:20 1985 UTC
./main.h-
--
./main.h- IMPLEMENT_SERIALIZE( READWRITE(FLATDATA(*this)); )
./main.h: void SetNull() { nFile = -1; nBlockPos = 0; nTxPos = 0; }
./main.h: bool IsNull() const { return (nFile == -1); }
./main.h-
--
./main.h- CInPoint(CTransaction* ptxIn, unsigned int nIn) { ptx = ptxIn; n = nIn; }
./main.h: void SetNull() { ptx = NULL; n = -1; }
./main.h: bool IsNull() const { return (ptx == NULL && n == -1); }
./main.h-};
--
./main.h- COutPoint() { SetNull(); }
./main.h: COutPoint(uint256 hashIn, unsigned int nIn) { hash = hashIn; n = nIn; }
./main.h- IMPLEMENT_SERIALIZE( READWRITE(FLATDATA(*this)); )
./main.h: void SetNull() { hash = 0; n = -1; }
./main.h: bool IsNull() const { return (hash == 0 && n == -1); }
./main.h-
--
./main.h- {
./main.h: return strprintf("COutPoint(%s, %d)", hash.ToString().substr(0,10).c_str(), n);
./main.h- }
--
./main.h- else
./main.h: str += strprintf(", scriptSig=%s", scriptSig.ToString().substr(0,24).c_str());
./main.h- if (nSequence != UINT_MAX)
--
./main.h- {
./main.h: nValue = -1;
./main.h- scriptPubKey.clear();
--
./main.h- {
./main.h: return (nValue == -1);
./main.h- }
./main.h-
./main.h: uint256 GetHash() const
./main.h- {
--
./main.h- {
./main.h: if (scriptPubKey.size() < 6)
./main.h- return "CTxOut(error)";
./main.h: return strprintf("CTxOut(nValue=%"PRI64d".%08"PRI64d", scriptPubKey=%s)", nValue / COIN, nValue % COIN, scriptPubKey.ToString().substr(0,30).c_str());
./main.h- }
--
./main.h- {
./main.h: nVersion = 1;
./main.h- vin.clear();
./main.h- vout.clear();
./main.h: nLockTime = 0;
./main.h: nDoS = 0; // Denial-of-service prevention
./main.h- }
--
./main.h- // need a fee.
./main.h: return dPriority > COIN * 144 / 250;
./main.h- }
./main.h-
./main.h: int64 GetMinFee(unsigned int nBlockSize=1, bool fAllowFree=true, bool fForRelay=false) const
./main.h- {
./main.h- // Base fee is either MIN_TX_FEE or MIN_RELAY_TX_FEE
./main.h: int64 nBaseFee = fForRelay ? MIN_RELAY_TX_FEE : MIN_TX_FEE;
./main.h-
--
./main.h- unsigned int nNewBlockSize = nBlockSize + nBytes;
./main.h: int64 nMinFee = (1 + (int64)nBytes / 1000) * nBaseFee;
./main.h-
--
./main.h- {
./main.h: if (nBlockSize == 1)
./main.h- {
./main.h: // Transactions under 10K are free
./main.h: // (about 4500bc if made of 50bc inputs)
./main.h: if (nBytes < 10000)
./main.h: nMinFee = 0;
./main.h- }
--
./main.h- // Free transaction area
./main.h: if (nNewBlockSize < 27000)
./main.h: nMinFee = 0;
./main.h- }
--
./main.h- // Raise the price as the block approaches full
./main.h: if (nBlockSize != 1 && nNewBlockSize >= MAX_BLOCK_SIZE_GEN/2)
./main.h- {
--
./main.h- // Read transaction
./main.h: if (fseek(filein, pos.nTxPos, SEEK_SET) != 0)
./main.h- return error("CTransaction::ReadFromDisk() : fseek failed");
--
./main.h- {
./main.h: if (fseek(filein, pos.nTxPos, SEEK_SET) != 0)
./main.h- return error("CTransaction::ReadFromDisk() : second fseek failed");
--
./main.h- str += strprintf("CTransaction(hash=%s, ver=%d, vin.size=%d, vout.size=%d, nLockTime=%d)\n",
./main.h: GetHash().ToString().substr(0,10).c_str(),
./main.h- nVersion,
--
./main.h- {
./main.h: hashBlock = 0;
./main.h: nIndex = -1;
./main.h- fMerkleVerified = false;
--
./main.h-//
./main.h:// Blocks are appended to blk0001.dat files on disk. Their location on disk
./main.h-// is indexed by CBlockIndex objects in memory.
--
./main.h- nBlockPosRet = ftell(fileout);
./main.h: if (nBlockPosRet == -1)
./main.h- return error("CBlock::WriteToDisk() : ftell failed");
--
./main.h- fflush(fileout);
./main.h: if (!IsInitialBlockDownload() || (nBestHeight+1) % 500 == 0)
./main.h- {
--
./main.h- {
./main.h: printf("CBlock(hash=%s, ver=%d, hashPrevBlock=%s, hashMerkleRoot=%s, nTime=%u, nBits=%08x, nNonce=%u, vtx=%d)\n",
./main.h: GetHash().ToString().substr(0,20).c_str(),
./main.h- nVersion,
./main.h: hashPrevBlock.ToString().substr(0,20).c_str(),
./main.h: hashMerkleRoot.ToString().substr(0,10).c_str(),
./main.h- nTime, nBits, nNonce,
./main.h- vtx.size());
./main.h: for (int i = 0; i < vtx.size(); i++)
./main.h- {
--
./main.h- printf(" vMerkleTree: ");
./main.h: for (int i = 0; i < vMerkleTree.size(); i++)
./main.h: printf("%s ", vMerkleTree[i].ToString().substr(0,10).c_str());
./main.h- printf("\n");
--
./main.h- bnTarget.SetCompact(nBits);
./main.h: if (bnTarget <= 0)
./main.h: return 0;
./main.h: return (CBigNum(1)<<256) / (bnTarget+1);
./main.h- }
--
./main.h-
./main.h: enum { nMedianTimeSpan=11 };
./main.h-
--
./main.h- {
./main.h: return strprintf("CBlockIndex(nprev=%08x, pnext=%08x, nFile=%d, nBlockPos=%-6d nHeight=%d, merkle=%s, hashBlock=%s)",
./main.h- pprev, pnext, nFile, nBlockPos, nHeight,
./main.h: hashMerkleRoot.ToString().substr(0,10).c_str(),
./main.h: GetBlockHash().ToString().substr(0,20).c_str());
./main.h- }
--
./main.h- GetBlockHash().ToString().c_str(),
./main.h: hashPrev.ToString().substr(0,20).c_str(),
./main.h: hashNext.ToString().substr(0,20).c_str());
./main.h- return str;
--
./main.h- // Exponentially larger steps back
./main.h: for (int i = 0; pindex && i < nStep; i++)
./main.h- pindex = pindex->pprev;
./main.h: if (vHave.size() > 10)
./main.h: nStep *= 2;
./main.h- }
--
./main.h- nDistance += nStep;
./main.h: if (nDistance > 10)
./main.h: nStep *= 2;
./main.h- }
--
./wallet.cpp- {
./wallet.cpp: int64 nStartTime = GetTimeMillis();
./wallet.cpp- crypter.SetKeyFromPassphrase(strNewWalletPassphrase, pMasterKey.second.vchSalt, pMasterKey.second.nDeriveIterations, pMasterKey.second.nDerivationMethod);
./wallet.cpp: pMasterKey.second.nDeriveIterations = pMasterKey.second.nDeriveIterations * (100 / ( (double)(GetTimeMillis() - nStartTime)));
./wallet.cpp-
--
./wallet.cpp- crypter.SetKeyFromPassphrase(strNewWalletPassphrase, pMasterKey.second.vchSalt, pMasterKey.second.nDeriveIterations, pMasterKey.second.nDerivationMethod);
./wallet.cpp: pMasterKey.second.nDeriveIterations = (pMasterKey.second.nDeriveIterations + pMasterKey.second.nDeriveIterations * 100 / ( (double)(GetTimeMillis() - nStartTime))) / 2;
./wallet.cpp-
./wallet.cpp: if (pMasterKey.second.nDeriveIterations < 25000)
./wallet.cpp: pMasterKey.second.nDeriveIterations = 25000;
./wallet.cpp-
--
./wallet.cpp- kMasterKey.vchSalt.resize(WALLET_CRYPTO_SALT_SIZE);
./wallet.cpp: RAND_bytes(&kMasterKey.vchSalt[0], WALLET_CRYPTO_SALT_SIZE);
./wallet.cpp-
./wallet.cpp- CCrypter crypter;
./wallet.cpp: int64 nStartTime = GetTimeMillis();
./wallet.cpp: crypter.SetKeyFromPassphrase(strWalletPassphrase, kMasterKey.vchSalt, 25000, kMasterKey.nDerivationMethod);
./wallet.cpp: kMasterKey.nDeriveIterations = 2500000 / ( (double)(GetTimeMillis() - nStartTime));
./wallet.cpp-
--
./wallet.cpp- crypter.SetKeyFromPassphrase(strWalletPassphrase, kMasterKey.vchSalt, kMasterKey.nDeriveIterations, kMasterKey.nDerivationMethod);
./wallet.cpp: kMasterKey.nDeriveIterations = (kMasterKey.nDeriveIterations + kMasterKey.nDeriveIterations * 100 / ( (double)(GetTimeMillis() - nStartTime))) / 2;
./wallet.cpp-
./wallet.cpp: if (kMasterKey.nDeriveIterations < 25000)
./wallet.cpp: kMasterKey.nDeriveIterations = 25000;
./wallet.cpp-
--
./wallet.cpp- //// debug print
./wallet.cpp: printf("AddToWallet %s %s%s\n", wtxIn.GetHash().ToString().substr(0,10).c_str(), (fInsertedNew ? "new" : ""), (fUpdated ? "update" : ""));
./wallet.cpp-
--
./wallet.cpp- {
./wallet.cpp: uint256 hash = GetHash();
./wallet.cpp- if (!txdb.ContainsTx(hash))
./wallet.cpp- {
./wallet.cpp: printf("Relaying wtx %s\n", hash.ToString().substr(0,10).c_str());
./wallet.cpp- RelayMessage(CInv(MSG_TX, hash), (CTransaction)*this);
--
./wallet.cpp- // that these are our transactions.
./wallet.cpp: static int64 nNextTime;
./wallet.cpp- if (GetTime() < nNextTime)
./wallet.cpp- return;
./wallet.cpp: bool fFirst = (nNextTime == 0);
./wallet.cpp: nNextTime = GetTime() + GetRand(30 * 60);
./wallet.cpp- if (fFirst)
--
./wallet.cpp- // it should have gotten in already by now.
./wallet.cpp: if (nTimeBestReceived - (int64)wtx.nTimeReceived > 5 * 60)
./wallet.cpp- mapSorted.insert(make_pair(wtx.nTimeReceived, &wtx));
--
./wallet.cpp- vector vfBest(vValue.size(), true);
./wallet.cpp: int64 nBest = nTotalLower;
./wallet.cpp-
./wallet.cpp: for (int nRep = 0; nRep < 1000 && nBest != nTargetValue; nRep++)
./wallet.cpp- {
./wallet.cpp- vfIncluded.assign(vValue.size(), false);
./wallet.cpp: int64 nTotal = 0;
./wallet.cpp- bool fReachedTarget = false;
./wallet.cpp: for (int nPass = 0; nPass < 2 && !fReachedTarget; nPass++)
./wallet.cpp- {
./wallet.cpp: for (int i = 0; i < vValue.size(); i++)
./wallet.cpp- {
./wallet.cpp: if (nPass == 0 ? rand() % 2 : !vfIncluded[i])
./wallet.cpp- {
--
./wallet.cpp-
./wallet.cpp:bool CWallet::SelectCoins(int64 nTargetValue, set >& setCoinsRet, int64& nValueRet) const
./wallet.cpp-{
./wallet.cpp: return (SelectCoinsMinConf(nTargetValue, 1, 6, setCoinsRet, nValueRet) ||
./wallet.cpp: SelectCoinsMinConf(nTargetValue, 1, 1, setCoinsRet, nValueRet) ||
./wallet.cpp: SelectCoinsMinConf(nTargetValue, 0, 1, setCoinsRet, nValueRet));
./wallet.cpp-}
--
./wallet.cpp- unsigned int nBytes = ::GetSerializeSize(*(CTransaction*)&wtxNew, SER_NETWORK);
./wallet.cpp: if (nBytes >= MAX_BLOCK_SIZE_GEN/5)
./wallet.cpp- return false;
--
./wallet.cpp- // Check that enough fee is included
./wallet.cpp: int64 nPayFee = nTransactionFee * (1 + (int64)nBytes / 1000);
./wallet.cpp- bool fAllowFree = CTransaction::AllowFree(dPriority);
./wallet.cpp: int64 nMinFee = wtxNew.GetMinFee(1, fAllowFree);
./wallet.cpp- if (nFeeRet < max(nPayFee, nMinFee))
--
./wallet.cpp- {
./wallet.cpp: if (CDB::Rewrite(strWalletFile, "\x04pool"))
./wallet.cpp- {
--
./wallet.cpp-
./wallet.cpp: int64 nKeys = max(GetArg("-keypool", 100), (int64)0);
./wallet.cpp: for (int i = 0; i < nKeys; i++)
./wallet.cpp- {
./wallet.cpp: int64 nIndex = i+1;
./wallet.cpp- walletdb.WritePool(nIndex, CKeyPool(GenerateNewKey()));
--
./wallet.cpp- // Top up key pool
./wallet.cpp: int64 nTargetSize = max(GetArg("-keypool", 100), (int64)0);
./wallet.cpp: while (setKeyPool.size() < nTargetSize+1)
./wallet.cpp- {
./wallet.cpp: int64 nEnd = 1;
./wallet.cpp- if (!setKeyPool.empty())
./wallet.cpp: nEnd = *(--setKeyPool.end()) + 1;
./wallet.cpp- if (!walletdb.WritePool(nEnd, CKeyPool(GenerateNewKey())))
--
./script.h-{
./script.h: SIGHASH_ALL = 1,
./script.h: SIGHASH_NONE = 2,
./script.h: SIGHASH_SINGLE = 3,
./script.h: SIGHASH_ANYONECANPAY = 0x80,
./script.h-};
--
./script.h- // push value
./script.h: OP_0=0,
./script.h: OP_FALSE=OP_0,
./script.h: OP_PUSHDATA1=76,
./script.h: OP_PUSHDATA2,
./script.h: OP_PUSHDATA4,
./script.h: OP_1NEGATE,
./script.h- OP_RESERVED,
./script.h: OP_1,
./script.h: OP_TRUE=OP_1,
./script.h: OP_2,
./script.h: OP_3,
./script.h: OP_4,
./script.h: OP_5,
./script.h: OP_6,
./script.h: OP_7,
./script.h: OP_8,
./script.h: OP_9,
./script.h: OP_10,
./script.h: OP_11,
./script.h: OP_12,
./script.h: OP_13,
./script.h: OP_14,
./script.h: OP_15,
./script.h: OP_16,
./script.h-
--
./script.h- OP_FROMALTSTACK,
./script.h: OP_2DROP,
./script.h: OP_2DUP,
./script.h: OP_3DUP,
./script.h: OP_2OVER,
./script.h: OP_2ROT,
./script.h: OP_2SWAP,
./script.h- OP_IFDUP,
--
./script.h- OP_EQUALVERIFY,
./script.h: OP_RESERVED1,
./script.h: OP_RESERVED2,
./script.h-
./script.h- // numeric
./script.h: OP_1ADD,
./script.h: OP_1SUB,
./script.h: OP_2MUL,
./script.h: OP_2DIV,
./script.h- OP_NEGATE,
--
./script.h- OP_NOT,
./script.h: OP_0NOTEQUAL,
./script.h-
--
./script.h- // crypto
./script.h: OP_RIPEMD160,
./script.h: OP_SHA1,
./script.h: OP_SHA256,
./script.h: OP_HASH160,
./script.h: OP_HASH256,
./script.h- OP_CODESEPARATOR,
--
./script.h- // expansion
./script.h: OP_NOP1,
./script.h: OP_NOP2,
./script.h: OP_NOP3,
./script.h: OP_NOP4,
./script.h: OP_NOP5,
./script.h: OP_NOP6,
./script.h: OP_NOP7,
./script.h: OP_NOP8,
./script.h: OP_NOP9,
./script.h: OP_NOP10,
./script.h-
--
./script.h- // template matching params
./script.h: OP_PUBKEYHASH = 0xfd,
./script.h: OP_PUBKEY = 0xfe,
./script.h-
./script.h: OP_INVALIDOPCODE = 0xff,
./script.h-};
--
./script.h- // push value
./script.h: case OP_0 : return "0";
./script.h: case OP_PUSHDATA1 : return "OP_PUSHDATA1";
./script.h: case OP_PUSHDATA2 : return "OP_PUSHDATA2";
./script.h: case OP_PUSHDATA4 : return "OP_PUSHDATA4";
./script.h: case OP_1NEGATE : return "-1";
./script.h- case OP_RESERVED : return "OP_RESERVED";
./script.h: case OP_1 : return "1";
./script.h: case OP_2 : return "2";
./script.h: case OP_3 : return "3";
./script.h: case OP_4 : return "4";
./script.h: case OP_5 : return "5";
./script.h: case OP_6 : return "6";
./script.h: case OP_7 : return "7";
./script.h: case OP_8 : return "8";
./script.h: case OP_9 : return "9";
./script.h: case OP_10 : return "10";
./script.h: case OP_11 : return "11";
./script.h: case OP_12 : return "12";
./script.h: case OP_13 : return "13";
./script.h: case OP_14 : return "14";
./script.h: case OP_15 : return "15";
./script.h: case OP_16 : return "16";
./script.h-
--
./script.h- case OP_FROMALTSTACK : return "OP_FROMALTSTACK";
./script.h: case OP_2DROP : return "OP_2DROP";
./script.h: case OP_2DUP : return "OP_2DUP";
./script.h: case OP_3DUP : return "OP_3DUP";
./script.h: case OP_2OVER : return "OP_2OVER";
./script.h: case OP_2ROT : return "OP_2ROT";
./script.h: case OP_2SWAP : return "OP_2SWAP";
./script.h- case OP_IFDUP : return "OP_IFDUP";
--
./script.h- case OP_EQUALVERIFY : return "OP_EQUALVERIFY";
./script.h: case OP_RESERVED1 : return "OP_RESERVED1";
./script.h: case OP_RESERVED2 : return "OP_RESERVED2";
./script.h-
./script.h- // numeric
./script.h: case OP_1ADD : return "OP_1ADD";
./script.h: case OP_1SUB : return "OP_1SUB";
./script.h: case OP_2MUL : return "OP_2MUL";
./script.h: case OP_2DIV : return "OP_2DIV";
./script.h- case OP_NEGATE : return "OP_NEGATE";
--
./script.h- case OP_NOT : return "OP_NOT";
./script.h: case OP_0NOTEQUAL : return "OP_0NOTEQUAL";
./script.h- case OP_ADD : return "OP_ADD";
--
./script.h- // crypto
./script.h: case OP_RIPEMD160 : return "OP_RIPEMD160";
./script.h: case OP_SHA1 : return "OP_SHA1";
./script.h: case OP_SHA256 : return "OP_SHA256";
./script.h: case OP_HASH160 : return "OP_HASH160";
./script.h: case OP_HASH256 : return "OP_HASH256";
./script.h- case OP_CODESEPARATOR : return "OP_CODESEPARATOR";
--
./script.h- // expanson
./script.h: case OP_NOP1 : return "OP_NOP1";
./script.h: case OP_NOP2 : return "OP_NOP2";
./script.h: case OP_NOP3 : return "OP_NOP3";
./script.h: case OP_NOP4 : return "OP_NOP4";
./script.h: case OP_NOP5 : return "OP_NOP5";
./script.h: case OP_NOP6 : return "OP_NOP6";
./script.h: case OP_NOP7 : return "OP_NOP7";
./script.h: case OP_NOP8 : return "OP_NOP8";
./script.h: case OP_NOP9 : return "OP_NOP9";
./script.h: case OP_NOP10 : return "OP_NOP10";
./script.h-
--
./script.h-{
./script.h: if (vch.size() <= 4)
./script.h- return strprintf("%d", CBigNum(vch).getint());
--
./script.h-protected:
./script.h: CScript& push_int64(int64 n)
./script.h- {
./script.h: if (n == -1 || (n >= 1 && n <= 16))
./script.h- {
./script.h: push_back(n + (OP_1 - 1));
./script.h- }
--
./script.h-
./script.h: CScript& push_uint64(uint64 n)
./script.h- {
./script.h: if (n >= 1 && n <= 16)
./script.h- {
./script.h: push_back(n + (OP_1 - 1));
./script.h- }
--
./script.h- {
./script.h: if (opcode < 0 || opcode > 0xff)
./script.h- throw std::runtime_error("CScript::operator<<() : invalid opcode");
--
./script.h- }
./script.h: else if (b.size() <= 0xff)
./script.h- {
./script.h: insert(end(), OP_PUSHDATA1);
./script.h- insert(end(), (unsigned char)b.size());
./script.h- }
./script.h: else if (b.size() <= 0xffff)
./script.h- {
./script.h: insert(end(), OP_PUSHDATA2);
./script.h- unsigned short nSize = b.size();
--
./script.h- // Wrapper so it can be called with either iterator or const_iterator
./script.h: const_iterator pc2 = pc;
./script.h: bool fRet = GetOp2(pc2, opcodeRet, &vchRet);
./script.h: pc = begin() + (pc2 - begin());
./script.h- return fRet;
--
./script.h- {
./script.h: const_iterator pc2 = pc;
./script.h: bool fRet = GetOp2(pc2, opcodeRet, NULL);
./script.h: pc = begin() + (pc2 - begin());
./script.h- return fRet;
--
./script.h- {
./script.h: return GetOp2(pc, opcodeRet, &vchRet);
./script.h- }
--
./script.h- {
./script.h: return GetOp2(pc, opcodeRet, NULL);
./script.h- }
./script.h-
./script.h: bool GetOp2(const_iterator& pc, opcodetype& opcodeRet, std::vector* pvchRet) const
./script.h- {
--
./script.h- else if (opcode == OP_CHECKMULTISIG || opcode == OP_CHECKMULTISIGVERIFY)
./script.h: n += 20;
./script.h- }
--
./script.h- {
./script.h: if (size() > 200)
./script.h- return false;
--
./script.h- return false;
./script.h: if (opcode > OP_16)
./script.h- return false;
--
./db.h- CDataStream ssKey(SER_DISK);
./db.h: ssKey.reserve(1000);
./db.h- ssKey << key;
./db.h: Dbt datKey(&ssKey[0], ssKey.size());
./db.h-
--
./db.h- CDataStream ssKey(SER_DISK);
./db.h: ssKey.reserve(1000);
./db.h- ssKey << key;
./db.h: Dbt datKey(&ssKey[0], ssKey.size());
./db.h-
--
./db.h- CDataStream ssValue(SER_DISK);
./db.h: ssValue.reserve(10000);
./db.h- ssValue << value;
./db.h: Dbt datValue(&ssValue[0], ssValue.size());
./db.h-
./db.h- // Write
./db.h: int ret = pdb->put(GetTxn(), &datKey, &datValue, (fOverwrite ? 0 : DB_NOOVERWRITE));
./db.h-
./db.h- // Clear memory in case it was a private key
./db.h: memset(datKey.get_data(), 0, datKey.get_size());
./db.h: memset(datValue.get_data(), 0, datValue.get_size());
./db.h: return (ret == 0);
./db.h- }
--
./db.h- CDataStream ssKey(SER_DISK);
./db.h: ssKey.reserve(1000);
./db.h- ssKey << key;
./db.h: Dbt datKey(&ssKey[0], ssKey.size());
./db.h-
./db.h- // Erase
./db.h: int ret = pdb->del(GetTxn(), &datKey, 0);
./db.h-
./db.h- // Clear memory
./db.h: memset(datKey.get_data(), 0, datKey.get_size());
./db.h: return (ret == 0 || ret == DB_NOTFOUND);
./db.h- }
--
./db.h- CDataStream ssKey(SER_DISK);
./db.h: ssKey.reserve(1000);
./db.h- ssKey << key;
./db.h: Dbt datKey(&ssKey[0], ssKey.size());
./db.h-
./db.h- // Exists
./db.h: int ret = pdb->exists(GetTxn(), &datKey, 0);
./db.h-
./db.h- // Clear memory
./db.h: memset(datKey.get_data(), 0, datKey.get_size());
./db.h: return (ret == 0);
./db.h- }
--
./db.h- int ret = pcursor->get(&datKey, &datValue, fFlags);
./db.h: if (ret != 0)
./db.h- return ret;
./db.h- else if (datKey.get_data() == NULL || datValue.get_data() == NULL)
./db.h: return 99999;
./db.h-
--
./db.h-
./db.h: bool ReadPool(int64 nPool, CKeyPool& keypool)
./db.h- {
--
./db.h-
./db.h: bool WritePool(int64 nPool, const CKeyPool& keypool)
./db.h- {
--
./db.h-
./db.h: bool ErasePool(int64 nPool)
./db.h- {
--
./db.h- bool WriteAccountingEntry(const CAccountingEntry& acentry);
./db.h: int64 GetAccountCreditDebit(const std::string& strAccount);
./db.h- void ListAccountCreditDebit(const std::string& strAccount, std::list& acentries);
--
./base58.h:// Copyright (c) 2009-2010 Satoshi Nakamoto
./base58.h:// Copyright (c) 2011 The Bitcoin Developers
./base58.h:// Distributed under the MIT/X11 software license, see the accompanying
./base58.h-// file license.txt or http://www.opensource.org/licenses/mit-license.php.
--
./base58.h-
./base58.h:static const char* pszBase58 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
./base58.h-
./base58.h:// Encode a byte sequence as a base58-encoded string
./base58.h:inline std::string EncodeBase58(const unsigned char* pbegin, const unsigned char* pend)
./base58.h-{
./base58.h- CAutoBN_CTX pctx;
./base58.h: CBigNum bn58 = 58;
./base58.h: CBigNum bn0 = 0;
./base58.h-
--
./base58.h- // Extra zero at the end make sure bignum will interpret as a positive number
./base58.h: std::vector vchTmp(pend-pbegin+1, 0);
./base58.h- reverse_copy(pbegin, pend, vchTmp.begin());
--
./base58.h- std::string str;
./base58.h: // Expected size increase from base58 conversion is approximately 137%
./base58.h: // use 138% to be safe
./base58.h: str.reserve( (pend - pbegin) * 138 / 100 + 1);
./base58.h- CBigNum dv;
./base58.h- CBigNum rem;
./base58.h: while (bn > bn0)
./base58.h- {
./base58.h: if (!BN_div(&dv, &rem, &bn, &bn58, pctx))
./base58.h: throw bignum_error("EncodeBase58 : BN_div failed");
./base58.h- bn = dv;
./base58.h- unsigned int c = rem.getulong();
./base58.h: str += pszBase58[c];
./base58.h- }
./base58.h-
./base58.h: // Leading zeroes encoded as base58 zeros
./base58.h: for (const unsigned char* p = pbegin; p < pend && *p == 0; p++)
./base58.h: str += pszBase58[0];
./base58.h-
--
./base58.h-
./base58.h:// Encode a byte vector as a base58-encoded string
./base58.h:inline std::string EncodeBase58(const std::vector& vch)
./base58.h-{
./base58.h: return EncodeBase58(&vch[0], &vch[0] + vch.size());
./base58.h-}
./base58.h-
./base58.h:// Decode a base58-encoded string psz into byte vector vchRet
./base58.h-// returns true if decoding is succesful
./base58.h:inline bool DecodeBase58(const char* psz, std::vector& vchRet)
./base58.h-{
--
./base58.h- vchRet.clear();
./base58.h: CBigNum bn58 = 58;
./base58.h: CBigNum bn = 0;
./base58.h- CBigNum bnChar;
--
./base58.h- // Trim off sign byte if present
./base58.h: if (vchTmp.size() >= 2 && vchTmp.end()[-1] == 0 && vchTmp.end()[-2] >= 0x80)
./base58.h: vchTmp.erase(vchTmp.end()-1);
./base58.h-
./base58.h- // Restore leading zeros
./base58.h: int nLeadingZeros = 0;
./base58.h: for (const char* p = psz; *p == pszBase58[0]; p++)
./base58.h- nLeadingZeros++;
./base58.h: vchRet.assign(nLeadingZeros + vchTmp.size(), 0);
./base58.h-
--
./base58.h-
./base58.h:// Encode a byte vector to a base58-encoded string, including checksum
./base58.h:inline std::string EncodeBase58Check(const std::vector& vchIn)
./base58.h-{
./base58.h: // add 4-byte hash check to the end
./base58.h- std::vector vch(vchIn);
./base58.h: uint256 hash = Hash(vch.begin(), vch.end());
./base58.h: vch.insert(vch.end(), (unsigned char*)&hash, (unsigned char*)&hash + 4);
./base58.h: return EncodeBase58(vch);
./base58.h-}
./base58.h-
./base58.h:// Decode a base58-encoded string psz that includes a checksum, into byte vector vchRet
./base58.h-// returns true if decoding is succesful
./base58.h:inline bool DecodeBase58Check(const char* psz, std::vector& vchRet)
./base58.h-{
./base58.h: if (!DecodeBase58(psz, vchRet))
./base58.h- return false;
./base58.h: if (vchRet.size() < 4)
./base58.h- {
--
./base58.h- }
./base58.h: uint256 hash = Hash(vchRet.begin(), vchRet.end()-4);
./base58.h: if (memcmp(&hash, &vchRet.end()[-4], 4) != 0)
./base58.h- {
--
./base58.h- }
./base58.h: vchRet.resize(vchRet.size()-4);
./base58.h- return true;
--
./base58.h- {
./base58.h: std::vector vch(1, nVersion);
./base58.h- vch.insert(vch.end(), vchData.begin(), vchData.end());
./base58.h: return EncodeBase58Check(vch);
./base58.h- }
./base58.h-
./base58.h: int CompareTo(const CBase58Data& b58) const
./base58.h- {
./base58.h: if (nVersion < b58.nVersion) return -1;
./base58.h: if (nVersion > b58.nVersion) return 1;
./base58.h: if (vchData < b58.vchData) return -1;
./base58.h: if (vchData > b58.vchData) return 1;
./base58.h: return 0;
./base58.h- }
./base58.h-
./base58.h: bool operator==(const CBase58Data& b58) const { return CompareTo(b58) == 0; }
./base58.h: bool operator<=(const CBase58Data& b58) const { return CompareTo(b58) <= 0; }
./base58.h: bool operator>=(const CBase58Data& b58) const { return CompareTo(b58) >= 0; }
./base58.h: bool operator< (const CBase58Data& b58) const { return CompareTo(b58) < 0; }
./base58.h: bool operator> (const CBase58Data& b58) const { return CompareTo(b58) > 0; }
./base58.h-};
./base58.h-
./base58.h:// base58-encoded bitcoin addresses
./base58.h:// Addresses have version 0
./base58.h:// The data vector contains RIPEMD160(SHA256(pubkey)), where pubkey is the serialized public key
./base58.h:class CBitcoinAddress : public CBase58Data
./base58.h-{
./base58.h-public:
./base58.h: bool SetHash160(const uint160& hash160)
./base58.h- {
./base58.h: SetData(0, &hash160, 20);
./base58.h- return true;
--
./base58.h- {
./base58.h: int nExpectedSize = 20;
./base58.h- switch(nVersion)
./base58.h- {
./base58.h: case 0:
./base58.h- break;
--
./base58.h-
./base58.h: uint160 GetHash160() const
./base58.h- {
./base58.h: assert(vchData.size() == 20);
./base58.h: uint160 hash160;
./base58.h: memcpy(&hash160, &vchData[0], 20);
./base58.h: return hash160;
./base58.h- }
--
./net.h-
./net.h:inline unsigned int ReceiveBufferSize() { return 1000*GetArg("-maxreceivebuffer", 10*1000); }
./net.h:inline unsigned int SendBufferSize() { return 1000*GetArg("-maxsendbuffer", 10*1000); }
./net.h:static const unsigned int PUBLISH_HOPS = 5;
./net.h-
./net.h-bool ConnectSocket(const CAddress& addrConnect, SOCKET& hSocketRet, int nTimeout=nConnectTimeout);
./net.h:bool Lookup(const char *pszName, std::vector& vaddr, int nServices, int nMaxSolutions, int portDefault = 0, bool fAllowPort = false);
./net.h:bool Lookup(const char *pszName, CAddress& addr, int nServices, int portDefault = 0, bool fAllowPort = false);
./net.h:bool AddAddress(CAddress addr, int64 nTimePenalty=0, CAddrDB *pAddrDB=NULL);
./net.h-void AddressCurrentlyConnected(const CAddress& addr);
./net.h-CNode* FindNode(unsigned int ip);
./net.h:CNode* ConnectNode(CAddress addrConnect, int64 nTimeout=0);
./net.h:void AbandonRequests(void (*fn)(void*, CDataStream&), void* param1);
./net.h-bool AnySubscribed(unsigned int nChannel);
--
./net.h-extern bool fAllowDNS;
./net.h:extern uint64 nLocalServices;
./net.h-extern CAddress addrLocalHost;
./net.h:extern uint64 nLocalHostNonce;
./net.h:extern boost::array vnThreadsRunning;
./net.h-
--
./net.h- {
./net.h: nServices = 0;
./net.h- hSocket = hSocketIn;
./net.h- vSend.SetType(SER_NETWORK);
./net.h: vSend.SetVersion(0);
./net.h- vRecv.SetType(SER_NETWORK);
./net.h: vRecv.SetVersion(0);
./net.h: // Version 0.2 obsoletes 20 Feb 2012
./net.h: if (GetTime() > 1329696000)
./net.h- {
./net.h: vSend.SetVersion(209);
./net.h: vRecv.SetVersion(209);
./net.h- }
./net.h: nLastSend = 0;
./net.h: nLastRecv = 0;
./net.h- nLastSendEmpty = GetTime();
./net.h- nTimeConnected = GetTime();
./net.h: nHeaderStart = -1;
./net.h: nMessageStart = -1;
./net.h- addr = addrIn;
./net.h: nVersion = 0;
./net.h- strSubVer = "";
--
./net.h- // the key is the earliest time the request can be sent
./net.h: int64& nRequestTime = mapAlreadyAskedFor[inv];
./net.h: printf("askfor %s %"PRI64d"\n", inv.ToString().c_str(), nRequestTime);
./net.h-
./net.h- // Make sure not to reuse time indexes to keep things in the same order
./net.h: int64 nNow = (GetTime() - 1) * 1000000;
./net.h: static int64 nLastTime;
./net.h- ++nLastTime;
--
./net.h-
./net.h: // Each retry is 2 minutes after the last
./net.h: nRequestTime = std::max(nRequestTime + 2 * 60 * 1000000, nNow);
./net.h- mapAskFor.insert(std::make_pair(nRequestTime, inv));
--
./net.h- // Set the checksum
./net.h: if (vSend.GetVersion() >= 209)
./net.h- {
./net.h: uint256 hash = Hash(vSend.begin() + nMessageStart, vSend.end());
./net.h: unsigned int nChecksum = 0;
./net.h- memcpy(&nChecksum, &hash, sizeof(nChecksum));
--
./net.h- /// when NTP implemented, change to just nTime = GetAdjustedTime()
./net.h: int64 nTime = (fInbound ? GetAdjustedTime() : GetTime());
./net.h: CAddress addrYou = (fUseProxy ? CAddress("0.0.0.0") : addr);
./net.h: CAddress addrMe = (fUseProxy || !addrLocalHost.IsRoutable() ? CAddress("0.0.0.0") : addrLocalHost);
./net.h- RAND_bytes( (unsigned char*)&nLocalHostNonce, sizeof(nLocalHostNonce));
--
--
./net.h- BeginMessage(pszCommand);
./net.h: vSend << a1 << a2 << a3;
./net.h- EndMessage();
--
./net.h- BeginMessage(pszCommand);
./net.h: vSend << a1 << a2 << a3 << a4;
./net.h- EndMessage();
--
./net.h- BeginMessage(pszCommand);
./net.h: vSend << a1 << a2 << a3 << a4 << a5;
./net.h- EndMessage();
--
./net.h- BeginMessage(pszCommand);
./net.h: vSend << a1 << a2 << a3 << a4 << a5 << a6;
./net.h- EndMessage();
--
./net.h- BeginMessage(pszCommand);
./net.h: vSend << a1 << a2 << a3 << a4 << a5 << a6 << a7;
./net.h- EndMessage();
--
./net.h- BeginMessage(pszCommand);
./net.h: vSend << a1 << a2 << a3 << a4 << a5 << a6 << a7 << a8;
./net.h- EndMessage();
--
./net.h- BeginMessage(pszCommand);
./net.h: vSend << a1 << a2 << a3 << a4 << a5 << a6 << a7 << a8 << a9;iii
./net.h- EndMessage();
--
./net.h- static bool IsBanned(unsigned int ip);
./net.h: bool Misbehaving(int howmuch); // 1 == a little, 100 == a lot
./net.h-};
--
./net.h- CDataStream ss(SER_NETWORK);
./net.h: ss.reserve(10000);
./net.h- ss << a;
--
./net.h- mapRelay[inv] = ss;
./net.h: vRelayExpiration.push_back(std::make_pair(GetTime() + 15 * 60, inv));
./net.h- }
--
./json/json_spirit_writer_template.h- {
./json/json_spirit_writer_template.h: assert( c <= 0xF );
./json/json_spirit_writer_template.h-
--
./json/json_spirit_writer_template.h-
./json/json_spirit_writer_template.h: if( ch < 10 ) return '0' + ch;
./json/json_spirit_writer_template.h-
./json/json_spirit_writer_template.h: return 'A' - 10 + ch;
./json/json_spirit_writer_template.h- }
--
./json/json_spirit_writer_template.h-
./json/json_spirit_writer_template.h: String_type result( 6, '\\' );
./json/json_spirit_writer_template.h-
./json/json_spirit_writer_template.h: result[1] = 'u';
./json/json_spirit_writer_template.h-
./json/json_spirit_writer_template.h: result[ 5 ] = to_hex_char( c & 0x000F ); c >>= 4;
./json/json_spirit_writer_template.h: result[ 4 ] = to_hex_char( c & 0x000F ); c >>= 4;
./json/json_spirit_writer_template.h: result[ 3 ] = to_hex_char( c & 0x000F ); c >>= 4;
./json/json_spirit_writer_template.h: result[ 2 ] = to_hex_char( c & 0x000F );
./json/json_spirit_writer_template.h-
--
./json/json_spirit_writer_template.h-
./json/json_spirit_writer_template.h: const wint_t unsigned_c( ( c >= 0 ) ? c : 256 + c );
./json/json_spirit_writer_template.h-
--
./json/json_spirit_writer_template.h-
./json/json_spirit_writer_template.h: /// Bitcoin: Added std::fixed and changed precision from 16 to 8
./json/json_spirit_writer_template.h: case real_type: os_ << std::showpoint << std::fixed << std::setprecision(8)
./json/json_spirit_writer_template.h- << value.get_real(); break;
--
./json/json_spirit_reader.h:#if defined(_MSC_VER) && (_MSC_VER >= 1020)
./json/json_spirit_reader.h-# pragma once
--
./json/json_spirit_value.h:#if defined(_MSC_VER) && (_MSC_VER >= 1020)
./json/json_spirit_value.h-# pragma once
--
./json/json_spirit.h:#if defined(_MSC_VER) && (_MSC_VER >= 1020)
./json/json_spirit.h-# pragma once
--
./json/json_spirit_reader_template.h-
./json/json_spirit_reader_template.h:#if BOOST_VERSION >= 103800
./json/json_spirit_reader_template.h- #include
--
./json/json_spirit_reader_template.h- {
./json/json_spirit_reader_template.h: if( ( c >= '0' ) && ( c <= '9' ) ) return c - '0';
./json/json_spirit_reader_template.h: if( ( c >= 'a' ) && ( c <= 'f' ) ) return c - 'a' + 10;
./json/json_spirit_reader_template.h: if( ( c >= 'A' ) && ( c <= 'F' ) ) return c - 'A' + 10;
./json/json_spirit_reader_template.h: return 0;
./json/json_spirit_reader_template.h- }
--
./json/json_spirit_reader_template.h- {
./json/json_spirit_reader_template.h: const Char_type c1( *( ++begin ) );
./json/json_spirit_reader_template.h: const Char_type c2( *( ++begin ) );
./json/json_spirit_reader_template.h-
./json/json_spirit_reader_template.h: return ( hex_to_num( c1 ) << 4 ) + hex_to_num( c2 );
./json/json_spirit_reader_template.h- }
--
./json/json_spirit_reader_template.h- {
./json/json_spirit_reader_template.h: const Char_type c1( *( ++begin ) );
./json/json_spirit_reader_template.h: const Char_type c2( *( ++begin ) );
./json/json_spirit_reader_template.h: const Char_type c3( *( ++begin ) );
./json/json_spirit_reader_template.h: const Char_type c4( *( ++begin ) );
./json/json_spirit_reader_template.h-
./json/json_spirit_reader_template.h: return ( hex_to_num( c1 ) << 12 ) +
./json/json_spirit_reader_template.h: ( hex_to_num( c2 ) << 8 ) +
./json/json_spirit_reader_template.h: ( hex_to_num( c3 ) << 4 ) +
./json/json_spirit_reader_template.h: hex_to_num( c4 );
./json/json_spirit_reader_template.h- }
--
./json/json_spirit_reader_template.h-
./json/json_spirit_reader_template.h: const Char_type c2( *begin );
./json/json_spirit_reader_template.h-
./json/json_spirit_reader_template.h: switch( c2 )
./json/json_spirit_reader_template.h- {
--
./json/json_spirit_reader_template.h- {
./json/json_spirit_reader_template.h: if( end - begin >= 3 ) // expecting "xHH..."
./json/json_spirit_reader_template.h- {
--
./json/json_spirit_reader_template.h- {
./json/json_spirit_reader_template.h: if( end - begin >= 5 ) // expecting "uHHHH..."
./json/json_spirit_reader_template.h- {
--
./json/json_spirit_reader_template.h-
./json/json_spirit_reader_template.h: if( end - begin < 2 ) return String_type( begin, end );
./json/json_spirit_reader_template.h-
--
./json/json_spirit_reader_template.h- {
./json/json_spirit_reader_template.h: assert( end - begin >= 2 );
./json/json_spirit_reader_template.h-
--
./json/json_spirit_error_position.h:#if defined(_MSC_VER) && (_MSC_VER >= 1020)
./json/json_spirit_error_position.h-# pragma once
--
./noui.h-typedef void wxWindow;
./noui.h:#define wxYES 0x00000002
./noui.h:#define wxOK 0x00000004
./noui.h:#define wxNO 0x00000008
./noui.h-#define wxYES_NO (wxYES|wxNO)
./noui.h:#define wxCANCEL 0x00000010
./noui.h:#define wxAPPLY 0x00000020
./noui.h:#define wxCLOSE 0x00000040
./noui.h:#define wxOK_DEFAULT 0x00000000
./noui.h:#define wxYES_DEFAULT 0x00000000
./noui.h:#define wxNO_DEFAULT 0x00000080
./noui.h:#define wxCANCEL_DEFAULT 0x80000000
./noui.h:#define wxICON_EXCLAMATION 0x00000100
./noui.h:#define wxICON_HAND 0x00000200
./noui.h-#define wxICON_WARNING wxICON_EXCLAMATION
./noui.h-#define wxICON_ERROR wxICON_HAND
./noui.h:#define wxICON_QUESTION 0x00000400
./noui.h:#define wxICON_INFORMATION 0x00000800
./noui.h-#define wxICON_STOP wxICON_HAND
./noui.h-#define wxICON_ASTERISK wxICON_INFORMATION
./noui.h:#define wxICON_MASK (0x00000100|0x00000200|0x00000400|0x00000800)
./noui.h:#define wxFORWARD 0x00001000
./noui.h:#define wxBACKWARD 0x00002000
./noui.h:#define wxRESET 0x00004000
./noui.h:#define wxHELP 0x00008000
./noui.h:#define wxMORE 0x00010000
./noui.h:#define wxSETUP 0x00020000
./noui.h-
./noui.h:inline int MyMessageBox(const std::string& message, const std::string& caption="Message", int style=wxOK, wxWindow* parent=NULL, int x=-1, int y=-1)
./noui.h-{
--
./noui.h- fprintf(stderr, "%s: %s\n", caption.c_str(), message.c_str());
./noui.h: return 4;
./noui.h-}
--
./noui.h-
./noui.h:inline int ThreadSafeMessageBox(const std::string& message, const std::string& caption, int style=wxOK, wxWindow* parent=NULL, int x=-1, int y=-1)
./noui.h-{
--
./main.cpp-
./main.cpp:static map mapTransactions;
./main.cpp-CCriticalSection cs_mapTransactions;
./main.cpp:unsigned int nTransactionsUpdated = 0;
./main.cpp-map mapNextTx;
./main.cpp-
./main.cpp:map mapBlockIndex;
./main.cpp:uint256 hashGenesisBlock("0x000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f");
./main.cpp:static CBigNum bnProofOfWorkLimit(~uint256(0) >> 32);
./main.cpp-CBlockIndex* pindexGenesisBlock = NULL;
./main.cpp:int nBestHeight = -1;
./main.cpp:CBigNum bnBestChainWork = 0;
./main.cpp:CBigNum bnBestInvalidWork = 0;
./main.cpp:uint256 hashBestChain = 0;
./main.cpp-CBlockIndex* pindexBest = NULL;
./main.cpp:int64 nTimeBestReceived = 0;
./main.cpp-
./main.cpp:CMedianFilter cPeerBlockCounts(5, 0); // Amount of blocks that other nodes claim to have
./main.cpp-
--
./main.cpp- if (vin.empty())
./main.cpp: return DoS(10, error("CTransaction::CheckTransaction() : vin empty"));
./main.cpp- if (vout.empty())
./main.cpp: return DoS(10, error("CTransaction::CheckTransaction() : vout empty"));
./main.cpp- // Size limits
./main.cpp- if (::GetSerializeSize(*this, SER_NETWORK) > MAX_BLOCK_SIZE)
./main.cpp: return DoS(100, error("CTransaction::CheckTransaction() : size limits failed"));
./main.cpp-
./main.cpp- // Check for negative or overflow output values
./main.cpp: int64 nValueOut = 0;
./main.cpp- BOOST_FOREACH(const CTxOut& txout, vout)
./main.cpp- {
./main.cpp: if (txout.nValue < 0)
./main.cpp: return DoS(100, error("CTransaction::CheckTransaction() : txout.nValue negative"));
./main.cpp- if (txout.nValue > MAX_MONEY)
./main.cpp: return DoS(100, error("CTransaction::CheckTransaction() : txout.nValue too high"));
./main.cpp- nValueOut += txout.nValue;
./main.cpp- if (!MoneyRange(nValueOut))
./main.cpp: return DoS(100, error("CTransaction::CheckTransaction() : txout total out of range"));
./main.cpp- }
--
./main.cpp- {
./main.cpp: if (vin[0].scriptSig.size() < 2 || vin[0].scriptSig.size() > 100)
./main.cpp: return DoS(100, error("CTransaction::CheckTransaction() : coinbase script size"));
./main.cpp- }
--
./main.cpp- if (txin.prevout.IsNull())
./main.cpp: return DoS(10, error("CTransaction::CheckTransaction() : prevout is null"));
./main.cpp- }
--
./main.cpp- if (IsCoinBase())
./main.cpp: return DoS(100, error("AcceptToMemoryPool() : coinbase as individual tx"));
./main.cpp-
./main.cpp: // To help v0.1.5 clients who would see it as a negative number
./main.cpp: if ( (int64)nLockTime > INT_MAX)
./main.cpp: return error("AcceptToMemoryPool() : not accepting nLockTime beyond 2038 yet");
./main.cpp-
--
./main.cpp- // Checking ECDSA signatures is a CPU bottleneck, so to avoid denial-of-service
./main.cpp: // attacks disallow transactions with more than one SigOp per 34 bytes.
./main.cpp: // 34 bytes because a TxOut is:
./main.cpp: // 20-byte address + 8 byte bitcoin amount + 5 bytes of ops + 1 byte script length
./main.cpp: if (GetSigOpCount() > nSize / 34 || nSize < 100)
./main.cpp- return error("AcceptToMemoryPool() : transaction with out-of-bounds SigOpCount");
--
./main.cpp- // Check against previous transactions
./main.cpp: map mapUnused;
./main.cpp: int64 nFees = 0;
./main.cpp- bool fInvalid = false;
./main.cpp: if (!ConnectInputs(txdb, mapUnused, CDiskTxPos(1,1,1), pindexBest, nFees, false, false, 0, fInvalid))
./main.cpp- {
./main.cpp- if (fInvalid)
./main.cpp: return error("AcceptToMemoryPool() : FetchInputs found invalid tx %s", hash.ToString().substr(0,10).c_str());
./main.cpp: return error("AcceptToMemoryPool() : ConnectInputs failed %s", hash.ToString().substr(0,10).c_str());
./main.cpp- }
--
./main.cpp- // Don't accept it if it can't get into a block
./main.cpp: if (nFees < GetMinFee(1000, true, true))
./main.cpp- return error("AcceptToMemoryPool() : not enough fees");
--
./main.cpp- {
./main.cpp: // Use an exponentially decaying ~10-minute window:
./main.cpp: dFreeCount *= pow(1.0 - 1.0/600.0, (double)(nNow - nLastTime));
./main.cpp- nLastTime = nNow;
./main.cpp- // -limitfreerelay unit is thousand-bytes-per-minute
./main.cpp: // At default rate it would take over a month to fill 1GB
./main.cpp: if (dFreeCount > GetArg("-limitfreerelay", 15)*10*1000 && !IsFromMe(*this))
./main.cpp- return error("AcceptToMemoryPool() : free transaction rejected by rate limiter");
--
./main.cpp-
./main.cpp: printf("AcceptToMemoryPool(): accepted %s\n", hash.ToString().substr(0,10).c_str());
./main.cpp- return true;
--
./main.cpp- if (!IsCoinBase())
./main.cpp: return 0;
./main.cpp: return max(0, (COINBASE_MATURITY+20) - GetDepthInMainChain());
./main.cpp-}
--
./main.cpp-
./main.cpp:int64 static GetBlockValue(int nHeight, int64 nFees)
./main.cpp-{
./main.cpp: int64 nSubsidy = 50 * COIN;
./main.cpp-
./main.cpp: // Subsidy is cut in half every 4 years
./main.cpp: nSubsidy >>= (nHeight / 210000);
./main.cpp-
--
./main.cpp-
./main.cpp:static const int64 nTargetTimespan = 14 * 24 * 60 * 60; // two weeks
./main.cpp:static const int64 nTargetSpacing = 10 * 60;
./main.cpp:static const int64 nInterval = nTargetTimespan / nTargetSpacing;
./main.cpp-
--
./main.cpp- bnResult.SetCompact(nBase);
./main.cpp: while (nTime > 0 && bnResult < bnProofOfWorkLimit)
./main.cpp- {
./main.cpp: // Maximum 400% adjustment...
./main.cpp: bnResult *= 4;
./main.cpp: // ... in best-case exactly 4-times-normal target time
./main.cpp: nTime -= nTargetTimespan*4;
./main.cpp- }
--
./main.cpp- // Limit adjustment step
./main.cpp: int64 nActualTimespan = pindexLast->GetBlockTime() - pindexFirst->GetBlockTime();
./main.cpp: printf(" nActualTimespan = %"PRI64d" before bounds\n", nActualTimespan);
./main.cpp: if (nActualTimespan < nTargetTimespan/4)
./main.cpp: nActualTimespan = nTargetTimespan/4;
./main.cpp: if (nActualTimespan > nTargetTimespan*4)
./main.cpp: nActualTimespan = nTargetTimespan*4;
./main.cpp-
--
./main.cpp- }
./main.cpp: return (GetTime() - nLastUpdate < 10 &&
./main.cpp: pindexBest->GetBlockTime() < GetTime() - 24 * 60 * 60);
./main.cpp-}
--
./main.cpp- }
./main.cpp: printf("InvalidChainFound: invalid block=%s height=%d work=%s\n", pindexNew->GetBlockHash().ToString().substr(0,20).c_str(), pindexNew->nHeight, pindexNew->bnChainWork.ToString().c_str());
./main.cpp: printf("InvalidChainFound: current best=%s height=%d work=%s\n", hashBestChain.ToString().substr(0,20).c_str(), nBestHeight, bnBestChainWork.ToString().c_str());
./main.cpp: if (pindexBest && bnBestInvalidWork > bnBestChainWork + pindexBest->GetBlockWork() * 6)
./main.cpp- printf("InvalidChainFound: WARNING: Displayed transactions may not be correct! You may need to upgrade, or other nodes may need to upgrade.\n");
--
./main.cpp- if (!fFound && (fBlock || fMiner))
./main.cpp: return fMiner ? false : error("ConnectInputs() : %s prev tx %s index entry not found", GetHash().ToString().substr(0,10).c_str(), prevout.hash.ToString().substr(0,10).c_str());
./main.cpp-
--
./main.cpp- CTransaction txPrev;
./main.cpp: if (!fFound || txindex.pos == CDiskTxPos(1,1,1))
./main.cpp- {
--
./main.cpp- if (!mapTransactions.count(prevout.hash))
./main.cpp: return error("ConnectInputs() : %s mapTransactions prev not found %s", GetHash().ToString().substr(0,10).c_str(), prevout.hash.ToString().substr(0,10).c_str());
./main.cpp- txPrev = mapTransactions[prevout.hash];
--
./main.cpp- if (!txPrev.ReadFromDisk(txindex.pos))
./main.cpp: return error("ConnectInputs() : %s ReadFromDisk prev tx %s failed", GetHash().ToString().substr(0,10).c_str(), prevout.hash.ToString().substr(0,10).c_str());
./main.cpp- }
--
./main.cpp- fInvalid = true;
./main.cpp: return DoS(100, error("ConnectInputs() : %s prevout.n out of range %d %d %d prev tx %s\n%s", GetHash().ToString().substr(0,10).c_str(), prevout.n, txPrev.vout.size(), txindex.vSpent.size(), prevout.hash.ToString().substr(0,10).c_str(), txPrev.ToString().c_str()));
./main.cpp- }
--
./main.cpp- if (!VerifySignature(txPrev, *this, i))
./main.cpp: return DoS(100,error("ConnectInputs() : %s VerifySignature failed", GetHash().ToString().substr(0,10).c_str()));
./main.cpp-
--
./main.cpp- if (!txindex.vSpent[prevout.n].IsNull())
./main.cpp: return fMiner ? false : error("ConnectInputs() : %s prev tx already used at %s", GetHash().ToString().substr(0,10).c_str(), txindex.vSpent[prevout.n].ToString().c_str());
./main.cpp-
--
./main.cpp- if (!MoneyRange(txPrev.vout[prevout.n].nValue) || !MoneyRange(nValueIn))
./main.cpp: return DoS(100, error("ConnectInputs() : txin values out of range"));
./main.cpp-
--
./main.cpp- if (nValueIn < GetValueOut())
./main.cpp: return DoS(100, error("ConnectInputs() : %s value in < value out", GetHash().ToString().substr(0,10).c_str()));
./main.cpp-
./main.cpp- // Tally transaction fees
./main.cpp: int64 nTxFee = nValueIn - GetValueOut();
./main.cpp: if (nTxFee < 0)
./main.cpp: return DoS(100, error("ConnectInputs() : %s nTxFee < 0", GetHash().ToString().substr(0,10).c_str()));
./main.cpp- if (nTxFee < nMinFee)
--
./main.cpp- if (!MoneyRange(nFees))
./main.cpp: return DoS(100, error("ConnectInputs() : nFees out of range"));
./main.cpp- }
--
./main.cpp- // Add transaction to test pool
./main.cpp: mapTestPool[GetHash()] = CTxIndex(CDiskTxPos(1,1,1), vout.size());
./main.cpp- }
--
./main.cpp- // being sent to another address.
./main.cpp: // See BIP30 and http://r6.ca/blog/20120206T005236Z.html for more information.
./main.cpp- // This logic is not necessary for memory pool transactions, as AcceptToMemoryPool
./main.cpp- // already refuses previously-known transaction id's entirely.
./main.cpp: // This rule applies to all blocks whose timestamp is after March 15, 2012, 0:00 UTC.
./main.cpp: if (pindex->nTime > 1331769600)
./main.cpp- BOOST_FOREACH(CTransaction& tx, vtx)
--
./main.cpp- nTransactionsUpdated++;
./main.cpp: printf("SetBestChain: new best=%s height=%d work=%s\n", hashBestChain.ToString().substr(0,20).c_str(), nBestHeight, bnBestChainWork.ToString().c_str());
./main.cpp-
--
./main.cpp- // Check for duplicate
./main.cpp: uint256 hash = GetHash();
./main.cpp- if (mapBlockIndex.count(hash))
./main.cpp: return error("AddToBlockIndex() : %s already exists", hash.ToString().substr(0,20).c_str());
./main.cpp-
--
./main.cpp- if (vtx.empty() || vtx.size() > MAX_BLOCK_SIZE || ::GetSerializeSize(*this, SER_NETWORK) > MAX_BLOCK_SIZE)
./main.cpp: return DoS(100, error("CheckBlock() : size limits failed"));
./main.cpp-
--
./main.cpp- if (!CheckProofOfWork(GetHash(), nBits))
./main.cpp: return DoS(50, error("CheckBlock() : proof of work failed"));
./main.cpp-
./main.cpp- // Check timestamp
./main.cpp: if (GetBlockTime() > GetAdjustedTime() + 2 * 60 * 60)
./main.cpp- return error("CheckBlock() : block timestamp too far in the future");
--
./main.cpp- // First transaction must be coinbase, the rest must not be
./main.cpp: if (vtx.empty() || !vtx[0].IsCoinBase())
./main.cpp: return DoS(100, error("CheckBlock() : first tx is not coinbase"));
./main.cpp: for (int i = 1; i < vtx.size(); i++)
./main.cpp- if (vtx[i].IsCoinBase())
./main.cpp: return DoS(100, error("CheckBlock() : more than one coinbase"));
./main.cpp-
--
./main.cpp- if (GetSigOpCount() > MAX_BLOCK_SIGOPS)
./main.cpp: return DoS(100, error("CheckBlock() : out-of-bounds SigOpCount"));
./main.cpp-
--
./main.cpp- if (hashMerkleRoot != BuildMerkleTree())
./main.cpp: return DoS(100, error("CheckBlock() : hashMerkleRoot mismatch"));
./main.cpp-
--
./main.cpp- // Get prev block index
./main.cpp: map::iterator mi = mapBlockIndex.find(hashPrevBlock);
./main.cpp- if (mi == mapBlockIndex.end())
./main.cpp: return DoS(10, error("AcceptBlock() : prev block not found"));
./main.cpp- CBlockIndex* pindexPrev = (*mi).second;
./main.cpp: int nHeight = pindexPrev->nHeight+1;
./main.cpp-
--
./main.cpp- if (nBits != GetNextWorkRequired(pindexPrev, this))
./main.cpp: return DoS(100, error("AcceptBlock() : incorrect proof of work"));
./main.cpp-
--
./main.cpp- if (!tx.IsFinal(nHeight, GetBlockTime()))
./main.cpp: return DoS(10, error("AcceptBlock() : contains a non-final transaction"));
./main.cpp-
--
./main.cpp- if (!Checkpoints::CheckBlock(nHeight, hash))
./main.cpp: return DoS(100, error("AcceptBlock() : rejected by checkpoint lockin at %d", nHeight));
./main.cpp-
--
./main.cpp- BOOST_FOREACH(CNode* pnode, vNodes)
./main.cpp: if (nBestHeight > (pnode->nStartingHeight != -1 ? pnode->nStartingHeight - 2000 : 140700))
./main.cpp- pnode->PushInventory(CInv(MSG_BLOCK, hash));
--
./main.cpp- // Check for duplicate
./main.cpp: uint256 hash = pblock->GetHash();
./main.cpp- if (mapBlockIndex.count(hash))
./main.cpp: return error("ProcessBlock() : already have block %d %s", mapBlockIndex[hash]->nHeight, hash.ToString().substr(0,20).c_str());
./main.cpp-
--
./main.cpp- // Extra checks to prevent "fill up memory by spamming with bogus blocks"
./main.cpp: int64 deltaTime = pblock->GetBlockTime() - pcheckpoint->nTime;
./main.cpp: if (deltaTime < 0)
./main.cpp- {
./main.cpp- if (pfrom)
./main.cpp: pfrom->Misbehaving(100);
./main.cpp- return error("ProcessBlock() : block with timestamp before last checkpoint");
--
./main.cpp- if (pfrom)
./main.cpp: pfrom->Misbehaving(100);
./main.cpp- return error("ProcessBlock() : block with too little proof-of-work");
--
./main.cpp- {
./main.cpp: printf("ProcessBlock: BASTARD BLOCK, prev=%s, DISCARDED\n", pblock->hashPrevBlock.ToString().substr(0,20).c_str());
./main.cpp-
--
./main.cpp-
./main.cpp:bool CheckDiskSpace(uint64 nAdditionalBytes)
./main.cpp-{
./main.cpp: uint64 nFreeBytesAvailable = filesystem::space(GetDataDir()).available;
./main.cpp-
./main.cpp: // Check for 15MB because database could create another 10MB log file at any time
./main.cpp: if (nFreeBytesAvailable < (uint64)15000000 + nAdditionalBytes)
./main.cpp- {
--
./main.cpp-{
./main.cpp: if (nFile == -1)
./main.cpp- return NULL;
./main.cpp: FILE* file = fopen(strprintf("%s/blk%04d.dat", GetDataDir().c_str(), nFile).c_str(), pszMode);
./main.cpp- if (!file)
./main.cpp- return NULL;
./main.cpp: if (nBlockPos != 0 && !strchr(pszMode, 'a') && !strchr(pszMode, 'w'))
./main.cpp- {
./main.cpp: if (fseek(file, nBlockPos, SEEK_SET) != 0)
./main.cpp- {
--
./main.cpp-{
./main.cpp: nFileRet = 0;
./main.cpp- loop
./main.cpp- {
./main.cpp: FILE* file = OpenBlockFile(nCurrentBlockFile, 0, "ab");
./main.cpp- if (!file)
./main.cpp- return NULL;
./main.cpp: if (fseek(file, 0, SEEK_END) != 0)
./main.cpp- return NULL;
./main.cpp: // FAT32 filesize max 4GB, fseek and ftell max 2GB, so we must stay under 2GB
./main.cpp: if (ftell(file) < 0x7F000000 - MAX_SIZE)
./main.cpp- {
--
./main.cpp- // Genesis Block:
./main.cpp: // CBlock(hash=000000000019d6, ver=1, hashPrevBlock=00000000000000, hashMerkleRoot=4a5e1e, nTime=1231006505, nBits=1d00ffff, nNonce=2083236893, vtx=1)
./main.cpp: // CTransaction(hash=4a5e1e, ver=1, vin.size=1, vout.size=1, nLockTime=0)
./main.cpp: // CTxIn(COutPoint(000000, -1), coinbase 04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73)
./main.cpp: // CTxOut(nValue=50.00000000, scriptPubKey=0x5F1DF16B2B704C8A578D0B)
./main.cpp: // vMerkleTree: 4a5e1e
./main.cpp-
./main.cpp- // Genesis block
./main.cpp: const char* pszTimestamp = "The Times 03/Jan/2009 Chancellor on brink of second bailout for banks";
./main.cpp- CTransaction txNew;
./main.cpp: txNew.vin.resize(1);
./main.cpp: txNew.vout.resize(1);
./main.cpp: txNew.vin[0].scriptSig = CScript() << 486604799 << CBigNum(4) << vector( (const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp));
./main.cpp: txNew.vout[0].nValue = 50 * COIN;
./main.cpp: txNew.vout[0].scriptPubKey = CScript() << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f") << OP_CHECKSIG;
./main.cpp- CBlock block;
./main.cpp- block.vtx.push_back(txNew);
./main.cpp: block.hashPrevBlock = 0;
./main.cpp- block.hashMerkleRoot = block.BuildMerkleTree();
./main.cpp: block.nVersion = 1;
./main.cpp: block.nTime = 1231006505;
./main.cpp: block.nBits = 0x1d00ffff;
./main.cpp: block.nNonce = 2083236893;
./main.cpp-
--
./main.cpp- printf("%s\n", block.hashMerkleRoot.ToString().c_str());
./main.cpp: assert(block.hashMerkleRoot == uint256("0x4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b"));
./main.cpp- block.print();
--
./main.cpp- // test
./main.cpp: //while (rand() % 3 == 0)
./main.cpp- // mapNext[pindex->pprev].push_back(pindex);
--
./main.cpp- pindex->nBlockPos,
./main.cpp: block.GetHash().ToString().substr(0,20).c_str(),
./main.cpp- DateTimeStrFormat("%x %H:%M:%S", block.GetBlockTime()).c_str(),
--
./main.cpp- {
./main.cpp: nPriority = 1000;
./main.cpp- strStatusBar = strMiscWarning;
--
./main.cpp- // Longer invalid proof-of-work chain
./main.cpp: if (pindexBest && bnBestInvalidWork > bnBestChainWork + pindexBest->GetBlockWork() * 6)
./main.cpp- {
./main.cpp: nPriority = 2000;
./main.cpp- strStatusBar = strRPC = "WARNING: Displayed transactions may not be correct! You may need to upgrade, or other nodes may need to upgrade.";
--
./main.cpp-// The message start string is designed to be unlikely to occur in normal data.
./main.cpp:// The characters are rarely used upper ascii, not valid as UTF-8, and produce
./main.cpp:// a large 4-byte int at any alignment.
./main.cpp:unsigned char pchMessageStart[4] = { 0xf9, 0xbe, 0xb4, 0xd9 };
./main.cpp-
--
./main.cpp-
./main.cpp: int64 nTime;
./main.cpp- CAddress addrMe;
./main.cpp- CAddress addrFrom;
./main.cpp: uint64 nNonce = 1;
./main.cpp- vRecv >> pfrom->nVersion >> pfrom->nServices >> nTime >> addrMe;
./main.cpp: if (pfrom->nVersion == 10300)
./main.cpp: pfrom->nVersion = 300;
./main.cpp: if (pfrom->nVersion >= 106 && !vRecv.empty())
./main.cpp- vRecv >> addrFrom >> nNonce;
./main.cpp: if (pfrom->nVersion >= 106 && !vRecv.empty())
./main.cpp- vRecv >> pfrom->strSubVer;
./main.cpp: if (pfrom->nVersion >= 209 && !vRecv.empty())
./main.cpp- vRecv >> pfrom->nStartingHeight;
./main.cpp-
./main.cpp: if (pfrom->nVersion == 0)
./main.cpp- return false;
--
./main.cpp- // Change version
./main.cpp: if (pfrom->nVersion >= 209)
./main.cpp- pfrom->PushMessage("verack");
./main.cpp- pfrom->vSend.SetVersion(min(pfrom->nVersion, VERSION));
./main.cpp: if (pfrom->nVersion < 209)
./main.cpp- pfrom->vRecv.SetVersion(min(pfrom->nVersion, VERSION));
--
./main.cpp- // Get recent addresses
./main.cpp: if (pfrom->nVersion >= 31402 || mapAddresses.size() < 1000)
./main.cpp- {
--
./main.cpp- if (!pfrom->fClient &&
./main.cpp: (pfrom->nVersion < 32000 || pfrom->nVersion >= 32400) &&
./main.cpp: (nAskedForBlocks < 1 || vNodes.size() <= 1))
./main.cpp- {
./main.cpp- nAskedForBlocks++;
./main.cpp: pfrom->PushGetBlocks(pindexBest, uint256(0));
./main.cpp- }
--
./main.cpp- // Don't want addr from older versions unless seeding
./main.cpp: if (pfrom->nVersion < 209)
./main.cpp- return true;
./main.cpp: if (pfrom->nVersion < 31402 && mapAddresses.size() > 1000)
./main.cpp- return true;
./main.cpp: if (vAddr.size() > 1000)
./main.cpp- {
./main.cpp: pfrom->Misbehaving(20);
./main.cpp- return error("message addr size() = %d", vAddr.size());
--
./main.cpp- addrDB.TxnBegin();
./main.cpp: int64 nNow = GetAdjustedTime();
./main.cpp: int64 nSince = nNow - 10 * 60;
./main.cpp- BOOST_FOREACH(CAddress& addr, vAddr)
--
./main.cpp- return true;
./main.cpp: // ignore IPv6 for now, since it isn't implemented anyway
./main.cpp: if (!addr.IsIPv4())
./main.cpp- continue;
./main.cpp: if (addr.nTime <= 100000000 || addr.nTime > nNow + 10 * 60)
./main.cpp: addr.nTime = nNow - 5 * 24 * 60 * 60;
./main.cpp: AddAddress(addr, 2 * 60 * 60, &addrDB);
./main.cpp- pfrom->AddAddressKnown(addr);
./main.cpp: if (addr.nTime > nSince && !pfrom->fGetAddr && vAddr.size() <= 10 && addr.IsRoutable())
./main.cpp- {
--
./main.cpp- {
./main.cpp: // Use deterministic randomness to send to the same nodes for 24 hours
./main.cpp- // at a time so the setAddrKnowns of the chosen nodes prevent repeats
./main.cpp: static uint256 hashSalt;
./main.cpp: if (hashSalt == 0)
./main.cpp- RAND_bytes( (unsigned char*)&hashSalt, sizeof(hashSalt));
./main.cpp: uint256 hashRand = hashSalt ^ ( ( (int64)addr.ip)<<32) ^ ( (GetTime()+addr.ip)/(24*60*60));
./main.cpp- hashRand = Hash(BEGIN(hashRand), END(hashRand));
./main.cpp: multimap mapMix;
./main.cpp- BOOST_FOREACH(CNode* pnode, vNodes)
./main.cpp- {
./main.cpp: if (pnode->nVersion < 31402)
./main.cpp- continue;
--
./main.cpp- }
./main.cpp: int nRelayNodes = 2;
./main.cpp: for (multimap::iterator mi = mapMix.begin(); mi != mapMix.end() && nRelayNodes-- > 0; ++mi)
./main.cpp- ( (*mi).second)->PushAddress(addr);
--
./main.cpp- addrDB.TxnCommit(); // Save addresses (it's ok if this fails)
./main.cpp: if (vAddr.size() < 1000)
./main.cpp- pfrom->fGetAddr = false;
--
./main.cpp- vRecv >> vInv;
./main.cpp: if (vInv.size() > 50000)
./main.cpp- {
./main.cpp: pfrom->Misbehaving(20);
./main.cpp- return error("message inv size() = %d", vInv.size());
--
./main.cpp- vRecv >> vInv;
./main.cpp: if (vInv.size() > 50000)
./main.cpp- {
./main.cpp: pfrom->Misbehaving(20);
./main.cpp- return error("message getdata size() = %d", vInv.size());
--
./main.cpp- pindex = pindex->pnext;
./main.cpp: int nLimit = 500 + locator.GetDistanceBack();
./main.cpp: unsigned int nBytes = 0;
./main.cpp: printf("getblocks %d to %s limit %d\n", (pindex ? pindex->nHeight : -1), hashStop.ToString().substr(0,20).c_str(), nLimit);
./main.cpp- for (; pindex; pindex = pindex->pnext)
--
./main.cpp- {
./main.cpp: printf(" getblocks stopping at %d %s (%u bytes)\n", pindex->nHeight, pindex->GetBlockHash().ToString().substr(0,20).c_str(), nBytes);
./main.cpp- break;
--
./main.cpp- nBytes += block.GetSerializeSize(SER_NETWORK);
./main.cpp: if (--nLimit <= 0 || nBytes >= SendBufferSize()/2)
./main.cpp- {
--
./main.cpp- // getblocks the next batch of inventory.
./main.cpp: printf(" getblocks stopping at limit %d %s (%u bytes)\n", pindex->nHeight, pindex->GetBlockHash().ToString().substr(0,20).c_str(), nBytes);
./main.cpp- pfrom->hashContinue = pindex->GetBlockHash();
--
./main.cpp- vector vHeaders;
./main.cpp: int nLimit = 2000 + locator.GetDistanceBack();
./main.cpp: printf("getheaders %d to %s limit %d\n", (pindex ? pindex->nHeight : -1), hashStop.ToString().substr(0,20).c_str(), nLimit);
./main.cpp- for (; pindex; pindex = pindex->pnext)
--
./main.cpp- {
./main.cpp: printf("REJECTED orphan tx %s\n", inv.hash.ToString().substr(0,10).c_str());
./main.cpp- }
--
./main.cpp-
./main.cpp: printf("received block %s\n", block.GetHash().ToString().substr(0,20).c_str());
./main.cpp- // block.print();
--
./main.cpp- {
./main.cpp: // Nodes rebroadcast an addr every 24 hours
./main.cpp- pfrom->vAddrToSend.clear();
./main.cpp: int64 nSince = GetAdjustedTime() - 3 * 60 * 60; // in the last 3 hours
./main.cpp- CRITICAL_BLOCK(cs_mapAddresses)
./main.cpp- {
./main.cpp: unsigned int nCount = 0;
./main.cpp- BOOST_FOREACH(const PAIRTYPE(vector, CAddress)& item, mapAddresses)
--
./main.cpp- const CAddress& addr = item.second;
./main.cpp: if (addr.nTime > nSince && GetRand(nCount) < 2500)
./main.cpp- pfrom->PushAddress(addr);
--
./main.cpp- {
./main.cpp: pfrom->PushMessage("reply", hashReply, (int)2, string(""));
./main.cpp- return true;
--
./main.cpp- // Message format
./main.cpp: // (4) message start
./main.cpp: // (12) command
./main.cpp: // (4) size
./main.cpp: // (4) checksum
./main.cpp- // (x) data
--
./main.cpp- // Checksum
./main.cpp: if (vRecv.GetVersion() >= 209)
./main.cpp- {
./main.cpp: uint256 hash = Hash(vRecv.begin(), vRecv.begin() + nMessageSize);
./main.cpp: unsigned int nChecksum = 0;
./main.cpp- memcpy(&nChecksum, &hash, sizeof(nChecksum));
--
./main.cpp- {
./main.cpp: printf("ProcessMessage(%s, %u bytes) : CHECKSUM ERROR nChecksum=%08x hdr.nChecksum=%08x\n",
./main.cpp- strCommand.c_str(), nMessageSize, nChecksum, hdr.nChecksum);
--
./main.cpp- // Keep-alive ping
./main.cpp: if (pto->nLastSend && GetTime() - pto->nLastSend > 30 * 60 && pto->vSend.empty())
./main.cpp- pto->PushMessage("ping");
--
./main.cpp- // Address refresh broadcast
./main.cpp: static int64 nLastRebroadcast;
./main.cpp: if (GetTime() - nLastRebroadcast > 24 * 60 * 60)
./main.cpp- {
--
./main.cpp- // Clear out old addresses periodically so it's not too much work at once
./main.cpp: static int64 nLastClear;
./main.cpp: if (nLastClear == 0)
./main.cpp- nLastClear = GetTime();
./main.cpp: if (GetTime() - nLastClear > 10 * 60 && vNodes.size() >= 3)
./main.cpp- {
--
./main.cpp- CAddrDB addrdb;
./main.cpp: int64 nSince = GetAdjustedTime() - 14 * 24 * 60 * 60;
./main.cpp- for (map, CAddress>::iterator mi = mapAddresses.begin();
--
./main.cpp- {
./main.cpp: if (mapAddresses.size() < 1000 || GetTime() > nLastClear + 20)
./main.cpp- break;
--
./main.cpp- vAddr.push_back(addr);
./main.cpp: // receiver rejects addr messages larger than 1000
./main.cpp: if (vAddr.size() >= 1000)
./main.cpp- {
--
./main.cpp- {
./main.cpp: // 1/4 of tx invs blast to all immediately
./main.cpp: static uint256 hashSalt;
./main.cpp: if (hashSalt == 0)
./main.cpp- RAND_bytes( (unsigned char*)&hashSalt, sizeof(hashSalt));
./main.cpp: uint256 hashRand = inv.hash ^ hashSalt;
./main.cpp- hashRand = Hash(BEGIN(hashRand), END(hashRand));
./main.cpp: bool fTrickleWait = ( (hashRand & 3) != 0);
./main.cpp-
--
./main.cpp- vInv.push_back(inv);
./main.cpp: if (vInv.size() >= 1000)
./main.cpp- {
--
./main.cpp- vector vGetData;
./main.cpp: int64 nNow = GetTime() * 1000000;
./main.cpp- CTxDB txdb("r");
--
./main.cpp- vGetData.push_back(inv);
./main.cpp: if (vGetData.size() >= 1000)
./main.cpp- {
--
./main.cpp- unsigned char* pdata = (unsigned char*)pbuffer;
./main.cpp: unsigned int blocks = 1 + ( (len + 8) / 64);
./main.cpp: unsigned char* pend = pdata + 64 * blocks;
./main.cpp: memset(pdata + len, 0, 64 * blocks - len);
./main.cpp: pdata[len] = 0x80;
./main.cpp: unsigned int bits = len * 8;
./main.cpp: pend[-1] = (bits >> 0) & 0xff;
./main.cpp: pend[-2] = (bits >> 8) & 0xff;
./main.cpp: pend[-3] = (bits >> 16) & 0xff;
./main.cpp: pend[-4] = (bits >> 24) & 0xff;
./main.cpp- return blocks;
--
./main.cpp-
./main.cpp:static const unsigned int pSHA256InitState[8] =
./main.cpp:{0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19};
./main.cpp-
./main.cpp:void SHA256Transform(void* pstate, void* pinput, const void* pinit)
./main.cpp-{
./main.cpp: SHA256_CTX ctx;
./main.cpp: unsigned char data[64];
./main.cpp-
./main.cpp: SHA256_Init(&ctx);
./main.cpp-
./main.cpp: for (int i = 0; i < 16; i++)
./main.cpp: ( (uint32_t*)data)[i] = ByteReverse( ( (uint32_t*)pinput)[i]);
./main.cpp-
./main.cpp: for (int i = 0; i < 8; i++)
./main.cpp: ctx.h[i] = ( (uint32_t*)pinit)[i];
./main.cpp-
./main.cpp: SHA256_Update(&ctx, data, sizeof(data));
./main.cpp: for (int i = 0; i < 8; i++)
./main.cpp: ( (uint32_t*)pstate)[i] = ctx.h[i];
./main.cpp-}
--
./main.cpp-{
./main.cpp: unsigned int& nNonce = *(unsigned int*)(pdata + 12);
./main.cpp- for (;;)
./main.cpp- {
./main.cpp: // Crypto++ SHA-256
--
./main.cpp- // caller will check if it has enough to reach the target
./main.cpp: if ( ( (unsigned short*)phash)[14] == 0)
./main.cpp- return nNonce;
./main.cpp-
./main.cpp: // If nothing found after trying for a while, return -1
./main.cpp: if ( (nNonce & 0xffff) == 0)
./main.cpp- {
./main.cpp: nHashesDone = 0xffff+1;
./main.cpp: return -1;
./main.cpp- }
--
./main.cpp- {
./main.cpp: printf("COrphan(hash=%s, dPriority=%.1f)\n", ptx->GetHash().ToString().substr(0,10).c_str(), dPriority);
./main.cpp: BOOST_FOREACH(uint256 hash, setDependsOn)
./main.cpp: printf(" setDependsOn %s\n", hash.ToString().substr(0,10).c_str());
./main.cpp- }
--
./main.cpp- if (fDebug && GetBoolArg("-printpriority"))
./main.cpp: printf("priority nValueIn=%-12I64d nConf=%-5d dPriority=%-20.1f\n", nValueIn, nConf, dPriority);
./main.cpp- }
--
./main.cpp- {
./main.cpp: printf("priority %-20.1f %s\n%s", dPriority, tx.GetHash().ToString().substr(0,10).c_str(), tx.ToString().c_str());
./main.cpp- if (porphan)
--
./main.cpp- // Collect transactions into block
./main.cpp: map mapTestPool;
./main.cpp: uint64 nBlockSize = 1000;
./main.cpp: int nBlockSigOps = 100;
./main.cpp- while (!mapPriority.empty())
--
./main.cpp- // Transaction fee required depends on block size
./main.cpp: bool fAllowFree = (nBlockSize + nTxSize < 4000 || CTransaction::AllowFree(dPriority));
./main.cpp: int64 nMinFee = tx.GetMinFee(nBlockSize, fAllowFree);
./main.cpp-
--
./main.cpp- // because we're already processing them in order of dependency
./main.cpp: map mapTestPoolTmp(mapTestPool);
./main.cpp- bool fInvalid;
./main.cpp: if (!tx.ConnectInputs(txdb, mapTestPoolTmp, CDiskTxPos(1,1,1), pindexPrev, nFees, false, true, nMinFee, fInvalid))
./main.cpp- continue;
--
./main.cpp- FormatHashBlocks(&tmp.block, sizeof(tmp.block));
./main.cpp: FormatHashBlocks(&tmp.hash1, sizeof(tmp.hash1));
./main.cpp-
./main.cpp- // Byte swap all the input buffer
./main.cpp: for (int i = 0; i < sizeof(tmp)/4; i++)
./main.cpp- ( (unsigned int*)&tmp)[i] = ByteReverse( ( (unsigned int*)&tmp)[i]);
--
./main.cpp- // Precalc the first half of the first hash, which stays constant
./main.cpp: SHA256Transform(pmidstate, &tmp.block, pSHA256InitState);
./main.cpp-
./main.cpp: memcpy(pdata, &tmp.block, 128);
./main.cpp: memcpy(phash1, &tmp.hash1, 64);
./main.cpp-}
--
./main.cpp- {
./main.cpp: Sleep(1000);
./main.cpp- if (fShutdown)
--
./main.cpp- //
./main.cpp: char pmidstatebuf[32+16]; char* pmidstate = alignup<16>(pmidstatebuf);
./main.cpp: char pdatabuf[128+16]; char* pdata = alignup<16>(pdatabuf);
./main.cpp: char phash1buf[64+16]; char* phash1 = alignup<16>(phash1buf);
./main.cpp-
./main.cpp: FormatHashBuffers(pblock.get(), pmidstate, pdata, phash1);
./main.cpp-
./main.cpp: unsigned int& nBlockTime = *(unsigned int*)(pdata + 64 + 4);
./main.cpp: unsigned int& nBlockNonce = *(unsigned int*)(pdata + 64 + 12);
./main.cpp-
--
./main.cpp- //
./main.cpp: int64 nStart = GetTime();
./main.cpp: uint256 hashTarget = CBigNum().SetCompact(pblock->nBits).getuint256();
./main.cpp: uint256 hashbuf[2];
./main.cpp: uint256& hash = *alignup<16>(hashbuf);
./main.cpp- loop
./main.cpp- {
./main.cpp: unsigned int nHashesDone = 0;
./main.cpp- unsigned int nNonceFound;
./main.cpp-
./main.cpp: // Crypto++ SHA-256
./main.cpp: nNonceFound = ScanHash_CryptoPP(pmidstate, pdata + 64, phash1,
./main.cpp- (char*)&hash, nHashesDone);
--
./main.cpp- // Check if something found
./main.cpp: if (nNonceFound != -1)
./main.cpp- {
./main.cpp: for (int i = 0; i < sizeof(hash)/4; i++)
./main.cpp- ( (unsigned int*)&hash)[i] = ByteReverse( ( (unsigned int*)&hash)[i]);
--
./main.cpp- nHashCounter += nHashesDone;
./main.cpp: if (GetTimeMillis() - nHPSTimerStart > 4000)
./main.cpp- {
--
./main.cpp- {
./main.cpp: if (GetTimeMillis() - nHPSTimerStart > 4000)
./main.cpp- {
./main.cpp: dHashesPerSec = 1000.0 * nHashCounter / (GetTimeMillis() - nHPSTimerStart);
./main.cpp- nHPSTimerStart = GetTimeMillis();
./main.cpp: nHashCounter = 0;
./main.cpp: string strStatus = strprintf(" %.0f khash/s", dHashesPerSec/1000.0);
./main.cpp: UIThreadCall(boost::bind(CalledSetStatusBar, strStatus, 0));
./main.cpp: static int64 nLogTime;
./main.cpp: if (GetTime() - nLogTime > 30 * 60)
./main.cpp- {
--
./main.cpp- printf("%s ", DateTimeStrFormat("%x %H:%M", GetTime()).c_str());
./main.cpp: printf("hashmeter %3d CPUs %6.0f khash/s\n", vnThreadsRunning[3], dHashesPerSec/1000.0);
./main.cpp- }
--
./main.cpp- return;
./main.cpp: if (fLimitProcessors && vnThreadsRunning[3] > nLimitProcessors)
./main.cpp- return;
--
./main.cpp- break;
./main.cpp: if (nBlockNonce >= 0xffff0000)
./main.cpp- break;
./main.cpp: if (nTransactionsUpdated != nTransactionsUpdatedLast && GetTime() - nStart > 60)
./main.cpp- break;
--
./main.cpp- {
./main.cpp: vnThreadsRunning[3]++;
./main.cpp- BitcoinMiner(pwallet);
./main.cpp: vnThreadsRunning[3]--;
./main.cpp- }
./main.cpp- catch (std::exception& e) {
./main.cpp: vnThreadsRunning[3]--;
./main.cpp- PrintException(&e, "ThreadBitcoinMiner()");
./main.cpp- } catch (...) {
./main.cpp: vnThreadsRunning[3]--;
./main.cpp- PrintException(NULL, "ThreadBitcoinMiner()");
./main.cpp- }
./main.cpp: UIThreadCall(boost::bind(CalledSetStatusBar, "", 0));
./main.cpp: nHPSTimerStart = 0;
./main.cpp: if (vnThreadsRunning[3] == 0)
./main.cpp: dHashesPerSec = 0;
./main.cpp: printf("ThreadBitcoinMiner exiting, %d threads remaining\n", vnThreadsRunning[3]);
./main.cpp-}
--
./main.cpp- printf("%d processors\n", nProcessors);
./main.cpp: if (nProcessors < 1)
./main.cpp: nProcessors = 1;
./main.cpp- if (fLimitProcessors && nProcessors > nLimitProcessors)
./main.cpp- nProcessors = nLimitProcessors;
./main.cpp: int nAddThreads = nProcessors - vnThreadsRunning[3];
./main.cpp- printf("Starting %d BitcoinMiner threads\n", nAddThreads);
./main.cpp: for (int i = 0; i < nAddThreads; i++)
./main.cpp- {
--
./main.cpp- printf("Error: CreateThread(ThreadBitcoinMiner) failed\n");
./main.cpp: Sleep(10);
./main.cpp- }
--
./db.cpp- dbenv.set_lg_dir(strLogDir.c_str());
./db.cpp: dbenv.set_lg_max(1000000);
./db.cpp: dbenv.set_lk_max_locks(2737000);
./db.cpp: dbenv.set_lk_max_objects(1119200);
./db.cpp: dbenv.set_lk_max_lockers(1119200);
./db.cpp- dbenv.set_errfile(fopen(strErrorFile.c_str(), "a")); /// debug
./db.cpp: dbenv.set_flags(DB_AUTO_COMMIT, 1);
./db.cpp: dbenv.set_flags(DB_TXN_WRITE_NOSYNC, 1);
./db.cpp: dbenv.log_set_config(DB_LOG_AUTO_REMOVE, 1);
./db.cpp- ret = dbenv.open(strDataDir.c_str(),
--
./db.cpp- // Flush database activity from memory pool to disk log
./db.cpp: unsigned int nMinutes = 0;
./db.cpp- if (fReadOnly)
./db.cpp: nMinutes = 1;
./db.cpp- if (strFile == "addr.dat")
./db.cpp: nMinutes = 2;
./db.cpp: if (strFile == "blkindex.dat" && IsInitialBlockDownload() && nBestHeight % 500 != 0)
./db.cpp: nMinutes = 1;
./db.cpp: dbenv.txn_checkpoint(0, nMinutes, 0);
./db.cpp-
--
./db.cpp- if (pszSkip &&
./db.cpp: strncmp(&ssKey[0], pszSkip, std::min(ssKey.size(), strlen(pszSkip))) == 0)
./db.cpp- continue;
./db.cpp: if (strncmp(&ssKey[0], "\x07version", 8) == 0)
./db.cpp- {
--
./db.cpp- }
./db.cpp: Sleep(100);
./db.cpp- }
--
./db.cpp- bnBestChainWork = pindexBest->bnChainWork;
./db.cpp: printf("LoadBlockIndex(): hashBestChain=%s height=%d\n", hashBestChain.ToString().substr(0,20).c_str(), nBestHeight);
./db.cpp-
--
./db.cpp- {
./db.cpp: if (pindex->nHeight < nBestHeight-2500 && !mapArgs.count("-checkblocks"))
./db.cpp- break;
--
./db.cpp-
./db.cpp: // Undo serialize changes in 31600
./db.cpp: if (31404 <= wtx.fTimeReceivedIsTxTime && wtx.fTimeReceivedIsTxTime <= 31703)
./db.cpp- {
--
./db.cpp- //printf("LoadWallet %s\n", wtx.GetHash().ToString().c_str());
./db.cpp: //printf(" %12I64d %s %s %s\n",
./db.cpp: // wtx.vout[0].nValue,
./db.cpp- // DateTimeStrFormat("%x %H:%M:%S", wtx.GetBlockTime()).c_str(),
./db.cpp: // wtx.hashBlock.ToString().substr(0,20).c_str(),
./db.cpp- // wtx.mapValue["message"].c_str());
--
./db.cpp- ssValue >> nFileVersion;
./db.cpp: if (nFileVersion == 10300)
./db.cpp: nFileVersion = 300;
./db.cpp- }
--
./db.cpp-
./db.cpp: // Rewrite encrypted wallets of versions 0.4.0 and 0.5.0rc:
./db.cpp: if (fIsEncrypted && (nFileVersion == 40000 || nFileVersion == 50000))
./db.cpp- return DB_NEED_REWRITE;
--
./db.cpp- // Get rid of old debug.log file in current directory
./db.cpp: if (nFileVersion <= 105 && !pszSetDataDir[0])
./db.cpp- unlink("debug.log");
--
./db.cpp- unsigned int nLastFlushed = nWalletDBUpdated;
./db.cpp: int64 nLastWalletUpdate = GetTime();
./db.cpp- while (!fShutdown)
./db.cpp- {
./db.cpp: Sleep(500);
./db.cpp-
--
./db.cpp-
./db.cpp: if (nLastFlushed != nWalletDBUpdated && GetTime() - nLastWalletUpdate >= 2)
./db.cpp- {
--
./db.cpp- pathDest = pathDest / wallet.strWalletFile;
./db.cpp:#if BOOST_VERSION >= 104000
./db.cpp- filesystem::copy_file(pathSrc, pathDest, filesystem::copy_option::overwrite_if_exists);
--
./db.cpp- }
./db.cpp: Sleep(100);
./db.cpp- }
--
./util.cpp- // Seed with CPU performance counter
./util.cpp: int64 nCounter = GetPerformanceCounter();
./util.cpp: RAND_add(&nCounter, sizeof(nCounter), 1.5);
./util.cpp: memset(&nCounter, 0, sizeof(nCounter));
./util.cpp-}
--
./util.cpp-
./util.cpp: // This can take up to 2 seconds, so only do it every 10 minutes
./util.cpp: static int64 nLastPerfmon;
./util.cpp: if (GetTime() < nLastPerfmon + 10 * 60)
./util.cpp- return;
--
./util.cpp- {
./util.cpp: char pszFile[MAX_PATH+100];
./util.cpp- GetDataDir(pszFile);
--
./util.cpp-{
./util.cpp: char buffer[50000];
./util.cpp- char* p = buffer;
--
./util.cpp- delete[] p;
./util.cpp: limit *= 2;
./util.cpp- p = new char[limit];
--
./util.cpp-{
./util.cpp: char buffer[50000];
./util.cpp- int limit = sizeof(buffer);
--
./util.cpp- // localized number formatting.
./util.cpp: int64 n_abs = (n > 0 ? n : -n);
./util.cpp: int64 quotient = n_abs/COIN;
./util.cpp: int64 remainder = n_abs%COIN;
./util.cpp: string str = strprintf("%"PRI64d".%08"PRI64d, quotient, remainder);
./util.cpp-
./util.cpp: // Right-trim excess 0's before the decimal point:
./util.cpp: int nTrim = 0;
./util.cpp: for (int i = str.size()-1; (str[i] == '0' && isdigit(str[i-2])); --i)
./util.cpp- ++nTrim;
--
./util.cpp- p++;
./util.cpp: int64 nMult = CENT*10;
./util.cpp: while (isdigit(*p) && (nMult > 0))
./util.cpp- {
./util.cpp: nUnits += nMult * (*p++ - '0');
./util.cpp: nMult /= 10;
./util.cpp- }
--
./util.cpp- return false;
./util.cpp: if (strWhole.size() > 10) // guard against 63 bit overflow
./util.cpp- return false;
./util.cpp: if (nUnits < 0 || nUnits > COIN)
./util.cpp- return false;
./util.cpp: int64 nWhole = atoi64(strWhole);
./util.cpp: int64 nValue = nWhole*COIN + nUnits;
./util.cpp-
--
./util.cpp-{
./util.cpp: static char phexdigit[256] =
./util.cpp: { -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
./util.cpp: -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
./util.cpp: -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
./util.cpp: 0,1,2,3,4,5,6,7,8,9,-1,-1,-1,-1,-1,-1,
./util.cpp: -1,0xa,0xb,0xc,0xd,0xe,0xf,-1,-1,-1,-1,-1,-1,-1,-1,-1,
./util.cpp: -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
./util.cpp: -1,0xa,0xb,0xc,0xd,0xe,0xf,-1,-1,-1,-1,-1,-1,-1,-1,-1
./util.cpp: -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
./util.cpp: -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
./util.cpp: -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
./util.cpp: -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
./util.cpp: -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
./util.cpp: -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
./util.cpp: -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
./util.cpp: -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
./util.cpp: -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, };
./util.cpp-
--
./util.cpp- char c = phexdigit[(unsigned char)*psz++];
./util.cpp: if (c == (char)-1)
./util.cpp- break;
./util.cpp: unsigned char n = (c << 4);
./util.cpp- c = phexdigit[(unsigned char)*psz++];
./util.cpp: if (c == (char)-1)
./util.cpp- break;
--
./util.cpp- mapMultiArgs.clear();
./util.cpp: for (int i = 1; i < argc; i++)
./util.cpp- {
./util.cpp: char psz[10000];
./util.cpp- strlcpy(psz, argv[i], sizeof(psz));
--
./util.cpp-
./util.cpp:string EncodeBase64(const unsigned char* pch, size_t len)
./util.cpp-{
./util.cpp: static const char *pbase64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
./util.cpp-
./util.cpp- string strRet="";
./util.cpp: strRet.reserve( (len+2)/3*4);
./util.cpp-
./util.cpp: int mode=0, left=0;
./util.cpp- const unsigned char *pchEnd = pch+len;
--
./util.cpp- {
./util.cpp: case 0: // we have no bits
./util.cpp: strRet += pbase64[enc >> 2];
./util.cpp: left = (enc & 3) << 4;
./util.cpp: mode = 1;
./util.cpp- break;
./util.cpp-
./util.cpp: case 1: // we have two bits
./util.cpp: strRet += pbase64[left | (enc >> 4)];
./util.cpp: left = (enc & 15) << 2;
./util.cpp: mode = 2;
./util.cpp- break;
./util.cpp-
./util.cpp: case 2: // we have four bits
./util.cpp: strRet += pbase64[left | (enc >> 6)];
./util.cpp: strRet += pbase64[enc & 63];
./util.cpp: mode = 0;
./util.cpp- break;
--
./util.cpp-
./util.cpp:string EncodeBase64(const string& str)
./util.cpp-{
./util.cpp: return EncodeBase64( (const unsigned char*)str.c_str(), str.size());
./util.cpp-}
./util.cpp-
./util.cpp:vector DecodeBase64(const char* p, bool* pfInvalid)
./util.cpp-{
./util.cpp: static const int decode64_table[256] =
./util.cpp- {
./util.cpp: -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
./util.cpp: -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
./util.cpp: -1, -1, -1, 62, -1, -1, -1, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1,
./util.cpp: -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
./util.cpp: 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, -1, 26, 27, 28,
./util.cpp: 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
./util.cpp: 49, 50, 51, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
./util.cpp: -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
./util.cpp: -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
./util.cpp: -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
./util.cpp: -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
./util.cpp: -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
./util.cpp: -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
./util.cpp- };
--
./util.cpp- vector vchRet;
./util.cpp: vchRet.reserve(strlen(p)*3/4);
./util.cpp-
./util.cpp: int mode = 0;
./util.cpp: int left = 0;
./util.cpp-
./util.cpp: while (1)
./util.cpp- {
./util.cpp: int dec = decode64_table[*p];
./util.cpp: if (dec == -1) break;
./util.cpp- p++;
--
./util.cpp- {
./util.cpp: case 0: // we have no bits and get 6
./util.cpp- left = dec;
./util.cpp: mode = 1;
./util.cpp- break;
./util.cpp-
./util.cpp: case 1: // we have 6 bits and keep 4
./util.cpp: vchRet.push_back( (left<<2) | (dec>>4));
./util.cpp: left = dec & 15;
./util.cpp: mode = 2;
./util.cpp- break;
./util.cpp-
./util.cpp: case 2: // we have 4 bits and get 6, we keep 2
./util.cpp: vchRet.push_back( (left<<4) | (dec>>2));
./util.cpp: left = dec & 3;
./util.cpp: mode = 3;
./util.cpp- break;
./util.cpp-
./util.cpp: case 3: // we have 2 bits and get 6
./util.cpp: vchRet.push_back( (left<<6) | dec);
./util.cpp: mode = 0;
./util.cpp- break;
--
./util.cpp- {
./util.cpp: case 0: // 4n base64 characters processed: ok
./util.cpp- break;
./util.cpp-
./util.cpp: case 1: // 4n+1 base64 character processed: impossible
./util.cpp- *pfInvalid = true;
--
./util.cpp-
./util.cpp: case 2: // 4n+2 base64 characters processed: require '=='
./util.cpp: if (left || p[0] != '=' || p[1] != '=' || decode64_table[p[2]] != -1)
./util.cpp- *pfInvalid = true;
--
./util.cpp-
./util.cpp: case 3: // 4n+3 base64 characters processed: require '='
./util.cpp: if (left || p[0] != '=' || decode64_table[p[1]] != -1)
./util.cpp- *pfInvalid = true;
--
./util.cpp- if (pex)
./util.cpp: snprintf(pszMessage, 1000,
./util.cpp- "EXCEPTION: %s \n%s \n%s in %s \n", typeid(*pex).name(), pex->what(), pszModule, pszThread);
./util.cpp- else
./util.cpp: snprintf(pszMessage, 1000,
./util.cpp- "UNKNOWN EXCEPTION \n%s in %s \n", pszModule, pszThread);
--
./util.cpp-{
./util.cpp: char pszMessage[10000];
./util.cpp- FormatException(pszMessage, pex, pszThread);
--
./util.cpp-{
./util.cpp: char pszMessage[10000];
./util.cpp- FormatException(pszMessage, pex, pszThread);
--
./util.cpp-{
./util.cpp: char pszMessage[10000];
./util.cpp- FormatException(pszMessage, pex, pszThread);
--
./util.cpp: static bool pfMkdir[4];
./util.cpp- if (!pfMkdir[nVariation])
--
./util.cpp- FILE* file = fopen(strFile.c_str(), "r");
./util.cpp: if (file && GetFilesize(file) > 10 * 1000000)
./util.cpp- {
./util.cpp- // Restart the file with some of the end
./util.cpp: char pch[200000];
./util.cpp- fseek(file, -sizeof(pch), SEEK_END);
./util.cpp: int nBytes = fread(pch, 1, sizeof(pch), file);
./util.cpp- fclose(file);
--
./util.cpp- // Add data
./util.cpp: static vector vTimeOffsets;
./util.cpp- if (vTimeOffsets.empty())
./util.cpp: vTimeOffsets.push_back(0);
./util.cpp- vTimeOffsets.push_back(nOffsetSample);
./util.cpp: printf("Added time data, samples %d, offset %+"PRI64d" (%+"PRI64d" minutes)\n", vTimeOffsets.size(), vTimeOffsets.back(), vTimeOffsets.back()/60);
./util.cpp: if (vTimeOffsets.size() >= 5 && vTimeOffsets.size() % 2 == 1)
./util.cpp- {
./util.cpp- sort(vTimeOffsets.begin(), vTimeOffsets.end());
./util.cpp: int64 nMedian = vTimeOffsets[vTimeOffsets.size()/2];
./util.cpp- // Only let other nodes change our time by so much
./util.cpp: if (abs64(nMedian) < 70 * 60)
./util.cpp- {
--
./util.cpp- {
./util.cpp: // If nobody has a time different than ours but within 5 minutes of ours, give a warning
./util.cpp- bool fMatch = false;
./util.cpp: BOOST_FOREACH(int64 nOffset, vTimeOffsets)
./util.cpp: if (nOffset != 0 && abs64(nOffset) < 5 * 60)
./util.cpp- fMatch = true;
--
./util.cpp- printf("*** %s\n", strMessage.c_str());
./util.cpp: boost::thread(boost::bind(ThreadSafeMessageBox, strMessage+" ", string("Bitcoin"), wxOK | wxICON_EXCLAMATION, (wxWindow*)NULL, -1, -1));
./util.cpp- }
--
./util.cpp- }
./util.cpp: BOOST_FOREACH(int64 n, vTimeOffsets)
./util.cpp: printf("%+"PRI64d" ", n);
./util.cpp: printf("| nTimeOffset = %+"PRI64d" (%+"PRI64d" minutes)\n", nTimeOffset, nTimeOffset/60);
./util.cpp- }
--
./util.cpp-{
./util.cpp: if (nVersion%100 == 0)
./util.cpp: return strprintf("%d.%d.%d", nVersion/1000000, (nVersion/10000)%100, (nVersion/100)%100);
./util.cpp- else
./util.cpp: return strprintf("%d.%d.%d.%d", nVersion/1000000, (nVersion/10000)%100, (nVersion/100)%100, nVersion%100);
./util.cpp-}
--
./util.cpp-// Problem being solved:
./util.cpp:// Thread 1 locks A, then B, then C
./util.cpp:// Thread 2 locks D, then C, then A
./util.cpp-// --> may result in deadlock between the two threads, depending on when they run.
--
./util.cpp- printf("Previous lock order was:\n");
./util.cpp: BOOST_FOREACH(const PAIRTYPE(CCriticalSection*, CLockLocation)& i, s2)
./util.cpp- {
./util.cpp: if (i.first == mismatch.first) printf(" (1)");
./util.cpp: if (i.first == mismatch.second) printf(" (2)");
./util.cpp- printf(" %s\n", i.second.ToString().c_str());
--
./util.cpp- printf("Current lock order is:\n");
./util.cpp: BOOST_FOREACH(const PAIRTYPE(CCriticalSection*, CLockLocation)& i, s1)
./util.cpp- {
./util.cpp: if (i.first == mismatch.first) printf(" (1)");
./util.cpp: if (i.first == mismatch.second) printf(" (2)");
./util.cpp- printf(" %s\n", i.second.ToString().c_str());
--
./checkpoints.cpp- boost::assign::map_list_of
./checkpoints.cpp: ( 11111, uint256("0x0000000069e244f73d78e8fd29ba2fd2ed618bd6fa2ee92559f542fdb26e7c1d"))
./checkpoints.cpp: ( 33333, uint256("0x000000002dd5588a74784eaa7ab0507a18ad16a236e7b1ce69f00d7ddfb5d0a6"))
./checkpoints.cpp: ( 68555, uint256("0x00000000001e1b4903550a0b96e9a9405c8a95f387162e4944e8d9fbe501cd6a"))
./checkpoints.cpp: ( 70567, uint256("0x00000000006a49b14bcf27462068f1264c961f11fa2e0eddd2be0791e1d4124a"))
./checkpoints.cpp: ( 74000, uint256("0x0000000000573993a3c9e41ce34471c079dcf5f52a0e824a81e7f953b8661a20"))
./checkpoints.cpp: (105000, uint256("0x00000000000291ce28027faea320c8d2b054b2e0fe44a773f3eefb151d6bdc97"))
./checkpoints.cpp: (118000, uint256("0x000000000000774a7f8a7a12dc906ddb9e17e75d684f15e00f8767f9e8f36553"))
./checkpoints.cpp: (134444, uint256("0x00000000000005b12ffd4cd315cd34ffd4a594f430ac814c91184a0d42d2b0fe"))
./checkpoints.cpp: (140700, uint256("0x000000000000033b512028abb90e1626d8b346fd0ed598ac0a3c371138dce2bd"))
./checkpoints.cpp: (168000, uint256("0x000000000000099e61ea72015e79632f216fe6cb33d7899acb35b75c8303b763"))
./checkpoints.cpp- ;
./checkpoints.cpp-
./checkpoints.cpp: bool CheckBlock(int nHeight, const uint256& hash)
./checkpoints.cpp- {
--
./protocol.h-{
./protocol.h: return 8333;
./protocol.h-}
--
./protocol.h-// Message header
./protocol.h:// (4) message start
./protocol.h:// (12) command
./protocol.h:// (4) size
./protocol.h:// (4) checksum
./protocol.h-
./protocol.h:extern unsigned char pchMessageStart[4];
./protocol.h-
--
./protocol.h- READWRITE(nMessageSize);
./protocol.h: if (nVersion >= 209)
./protocol.h- READWRITE(nChecksum);
--
./protocol.h- public:
./protocol.h: enum { COMMAND_SIZE=12 };
./protocol.h- char pchMessageStart[sizeof(::pchMessageStart)];
--
./protocol.h- READWRITE(nVersion);
./protocol.h: if ( (nType & SER_DISK) || (nVersion >= 31402 && !(nType & SER_GETHASH)))
./protocol.h- READWRITE(nTime);
./protocol.h- READWRITE(nServices);
./protocol.h: READWRITE(FLATDATA(pchReserved)); // for IPv6
./protocol.h- READWRITE(ip);
--
./bignum.h-
./bignum.h: void setint64(int64 n)
./bignum.h- {
./bignum.h: unsigned char pch[sizeof(n) + 6];
./bignum.h: unsigned char* p = pch + 4;
./bignum.h- bool fNegative = false;
./bignum.h: if (n < (int64)0)
./bignum.h- {
--
./bignum.h- bool fLeadingZeroes = true;
./bignum.h: for (int i = 0; i < 8; i++)
./bignum.h- {
./bignum.h: unsigned char c = (n >> 56) & 0xff;
./bignum.h: n <<= 8;
./bignum.h- if (fLeadingZeroes)
./bignum.h- {
./bignum.h: if (c == 0)
./bignum.h- continue;
./bignum.h: if (c & 0x80)
./bignum.h: *p++ = (fNegative ? 0x80 : 0);
./bignum.h- else if (fNegative)
./bignum.h: c |= 0x80;
./bignum.h- fLeadingZeroes = false;
--
./bignum.h- }
./bignum.h: unsigned int nSize = p - (pch + 4);
./bignum.h: pch[0] = (nSize >> 24) & 0xff;
./bignum.h: pch[1] = (nSize >> 16) & 0xff;
./bignum.h: pch[2] = (nSize >> 8) & 0xff;
./bignum.h: pch[3] = (nSize) & 0xff;
./bignum.h: BN_mpi2bn(pch, p - pch, this);
./bignum.h- }
./bignum.h-
./bignum.h: void setuint64(uint64 n)
./bignum.h- {
./bignum.h: unsigned char pch[sizeof(n) + 6];
./bignum.h: unsigned char* p = pch + 4;
./bignum.h- bool fLeadingZeroes = true;
./bignum.h: for (int i = 0; i < 8; i++)
./bignum.h- {
./bignum.h: unsigned char c = (n >> 56) & 0xff;
./bignum.h: n <<= 8;
./bignum.h- if (fLeadingZeroes)
./bignum.h- {
./bignum.h: if (c == 0)
./bignum.h- continue;
./bignum.h: if (c & 0x80)
./bignum.h: *p++ = 0;
./bignum.h- fLeadingZeroes = false;
--
./bignum.h- }
./bignum.h: unsigned int nSize = p - (pch + 4);
./bignum.h: pch[0] = (nSize >> 24) & 0xff;
./bignum.h: pch[1] = (nSize >> 16) & 0xff;
./bignum.h: pch[2] = (nSize >> 8) & 0xff;
./bignum.h: pch[3] = (nSize) & 0xff;
./bignum.h: BN_mpi2bn(pch, p - pch, this);
./bignum.h- }
./bignum.h-
./bignum.h: void setuint256(uint256 n)
./bignum.h- {
./bignum.h: unsigned char pch[sizeof(n) + 6];
./bignum.h: unsigned char* p = pch + 4;
./bignum.h- bool fLeadingZeroes = true;
--
./bignum.h- {
./bignum.h: if (c == 0)
./bignum.h- continue;
./bignum.h: if (c & 0x80)
./bignum.h: *p++ = 0;
./bignum.h- fLeadingZeroes = false;
--
./bignum.h- }
./bignum.h: unsigned int nSize = p - (pch + 4);
./bignum.h: pch[0] = (nSize >> 24) & 0xff;
./bignum.h: pch[1] = (nSize >> 16) & 0xff;
./bignum.h: pch[2] = (nSize >> 8) & 0xff;
./bignum.h: pch[3] = (nSize >> 0) & 0xff;
./bignum.h: BN_mpi2bn(pch, p - pch, this);
./bignum.h- }
./bignum.h-
./bignum.h: uint256 getuint256()
./bignum.h- {
./bignum.h: unsigned int nSize = BN_bn2mpi(this, NULL);
./bignum.h: if (nSize < 4)
./bignum.h: return 0;
./bignum.h- std::vector vch(nSize);
./bignum.h: BN_bn2mpi(this, &vch[0]);
./bignum.h: if (vch.size() > 4)
./bignum.h: vch[4] &= 0x7f;
./bignum.h: uint256 n = 0;
./bignum.h: for (int i = 0, j = vch.size()-1; i < sizeof(n) && j >= 4; i++, j--)
./bignum.h- ( (unsigned char*)&n)[i] = vch[j];
--
./bignum.h- {
./bignum.h: std::vector vch2(vch.size() + 4);
./bignum.h- unsigned int nSize = vch.size();
./bignum.h: // BIGNUM's byte stream format expects 4 bytes of
./bignum.h- // big endian size data info at the front
./bignum.h: vch2[0] = (nSize >> 24) & 0xff;
./bignum.h: vch2[1] = (nSize >> 16) & 0xff;
./bignum.h: vch2[2] = (nSize >> 8) & 0xff;
./bignum.h: vch2[3] = (nSize >> 0) & 0xff;
./bignum.h- // swap data to big endian
./bignum.h: reverse_copy(vch.begin(), vch.end(), vch2.begin() + 4);
./bignum.h: BN_mpi2bn(&vch2[0], vch2.size(), this);
./bignum.h- }
--
./bignum.h- {
./bignum.h: unsigned int nSize = BN_bn2mpi(this, NULL);
./bignum.h: if (nSize < 4)
./bignum.h- return std::vector();
./bignum.h- std::vector vch(nSize);
./bignum.h: BN_bn2mpi(this, &vch[0]);
./bignum.h: vch.erase(vch.begin(), vch.begin() + 4);
./bignum.h- reverse(vch.begin(), vch.end());
--
./bignum.h- {
./bignum.h: unsigned int nSize = nCompact >> 24;
./bignum.h: std::vector vch(4 + nSize);
./bignum.h: vch[3] = nSize;
./bignum.h: if (nSize >= 1) vch[4] = (nCompact >> 16) & 0xff;
./bignum.h: if (nSize >= 2) vch[5] = (nCompact >> 8) & 0xff;
./bignum.h: if (nSize >= 3) vch[6] = (nCompact >> 0) & 0xff;
./bignum.h: BN_mpi2bn(&vch[0], vch.size(), this);
./bignum.h- return *this;
--
./bignum.h- {
./bignum.h: unsigned int nSize = BN_bn2mpi(this, NULL);
./bignum.h- std::vector vch(nSize);
./bignum.h: nSize -= 4;
./bignum.h: BN_bn2mpi(this, &vch[0]);
./bignum.h: unsigned int nCompact = nSize << 24;
./bignum.h: if (nSize >= 1) nCompact |= (vch[4] << 16);
./bignum.h: if (nSize >= 2) nCompact |= (vch[5] << 8);
./bignum.h: if (nSize >= 3) nCompact |= (vch[6] << 0);
./bignum.h- return nCompact;
--
./bignum.h- }
./bignum.h: if (psz[0] == '0' && tolower(psz[1]) == 'x')
./bignum.h: psz += 2;
./bignum.h- while (isspace(*psz))
--
./bignum.h- // hex string to bignum
./bignum.h: static char phexdigit[256] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,1,2,3,4,5,6,7,8,9,0,0,0,0,0,0, 0,0xa,0xb,0xc,0xd,0xe,0xf,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0xa,0xb,0xc,0xd,0xe,0xf,0,0,0,0,0,0,0,0,0 };
./bignum.h: *this = 0;
./bignum.h- while (isxdigit(*psz))
./bignum.h- {
./bignum.h: *this <<= 4;
./bignum.h- int n = phexdigit[*psz++];
--
./bignum.h- if (fNegative)
./bignum.h: *this = 0 - *this;
./bignum.h- }
./bignum.h-
./bignum.h: std::string ToString(int nBase=10) const
./bignum.h- {
--
./bignum.h- unsigned int c = rem.getulong();
./bignum.h: str += "0123456789abcdef"[c];
./bignum.h- }
--
./bignum.h- {
./bignum.h: return ToString(16);
./bignum.h- }
./bignum.h-
./bignum.h: unsigned int GetSerializeSize(int nType=0, int nVersion=VERSION) const
./bignum.h- {
--
./util.h-#define _strlwr(psz) to_lower(psz)
./util.h:#define MAX_PATH 1024
./util.h:#define Beep(n1,n2) (0)
./util.h:inline void Sleep(int64 n)
./util.h-{
./util.h: /*Boost has a year 2038 problem— if the request sleep time is past epoch+2^31 seconds the sleep returns instantly.
./util.h: So we clamp our sleeps here to 10 years and hope that boost is fixed by 2028.*/iv
./util.h: boost::thread::sleep(boost::get_system_time() + boost::posix_time::milliseconds(n>315576000000LL?315576000000LL:n));
./util.h-}
--
./util.h-
./util.h:inline int64 atoi64(const char* psz)
./util.h-{
./util.h: return strtoll(psz, NULL, 10);
./util.h-}
./util.h-
./util.h:inline int64 atoi64(const std::string& str)
./util.h-{
./util.h: return strtoll(str.c_str(), NULL, 10);
./util.h-}
--
./util.h-{
./util.h: return (int)(d > 0 ? d + 0.5 : d - 0.5);
./util.h-}
./util.h-
./util.h:inline int64 roundint64(double d)
./util.h-{
./util.h: return (int64)(d > 0 ? d + 0.5 : d - 0.5);
./util.h-}
./util.h-
./util.h:inline int64 abs64(int64 n)
./util.h-{
./util.h: return (n >= 0 ? n : -n);
./util.h-}
--
./util.h- return "";
./util.h: const unsigned char* pbegin = (const unsigned char*)&itbegin[0];
./util.h: const unsigned char* pend = pbegin + (itend - itbegin) * sizeof(itbegin[0]);
./util.h- std::string str;
./util.h: str.reserve( (pend-pbegin) * (fSpaces ? 3 : 2));
./util.h- for (const unsigned char* p = pbegin; p != pend; p++)
./util.h: str += strprintf( (fSpaces && p != pend-1 ? "%02x " : "%02x"), *p);
./util.h- return str;
--
./util.h-
./util.h:inline std::string HexNumStr(const std::vector& vch, bool f0x=true)
./util.h-{
./util.h: return HexNumStr(vch.begin(), vch.end(), f0x);
./util.h-}
--
./util.h-
./util.h:inline int64 GetPerformanceCounter()
./util.h-{
./util.h: int64 nCounter = 0;
./util.h- timeval t;
./util.h- gettimeofday(&t, NULL);
./util.h: nCounter = t.tv_sec * 1000000 + t.tv_usec;
./util.h- return nCounter;
--
./util.h-
./util.h:inline int64 GetTimeMillis()
./util.h-{
./util.h- return (boost::posix_time::ptime(boost::posix_time::microsec_clock::universal_time()) -
./util.h: boost::posix_time::ptime(boost::gregorian::date(1970,1,1))).total_milliseconds();
./util.h-}
./util.h-
./util.h:inline std::string DateTimeStrFormat(const char* pszFormat, int64 nTime)
./util.h-{
--
./util.h- struct tm* ptmTime = gmtime(&n);
./util.h: char pszTime[200];
./util.h- strftime(pszTime, sizeof(pszTime), pszFormat, ptmTime);
--
./util.h- static char nLoops; \
./util.h: if (nLoops <= 0) \
./util.h: nLoops = GetRand(20) + 1; \
./util.h: if (nLoops-- > 1) \
./util.h- { \
--
./util.h- CDataStream ss(nType, nVersion);
./util.h: ss.reserve(10000);
./util.h- ss << obj;
--
./util.h- int size = vSorted.size();
./util.h: assert(size>0);
./util.h: if(size & 1) // Odd number of elements
./util.h- {
./util.h: return vSorted[size/2];
./util.h- }
--
./util.h- {
./util.h: return (vSorted[size/2-1] + vSorted[size/2]) / 2;
./util.h- }
--
./util.h-#define THREAD_PRIORITY_LOWEST PRIO_MAX
./util.h:#define THREAD_PRIORITY_BELOW_NORMAL 2
./util.h:#define THREAD_PRIORITY_NORMAL 0
./util.h:#define THREAD_PRIORITY_ABOVE_NORMAL 0
./util.h-
--
./util.h-
./util.h:inline uint32_t ByteReverse(uint32_t value)
./util.h-{
./util.h: value = ( (value & 0xFF00FF00) >> 8) | ( (value & 0x00FF00FF) << 8);
./util.h: return (value<<16) | (value>>16);
./util.h-}
--
./init.cpp- CreateThread(ExitTimeout, NULL);
./init.cpp: Sleep(50);
./init.cpp- printf("Bitcoin exiting\n\n");
./init.cpp- fExit = true;
./init.cpp: exit(0);
./init.cpp- }
--
./init.cpp- while (!fExit)
./init.cpp: Sleep(500);
./init.cpp: Sleep(100);
./init.cpp: ExitThread(0);
./init.cpp- }
--
./init.cpp-
./init.cpp:bool AppInit2(int argc, char* argv[])
./init.cpp-{
./init.cpp: umask(077);
./init.cpp-
--
./init.cpp- {
./init.cpp: int nNewTimeout = GetArg("-timeout", 5000);
./init.cpp: if (nNewTimeout > 0 && nNewTimeout < 600000)
./init.cpp- nConnectTimeout = nNewTimeout;
--
./init.cpp-
./init.cpp: bool fTor = (fUseProxy && addrProxy.port == htons(9050));
./init.cpp- if (fTor)
--
./init.cpp- }
./init.cpp: if (nTransactionFee > 0.25 * COIN)
./init.cpp- wxMessageBox(_("Warning: -paytxfee is set very high. This is the transaction fee you will pay if you send a transaction."), "Bitcoin", wxOK | wxICON_EXCLAMATION);
--
./init.cpp-
./init.cpp: while (1)
./init.cpp: Sleep(5000);
./init.cpp-
--
./script.cpp-typedef vector valtype;
./script.cpp:static const valtype vchFalse(0);
./script.cpp:static const valtype vchZero(0);
./script.cpp:static const valtype vchTrue(1, 1);
./script.cpp:static const CBigNum bnZero(0);
./script.cpp:static const CBigNum bnOne(1);
./script.cpp:static const CBigNum bnFalse(0);
./script.cpp:static const CBigNum bnTrue(1);
./script.cpp:static const size_t nMaxNumSize = 4;
./script.cpp-
--
./script.cpp-{
./script.cpp: for (int i = 0; i < vch.size(); i++)
./script.cpp- {
./script.cpp: if (vch[i] != 0)
./script.cpp- {
./script.cpp- // Can be negative zero
./script.cpp: if (i == vch.size()-1 && vch[i] == 0x80)
./script.cpp- return false;
--
./script.cpp- vector altstack;
./script.cpp: if (script.size() > 10000)
./script.cpp- return false;
./script.cpp: int nOpCount = 0;
./script.cpp-
--
./script.cpp- return false;
./script.cpp: if (vchPushValue.size() > 520)
./script.cpp- return false;
./script.cpp: if (opcode > OP_16 && ++nOpCount > 201)
./script.cpp- return false;
--
./script.cpp- //
./script.cpp: case OP_1NEGATE:
./script.cpp: case OP_1:
./script.cpp: case OP_2:
./script.cpp: case OP_3:
./script.cpp: case OP_4:
./script.cpp: case OP_5:
./script.cpp: case OP_6:
./script.cpp: case OP_7:
./script.cpp: case OP_8:
./script.cpp: case OP_9:
./script.cpp: case OP_10:
./script.cpp: case OP_11:
./script.cpp: case OP_12:
./script.cpp: case OP_13:
./script.cpp: case OP_14:
./script.cpp: case OP_15:
./script.cpp: case OP_16:
./script.cpp- {
./script.cpp- // ( -- value)
./script.cpp: CBigNum bn( (int)opcode - (int)(OP_1 - 1));
./script.cpp- stack.push_back(bn.getvch());
--
./script.cpp- case OP_NOP:
./script.cpp: case OP_NOP1: case OP_NOP2: case OP_NOP3: case OP_NOP4: case OP_NOP5:
./script.cpp: case OP_NOP6: case OP_NOP7: case OP_NOP8: case OP_NOP9: case OP_NOP10:
./script.cpp- break;
--
./script.cpp-
./script.cpp: case OP_2DROP:
./script.cpp- {
./script.cpp: // (x1 x2 -- )
./script.cpp: if (stack.size() < 2)
./script.cpp- return false;
--
./script.cpp-
./script.cpp: case OP_2DUP:
./script.cpp- {
./script.cpp: // (x1 x2 -- x1 x2 x1 x2)
./script.cpp: if (stack.size() < 2)
./script.cpp- return false;
./script.cpp: valtype vch1 = stacktop(-2);
./script.cpp: valtype vch2 = stacktop(-1);
./script.cpp: stack.push_back(vch1);
./script.cpp: stack.push_back(vch2);
./script.cpp- }
--
./script.cpp-
./script.cpp: case OP_3DUP:
./script.cpp- {
./script.cpp: // (x1 x2 x3 -- x1 x2 x3 x1 x2 x3)
./script.cpp: if (stack.size() < 3)
./script.cpp- return false;
./script.cpp: valtype vch1 = stacktop(-3);
./script.cpp: valtype vch2 = stacktop(-2);
./script.cpp: valtype vch3 = stacktop(-1);
./script.cpp: stack.push_back(vch1);
./script.cpp: stack.push_back(vch2);
./script.cpp: stack.push_back(vch3);
./script.cpp- }
--
./script.cpp-
./script.cpp: case OP_2OVER:
./script.cpp- {
./script.cpp: // (x1 x2 x3 x4 -- x1 x2 x3 x4 x1 x2)
./script.cpp: if (stack.size() < 4)
./script.cpp- return false;
./script.cpp: valtype vch1 = stacktop(-4);
./script.cpp: valtype vch2 = stacktop(-3);
./script.cpp: stack.push_back(vch1);
./script.cpp: stack.push_back(vch2);
./script.cpp- }
--
./script.cpp-
./script.cpp: case OP_2ROT:
./script.cpp- {
./script.cpp: // (x1 x2 x3 x4 x5 x6 -- x3 x4 x5 x6 x1 x2)
./script.cpp: if (stack.size() < 6)
./script.cpp- return false;
./script.cpp: valtype vch1 = stacktop(-6);
./script.cpp: valtype vch2 = stacktop(-5);
./script.cpp: stack.erase(stack.end()-6, stack.end()-4);
./script.cpp: stack.push_back(vch1);
./script.cpp: stack.push_back(vch2);
./script.cpp- }
--
./script.cpp-
./script.cpp: case OP_2SWAP:
./script.cpp- {
./script.cpp: // (x1 x2 x3 x4 -- x3 x4 x1 x2)
./script.cpp: if (stack.size() < 4)
./script.cpp- return false;
./script.cpp: swap(stacktop(-4), stacktop(-2));
./script.cpp: swap(stacktop(-3), stacktop(-1));
./script.cpp- }
--
./script.cpp- {
./script.cpp: // (x - 0 | x x)
./script.cpp: if (stack.size() < 1)
./script.cpp- return false;
./script.cpp: valtype vch = stacktop(-1);
./script.cpp- if (CastToBool(vch))
--
./script.cpp- // (x -- )
./script.cpp: if (stack.size() < 1)
./script.cpp- return false;
--
./script.cpp- // (x -- x x)
./script.cpp: if (stack.size() < 1)
./script.cpp- return false;
./script.cpp: valtype vch = stacktop(-1);
./script.cpp- stack.push_back(vch);
--
./script.cpp- {
./script.cpp: // (x1 x2 -- x2)
./script.cpp: if (stack.size() < 2)
./script.cpp- return false;
./script.cpp: stack.erase(stack.end() - 2);
./script.cpp- }
--
./script.cpp- {
./script.cpp: // (x1 x2 -- x1 x2 x1)
./script.cpp: if (stack.size() < 2)
./script.cpp- return false;
./script.cpp: valtype vch = stacktop(-2);
./script.cpp- stack.push_back(vch);
--
./script.cpp- {
./script.cpp: // (xn ... x2 x1 x0 n - xn ... x2 x1 x0 xn)
./script.cpp: // (xn ... x2 x1 x0 n - ... x2 x1 x0 xn)
./script.cpp: if (stack.size() < 2)
./script.cpp- return false;
./script.cpp: int n = CastToBigNum(stacktop(-1)).getint();
./script.cpp- popstack(stack);
./script.cpp: if (n < 0 || n >= stack.size())
./script.cpp- return false;
./script.cpp: valtype vch = stacktop(-n-1);
./script.cpp- if (opcode == OP_ROLL)
./script.cpp: stack.erase(stack.end()-n-1);
./script.cpp- stack.push_back(vch);
--
./script.cpp- {
./script.cpp: // (x1 x2 x3 -- x2 x3 x1)
./script.cpp: // x2 x1 x3 after first swap
./script.cpp: // x2 x3 x1 after second swap
./script.cpp: if (stack.size() < 3)
./script.cpp- return false;
./script.cpp: swap(stacktop(-3), stacktop(-2));
./script.cpp: swap(stacktop(-2), stacktop(-1));
./script.cpp- }
--
./script.cpp- {
./script.cpp: // (x1 x2 -- x2 x1)
./script.cpp: if (stack.size() < 2)
./script.cpp- return false;
./script.cpp: swap(stacktop(-2), stacktop(-1));
./script.cpp- }
--
./script.cpp- {
./script.cpp: // (x1 x2 -- x2 x1 x2)
./script.cpp: if (stack.size() < 2)
./script.cpp- return false;
./script.cpp: valtype vch = stacktop(-1);
./script.cpp: stack.insert(stack.end()-2, vch);
./script.cpp- }
--
./script.cpp- {
./script.cpp: // (x1 x2 -- out)
./script.cpp: if (stack.size() < 2)
./script.cpp- return false;
./script.cpp: valtype& vch1 = stacktop(-2);
./script.cpp: valtype& vch2 = stacktop(-1);
./script.cpp: vch1.insert(vch1.end(), vch2.begin(), vch2.end());
./script.cpp- popstack(stack);
./script.cpp: if (stacktop(-1).size() > 520)
./script.cpp- return false;
--
./script.cpp- // (in begin size -- out)
./script.cpp: if (stack.size() < 3)
./script.cpp- return false;
./script.cpp: valtype& vch = stacktop(-3);
./script.cpp: int nBegin = CastToBigNum(stacktop(-2)).getint();
./script.cpp: int nEnd = nBegin + CastToBigNum(stacktop(-1)).getint();
./script.cpp: if (nBegin < 0 || nEnd < nBegin)
./script.cpp- return false;
--
./script.cpp- // (in size -- out)
./script.cpp: if (stack.size() < 2)
./script.cpp- return false;
./script.cpp: valtype& vch = stacktop(-2);
./script.cpp: int nSize = CastToBigNum(stacktop(-1)).getint();
./script.cpp: if (nSize < 0)
./script.cpp- return false;
--
./script.cpp- {
./script.cpp: // (x1 x2 - out)
./script.cpp: if (stack.size() < 2)
./script.cpp- return false;
./script.cpp: valtype& vch1 = stacktop(-2);
./script.cpp: valtype& vch2 = stacktop(-1);
./script.cpp: MakeSameSize(vch1, vch2);
./script.cpp- if (opcode == OP_AND)
./script.cpp- {
./script.cpp: for (int i = 0; i < vch1.size(); i++)
./script.cpp: vch1[i] &= vch2[i];
./script.cpp- }
--
./script.cpp- {
./script.cpp: for (int i = 0; i < vch1.size(); i++)
./script.cpp: vch1[i] |= vch2[i];
./script.cpp- }
--
./script.cpp- {
./script.cpp: for (int i = 0; i < vch1.size(); i++)
./script.cpp: vch1[i] ^= vch2[i];
./script.cpp- }
--
./script.cpp- {
./script.cpp: // (x1 x2 - bool)
./script.cpp: if (stack.size() < 2)
./script.cpp- return false;
./script.cpp: valtype& vch1 = stacktop(-2);
./script.cpp: valtype& vch2 = stacktop(-1);
./script.cpp: bool fEqual = (vch1 == vch2);
./script.cpp- // OP_NOTEQUAL is disabled because it would be too easy to say
./script.cpp: // something like n != 1 and have some wiseguy pass in 1 with extra
./script.cpp: // zero bytes after it (numerically, 0x01 == 0x0001 == 0x000001)
./script.cpp- //if (opcode == OP_NOTEQUAL)
--
./script.cpp- //
./script.cpp: case OP_1ADD:
./script.cpp: case OP_1SUB:
./script.cpp: case OP_2MUL:
./script.cpp: case OP_2DIV:
./script.cpp- case OP_NEGATE:
--
./script.cpp- case OP_NOT:
./script.cpp: case OP_0NOTEQUAL:
./script.cpp- {
./script.cpp- // (in -- out)
./script.cpp: if (stack.size() < 1)
./script.cpp- return false;
./script.cpp: CBigNum bn = CastToBigNum(stacktop(-1));
./script.cpp- switch (opcode)
./script.cpp- {
./script.cpp: case OP_1ADD: bn += bnOne; break;
./script.cpp: case OP_1SUB: bn -= bnOne; break;
./script.cpp: case OP_2MUL: bn <<= 1; break;
./script.cpp: case OP_2DIV: bn >>= 1; break;
./script.cpp- case OP_NEGATE: bn = -bn; break;
--
./script.cpp- case OP_NOT: bn = (bn == bnZero); break;
./script.cpp: case OP_0NOTEQUAL: bn = (bn != bnZero); break;
./script.cpp- default: assert(!"invalid opcode"); break;
--
./script.cpp- {
./script.cpp: // (x1 x2 -- out)
./script.cpp: if (stack.size() < 2)
./script.cpp- return false;
./script.cpp: CBigNum bn1 = CastToBigNum(stacktop(-2));
./script.cpp: CBigNum bn2 = CastToBigNum(stacktop(-1));
./script.cpp- CBigNum bn;
--
./script.cpp- case OP_ADD:
./script.cpp: bn = bn1 + bn2;
./script.cpp- break;
--
./script.cpp- case OP_SUB:
./script.cpp: bn = bn1 - bn2;
./script.cpp- break;
--
./script.cpp- case OP_MUL:
./script.cpp: if (!BN_mul(&bn, &bn1, &bn2, pctx))
./script.cpp- return false;
--
./script.cpp- case OP_DIV:
./script.cpp: if (!BN_div(&bn, NULL, &bn1, &bn2, pctx))
./script.cpp- return false;
--
./script.cpp- case OP_MOD:
./script.cpp: if (!BN_mod(&bn, &bn1, &bn2, pctx))
./script.cpp- return false;
--
./script.cpp- case OP_LSHIFT:
./script.cpp: if (bn2 < bnZero || bn2 > CBigNum(2048))
./script.cpp- return false;
./script.cpp: bn = bn1 << bn2.getulong();
./script.cpp- break;
--
./script.cpp- case OP_RSHIFT:
./script.cpp: if (bn2 < bnZero || bn2 > CBigNum(2048))
./script.cpp- return false;
./script.cpp: bn = bn1 >> bn2.getulong();
./script.cpp- break;
./script.cpp-
./script.cpp: case OP_BOOLAND: bn = (bn1 != bnZero && bn2 != bnZero); break;
./script.cpp: case OP_BOOLOR: bn = (bn1 != bnZero || bn2 != bnZero); break;
./script.cpp: case OP_NUMEQUAL: bn = (bn1 == bn2); break;
./script.cpp: case OP_NUMEQUALVERIFY: bn = (bn1 == bn2); break;
./script.cpp: case OP_NUMNOTEQUAL: bn = (bn1 != bn2); break;
./script.cpp: case OP_LESSTHAN: bn = (bn1 < bn2); break;
./script.cpp: case OP_GREATERTHAN: bn = (bn1 > bn2); break;
./script.cpp: case OP_LESSTHANOREQUAL: bn = (bn1 <= bn2); break;
./script.cpp: case OP_GREATERTHANOREQUAL: bn = (bn1 >= bn2); break;
./script.cpp: case OP_MIN: bn = (bn1 < bn2 ? bn1 : bn2); break;
./script.cpp: case OP_MAX: bn = (bn1 > bn2 ? bn1 : bn2); break;
./script.cpp- default: assert(!"invalid opcode"); break;
--
./script.cpp- {
./script.cpp: if (CastToBool(stacktop(-1)))
./script.cpp- popstack(stack);
--
./script.cpp- // (x min max -- out)
./script.cpp: if (stack.size() < 3)
./script.cpp- return false;
./script.cpp: CBigNum bn1 = CastToBigNum(stacktop(-3));
./script.cpp: CBigNum bn2 = CastToBigNum(stacktop(-2));
./script.cpp: CBigNum bn3 = CastToBigNum(stacktop(-1));
./script.cpp: bool fValue = (bn2 <= bn1 && bn1 < bn3);
./script.cpp- popstack(stack);
--
./script.cpp: valtype& vch = stacktop(-1);
./script.cpp: valtype vchHash( (opcode == OP_RIPEMD160 || opcode == OP_SHA1 || opcode == OP_HASH160) ? 20 : 32);
--
./script.cpp- int nKeysCount = CastToBigNum(stacktop(-i)).getint();
./script.cpp: if (nKeysCount < 0 || nKeysCount > 20)
./script.cpp- return false;
./script.cpp- nOpCount += nKeysCount;
./script.cpp: if (nOpCount > 201)
./script.cpp- return false;
--
./script.cpp- // Size limits
./script.cpp: if (stack.size() + altstack.size() > 1000)
./script.cpp- return false;
--
./script.cpp- // Blank out some of the outputs
./script.cpp: if ( (nHashType & 0x1f) == SIGHASH_NONE)
./script.cpp- {
--
./script.cpp- CDataStream ss(SER_GETHASH);
./script.cpp: ss.reserve(10000);
./script.cpp- ss << txTmp << nHashType;
--
./script.cpp: if (opcode2 == OP_PUBKEY)
./script.cpp- {
./script.cpp: if (vch1.size() < 33 || vch1.size() > 120)
./script.cpp- break;
./script.cpp: vSolutionRet.push_back(make_pair(opcode2, vch1));
--
./makefile.unix-#
./makefile.unix: # This is a workaround for Ubuntu bug #691722, the default -fstack-protector causes
./makefile.unix- # -fstack-protector-all to be ignored unless -fno-stack-protector is used first.
./makefile.unix: # see: https://bugs.launchpad.net/ubuntu/+source/gcc-4.5/+bug/691722
./makefile.unix- HARDENING=-fno-stack-protector
--
./makefile.unix-
./makefile.unix: # -D_FORTIFY_SOURCE=2 does some checking for potentially exploitable code patterns in
./makefile.unix- # the source such overflowing a statically defined buffer.
./makefile.unix: HARDENING+=-D_FORTIFY_SOURCE=2
./makefile.unix-#
--
./bitcoinrpc.cpp-#define printf OutputDebugStringF
./bitcoinrpc.cpp:// MinGW 3.4.5 gets "fatal error: had to relocate PCH" if the json headers are
./bitcoinrpc.cpp-// precompiled in headers.h. The problem might be when the pch file goes over
./bitcoinrpc.cpp:// a certain size around 145MB. If we need access to json_spirit outside this
./bitcoinrpc.cpp-// file, we could use the compiled json_spirit option.
--
./bitcoinrpc.cpp-{
./bitcoinrpc.cpp: char buffer[50000];
./bitcoinrpc.cpp- int limit = sizeof(buffer);
--
./bitcoinrpc.cpp-
./bitcoinrpc.cpp:int64 AmountFromValue(const Value& value)
./bitcoinrpc.cpp-{
./bitcoinrpc.cpp- double dAmount = value.get_real();
./bitcoinrpc.cpp: if (dAmount <= 0.0 || dAmount > 21000000.0)
./bitcoinrpc.cpp: throw JSONRPCError(-3, "Invalid amount");
./bitcoinrpc.cpp: int64 nAmount = roundint64(dAmount * COIN);
./bitcoinrpc.cpp- if (!MoneyRange(nAmount))
./bitcoinrpc.cpp: throw JSONRPCError(-3, "Invalid amount");
./bitcoinrpc.cpp- return nAmount;
--
./bitcoinrpc.cpp- if (strAccount == "*")
./bitcoinrpc.cpp: throw JSONRPCError(-11, "Invalid account name");
./bitcoinrpc.cpp- return strAccount;
--
./bitcoinrpc.cpp- // Floating point number that is a multiple of the minimum difficulty,
./bitcoinrpc.cpp: // minimum difficulty = 1.0.
./bitcoinrpc.cpp-
./bitcoinrpc.cpp- if (pindexBest == NULL)
./bitcoinrpc.cpp: return 1.0;
./bitcoinrpc.cpp: int nShift = (pindexBest->nBits >> 24) & 0xff;
./bitcoinrpc.cpp-
./bitcoinrpc.cpp- double dDiff =
./bitcoinrpc.cpp: (double)0x0000ffff / (double)(pindexBest->nBits & 0x00ffffff);
./bitcoinrpc.cpp-
./bitcoinrpc.cpp: while (nShift < 29)
./bitcoinrpc.cpp- {
./bitcoinrpc.cpp: dDiff *= 256.0;
./bitcoinrpc.cpp- nShift++;
./bitcoinrpc.cpp- }
./bitcoinrpc.cpp: while (nShift > 29)
./bitcoinrpc.cpp- {
./bitcoinrpc.cpp: dDiff /= 256.0;
./bitcoinrpc.cpp- nShift--;
--
./bitcoinrpc.cpp-{
./bitcoinrpc.cpp: if (fHelp || params.size() < 1 || params.size() > 2)
./bitcoinrpc.cpp- throw runtime_error(
--
./bitcoinrpc.cpp-
./bitcoinrpc.cpp: if (GetTimeMillis() - nHPSTimerStart > 8000)
./bitcoinrpc.cpp: return (boost::int64_t)0;
./bitcoinrpc.cpp: return (boost::int64_t)dHashesPerSec;
./bitcoinrpc.cpp-}
--
./bitcoinrpc.cpp- if (pwalletMain->IsCrypted())
./bitcoinrpc.cpp: obj.push_back(Pair("unlocked_until", (boost::int64_t)nWalletUnlockTime / 1000));
./bitcoinrpc.cpp- obj.push_back(Pair("errors", GetWarnings("statusbar")));
--
./bitcoinrpc.cpp- if (!pwalletMain->GetKeyFromPool(newKey, false))
./bitcoinrpc.cpp: throw JSONRPCError(-12, "Error: Keypool ran out, please call keypoolrefill first");
./bitcoinrpc.cpp- CBitcoinAddress address(newKey);
--
./bitcoinrpc.cpp- if (!pwalletMain->GetKeyFromPool(account.vchPubKey, false))
./bitcoinrpc.cpp: throw JSONRPCError(-12, "Error: Keypool ran out, please call keypoolrefill first");
./bitcoinrpc.cpp-
--
./bitcoinrpc.cpp-{
./bitcoinrpc.cpp: if (fHelp || params.size() < 1 || params.size() > 2)
./bitcoinrpc.cpp- throw runtime_error(
--
./bitcoinrpc.cpp-{
./bitcoinrpc.cpp: if (fHelp || params.size() < 1 || params.size() > 1)
./bitcoinrpc.cpp- throw runtime_error(
./bitcoinrpc.cpp- "settxfee \n"
./bitcoinrpc.cpp: " is a real and is rounded to the nearest 0.00000001");
--
./bitcoinrpc.cpp-{
./bitcoinrpc.cpp: if (pwalletMain->IsCrypted() && (fHelp || params.size() < 2 || params.size() > 4))
./bitcoinrpc.cpp- throw runtime_error(
./bitcoinrpc.cpp- "sendtoaddress [comment] [comment-to]\n"
./bitcoinrpc.cpp: " is a real and is rounded to the nearest 0.00000001\n"
./bitcoinrpc.cpp- "requires wallet passphrase to be set with walletpassphrase first");
./bitcoinrpc.cpp: if (!pwalletMain->IsCrypted() && (fHelp || params.size() < 2 || params.size() > 4))
./bitcoinrpc.cpp- throw runtime_error(
./bitcoinrpc.cpp- "sendtoaddress [comment] [comment-to]\n"
./bitcoinrpc.cpp: " is a real and is rounded to the nearest 0.00000001");
./bitcoinrpc.cpp-
--
./bitcoinrpc.cpp- if (pwalletMain->IsLocked())
./bitcoinrpc.cpp: throw JSONRPCError(-13, "Error: Please enter the wallet passphrase with walletpassphrase first.");
./bitcoinrpc.cpp-
--
./bitcoinrpc.cpp- if (strError != "")
./bitcoinrpc.cpp: throw JSONRPCError(-4, strError);
./bitcoinrpc.cpp-
--
./bitcoinrpc.cpp-{
./bitcoinrpc.cpp: if (fHelp || params.size() != 2)
./bitcoinrpc.cpp- throw runtime_error(
--
./bitcoinrpc.cpp- if (pwalletMain->IsLocked())
./bitcoinrpc.cpp: throw JSONRPCError(-13, "Error: Please enter the wallet passphrase with walletpassphrase first.");
--
./bitcoinrpc.cpp- if (!addr.IsValid())
./bitcoinrpc.cpp: throw JSONRPCError(-3, "Invalid address");
./bitcoinrpc.cpp-
--
./bitcoinrpc.cpp- if (!pwalletMain->GetKey(addr, key))
./bitcoinrpc.cpp: throw JSONRPCError(-4, "Private key not available");
./bitcoinrpc.cpp-
--
./bitcoinrpc.cpp- if (!key.SignCompact(Hash(ss.begin(), ss.end()), vchSig))
./bitcoinrpc.cpp: throw JSONRPCError(-5, "Sign failed");
--
./bitcoinrpc.cpp-{
./bitcoinrpc.cpp: if (fHelp || params.size() != 3)
./bitcoinrpc.cpp- throw runtime_error(
--
./bitcoinrpc.cpp- if (!addr.IsValid())
./bitcoinrpc.cpp: throw JSONRPCError(-3, "Invalid address");
--
./bitcoinrpc.cpp-{
./bitcoinrpc.cpp: if (fHelp || params.size() < 1 || params.size() > 2)
./bitcoinrpc.cpp- throw runtime_error(
./bitcoinrpc.cpp: "getreceivedbyaddress [minconf=1]\n"
./bitcoinrpc.cpp- "Returns the total amount received by in transactions with at least [minconf] confirmations.");
--
./bitcoinrpc.cpp- if (!address.IsValid())
./bitcoinrpc.cpp: throw JSONRPCError(-5, "Invalid bitcoin address");
./bitcoinrpc.cpp- scriptPubKey.SetBitcoinAddress(address);
./bitcoinrpc.cpp- if (!IsMine(*pwalletMain,scriptPubKey))
./bitcoinrpc.cpp: return (double)0.0;
--
./bitcoinrpc.cpp-{
./bitcoinrpc.cpp: if (fHelp || params.size() < 1 || params.size() > 2)
./bitcoinrpc.cpp- throw runtime_error(
./bitcoinrpc.cpp: "getreceivedbyaccount [minconf=1]\n"
./bitcoinrpc.cpp- "Returns the total amount received by addresses with in transactions with at least [minconf] confirmations.");
--
./bitcoinrpc.cpp-{
./bitcoinrpc.cpp: if (fHelp || params.size() > 2)
./bitcoinrpc.cpp- throw runtime_error(
./bitcoinrpc.cpp: "getbalance [account] [minconf=1]\n"
./bitcoinrpc.cpp- "If [account] is not specified, returns the server's total available balance.\n"
--
./bitcoinrpc.cpp-{
./bitcoinrpc.cpp: if (fHelp || params.size() < 3 || params.size() > 5)
./bitcoinrpc.cpp- throw runtime_error(
./bitcoinrpc.cpp: "move [minconf=1] [comment]\n"
./bitcoinrpc.cpp- "Move from one account in your wallet to another.");
./bitcoinrpc.cpp-
./bitcoinrpc.cpp: string strFrom = AccountFromValue(params[0]);
./bitcoinrpc.cpp: string strTo = AccountFromValue(params[1]);
./bitcoinrpc.cpp: int64 nAmount = AmountFromValue(params[2]);
./bitcoinrpc.cpp: if (params.size() > 3)
./bitcoinrpc.cpp- // unused parameter, used to be nMinDepth, keep type-checking it though
./bitcoinrpc.cpp: (void)params[3].get_int();
./bitcoinrpc.cpp- string strComment;
./bitcoinrpc.cpp: if (params.size() > 4)
./bitcoinrpc.cpp: strComment = params[4].get_str();
./bitcoinrpc.cpp-
--
./bitcoinrpc.cpp-{
./bitcoinrpc.cpp: if (pwalletMain->IsCrypted() && (fHelp || params.size() < 3 || params.size() > 6))
./bitcoinrpc.cpp- throw runtime_error(
./bitcoinrpc.cpp: "sendfrom [minconf=1] [comment] [comment-to]\n"
./bitcoinrpc.cpp: " is a real and is rounded to the nearest 0.00000001\n"
./bitcoinrpc.cpp- "requires wallet passphrase to be set with walletpassphrase first");
./bitcoinrpc.cpp: if (!pwalletMain->IsCrypted() && (fHelp || params.size() < 3 || params.size() > 6))
./bitcoinrpc.cpp- throw runtime_error(
./bitcoinrpc.cpp: "sendfrom [minconf=1] [comment] [comment-to]\n"
./bitcoinrpc.cpp: " is a real and is rounded to the nearest 0.00000001");
--
./bitcoinrpc.cpp- if (nAmount > nBalance)
./bitcoinrpc.cpp: throw JSONRPCError(-6, "Account has insufficient funds");
./bitcoinrpc.cpp-
--
./bitcoinrpc.cpp- if (strError != "")
./bitcoinrpc.cpp: throw JSONRPCError(-4, strError);
./bitcoinrpc.cpp-
--
./bitcoinrpc.cpp-{
./bitcoinrpc.cpp: if (pwalletMain->IsCrypted() && (fHelp || params.size() < 2 || params.size() > 4))
./bitcoinrpc.cpp- throw runtime_error(
./bitcoinrpc.cpp: "sendmany {address:amount,...} [minconf=1] [comment]\n"
./bitcoinrpc.cpp- "amounts are double-precision floating point numbers\n"
./bitcoinrpc.cpp- "requires wallet passphrase to be set with walletpassphrase first");
./bitcoinrpc.cpp: if (!pwalletMain->IsCrypted() && (fHelp || params.size() < 2 || params.size() > 4))
./bitcoinrpc.cpp- throw runtime_error(
./bitcoinrpc.cpp: "sendmany {address:amount,...} [minconf=1] [comment]\n"
./bitcoinrpc.cpp- "amounts are double-precision floating point numbers");
--
./bitcoinrpc.cpp- wtx.strFromAccount = strAccount;
./bitcoinrpc.cpp: if (params.size() > 3 && params[3].type() != null_type && !params[3].get_str().empty())
./bitcoinrpc.cpp: wtx.mapValue["comment"] = params[3].get_str();
--
./bitcoinrpc.cpp- if (!address.IsValid())
./bitcoinrpc.cpp: throw JSONRPCError(-5, string("Invalid bitcoin address:")+s.name_);
./bitcoinrpc.cpp-
./bitcoinrpc.cpp- if (setAddress.count(address))
./bitcoinrpc.cpp: throw JSONRPCError(-8, string("Invalid parameter, duplicated address: ")+s.name_);
./bitcoinrpc.cpp- setAddress.insert(address);
--
./bitcoinrpc.cpp- if (pwalletMain->IsLocked())
./bitcoinrpc.cpp: throw JSONRPCError(-13, "Error: Please enter the wallet passphrase with walletpassphrase first.");
./bitcoinrpc.cpp-
./bitcoinrpc.cpp- // Check funds
./bitcoinrpc.cpp: int64 nBalance = GetAccountBalance(strAccount, nMinDepth);
./bitcoinrpc.cpp- if (totalAmount > nBalance)
./bitcoinrpc.cpp: throw JSONRPCError(-6, "Account has insufficient funds");
./bitcoinrpc.cpp-
--
./bitcoinrpc.cpp- if (totalAmount + nFeeRequired > pwalletMain->GetBalance())
./bitcoinrpc.cpp: throw JSONRPCError(-6, "Insufficient funds");
./bitcoinrpc.cpp: throw JSONRPCError(-4, "Transaction creation failed");
./bitcoinrpc.cpp- }
./bitcoinrpc.cpp- if (!pwalletMain->CommitTransaction(wtx, keyChange))
./bitcoinrpc.cpp: throw JSONRPCError(-4, "Transaction commit failed");
./bitcoinrpc.cpp-
--
./bitcoinrpc.cpp-{
./bitcoinrpc.cpp: if (fHelp || params.size() > 3)
./bitcoinrpc.cpp- throw runtime_error(
./bitcoinrpc.cpp: "listtransactions [account] [count=10] [from=0]\n"
./bitcoinrpc.cpp- "Returns up to [count] most recent transactions skipping the first [from] transactions for account [account].");
--
./bitcoinrpc.cpp- string strAccount = "*";
./bitcoinrpc.cpp: if (params.size() > 0)
./bitcoinrpc.cpp: strAccount = params[0].get_str();
./bitcoinrpc.cpp: int nCount = 10;
./bitcoinrpc.cpp: if (params.size() > 1)
./bitcoinrpc.cpp: nCount = params[1].get_int();
./bitcoinrpc.cpp: int nFrom = 0;
./bitcoinrpc.cpp: if (params.size() > 2)
./bitcoinrpc.cpp: nFrom = params[2].get_int();
./bitcoinrpc.cpp-
--
./bitcoinrpc.cpp: if (target_confirms < 1)
./bitcoinrpc.cpp: throw JSONRPCError(-8, "Invalid parameter");
./bitcoinrpc.cpp- }
--
./bitcoinrpc.cpp- if (!pwalletMain->mapWallet.count(hash))
./bitcoinrpc.cpp: throw JSONRPCError(-5, "Invalid or non-wallet transaction id");
./bitcoinrpc.cpp- const CWalletTx& wtx = pwalletMain->mapWallet[hash];
--
./bitcoinrpc.cpp- if (pwalletMain->IsLocked())
./bitcoinrpc.cpp: throw JSONRPCError(-13, "Error: Please enter the wallet passphrase with walletpassphrase first.");
./bitcoinrpc.cpp-
--
./bitcoinrpc.cpp-
./bitcoinrpc.cpp: if (pwalletMain->GetKeyPoolSize() < GetArg("-keypool", 100))
./bitcoinrpc.cpp: throw JSONRPCError(-4, "Error refreshing keypool.");
./bitcoinrpc.cpp-
--
./bitcoinrpc.cpp-{
./bitcoinrpc.cpp: int64 nMyWakeTime = GetTimeMillis() + *( (int64*)parg) * 1000;
./bitcoinrpc.cpp-
--
./bitcoinrpc.cpp-
./bitcoinrpc.cpp: } while(1);
./bitcoinrpc.cpp-
--
./bitcoinrpc.cpp- if (!pwalletMain->IsCrypted())
./bitcoinrpc.cpp: throw JSONRPCError(-15, "Error: running with an unencrypted wallet, but walletpassphrase was called.");
./bitcoinrpc.cpp-
./bitcoinrpc.cpp- if (!pwalletMain->IsLocked())
./bitcoinrpc.cpp: throw JSONRPCError(-17, "Error: Wallet is already unlocked.");
./bitcoinrpc.cpp-
./bitcoinrpc.cpp: // Note that the walletpassphrase is stored in params[0] which is not mlock()ed
./bitcoinrpc.cpp- SecureString strWalletPass;
./bitcoinrpc.cpp: strWalletPass.reserve(100);
./bitcoinrpc.cpp- // TODO: get rid of this .c_str() by implementing SecureString::operator=(std::string)
./bitcoinrpc.cpp: // Alternately, find a way to make params[0] mlock()'d to begin with.
./bitcoinrpc.cpp: strWalletPass = params[0].get_str().c_str();
./bitcoinrpc.cpp-
./bitcoinrpc.cpp: if (strWalletPass.length() > 0)
./bitcoinrpc.cpp- {
./bitcoinrpc.cpp- if (!pwalletMain->Unlock(strWalletPass))
./bitcoinrpc.cpp: throw JSONRPCError(-14, "Error: The wallet passphrase entered was incorrect.");
./bitcoinrpc.cpp- }
--
./bitcoinrpc.cpp- if (!pwalletMain->IsCrypted())
./bitcoinrpc.cpp: throw JSONRPCError(-15, "Error: running with an unencrypted wallet, but walletpassphrasechange was called.");
./bitcoinrpc.cpp-
./bitcoinrpc.cpp- // TODO: get rid of these .c_str() calls by implementing SecureString::operator=(std::string)
./bitcoinrpc.cpp: // Alternately, find a way to make params[0] mlock()'d to begin with.
./bitcoinrpc.cpp- SecureString strOldWalletPass;
./bitcoinrpc.cpp: strOldWalletPass.reserve(100);
./bitcoinrpc.cpp: strOldWalletPass = params[0].get_str().c_str();
./bitcoinrpc.cpp-
./bitcoinrpc.cpp- SecureString strNewWalletPass;
./bitcoinrpc.cpp: strNewWalletPass.reserve(100);
./bitcoinrpc.cpp: strNewWalletPass = params[1].get_str().c_str();
./bitcoinrpc.cpp-
./bitcoinrpc.cpp: if (strOldWalletPass.length() < 1 || strNewWalletPass.length() < 1)
./bitcoinrpc.cpp- throw runtime_error(
--
./bitcoinrpc.cpp- if (!pwalletMain->ChangeWalletPassphrase(strOldWalletPass, strNewWalletPass))
./bitcoinrpc.cpp: throw JSONRPCError(-14, "Error: The wallet passphrase entered was incorrect.");
./bitcoinrpc.cpp-
--
./bitcoinrpc.cpp- if (!pwalletMain->IsCrypted())
./bitcoinrpc.cpp: throw JSONRPCError(-15, "Error: running with an unencrypted wallet, but walletlock was called.");
./bitcoinrpc.cpp-
--
./bitcoinrpc.cpp- if (pwalletMain->IsCrypted())
./bitcoinrpc.cpp: throw JSONRPCError(-15, "Error: running with an encrypted wallet, but encryptwallet was called.");
./bitcoinrpc.cpp-
./bitcoinrpc.cpp- // TODO: get rid of this .c_str() by implementing SecureString::operator=(std::string)
./bitcoinrpc.cpp: // Alternately, find a way to make params[0] mlock()'d to begin with.
./bitcoinrpc.cpp- SecureString strWalletPass;
./bitcoinrpc.cpp: strWalletPass.reserve(100);
./bitcoinrpc.cpp: strWalletPass = params[0].get_str().c_str();
--
./bitcoinrpc.cpp- if (!pwalletMain->EncryptWallet(strWalletPass))
./bitcoinrpc.cpp: throw JSONRPCError(-16, "Error: Failed to encrypt the wallet.");
./bitcoinrpc.cpp-
--
./bitcoinrpc.cpp- if (vNodes.empty())
./bitcoinrpc.cpp: throw JSONRPCError(-9, "Bitcoin is not connected!");
./bitcoinrpc.cpp-
./bitcoinrpc.cpp- if (IsInitialBlockDownload())
./bitcoinrpc.cpp: throw JSONRPCError(-10, "Bitcoin is downloading blocks...");
--
./bitcoinrpc.cpp- if (pindexPrev != pindexBest ||
./bitcoinrpc.cpp: (nTransactionsUpdated != nTransactionsUpdatedLast && GetTime() - nStart > 60))
./bitcoinrpc.cpp- {
--
./bitcoinrpc.cpp- if (!pblock)
./bitcoinrpc.cpp: throw JSONRPCError(-7, "Out of memory");
./bitcoinrpc.cpp- vNewBlock.push_back(pblock);
--
./bitcoinrpc.cpp- // Prebuild hash buffers
./bitcoinrpc.cpp: char pmidstate[32];
./bitcoinrpc.cpp: char pdata[128];
./bitcoinrpc.cpp: char phash1[64];
./bitcoinrpc.cpp: FormatHashBuffers(pblock, pmidstate, pdata, phash1);
--
./bitcoinrpc.cpp- // Parse parameters
./bitcoinrpc.cpp: vector vchData = ParseHex(params[0].get_str());
./bitcoinrpc.cpp: if (vchData.size() != 128)
./bitcoinrpc.cpp: throw JSONRPCError(-8, "Invalid parameter");
./bitcoinrpc.cpp: CBlock* pdata = (CBlock*)&vchData[0];
./bitcoinrpc.cpp-
./bitcoinrpc.cpp- // Byte reverse
./bitcoinrpc.cpp: for (int i = 0; i < 128/4; i++)
./bitcoinrpc.cpp- ( (unsigned int*)pdata)[i] = ByteReverse( ( (unsigned int*)pdata)[i]);
--
./bitcoinrpc.cpp- if (vNodes.empty())
./bitcoinrpc.cpp: throw JSONRPCError(-9, "Bitcoin is not connected!");
./bitcoinrpc.cpp-
./bitcoinrpc.cpp- if (IsInitialBlockDownload())
./bitcoinrpc.cpp: throw JSONRPCError(-10, "Bitcoin is downloading blocks...");
./bitcoinrpc.cpp-
--
./bitcoinrpc.cpp- if (!pblock)
./bitcoinrpc.cpp: throw JSONRPCError(-7, "Out of memory");
./bitcoinrpc.cpp- }
--
./bitcoinrpc.cpp-
./bitcoinrpc.cpp:string rfc1123Time()
./bitcoinrpc.cpp-{
./bitcoinrpc.cpp: char buffer[64];
./bitcoinrpc.cpp- time_t now;
--
./bitcoinrpc.cpp-{
./bitcoinrpc.cpp: if (nStatus == 401)
./bitcoinrpc.cpp: return strprintf("HTTP/1.0 401 Authorization Required\r\n"
./bitcoinrpc.cpp- "Date: %s\r\n"
--
./bitcoinrpc.cpp- "Content-Type: text/html\r\n"
./bitcoinrpc.cpp: "Content-Length: 296\r\n"
./bitcoinrpc.cpp- "\r\n"
./bitcoinrpc.cpp: " ./bitcoinrpc.cpp: "\"http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd\">\r\n"
./bitcoinrpc.cpp- "\r\n"
--
./bitcoinrpc.cpp- "Error\r\n"
./bitcoinrpc.cpp: "\r\n"
./bitcoinrpc.cpp- "\r\n"
./bitcoinrpc.cpp: "

401 Unauthorized.

\r\n"
./bitcoinrpc.cpp: "\r\n", rfc1123Time().c_str(), FormatFullVersion().c_str());
./bitcoinrpc.cpp- const char *cStatus;
./bitcoinrpc.cpp: if (nStatus == 200) cStatus = "OK";
./bitcoinrpc.cpp: else if (nStatus == 400) cStatus = "Bad Request";
./bitcoinrpc.cpp: else if (nStatus == 403) cStatus = "Forbidden";
./bitcoinrpc.cpp: else if (nStatus == 404) cStatus = "Not Found";
./bitcoinrpc.cpp: else if (nStatus == 500) cStatus = "Internal Server Error";
./bitcoinrpc.cpp- else cStatus = "";
./bitcoinrpc.cpp- return strprintf(
./bitcoinrpc.cpp: "HTTP/1.1 %d %s\r\n"
./bitcoinrpc.cpp- "Date: %s\r\n"
--
./bitcoinrpc.cpp- boost::split(vWords, str, boost::is_any_of(" "));
./bitcoinrpc.cpp: if (vWords.size() < 2)
./bitcoinrpc.cpp: return 500;
./bitcoinrpc.cpp: return atoi(vWords[1].c_str());
./bitcoinrpc.cpp-}
--
./bitcoinrpc.cpp- int nLen = ReadHTTPHeader(stream, mapHeadersRet);
./bitcoinrpc.cpp: if (nLen < 0 || nLen > MAX_SIZE)
./bitcoinrpc.cpp: return 500;
--
./bitcoinrpc.cpp- string strAuth = mapHeaders["authorization"];
./bitcoinrpc.cpp: if (strAuth.substr(0,6) != "Basic ")
./bitcoinrpc.cpp- return false;
./bitcoinrpc.cpp: string strUserPass64 = strAuth.substr(6); boost::trim(strUserPass64);
./bitcoinrpc.cpp: string strUserPass = DecodeBase64(strUserPass64);
./bitcoinrpc.cpp- return strUserPass == strRPCUserColonPass;
--
./bitcoinrpc.cpp-//
./bitcoinrpc.cpp:// JSON-RPC protocol. Bitcoin speaks version 1.0 for maximum compatibility,
./bitcoinrpc.cpp:// but uses JSON-RPC 1.1/2.0 standards for parts of the 1.0 standard that were
./bitcoinrpc.cpp-// unspecified (HTTP errors and contents of 'error').
./bitcoinrpc.cpp-//
./bitcoinrpc.cpp:// 1.0 spec: http://json-rpc.org/wiki/specification
./bitcoinrpc.cpp:// 1.2 spec: http://groups.google.com/group/json-rpc/web/json-rpc-over-http
./bitcoinrpc.cpp-// http://www.codeproject.com/KB/recipes/JSON_Spirit.aspx
--
./bitcoinrpc.cpp- // Send error reply from json-rpc error object
./bitcoinrpc.cpp: int nStatus = 500;
./bitcoinrpc.cpp- int code = find_value(objError, "code").get_int();
./bitcoinrpc.cpp: if (code == -32600) nStatus = 400;
./bitcoinrpc.cpp: else if (code == -32601) nStatus = 404;
./bitcoinrpc.cpp- string strReply = JSONRPCReply(Value::null, objError, id);
--
./bitcoinrpc.cpp- {
./bitcoinrpc.cpp: vnThreadsRunning[4]++;
./bitcoinrpc.cpp: ThreadRPCServer2(parg);
./bitcoinrpc.cpp: vnThreadsRunning[4]--;
./bitcoinrpc.cpp- }
./bitcoinrpc.cpp- catch (std::exception& e) {
./bitcoinrpc.cpp: vnThreadsRunning[4]--;
./bitcoinrpc.cpp- PrintException(&e, "ThreadRPCServer()");
./bitcoinrpc.cpp- } catch (...) {
./bitcoinrpc.cpp: vnThreadsRunning[4]--;
./bitcoinrpc.cpp- PrintException(NULL, "ThreadRPCServer()");
--
./bitcoinrpc.cpp- {
./bitcoinrpc.cpp: unsigned char rand_pwd[32];
./bitcoinrpc.cpp: RAND_bytes(rand_pwd, 32);
./bitcoinrpc.cpp- string strWhatAmI = "To use bitcoind";
--
./bitcoinrpc.cpp- GetConfigFile().c_str(),
./bitcoinrpc.cpp: EncodeBase58(&rand_pwd[0],&rand_pwd[0]+32).c_str());
./bitcoinrpc.cpp- CreateThread(Shutdown, NULL);
--
./bitcoinrpc.cpp-
./bitcoinrpc.cpp: asio::ip::address bindAddress = mapArgs.count("-rpcallowip") ? asio::ip::address_v4::any() : asio::ip::address_v4::loopback();
./bitcoinrpc.cpp-
./bitcoinrpc.cpp- asio::io_service io_service;
./bitcoinrpc.cpp: ip::tcp::endpoint endpoint(bindAddress, GetArg("-rpcport", 8332));
./bitcoinrpc.cpp- ip::tcp::acceptor acceptor(io_service, endpoint);
--
./bitcoinrpc.cpp- ip::tcp::endpoint peer;
./bitcoinrpc.cpp: vnThreadsRunning[4]--;
./bitcoinrpc.cpp- acceptor.accept(*stream.rdbuf(), peer);
./bitcoinrpc.cpp: vnThreadsRunning[4]++;
./bitcoinrpc.cpp- if (fShutdown)
--
./bitcoinrpc.cpp- // snipsnipsnip
./bitcoinrpc.cpp: // Only send a 403 if we're not using SSL to prevent a DoS during the SSL handshake.
./bitcoinrpc.cpp- //if (!fUseSSL)
./bitcoinrpc.cpp: stream << HTTPReply(403, "") << std::flush;
./bitcoinrpc.cpp- continue;
--
./bitcoinrpc.cpp- boost::thread api_caller(ReadHTTP, boost::ref(stream), boost::ref(mapHeaders), boost::ref(strRequest));
./bitcoinrpc.cpp: if (!api_caller.timed_join(boost::posix_time::seconds(GetArg("-rpctimeout", 30))))
./bitcoinrpc.cpp- { // Timed out:
--
./bitcoinrpc.cpp- {
./bitcoinrpc.cpp: stream << HTTPReply(401, "") << std::flush;
./bitcoinrpc.cpp- continue;
--
./bitcoinrpc.cpp- shouldn't have their RPC port exposed.*/
./bitcoinrpc.cpp: if (mapArgs["-rpcpassword"].size() < 20)
./bitcoinrpc.cpp: Sleep(250);
./bitcoinrpc.cpp-
./bitcoinrpc.cpp: stream << HTTPReply(401, "") << std::flush;
./bitcoinrpc.cpp- continue;
--
./bitcoinrpc.cpp- if (!read_string(strRequest, valRequest) || valRequest.type() != obj_type)
./bitcoinrpc.cpp: throw JSONRPCError(-32700, "Parse error");
./bitcoinrpc.cpp- const Object& request = valRequest.get_obj();
--
./bitcoinrpc.cpp- if (valMethod.type() == null_type)
./bitcoinrpc.cpp: throw JSONRPCError(-32600, "Missing method");
./bitcoinrpc.cpp- if (valMethod.type() != str_type)
./bitcoinrpc.cpp: throw JSONRPCError(-32600, "Method must be a string");
./bitcoinrpc.cpp- string strMethod = valMethod.get_str();
--
./bitcoinrpc.cpp- else
./bitcoinrpc.cpp: throw JSONRPCError(-32600, "Params must be an array");
./bitcoinrpc.cpp-
--
./bitcoinrpc.cpp- if (mi == mapCallTable.end())
./bitcoinrpc.cpp: throw JSONRPCError(-32601, "Method not found");
./bitcoinrpc.cpp-
--
./bitcoinrpc.cpp- string strReply = JSONRPCReply(result, Value::null, id);
./bitcoinrpc.cpp: stream << HTTPReply(200, strReply) << std::flush;
./bitcoinrpc.cpp- }
--
./bitcoinrpc.cpp- {
./bitcoinrpc.cpp: ErrorReply(stream, JSONRPCError(-32700, e.what()), id);
./bitcoinrpc.cpp- }
--
./bitcoinrpc.cpp- // Connect to localhost
./bitcoinrpc.cpp: ip::tcp::iostream stream(GetArg("-rpcconnect", "127.0.0.1"), GetArg("-rpcport", "8332"));
./bitcoinrpc.cpp- if (stream.fail())
--
./bitcoinrpc.cpp- int nStatus = ReadHTTP(stream, mapHeaders, strReply);
./bitcoinrpc.cpp: if (nStatus == 401)
./bitcoinrpc.cpp- throw runtime_error("incorrect rpcuser or rpcpassword (authorization failed)");
./bitcoinrpc.cpp: else if (nStatus >= 400 && nStatus != 400 && nStatus != 404 && nStatus != 500)
./bitcoinrpc.cpp- throw runtime_error(strprintf("server returned HTTP error %d", nStatus));
--
./bitcoinrpc.cpp- strPrint = string("error: ") + e.what();
./bitcoinrpc.cpp: nRet = 87;
./bitcoinrpc.cpp- }
--
./key.h:// secp160k1
./key.h:// const unsigned int PRIVATE_KEY_SIZE = 192;
./key.h:// const unsigned int PUBLIC_KEY_SIZE = 41;
./key.h:// const unsigned int SIGNATURE_SIZE = 48;
./key.h-//
./key.h:// secp192k1
./key.h:// const unsigned int PRIVATE_KEY_SIZE = 222;
./key.h:// const unsigned int PUBLIC_KEY_SIZE = 49;
./key.h:// const unsigned int SIGNATURE_SIZE = 57;
./key.h-//
./key.h:// secp224k1
./key.h:// const unsigned int PRIVATE_KEY_SIZE = 250;
./key.h:// const unsigned int PUBLIC_KEY_SIZE = 57;
./key.h:// const unsigned int SIGNATURE_SIZE = 66;
./key.h-//
./key.h:// secp256k1:
./key.h:// const unsigned int PRIVATE_KEY_SIZE = 279;
./key.h:// const unsigned int PUBLIC_KEY_SIZE = 65;
./key.h:// const unsigned int SIGNATURE_SIZE = 72;
./key.h-//
./key.h-// see www.keylength.com
./key.h:// script supports up to 75 for single byte push
./key.h-
--
./key.h- vchSig.clear();
./key.h: unsigned char pchSig[10000];
./key.h: unsigned int nSize = 0;
--
./key.h- vchSig.clear();
./key.h: vchSig.resize(65,0);
./key.h- int nBitsR = BN_num_bits(sig->r);
./key.h- int nBitsS = BN_num_bits(sig->s);
./key.h: if (nBitsR <= 256 && nBitsS <= 256)
./key.h- {
./key.h: int nRecId = -1;
./key.h: for (int i=0; i<4; i++)
./key.h- {
--
./key.h-
./key.h: if (nRecId == -1)
./key.h- throw key_error("CKey::SignCompact() : unable to construct recoverable key");
./key.h-
./key.h: vchSig[0] = nRecId+27;
./key.h: BN_bn2bin(sig->r,&vchSig[33-(nBitsR+7)/8]);
./key.h: BN_bn2bin(sig->s,&vchSig[65-(nBitsS+7)/8]);
./key.h- fOk = true;
--
./key.h- // (the signature is a valid signature of the given data for that key)
./key.h: bool SetCompactSignature(uint256 hash, const std::vector& vchSig)
./key.h- {
./key.h: if (vchSig.size() != 65)
./key.h- return false;
./key.h: if (vchSig[0]<27 || vchSig[0]>=31)
./key.h- return false;
./key.h- ECDSA_SIG *sig = ECDSA_SIG_new();
./key.h: BN_bin2bn(&vchSig[1],32,sig->r);
./key.h: BN_bin2bn(&vchSig[33],32,sig->s);
./key.h-
./key.h- EC_KEY_free(pkey);
./key.h: pkey = EC_KEY_new_by_curve_name(NID_secp256k1);
./key.h: if (ECDSA_SIG_recover_key_GFp(pkey, sig, (unsigned char*)&hash, sizeof(hash), vchSig[0] - 27, 0) == 1)
./key.h- {
--
./serialize.h-class CAutoFile;
./serialize.h:static const unsigned int MAX_SIZE = 0x02000000;
./serialize.h-
./serialize.h:static const int VERSION = 50400;
./serialize.h-static const char* pszSubVer = "";
--
./serialize.h- // primary actions
./serialize.h: SER_NETWORK = (1 << 0),
./serialize.h: SER_DISK = (1 << 1),
./serialize.h: SER_GETHASH = (1 << 2),
./serialize.h-
./serialize.h- // modifiers
./serialize.h: SER_SKIPSIG = (1 << 16),
./serialize.h: SER_BLOCKHEADERONLY = (1 << 17),
./serialize.h-};
--
./serialize.h-// Compact size
./serialize.h:// size < 253 -- 1 byte
./serialize.h:// size <= USHRT_MAX -- 3 bytes (253 + 2 bytes)
./serialize.h:// size <= UINT_MAX -- 5 bytes (254 + 4 bytes)
./serialize.h:// size > UINT_MAX -- 9 bytes (255 + 8 bytes)
./serialize.h-//
./serialize.h:inline unsigned int GetSizeOfCompactSize(uint64 nSize)
./serialize.h-{
./serialize.h: if (nSize < 253) return sizeof(unsigned char);
./serialize.h- else if (nSize <= USHRT_MAX) return sizeof(unsigned char) + sizeof(unsigned short);
./serialize.h- else if (nSize <= UINT_MAX) return sizeof(unsigned char) + sizeof(unsigned int);
./serialize.h: else return sizeof(unsigned char) + sizeof(uint64);
./serialize.h-}
--
./serialize.h-template
./serialize.h:void WriteCompactSize(Stream& os, uint64 nSize)
./serialize.h-{
./serialize.h: if (nSize < 253)
./serialize.h- {
--
./serialize.h- {
./serialize.h: unsigned char chSize = 253;
./serialize.h- unsigned short xSize = nSize;
--
./serialize.h- {
./serialize.h: unsigned char chSize = 254;
./serialize.h- unsigned int xSize = nSize;
--
./serialize.h- {
./serialize.h: unsigned char chSize = 255;
./serialize.h: uint64 xSize = nSize;
./serialize.h- WRITEDATA(os, chSize);
--
./serialize.h-template
./serialize.h:uint64 ReadCompactSize(Stream& is)
./serialize.h-{
--
./serialize.h- READDATA(is, chSize);
./serialize.h: uint64 nSizeRet = 0;
./serialize.h: if (chSize < 253)
./serialize.h- {
--
./serialize.h- }
./serialize.h: else if (chSize == 253)
./serialize.h- {
--
./serialize.h- }
./serialize.h: else if (chSize == 254)
./serialize.h- {
--
./serialize.h-
./serialize.h:// 3 tuple
./serialize.h:template unsigned int GetSerializeSize(const boost::tuple& item, int nType, int nVersion=VERSION);
./serialize.h:template void Serialize(Stream& os, const boost::tuple& item, int nType, int nVersion=VERSION);
./serialize.h:template void Unserialize(Stream& is, boost::tuple& item, int nType, int nVersion=VERSION);
./serialize.h-
./serialize.h:// 4 tuple
./serialize.h:template unsigned int GetSerializeSize(const boost::tuple& item, int nType, int nVersion=VERSION);
./serialize.h:template void Serialize(Stream& os, const boost::tuple& item, int nType, int nVersion=VERSION);
./serialize.h:template void Unserialize(Stream& is, boost::tuple& item, int nType, int nVersion=VERSION);
./serialize.h-
--
./serialize.h- {
./serialize.h: unsigned int blk = std::min(nSize - i, (unsigned int)(1 + 4999999 / sizeof(T)));
./serialize.h- v.resize(i + blk);
--
./serialize.h- {
./serialize.h: nMid += 5000000 / sizeof(T);
./serialize.h- if (nMid > nSize)
--
./serialize.h-
./serialize.h:template
./serialize.h:void Serialize(Stream& os, const boost::tuple& item, int nType, int nVersion)
./serialize.h-{
./serialize.h: Serialize(os, boost::get<0>(item), nType, nVersion);
./serialize.h: Serialize(os, boost::get<1>(item), nType, nVersion);
./serialize.h: Serialize(os, boost::get<2>(item), nType, nVersion);
./serialize.h-}
./serialize.h-
./serialize.h:template
./serialize.h:void Unserialize(Stream& is, boost::tuple& item, int nType, int nVersion)
./serialize.h-{
./serialize.h: Unserialize(is, boost::get<0>(item), nType, nVersion);
./serialize.h: Unserialize(is, boost::get<1>(item), nType, nVersion);
./serialize.h: Unserialize(is, boost::get<2>(item), nType, nVersion);
./serialize.h-}
--
./serialize.h-//
./serialize.h:// 4 tuple
./serialize.h-//
./serialize.h:template
./serialize.h:unsigned int GetSerializeSize(const boost::tuple& item, int nType, int nVersion)
./serialize.h-{
./serialize.h: unsigned int nSize = 0;
./serialize.h: nSize += GetSerializeSize(boost::get<0>(item), nType, nVersion);
./serialize.h: nSize += GetSerializeSize(boost::get<1>(item), nType, nVersion);
./serialize.h: nSize += GetSerializeSize(boost::get<2>(item), nType, nVersion);
./serialize.h: nSize += GetSerializeSize(boost::get<3>(item), nType, nVersion);
./serialize.h- return nSize;
--
./serialize.h-
./serialize.h:template
./serialize.h:void Serialize(Stream& os, const boost::tuple& item, int nType, int nVersion)
./serialize.h-{
./serialize.h: Serialize(os, boost::get<0>(item), nType, nVersion);
./serialize.h: Serialize(os, boost::get<1>(item), nType, nVersion);
./serialize.h: Serialize(os, boost::get<2>(item), nType, nVersion);
./serialize.h: Serialize(os, boost::get<3>(item), nType, nVersion);
./serialize.h-}
./serialize.h-
./serialize.h:template
./serialize.h:void Unserialize(Stream& is, boost::tuple& item, int nType, int nVersion)
./serialize.h-{
./serialize.h: Unserialize(is, boost::get<0>(item), nType, nVersion);
./serialize.h: Unserialize(is, boost::get<1>(item), nType, nVersion);
./serialize.h: Unserialize(is, boost::get<2>(item), nType, nVersion);
./serialize.h: Unserialize(is, boost::get<3>(item), nType, nVersion);
./serialize.h-}
--
./serialize.h-#ifdef TESTCDATASTREAM
./serialize.h:// VC6sp6
./serialize.h-// CDataStream:
./serialize.h:// n=1000 0 seconds
./serialize.h:// n=2000 0 seconds
./serialize.h:// n=4000 0 seconds
./serialize.h:// n=8000 0 seconds
./serialize.h:// n=16000 0 seconds
./serialize.h:// n=32000 0 seconds
./serialize.h:// n=64000 1 seconds
./serialize.h:// n=128000 1 seconds
./serialize.h:// n=256000 2 seconds
./serialize.h:// n=512000 4 seconds
./serialize.h:// n=1024000 8 seconds
./serialize.h:// n=2048000 16 seconds
./serialize.h:// n=4096000 32 seconds
./serialize.h-// stringstream:
./serialize.h:// n=1000 1 seconds
./serialize.h:// n=2000 1 seconds
./serialize.h:// n=4000 13 seconds
./serialize.h:// n=8000 87 seconds
./serialize.h:// n=16000 400 seconds
./serialize.h:// n=32000 1660 seconds
./serialize.h:// n=64000 6749 seconds
./serialize.h:// n=128000 27241 seconds
./serialize.h:// n=256000 109804 seconds
./serialize.h-#include
--
./serialize.h-{
./serialize.h: vector vch(0xcc, 250);
./serialize.h- printf("CDataStream:\n");
./serialize.h: for (int n = 1000; n <= 4500000; n *= 2)
./serialize.h- {
--
./serialize.h- time_t nStart = time(NULL);
./serialize.h: for (int i = 0; i < n; i++)
./serialize.h: ss.write( (char*)&vch[0], vch.size());
./serialize.h: printf("n=%-10d %d seconds\n", n, time(NULL) - nStart);
./serialize.h- }
./serialize.h- printf("stringstream:\n");
./serialize.h: for (int n = 1000; n <= 4500000; n *= 2)
./serialize.h- {
--
./serialize.h- time_t nStart = time(NULL);
./serialize.h: for (int i = 0; i < n; i++)
./serialize.h: ss.write( (char*)&vch[0], vch.size());
./serialize.h: printf("n=%-10d %d seconds\n", n, time(NULL) - nStart);
./serialize.h- }
--
./protocol.cpp-
./protocol.cpp:static const unsigned char pchIPv4[12] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff };
./protocol.cpp-static const char* ppszTypeName[] =
--
./protocol.cpp- memcpy(pchMessageStart, ::pchMessageStart, sizeof(pchMessageStart));
./protocol.cpp: memset(pchCommand, 0, sizeof(pchCommand));
./protocol.cpp: pchCommand[1] = 1;
./protocol.cpp: nMessageSize = -1;
./protocol.cpp: nChecksum = 0;
./protocol.cpp-}
--
./protocol.cpp- }
./protocol.cpp: else if (*p1 < ' ' || *p1 > 0x7E)
./protocol.cpp- return false;
--
./protocol.cpp- port = htons(GetDefaultPort());
./protocol.cpp: nTime = 100000000;
./protocol.cpp: nLastTry = 0;
--
./protocol.cpp- CDataStream ss;
./protocol.cpp: ss.reserve(18);
./protocol.cpp- ss << FLATDATA(pchReserved) << ip << port;
--
./protocol.cpp: return IsIPv4() && (GetByte(3) == 10 ||
./protocol.cpp: (GetByte(3) == 192 && GetByte(2) == 168) ||
./protocol.cpp: (GetByte(3) == 172 &&
./protocol.cpp: (GetByte(2) >= 16 && GetByte(2) <= 31)));
./protocol.cpp-}
./protocol.cpp-
./protocol.cpp:bool CAddress::IsRFC3927() const
./protocol.cpp-{
./protocol.cpp: return IsIPv4() && (GetByte(3) == 169 && GetByte(2) == 254);
--
./protocol.cpp-{
./protocol.cpp: return IsIPv4() && (GetByte(3) == 127 ||
./protocol.cpp: GetByte(3) == 0);
./protocol.cpp-}
--
./protocol.cpp-{
./protocol.cpp: // Clean up 3-byte shifted addresses caused by garbage in size field
./protocol.cpp: // of addr messages from versions before 0.2.9 checksum.
./protocol.cpp- // Two consecutive addr messages look like this:
./protocol.cpp: // header20 vectorlen3 addr26 addr26 addr26 header20 vectorlen3 addr26 addr26 addr26...
./protocol.cpp- // so if the first length field is garbled, it reads the second batch
./protocol.cpp: // of addr misaligned by 3 bytes.
./protocol.cpp: if (memcmp(pchReserved, pchIPv4+3, sizeof(pchIPv4)-3) == 0)
./protocol.cpp- return false;
./protocol.cpp-
./protocol.cpp: return (ip != 0 && ip != INADDR_NONE && port != htons(USHRT_MAX));
./protocol.cpp-}
--
./protocol.cpp-{
./protocol.cpp: return ( (unsigned char*)&ip)[3-n];
./protocol.cpp-}
--
./protocol.cpp-{
./protocol.cpp: return strprintf("%u.%u.%u.%u:%u", GetByte(3), GetByte(2), GetByte(1), GetByte(0), ntohs(port));
./protocol.cpp-}
--
./protocol.cpp-{
./protocol.cpp: return strprintf("%u.%u.%u.%u", GetByte(3), GetByte(2), GetByte(1), GetByte(0));
./protocol.cpp-}
--
./protocol.cpp-{
./protocol.cpp: return strprintf("%u.%u.%u.%u:%u", GetByte(3), GetByte(2), GetByte(1), GetByte(0), ntohs(port));
./protocol.cpp-}
--
./protocol.cpp-{
./protocol.cpp: return strprintf("%s %s", GetCommand(), hash.ToString().substr(0,20).c_str());
./protocol.cpp-}


Code blocks can be readily referenced by selecting them and copying the modified url. It is my considered opinion that all these 602 instances of numeric wizardry must be carefully reviewed. It is possible any one entry is a false positive, but should that be the case the matter must be considered carefully and justified completely nevertheless.

Of particular note are the few instances of char pch[200000]; char pch[50000]; etc. As alf correctly points out... this is no good.

PS. Note that ALL files will have to be edited to remove spurious "re-copyright" claim of an imaginary "Bitcoin Developers" thing, as seen in the log.

———
  1. This passing comment has actually inspired a line of thought.

    You see, among the other things slowly stewing in my head, I'm also toying with designing a palace for the harem. Now... what if the girls had a communal toilet ? A round item where they can sit together in their relief ?

    Weird, huh. []

  2. I'm not sure this is actually a valid consideration : there's a very obvious way to minimize that count altogether. Then again, his point does carry - reading patches takes time. []
  3. What do you think you know of programming, ye of little expanded array knowledge ?

    Clearly, alf is wrong. []

  4. Epic. []
Category: Bitcoin
Comments feed : RSS 2.0. Leave your own comment below, or send a trackback.

5 Responses

  1. IIRC the Romans had the mega-toilet. (Though I'm not aware of any archaeological finds of ~round~ setups.)

  2. Mircea Popescu`s avatar
    2
    Mircea Popescu 
    Thursday, 21 January 2016

    To not leave this entirely hanging http://btcbase.org/log/?date=21-01-2016#1380191

  3. I've been to various sports stadiums that have the communal urinal: a long trough that will accommodate a number of men determined by how close you want to shoulder against your neighbor. I suppose this is not the same thing you are describing?

    Would it be possible for these magic numbers be moved to a config file, and be changeable by the user without having to recompile the source code? Maybe MIN_TX_FEE should be user adjustable, but MAX_MONEY = 21000000 * COIN should be left in the code?

  4. Mircea Popescu`s avatar
    4
    Mircea Popescu 
    Thursday, 21 January 2016

    > a long trough

    Quite specifically not what I mean, no. It wouldn't serve women too well, that arrangement. There's perhaps something deeper here, tho at the moment I'm not too keen to dig.

    > moved to a config file

    Depends which. Some are eminently the province of the node owner, and should be. Some are necessarily fixed in order to have a functioning protocol, much like the grammar rules in a language, and as such can not be. Most of them however are just bad programming at best (and rampant insanity otherwise) and don't belong written down in the first place.

    The MAX_MONEY thing particularly is an exercise in bizarro nonsense : the maximal qty of Bitcoin is actually established procedurally, through a fully described procedure, which tends to something under 21mn asymptotically.

    The actual final value is 210,000 * (50 + 25 + 12.5 +... +0.00000003 + 0.00000001). In proper notation that paranthesis is a common geometric series, that converges absolutely (to 1) and in this sense the max value is 21`000`000. Nevertheless, due to rounding, the actual sum of Bitcoin ever available will be 20999999.9769 (exactly). What the implications of the difference would be is not entirely clear yet - but hopefully nothing.

    You know, like the implication of a certain, famous "anti-spam" measure turned out to be hopefully nothing.

  1. [...] you will need an outhouse, possibly of the previously discussed modeliii, out of which proceeds a tube, which splits radially into a numberiv of inclined smaller tubes. [...]

Add your cents! »
    If this is your first comment, it will wait to be approved. This usually takes a few hours. Subsequent comments are not delayed.