Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tx: Fix EIP-155 transaction encoding on chain ID 0
When preparing Ethereum data for RLP encoding, you must convert all values to either byte arrays or lists. Scalar values (positive integers) are converted to byte arrays by using the fewest bytes possible to represent the value in big endian format. The canonical form of any scalar value prepped for RLP encoding is that any leading `0` bytes stripped. In the case of `0`, this means that the only byte (`0x00`) is stripped and you are left with an empty array. Most of the values in this code are properly 0-stripped using `bigIntToUnpaddedBuffer`. Unfortunately, it appears that the `chainId` was added without stripping leading zeros. In most cases this doesn't matter, but if someone is running a chainId 0 blockchain and they want to EIP-155 encode their transaction, the previous code would result in an invalid transaction because only the canonical form is allowed. This change fixes this bug and correctly prepares the chainId in EIP-155 transactions for RLP encoding.
- Loading branch information