From d98c6a62dff88391604855e7555624dd4064600b Mon Sep 17 00:00:00 2001 From: aya015757881 <2581015450@qq.com> Date: Fri, 9 Aug 2024 11:06:16 +0800 Subject: [PATCH] fix: erroneous judgement on the emptiness of r and s --- Cargo.lock | 8 ++++---- anychain-ethereum/Cargo.toml | 2 +- anychain-ethereum/src/transaction.rs | 10 ++++------ 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 79a74ed..639a23e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -188,7 +188,7 @@ dependencies = [ [[package]] name = "anychain-ethereum" -version = "0.1.16" +version = "0.1.17" dependencies = [ "anychain-core", "ethabi", @@ -214,7 +214,7 @@ dependencies = [ [[package]] name = "anychain-filecoin" -version = "0.1.6" +version = "0.1.7" dependencies = [ "anychain-core", "anyhow", @@ -286,7 +286,7 @@ dependencies = [ [[package]] name = "anychain-polkadot" -version = "0.1.2" +version = "0.1.3" dependencies = [ "anychain-core", "base58", @@ -309,7 +309,7 @@ dependencies = [ [[package]] name = "anychain-tron" -version = "0.2.5" +version = "0.2.6" dependencies = [ "anychain-core", "base58", diff --git a/anychain-ethereum/Cargo.toml b/anychain-ethereum/Cargo.toml index a4a5098..2c3e679 100644 --- a/anychain-ethereum/Cargo.toml +++ b/anychain-ethereum/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "anychain-ethereum" description = "A Rust library for Ethereum-focused cryptocurrency wallets, enabling seamless transactions on the Ethereum blockchain" -version = "0.1.16" +version = "0.1.17" keywords = ["blockchain", "crypto", "cryptocurrencies", "ethereum", "wallet"] # Workspace inherited keys diff --git a/anychain-ethereum/src/transaction.rs b/anychain-ethereum/src/transaction.rs index 67e3ad3..9cd48bc 100644 --- a/anychain-ethereum/src/transaction.rs +++ b/anychain-ethereum/src/transaction.rs @@ -154,9 +154,6 @@ impl Transaction for EthereumTransaction { let mut r = adapt2(rlp.val_at::>(7))?; let mut s = adapt2(rlp.val_at::>(8))?; - pad_zeros(&mut r, 32); - pad_zeros(&mut s, 32); - let params = EthereumTransactionParameters { nonce, gas_price, @@ -169,6 +166,8 @@ impl Transaction for EthereumTransaction { let mut tx = EthereumTransaction::::new(¶ms)?; if !r.is_empty() && !s.is_empty() { + pad_zeros(&mut r, 32); + pad_zeros(&mut s, 32); let sig = EthereumTransactionSignature { v, r, s }; tx.signature = Some(sig); tx.restore_sender()?; @@ -381,9 +380,6 @@ impl Transaction for Eip1559Transaction { let mut r = adapt2(rlp.val_at::>(10))?; let mut s = adapt2(rlp.val_at::>(11))?; - pad_zeros(&mut r, 32); - pad_zeros(&mut s, 32); - let params = Eip1559TransactionParameters { chain_id, nonce, @@ -399,6 +395,8 @@ impl Transaction for Eip1559Transaction { let mut tx = Eip1559Transaction::::new(¶ms)?; if !r.is_empty() && !s.is_empty() { + pad_zeros(&mut r, 32); + pad_zeros(&mut s, 32); let sig = Eip1559TransactionSignature { y_parity, r, s }; tx.signature = Some(sig); tx.restore_sender()?;