Skip to content

Commit

Permalink
add helper TxEnvelope
Browse files Browse the repository at this point in the history
  • Loading branch information
klkvr committed Mar 6, 2025
1 parent f987151 commit 000d339
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions crates/consensus/src/transaction/envelope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,20 @@ impl TxEnvelope {
}
}

/// Recover the signer of the transaction.
#[cfg(feature = "k256")]
pub fn try_into_recovered(
&self,
) -> Result<crate::transaction::Recovered<Self>, alloy_primitives::SignatureError> {
match self {
Self::Legacy(tx) => tx.try_into_recovered(),
Self::Eip2930(tx) => tx.try_into_recovered(),
Self::Eip1559(tx) => tx.try_into_recovered(),
Self::Eip4844(tx) => tx.try_into_recovered(),
Self::Eip7702(tx) => tx.try_into_recovered(),
}
}

/// Calculate the signing hash for the transaction.
pub fn signature_hash(&self) -> B256 {
match self {
Expand Down

0 comments on commit 000d339

Please sign in to comment.