Fix eip-155 transactions not being signed correctly for large chain ids #1470
+15
−1
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.
What does this PR do?
Fixes an issue signing EIP155 transactions that have large chain ids. Without this change signing EIP155 transactions with a large chain id such as 9218438534861846528 creates an incorrect v value and when the transaction is decoded it has an incorrect chain id.
Where should the reviewer start?
Look at the TransactionEncoder createEip155SignatureData method specifically line 67 to change the assignment of v from BigInteger.valueOf(chainId * 2) to BigInteger.valueOf(chainId).multiply(BigInteger.valueOf(2)
Why is it needed?
Without this change large chain ids are not encoded correctly in the signature data for EIP155 transactions.