dtr-org / unit-e

A digital currency for a new era of decentralized trust
https://unit-e.io
MIT License
45 stars 15 forks source link

Coinbase with just one output fails for the wrong reason #777

Closed Ruteri closed 5 years ago

Ruteri commented 5 years ago

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).

Nizametdinov commented 5 years ago

Maybe we should restrict the number of outputs in coinbase transactions. Then it can be checked earlier.

scravy commented 5 years ago

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?

Nizametdinov commented 5 years ago

Yes, I meant to check that a coinbase transaction has at least two outputs.

Nizametdinov commented 5 years ago

This issue should be postponed until #811 is merged since Consensus::CheckTxInputs has to be changed to take into account finalization rewards.

scravy commented 5 years ago

I would also like to have https://github.com/dtr-org/unit-e/pull/808 settled before that.