Premine coins from genesis block are gone after one transaction from account/wallet 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.

Next 

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


  Problem/Issue
  
  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





  Balance details from qt wallet and command



For mining using cpuminer

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


  UPDATE


I've tried &amp; 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 &amp; updated validation.cpp file here &amp; 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

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


Allow tx connection, L#2904:

if (*pindexPrev-&gt;phashBlock == chainparams.GetConsensus().hashGenesisBlock)
    // return true;

Skip coinbase amount check for genesis block, L#1933:

if (block.vtx[0]-&gt;GetValueOut() &gt; blockReward &amp;&amp; block.GetHash() != chainparams.GetConsensus().hashGenesisBlock)
    return state.DoS(100,
                     error("ConnectBlock(): coinbase pays too much (actual=%d vs limit=%d)", block.vtx[0]-&gt;GetValueOut(), blockReward),= REJECT_INVALID, "bad-cb-amount");

Skip writing undo data for genesis block L#1947:

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

                // update nUndoPos in block index
                pindex-&gt;nUndoPos = _pos.nPos;
                pindex-&gt;nStatus |= BLOCK_HAVE_UNDO;
            }

            pindex-&gt;RaiseValidity(BLOCK_VALID_SCRIPTS);
            setDirtyBlockIndex.insert(pindex);
    }
}