Please check the whole question once before giving negative marking or Mark as duplicate of

Why can’t the genesis block coinbase be spent?

Why I cannot get transaction from genesis block [duplicate]

I am creating AltCoin from litecoin source.And using GenesisHO generating genesis block details like nonce ,genesis hash , merkle etc.

While generating genesis block I have changed the coin value parameters in genesis coin value. that is -v parameters and generated genesis hash and merkle etc.

I've done changes regarding genesis , nonce, coins for genesis block.

genesis = CreateGenesisBlock(1538404994, 2086003386, 0x1e0ffff0, 1, 50000 * COIN);

eg. I want to premine 50,000 coins in genesis block. I don't want give condition in validation.cpp like if block height 1 than reward should be 50,000.

I've generated pub key and used the same pub key while generating genesis hash.So I can use that genesis block coins by importing private key of that pub key.

After all above change in source,I've build daemon ,cli ,tx and qt from same source.


From cli I have executed command(coin-cli generate 1) to generate one block so I can get genesis block coin(Yes!! initially it will be in immature state after x(which I've set to 1) amount of block it will be in mature state). And imported that private key in wallet.

Result of above :

After execution of coin-cli generate 1 genesis coins are generated.Displayed in wallet and account under account name ""

Started Mining (using cpuminer) which has another account's address. And after few blocks genesis block coins converted to mature state


Now when i tried to transfer from that genesis block coins its not transferring to any address.Its not displaying in qt wallet but using cli command its displaying balance.

So where do I need to make other changes to make that genesis coin spendable.

Transactions details

enter image description here

Balance details from qt wallet and command

enter image description here For mining using cpuminer

Litecoin source : https://github.com/litecoin-project/litecoin/tree/0.14


I've tried & follow steps from this answer too After updating as per from above answer in validation.cpp here is the link of same

Update 2

Changes mentioned in answer regarding validation.cpp & updated validation.cpp file here & same updated change mentioned below line wise

Changes in special case for the genesis block, skipping connection of its transactions (its coinbase is unspendable)

Changes for assert(pindex->pprev);

Added WriteUndoDataForBlock method :

Change to skip writing undo data for genesis block

After updating above things it give error Segmentation fault (core dumped)

And here is debug.log details


  • Did you make any adjustments to validation.cpp, specifically this line? github.com/litecoin-project/litecoin/blob/0.14/src/…
    – JBaczuk
    Oct 3, 2018 at 17:33
  • @JBaczuk Well actually as a newbie.What i tried is commented return true; statement and build again but it give error when I started daemon Segmentation fault (core dumped). Do i need to make any change in that file for that ? Oct 4, 2018 at 8:27
  • @JBaczuk please check question.I've added update Oct 4, 2018 at 9:43
  • You're right to comment that line. It segfaults b/c its trying to reference a previous block when it is on the Genesis, but there isn't one. Look for assert(pindex->pprev). All the changes you need to make are in that file.
    – JBaczuk
    Oct 4, 2018 at 11:57
  • @JBaczuk Ohh okay but once please check my updated question mentioned as Update 2 Oct 4, 2018 at 14:51

1 Answer 1


You need to do a few things to make the genesis block spendable, all in validation.cpp (untested):

  1. Allow tx connection, L#2904:

    if (*pindexPrev->phashBlock == chainparams.GetConsensus().hashGenesisBlock)
        // return true;
  2. Skip coinbase amount check for genesis block, L#1933:

    if (block.vtx[0]->GetValueOut() > blockReward && block.GetHash() != chainparams.GetConsensus().hashGenesisBlock)
        return state.DoS(100,
                         error("ConnectBlock(): coinbase pays too much (actual=%d vs limit=%d)", block.vtx[0]->GetValueOut(), blockReward),= REJECT_INVALID, "bad-cb-amount");
  3. Skip writing undo data for genesis block L#1947:

    if (block.GetHash() != chainparams.GetConsensus().hashGenesisBlock)
        if (pindex->GetUndoPos().IsNull() || !pindex->IsValid(BLOCK_VALID_SCRIPTS))
                if (pindex->GetUndoPos().IsNull()) {
                    CDiskBlockPos _pos;
                    if (!FindUndoPos(state, pindex->nFile, _pos, ::GetSerializeSize(blockundo, SER_DISK, CLIENT_VERSION) + 40))
                        return error("ConnectBlock(): FindUndoPos failed");
                    if (!UndoWriteToDisk(blockundo, _pos, pindex->pprev->GetBlockHash(), chainparams.MessageStart()))
                        return AbortNode(state, "Failed to write undo data");
                    // update nUndoPos in block index
                    pindex->nUndoPos = _pos.nPos;
                    pindex->nStatus |= BLOCK_HAVE_UNDO;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.