what file/method is block reward processed?

0

I have managed to build an altcoin (from litecoin source) but my coin requires that I make changes to the way rewards are made. I have been looking at the source code to try to find where block reward is handled and what method does all the work. I did find this (In what line of what file does the block reward depend on?) however this looks to be old as i don't see a main.cpp file in the litecoin source.

does anyone know the modern files/methods that handle this. I already managed to follow the steps for creating my genesis block and everything looks to be working. I'm now in the phase of making changes. I would like to find the method that handles creating a block with a block reward. I will be changing how the block reward is done.

while I see chainparams.cpp has an ability to change the reward amount. I'm looking for a way to build a new type of reward system so i will need to look at how a coin is made from nothing. My coin will not be minting coins on block creation so i need to change how that method works.

Patrick W. McMahon

Posted 2019-08-03T14:49:26.597

Reputation: 361

Answers

0

The function is called GetBlockSubsidy now and it can be found in validation.cpp.

Andrew Chow

Posted 2019-08-03T14:49:26.597

Reputation: 40 910

it looks like this method returns the amount how does this amount get accepted into a block. As this would be a transaction with no inputs and only the output of the reward.Patrick W. McMahon 2019-08-03T15:30:59.673

does IsCoinBase() have to do with that?Patrick W. McMahon 2019-08-03T15:45:15.697

Coinbase transactions have a special txid and vout combination that marks them as being coinbase transactions, which is what IsCoinbase() returns. If a transaction is a coinbase transaction, all input checks are just skipped. You can see that in ConnectBlock. The block reward is then checked after the inputs are checked here: https://github.com/bitcoin/bitcoin/blob/master/src/validation.cpp#L1940

Andrew Chow 2019-08-03T15:50:36.853

I see thank you this gets me on the right path. This looks to have solved two questions i had with removing the reward from the block and how to change how the reward is given out. Thank you.Patrick W. McMahon 2019-08-03T15:59:58.843