Closed Ruteri closed 5 years ago
Maybe we should restrict the number of outputs in coinbase transactions. Then it can be checked earlier.
The number of outputs in coinbase transactions is not restricted as this enables forward compatibility and you can have any number of outputs due to stake splitting.
Are you talking about a lower bound?
Yes, I meant to check that a coinbase transaction has at least two outputs.
This issue should be postponed until #811 is merged since Consensus::CheckTxInputs
has to be changed to take into account finalization rewards.
I would also like to have https://github.com/dtr-org/unit-e/pull/808 settled before that.
In case a coinbase has just one output (the reward), which is stake + block reward + fees, it fails on "bad-cb-spends-too-little", and it should fail as the reward is incorrect - should only be block reward + fees. This is because the check assumes the reward amount is correct.
Checking that the outputs spend the correct amount should be done after checking the reward (the reward has to be correct).