Skip to content

Commit

Permalink
fix: erroneous judgement on the emptiness of r and s
Browse files Browse the repository at this point in the history
  • Loading branch information
aya015757881 committed Aug 9, 2024
1 parent 6a778d6 commit d98c6a6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion anychain-ethereum/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
10 changes: 4 additions & 6 deletions anychain-ethereum/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,6 @@ impl<N: EthereumNetwork> Transaction for EthereumTransaction<N> {
let mut r = adapt2(rlp.val_at::<Vec<u8>>(7))?;
let mut s = adapt2(rlp.val_at::<Vec<u8>>(8))?;

pad_zeros(&mut r, 32);
pad_zeros(&mut s, 32);

let params = EthereumTransactionParameters {
nonce,
gas_price,
Expand All @@ -169,6 +166,8 @@ impl<N: EthereumNetwork> Transaction for EthereumTransaction<N> {
let mut tx = EthereumTransaction::<N>::new(&params)?;

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()?;
Expand Down Expand Up @@ -381,9 +380,6 @@ impl<N: EthereumNetwork> Transaction for Eip1559Transaction<N> {
let mut r = adapt2(rlp.val_at::<Vec<u8>>(10))?;
let mut s = adapt2(rlp.val_at::<Vec<u8>>(11))?;

pad_zeros(&mut r, 32);
pad_zeros(&mut s, 32);

let params = Eip1559TransactionParameters {
chain_id,
nonce,
Expand All @@ -399,6 +395,8 @@ impl<N: EthereumNetwork> Transaction for Eip1559Transaction<N> {
let mut tx = Eip1559Transaction::<N>::new(&params)?;

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()?;
Expand Down

0 comments on commit d98c6a6

Please sign in to comment.