-
Notifications
You must be signed in to change notification settings - Fork 0
Description
UTXO style covenants, generally speaking, need to make sure they are the only covenant input in a transaction. This is typically done my checking the current index is a fixed value, typically 0.
The issue arises because the covenant usually enforces constraints on the outputs of some kind. But if a transaction is constructed so that the same covenant appears twice in the input, then both instance will end up checking the same outputs are well formed, and will find out they are. However, there will actually be twice as many inputs fund, and they end up double counting the same outputs. This often breaks the covenant.
In rare cases, like the funding covenant, it is expected the covenant appears in more than one input, and this logic is accounted for by making sure all the expected inputs appear in fixed places, e.g. inputs 0 and 1.
The current index needs to be checked in all cases, but it is currently only checked in the funding case. I personally think the most natural place to put the check is in ensure_correct_change_at_input_0 and verify the current index is also 0 (possibly renaming this function a little).