<blockquote>
  <p>How would you change it to allow it to be spent?</p>
</blockquote>

<p>In order to make the coinbase spendable, the following changes have to be made to validation.cpp (v0.16.2). <strong>Note</strong>: as mentioned this would be considered a hard fork.</p>

<p><strong>Step 1</strong> - Disable skipping the genesis block (which is intended to keep the bug as part of consensus), <a href="https://github.com/bitcoin/bitcoin/blob/v0.16.2/src/validation.cpp#L1818" rel="noreferrer">Line 1818</a>:  </p>

<pre><code>// Special case for the genesis block, skipping connection of its transactions
    // (its coinbase is unspendable)
    if (block.GetHash() == chainparams.GetConsensus().hashGenesisBlock) {
        if (!fJustCheck)
            view.SetBestBlock(pindex-&gt;GetBlockHash());
        // return true; &lt;- comment this line out
}
</code></pre>

<p><strong>Step 2</strong> - Skip assertion of previous block for genesis block, <a href="https://github.com/bitcoin/bitcoin/blob/v0.16.2/src/validation.cpp#L1874" rel="noreferrer">Line 1874</a>:</p>

<pre><code>if (block.GetHash() != chainparams.GetConsensus().hashGenesisBlock) {
    assert(pindex-&gt;pprev);
}
</code></pre>

<p><strong>Step 3</strong> - Skip writing undo data for genesis block, <a href="https://github.com/bitcoin/bitcoin/blob/v0.16.2/src/validation.cpp#L1989" rel="noreferrer">Line 1989</a>:</p>

<pre><code>if (block.GetHash() != chainparams.GetConsensus().hashGenesisBlock)
{
    if (!WriteUndoDataForBlock(blockundo, state, pindex, chainparams))
        return false;
} 
</code></pre>

CC BY-SA 4.0
2018-09-10T18:47:24.210Z
2018-09-10T18:47:24.210Z
JBaczuk
<p>At least with current versions of the Bitcoin Core client, the Genesis block is actually hard coded into the client.</p>

<p>The part of the code that builds this block is located <a href="https://gist.github.com/drazisil/8f628627cff0d173e9b1" rel="nofollow noreferrer">here</a> and I have included a JSON dump of the coinbase transaction below for reference.</p>

<pre><code>{
    "txid" : "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b",
    "version" : 1,
    "locktime" : 0,
    "vin" : [
        {
            "coinbase" : "04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73",
            "sequence" : 4294967295
        }
    ],
    "vout" : [
        {
            "value" : 50.00000000,
            "n" : 0,
            "scriptPubKey" : {
                "asm" : "04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f OP_CHECKSIG",
                "hex" : "4104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac",
                "reqSigs" : 1,
                "type" : "pubkey",
                "addresses" : [
                    "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa"
                ]
            }
        }
    ]
}
</code></pre>

<p>Reference <a href="https://gist.github.com/drazisil/8f628627cff0d173e9b1" rel="nofollow noreferrer">Gist</a></p>

CC BY-SA 3.0
2018-04-26T16:54:25.357Z
This answer could be improved by addressing why the Genesis Block's output cannot be spent.
Murch
CC BY-SA 4.0
2015-08-31T03:59:23.433Z
2019-04-28T16:49:57.747Z
2019-04-28T16:49:57.747Z
Drazisil
<p>When a node starts up it initializes its copy of the block database alongside the genesis block and then begins the synchronization process. For some reason, Satoshi decided not to add the coinbase transaction from the genesis block to the global transaction database. Thus all the nodes in the network would reject the block.  </p>

<p>I'm not sure if this was done on purpose or if it was simply an oversight. In any event, it is forever bound to 1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa. </p>

CC BY-SA 3.0
2013-04-20T06:18:22.017Z
How would you change it to allow it to be spent?

Add this to the hardfork list
Charles Hoskinson
CC BY-SA 3.0
2013-11-20T12:23:47.467Z
How do we know of it if it's not in the database?
user5477
CC BY-SA 3.0
2014-11-21T19:22:43.970Z
We know it's not in the database because if you do `getrawtransaction 4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b` via RPC calls it returns an error, even though you can go to a block explorer (like [here](https://blockchain.info/tx/4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b)) and see that this is the genesis block coinbase transaction.
morsecoder
CC BY-SA 3.0
2014-11-21T19:49:53.827Z
(Even when `-txindex=1` is enabled)
morsecoder
CC BY-SA 3.0
2013-04-20T06:08:00.507Z
2013-04-20T06:08:00.507Z
Charles Hoskinson
<p>According to the <a href="https://en.bitcoin.it/wiki/Genesis_block">bitcoin wiki</a>:</p>

<blockquote>
  <p>The first 50BTC block reward went to address <a href="http://blockexplorer.com/address/1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa">1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa</a>, though this reward can't be spent due to a quirk in the way that the genesis block is expressed in the code (this may have been intentional).</p>
</blockquote>

<p>But where is this quirk? How would you change it to allow it to be spent?</p>

CC BY-SA 4.0
2018-06-03T08:46:17.917Z
One has to mind at that point of time 50 BTC was costing like.. literally 0 cents. I doubt he has given any thought to make this intentional or not.
EralpB
CC BY-SA 4.0
2021-08-22T13:45:38.060Z
Maybe it is because the 50 BTC reward is technically _premined_ since the code was released 6 days later. So technically it would have been unfair if Satoshi could spend those coins. IMO that's another beauty of Bitcoin.
Coding Enthusiast
<consensus><genesis-block>
Why can’t the genesis block coinbase be spent?
Nick ODell
# Why can’t the genesis block coinbase be spent?

(Asked by: username_0 on 2013-04-20)

According to the [bitcoin wiki](https://en.bitcoin.it/wiki/Genesis_block):

> The first 50BTC block reward went to address [1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa](http://blockexplorer.com/address/1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa), though this reward can't be spent due to a quirk in the way that the genesis block is expressed in the code (this may have been intentional).

But where is this quirk? How would you change it to allow it to be spent?

**Tags:** consensus, genesis-block

> **Comments:**
> **username_1**: One has to mind at that point of time 50 BTC was costing like.. literally 0 cents. I doubt he has given any thought to make this intentional or not.  
> **username_2**: Maybe it is because the 50 BTC reward is technically _premined_ since the code was released 6 days later. So technically it would have been unfair if Satoshi could spend those coins. IMO that's another beauty of Bitcoin.  

---

## 3 answers

### Answer by username_6 on 2013-04-20. Score: 32 | Accepted answer

When a node starts up it initializes its copy of the block database alongside the genesis block and then begins the synchronization process. For some reason, Satoshi decided not to add the coinbase transaction from the genesis block to the global transaction database. Thus all the nodes in the network would reject the block.

I'm not sure if this was done on purpose or if it was simply an oversight. In any event, it is forever bound to 1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa.

> **Comments:**
> **username_6**: How would you change it to allow it to be spent?  Add this to the hardfork list  
> **username_7**: How do we know of it if it's not in the database?  
> **username_8**: We know it's not in the database because if you do `getrawtransaction 4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b` via RPC calls it returns an error, even though you can go to a block explorer (like [here](https://blockchain.info/tx/4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b)) and see that this is the genesis block coinbase transaction.  
> **username_8**: (Even when `-txindex=1` is enabled)  

---

### Answer by username_3 on 2018-09-10. Score: 10

> How would you change it to allow it to be spent?

In order to make the coinbase spendable, the following changes have to be made to validation.cpp (v0.16.2). **Note**: as mentioned this would be considered a hard fork.

**Step 1** - Disable skipping the genesis block (which is intended to keep the bug as part of consensus), [Line 1818](https://github.com/bitcoin/bitcoin/blob/v0.16.2/src/validation.cpp#L1818):

```
// Special case for the genesis block, skipping connection of its transactions
    // (its coinbase is unspendable)
    if (block.GetHash() == chainparams.GetConsensus().hashGenesisBlock) {
        if (!fJustCheck)
            view.SetBestBlock(pindex->GetBlockHash());
        // return true; <- comment this line out
}

```

**Step 2** - Skip assertion of previous block for genesis block, [Line 1874](https://github.com/bitcoin/bitcoin/blob/v0.16.2/src/validation.cpp#L1874):

```
if (block.GetHash() != chainparams.GetConsensus().hashGenesisBlock) {
    assert(pindex->pprev);
}

```

**Step 3** - Skip writing undo data for genesis block, [Line 1989](https://github.com/bitcoin/bitcoin/blob/v0.16.2/src/validation.cpp#L1989):

```
if (block.GetHash() != chainparams.GetConsensus().hashGenesisBlock)
{
    if (!WriteUndoDataForBlock(blockundo, state, pindex, chainparams))
        return false;
} 

```


---

### Answer by username_4 on 2015-08-31. Score: 3

At least with current versions of the Bitcoin Core client, the Genesis block is actually hard coded into the client.

The part of the code that builds this block is located [here](https://gist.github.com/username_4/8f628627cff0d173e9b1) and I have included a JSON dump of the coinbase transaction below for reference.

```
{
    "txid" : "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b",
    "version" : 1,
    "locktime" : 0,
    "vin" : [
        {
            "coinbase" : "04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73",
            "sequence" : 4294967295
        }
    ],
    "vout" : [
        {
            "value" : 50.00000000,
            "n" : 0,
            "scriptPubKey" : {
                "asm" : "04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f OP_CHECKSIG",
                "hex" : "4104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac",
                "reqSigs" : 1,
                "type" : "pubkey",
                "addresses" : [
                    "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa"
                ]
            }
        }
    ]
}

```

Reference [Gist](https://gist.github.com/username_4/8f628627cff0d173e9b1)

> **Comments:**
> **username_5**: This answer could be improved by addressing why the Genesis Block's output cannot be spent.  

---

