fix: correct handling of collateral outputs for invalid transactions #77
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The current implementation processes the transaction outputs of an invalid transaction which means we can spoof balance of an address by creating an invalid transaction which sends that address funds as a txout, because these funds will be added to the address balance but actually this txout was was never created as the tx is invalid.
In this fix the collateral inputs are processed for invalid transactions as before, but now we do not process the txouts and instead check if there is a collateral return output (Babbage only) and if so we process that output as we would a normal txout.
Note that the txin of the collateral return output UTXO is defined in the ledger specification as
txhash:idx
whereidx
is the number of transaction outputs the tx has (in other words we create a UTXO in the next available index so as to not confuse with the normal transaction outputs which were not created):let idx = tx.outputs().len();