PPCoin: Official genesis blocks
[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 "../db.h"
5 #include "../net.h"
6 #include "../init.h"
7 #include "../main.h"
8 #include "../util.h"
9
10 using namespace std;
11 using namespace boost;
12
13 int main(int argc, char *argv[])
14 {
15     fPrintToConsole = true;
16     printf("PPCoin Begin Genesis Block\n");
17
18     // Genesis block
19     const char* pszTimestamp = "Matonis 07-AUG-2012 Parallel Currencies And The Roadmap To Monetary Freedom";
20     CTransaction txNew;
21     txNew.vin.resize(1);
22     txNew.vout.resize(1);
23     txNew.vin[0].scriptSig = CScript() << 486604799 << CBigNum(9999) << vector<unsigned char>((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp));
24     txNew.vout[0].SetEmpty();
25     txNew.nTime = 1345083810; // only for testnet
26     CBlock block;
27     block.vtx.push_back(txNew);
28     block.hashPrevBlock = 0;
29     block.hashMerkleRoot = block.BuildMerkleTree();
30     block.nVersion = 1;
31     block.nBits    = CBigNum(~uint256(0) >> 28).GetCompact(); //0x1d00ffff;
32     block.nTime    = 1345090000; //GetAdjustedTime();
33     block.nNonce   = 0;
34
35     CBigNum bnTarget;
36     bnTarget.SetCompact(block.nBits);
37
38     while (block.GetHash() > bnTarget.getuint256())
39     {
40         if ((block.nNonce >> 20) << 20 == block.nNonce)
41         {
42             //if (block.vtx[0].nTime + 7200 < GetAdjustedTime() + 60)
43             //{
44             //    block.vtx[0].nTime = GetAdjustedTime();
45             //    block.hashMerkleRoot = block.BuildMerkleTree();
46             //}
47             if (block.nNonce > 4000000000)
48             {
49                 block.nTime++; // = GetAdjustedTime();
50                 block.nNonce = 0;
51             }
52             printf("n=%dM hash=%s\n", block.nNonce >> 20,
53                    block.GetHash().ToString().c_str());
54         }
55         block.nNonce++;
56     }
57
58     printf("PPCoin Found Genesis Block:\n");
59     printf("genesis hash=%s\n", block.GetHash().ToString().c_str());
60     printf("merkle  root=%s\n", block.hashMerkleRoot.ToString().c_str());
61     block.print();
62
63     printf("PPCoin End Genesis Block\n");
64 }