Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

feat(core): Transaction::decode() sets the hash #2303

Merged
merged 1 commit into from
Apr 1, 2023

Conversation

achillelamb
Copy link
Contributor

Fixes: #1849

Motivation

As stated in issue #1849, when the function decode(rlp) is used to build a transaction from its rlp serialization (i.e. raw transaction) the field hash of the resulting Transaction is not set (set to default value, hash 0x0).

Solution

The hash field of the returned Transaction is calculated as the keccak256 of the rlp bytes.

The test for the correctness of this change can be run with

cargo test --package ethers-core types::transaction::response::tests::decode_tx_assert_hash

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

Copy link
Collaborator

@prestwich prestwich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

concept ack, running checks

@prestwich
Copy link
Collaborator

tests and build work, CI issues are unrelated. Gonna go ahead and merge

@prestwich prestwich merged commit d80e82a into gakonst:master Apr 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RLP decoding a transaction does not set hash
2 participants