From a0cb9c53fb1097bee09aa16840f6629bb48f9118 Mon Sep 17 00:00:00 2001 From: "Andreas M. Antonopoulos" Date: Mon, 12 Aug 2013 12:40:07 -0700 Subject: [PATCH] source genesis block test --- book.asciidoc | 6 ------ ch01.asciidoc | 29 +++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/book.asciidoc b/book.asciidoc index 518c083f..6497b5c9 100644 --- a/book.asciidoc +++ b/book.asciidoc @@ -2,12 +2,6 @@ = Mastering Bitcoin -by Andreas M. Antonopoulos - - - - - include::preface.asciidoc[] diff --git a/ch01.asciidoc b/ch01.asciidoc index 743cffc8..7dd4dfa0 100644 --- a/ch01.asciidoc +++ b/ch01.asciidoc @@ -6,6 +6,35 @@ === Simple Transactions === Wallets, addresses and coins === The Blockchain + +==== The Genesis Block + +The very first block mined, by Satoshi Nakamoto on Sat, 03 Jan 2009, is included in the source code of any "full node" client, as the basis for validating the entire blockchain. + +[[genesis_block_cpp]] +.The Genesis Block, statically encoded in the source code of the reference client +link:$$https://github.com/bitcoin/bitcoin/blob/master/src/chainparams.cpp#L120$$[bitcoin/src/chainparams.cpp:line 120] +==== +[source, c++] +---- +const char* pszTimestamp = "The Times 03/Jan/2009 Chancellor on brink of second bailout for banks"; +CTransaction txNew; +txNew.vin.resize(1); +txNew.vout.resize(1); +txNew.vin[0].scriptSig = CScript() << 486604799 << CBigNum(4) << vector((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp)); +txNew.vout[0].nValue = 50 * COIN; +txNew.vout[0].scriptPubKey = CScript() << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f") << OP_CHECKSIG; +genesis.vtx.push_back(txNew); +genesis.hashPrevBlock = 0; +genesis.hashMerkleRoot = genesis.BuildMerkleTree(); +genesis.nVersion = 1; +genesis.nTime = 1231006505; +genesis.nBits = 0x1d00ffff; +genesis.nNonce = 2083236893; + +---- +==== + === Bitcoin mining === Transaction Fees === Currency exchange