e87157a850888452e526eaa75f553d010aa328a3
[novacoin.git] / src / ppcoin / genesis.cpp
1 // Copyright (c) 2011 The PPCoin developers
2 // Distributed under the MIT/X11 software license, see the accompanying
3 // file license.txt or http://www.opensource.org/licenses/mit-license.php.
4 #include "../headers.h"
5 #include "../db.h"
6 #include "../net.h"
7 #include "../init.h"
8 #include "../main.h"
9 #include "../util.h"
10
11 using namespace std;
12 using namespace boost;
13
14 int main(int argc, char *argv[])
15 {
16     fPrintToConsole = true;
17     printf("PPCoin Begin Genesis Block\n");
18
19     // Genesis block
20     const char* pszTimestamp = "MarketWatch 07/Nov/2011 Gold tops $1,790 to end at over six-week high";
21     CTransaction txNew;
22     txNew.vin.resize(1);
23     txNew.vout.resize(1);
24     txNew.vin[0].scriptSig = CScript() << 486604799 << CBigNum(4) << vector<unsigned char>((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp));
25     txNew.vout[0].nValue = 9999 * COIN;
26     txNew.vout[0].scriptPubKey = CScript() << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f") << OP_CHECKSIG;
27     CBlock block;
28     block.vtx.push_back(txNew);
29     block.hashPrevBlock = 0;
30     block.hashMerkleRoot = block.BuildMerkleTree();
31     block.nVersion = 1;
32     block.nBits    = 0x1d00ffff;
33     block.nTime    = GetAdjustedTime();
34     block.nNonce   = 0;
35
36     CBigNum bnTarget;
37     bnTarget.SetCompact(block.nBits);
38
39     while (block.GetHash() > bnTarget.getuint256())
40     {
41         if (block.nNonce % 1048576 == 0)
42             printf("n=%dM hash=%s\n", block.nNonce / 1048576,
43                    block.GetHash().ToString().c_str());
44         block.nTime = GetAdjustedTime();
45         block.nNonce++;
46     }
47
48     printf("PPCoin Found Genesis Block:\n");
49     printf("genesis hash=%s\n", block.GetHash().ToString().c_str());
50     printf("merkle  root=%s\n", block.hashMerkleRoot.ToString().c_str());
51     block.print();
52
53     printf("PPCoin End Genesis Block\n");
54