Skip to content

Instantly share code, notes, and snippets.

@msinkec
Last active January 12, 2024 11:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save msinkec/5eaf5aa97ed0f5e8d66e7e32fd8b1a0a to your computer and use it in GitHub Desktop.
Save msinkec/5eaf5aa97ed0f5e8d66e7e32fd8b1a0a to your computer and use it in GitHub Desktop.
About the Genesis Block's Coinbase...

About the Genesis Block's Coinbase

The recent deposit of a large sum of BTC to the address associated with the genesis block's coinbase, 1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa, has sparked confusion and discussion in the blockchain sphere. To clarify, while the specific coinbase output of the genesis block cannot be spent, subsequent Unspent Transaction Outputs (UTXOs) sent to the same public key (or its hash / address) can be spent, assuming one has access to the corresponding private key.

Technical Explanation

Bitcoin's Genesis Block and Coinbase Transactions

  1. Genesis Block Coinbase Transaction: In Bitcoin, the genesis block is the first block of the blockchain. Notably, the coinbase transaction of this block is hardcoded into the Bitcoin client. This transaction is never added to the Unspent Transaction Output (UTXO) set, making its output unspendable.

  2. UTXO Model: Bitcoin utilizes the UTXO model, where each transaction output becomes a UTXO until it is spent by a new transaction. If a transaction output is not in the UTXO set, it cannot be spent.

Address and UTXO

  1. Address Reuse: The address 1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa is merely a public key hash. It can be reused multiple times to receive funds.

  2. Spending UTXOs: Any new UTXOs sent to this address are independent of the genesis block's coinbase transaction. They can be spent as long as someone possesses the corresponding private key.

Code Snippet from Early Bitcoin Software

In the early Bitcoin software, when a node initializes, it starts with the genesis block. Here's a simplified code snippet showcasing this process:

// Genesis block
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<unsigned char>((unsigned char*)pszTimestamp, (unsigned char*)pszTimestamp + strlen(pszTimestamp));
txNew.vout[0].nValue       = 50 * COIN;
txNew.vout[0].scriptPubKey = CScript() << CBigNum("0x5F1DF16B2B704C8A578D0BBAF74D385CDE12C11EE50455F3C438EF4C3FBCF649B6DE611FEAE06279A60939E028A8D65C10B73071A6F16719274855FEB0FD8A6704") << OP_CHECKSIG;
CBlock block;
block.vtx.push_back(txNew);
block.hashPrevBlock = 0;
block.hashMerkleRoot = block.BuildMerkleTree();
block.nVersion = 1;
block.nTime    = 1231006505;
block.nBits    = 0x1d00ffff;
block.nNonce   = 2083236893;

This data is hard-coded into the software itself and acts as an anchor to all subsequent blocks that will be built on top of it.

While the genesis block itself is stored in the clients block database, Satoshi chose not to add the coinbase transaction of the genesis block to the global transaction database. Consequently, nodes in the network inherently reject any attempts to spend this transactions output.

The very same is still true for the current BTC node software. The property is even explictly stated in a comment:

/**
 * Build the genesis block. Note that the output of its generation
 * transaction cannot be spent since it did not originally exist in the
 * database.
 *
 * CBlock(hash=000000000019d6, ver=1, hashPrevBlock=00000000000000, hashMerkleRoot=4a5e1e, nTime=1231006505, nBits=1d00ffff, nNonce=2083236893, vtx=1)
 *   CTransaction(hash=4a5e1e, ver=1, vin.size=1, vout.size=1, nLockTime=0)
 *     CTxIn(COutPoint(000000, -1), coinbase 04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73)
 *     CTxOut(nValue=50.00000000, scriptPubKey=0x5F1DF16B2B704C8A578D0B)
 *   vMerkleTree: 4a5e1e
 */
static CBlock CreateGenesisBlock(uint32_t nTime, uint32_t nNonce, uint32_t nBits, int32_t nVersion, const CAmount& genesisReward)
{
    const char* pszTimestamp = "The Times 03/Jan/2009 Chancellor on brink of second bailout for banks";
    const CScript genesisOutputScript = CScript() << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f") << OP_CHECKSIG;
    return CreateGenesisBlock(pszTimestamp, genesisOutputScript, nTime, nNonce, nBits, nVersion, genesisReward);
}

Implications

  • Unspendable Genesis Coinbase: The original coinbase transaction of the genesis block remains a historical artifact, unspendable and eternally embedded in the blockchain.
  • Subsequent Transactions to the Address: Any later transactions made to the same address (or public key) do not share the unspendable nature of the genesis coinbase transaction. They are normal UTXOs and can be spent using the correct private key.

References

  1. "The Mystery of 26.9 BTC Paid to the Genesis Block": Link
  2. "The Genesis of Genesis": Link
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment