Title: How to add premine in the bitcoin source Post by: vanshtah on February 04, 2020, 01:02:38 AM Hello all, I am learning about bitcoin development, a created a new genesis, I compiled it and i got the windows, Linux and mac wallet running pretty well. Now I also want to add premine to the source code and with some searches in the google I found a solution to it.
In validation.cpp #L1041 Code: CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams) I start the mining I got the coins but I cannot spend it, do anyone has a solution to it Title: Re: How to add premine in the bitcoin source Post by: nc50lc on February 04, 2020, 02:54:08 AM -snip- It needs to have at least 100 confirmations to be spendable.I start the mining I got the coins but I cannot spend it, do anyone has a solution to it In other words, you need to mine another 100 blocks. Title: Re: How to add premine in the bitcoin source Post by: vanshtah on February 04, 2020, 03:39:01 AM -snip- It needs to have at least 100 confirmations to be spendable.I start the mining I got the coins but I cannot spend it, do anyone has a solution to it In other words, you need to mine another 100 blocks. Title: Re: How to add premine in the bitcoin source Post by: nc50lc on February 04, 2020, 04:04:54 AM Hmm no confirmations, maybe because of the current value of MAX_MONEY (master/src/amount.h (https://github.com/bitcoin/bitcoin/blob/master/src/amount.h)) which is equal to the maximum "mineable" coins, not the actual value for max bitcoins.
The premine output exceeded the MAX_MONEY which makes those coinbase transactions with 1Billion BTC output invalid. Title: Re: How to add premine in the bitcoin source Post by: vanshtah on February 04, 2020, 04:08:59 AM Hmm no confirmations, maybe because of the current value of MAX_MONEY (master/src/amount.h (https://github.com/bitcoin/bitcoin/blob/master/src/amount.h)) which is equal to the maximum "mineable" coins. The premine output exceeded the MAX_MONEY which makes those coinbase transactions with 1Billion BTC output invalid. Updated that too Code: static const CAmount MAX_MONEY = 10000000000 * COIN; Block 4 details Code: { Title: Re: How to add premine in the bitcoin source Post by: Heisenberg_Hunter on February 06, 2020, 07:31:00 PM Guess I have answered a question of yours about building litecoin wallet way back in September last year. If you are running a cloned copy of original bitcoin code (I assume you are doing the same) you wouldn't be able to spend the genesis block coins. This was a feature which was included right from the original code by satoshi himself. If satoshi was to spend the coins from genesis block, the nodes would reject such a transaction today and this is how it was programmed. To make the genesis block coins spendable, you should probably try this out :
As for the latest version of Bitcoin Core 0.19.0.1 is concerned, the code for making the genesis block spendable is available in validation.cpp #L1936 Code: // Special case for the genesis block, skipping connection of its transactions Delete the return true; piece of line or comment the whole line. Last year, I got to read a post from stackexchange which indeed made the genesis block spendable via a fork. Will try to search them up and provide for reference. Until then, try the above one to see if you could spend your coins. Title: Re: How to add premine in the bitcoin source Post by: nc50lc on February 07, 2020, 04:18:17 AM The problem is that the coinbase transaction that he's trying to spend isn't the genesis block's.
He specifically set the block at height 4 to have a 1,000,000,000BTC reward and he's unable to spend it. I can only suggest him to try it with 'regtest' first but I suppose he already did that. |