File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -21,7 +21,13 @@ var supportedTxs = map[string]func() TxDataV2{
21
21
22
22
// getSender extracts the sender address from the signature values using the latest signer for the given chainID.
23
23
func getSender (txData TxDataV2 ) (common.Address , error ) {
24
- signer := ethtypes .LatestSignerForChainID (txData .GetChainID ())
24
+ chainID := txData .GetChainID ()
25
+ // legacy tx returns `0` as chainID when EIP-155 is not used
26
+ // see: DeriveChainID
27
+ if chainID != nil && chainID .Sign () == 0 {
28
+ chainID = nil
29
+ }
30
+ signer := ethtypes .LatestSignerForChainID (chainID )
25
31
from , err := signer .Sender (ethtypes .NewTx (txData .AsEthereumData ()))
26
32
if err != nil {
27
33
return common.Address {}, err
Original file line number Diff line number Diff line change @@ -9,6 +9,8 @@ import "math/big"
9
9
// - {0,1} + CHAIN_ID * 2 + 35, if EIP155 is used
10
10
// - {0,1} + 27, otherwise
11
11
//
12
+ // when EIP155 is not used, chain id `0` is returned.
13
+ //
12
14
// Ref: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-155.md
13
15
func DeriveChainID (v * big.Int ) * big.Int {
14
16
if v == nil || v .Sign () < 1 {
You can’t perform that action at this time.
0 commit comments