Skip to content

Commit

Permalink
Merge pull request #22 from core-coin/feature/recover_signer
Browse files Browse the repository at this point in the history
fix recover_signer in consensus crate
  • Loading branch information
error2215 authored Jun 28, 2024
2 parents aa0f08c + 90dbe8f commit 1a3ce94
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
7 changes: 3 additions & 4 deletions crates/consensus/src/signed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,8 @@ impl<T: SignableTransaction<Signature>> Signed<T, Signature> {
/// Recover the signer of the transaction
pub fn recover_signer(
&self,
) -> Result<alloy_primitives::Address, alloy_primitives::SignatureError> {
todo!();
// let sighash = self.tx.signature_hash();
// self.signature.recover_address_from_prehash(&sighash)
) -> Result<alloy_primitives::IcanAddress, alloy_primitives::SignatureError> {
let sighash = self.tx.signature_hash();
self.signature.recover_address_from_prehash(&sighash)
}
}
8 changes: 4 additions & 4 deletions crates/consensus/src/transaction/envelope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ impl TxEnvelope {
#[cfg(feature = "k256")]
pub fn recover_signer(
&self,
) -> Result<alloy_primitives::Address, alloy_primitives::SignatureError> {
) -> Result<alloy_primitives::IcanAddress, alloy_primitives::SignatureError> {
match self {
TxEnvelope::Legacy(tx) => tx.recover_signer(),
TxEnvelope::Eip2930(tx) => tx.recover_signer(),
Expand Down Expand Up @@ -301,7 +301,7 @@ mod tests {
use super::*;
use crate::transaction::SignableTransaction;
use alloy_eips::eip2930::{AccessList, AccessListItem};
use alloy_primitives::{hex, Address, Bytes, IcanAddress, TxKind, Signature, U256};
use alloy_primitives::{hex, Address, Bytes, IcanAddress, Signature, TxKind, U256};
use core::str::FromStr;
use std::{fs, path::PathBuf, vec};

Expand All @@ -312,7 +312,7 @@ mod tests {
#[cfg(feature = "k256")]
// Test vector from https://etherscan.io/tx/0xce4dc6d7a7549a98ee3b071b67e970879ff51b5b95d1c340bacd80fa1e1aab31
fn test_decode_live_1559_tx() {
use alloy_primitives::address;
use alloy_primitives::cAddress;

let raw_tx = alloy_primitives::hex::decode("02f86f0102843b9aca0085029e7822d68298f094d9e1459a7a482635700cbc20bbaf52d495ab9c9680841b55ba3ac080a0c199674fcb29f353693dd779c017823b954b3c69dffa3cd6b2a6ff7888798039a028ca912de909e7e6cdef9cdcaf24c54dd8c1032946dfa1d85c206b32a9064fe8").unwrap();
let res = TxEnvelope::decode(&mut raw_tx.as_slice()).unwrap();
Expand All @@ -333,7 +333,7 @@ mod tests {
#[cfg(feature = "k256")]
// Test vector from https://etherscan.io/tx/0x280cde7cdefe4b188750e76c888f13bd05ce9a4d7767730feefe8a0e50ca6fc4
fn test_decode_live_legacy_tx() {
use alloy_primitives::address;
use alloy_primitives::cAddress;

let raw_tx = alloy_primitives::hex::decode("f9015482078b8505d21dba0083022ef1947a250d5630b4cf539739df2c5dacb4c659f2488d880c46549a521b13d8b8e47ff36ab50000000000000000000000000000000000000000000066ab5a608bd00a23f2fe000000000000000000000000000000000000000000000000000000000000008000000000000000000000000048c04ed5691981c42154c6167398f95e8f38a7ff00000000000000000000000000000000000000000000000000000000632ceac70000000000000000000000000000000000000000000000000000000000000002000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000006c6ee5e31d828de241282b9606c8e98ea48526e225a0c9077369501641a92ef7399ff81c21639ed4fd8fc69cb793cfa1dbfab342e10aa0615facb2f1bcf3274a354cfe384a38d0cc008a11c2dd23a69111bc6930ba27a8").unwrap();
let res = TxEnvelope::decode(&mut raw_tx.as_slice()).unwrap();
Expand Down

0 comments on commit 1a3ce94

Please sign in to comment.