correct hmy txn sender in eth_ rpc

pull/3649/head
Rongjian Lan 4 years ago committed by Leo Chen
parent 62197e3a26
commit fea8f1aa91
  1. 4
      core/types/eth_transaction.go
  2. 8
      rpc/eth/types.go

@ -21,6 +21,8 @@ import (
"math/big" "math/big"
"sync/atomic" "sync/atomic"
"github.com/harmony-one/harmony/internal/params"
"github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/common/hexutil"
nodeconfig "github.com/harmony-one/harmony/internal/configs/node" nodeconfig "github.com/harmony-one/harmony/internal/configs/node"
@ -333,7 +335,7 @@ func (tx *EthTransaction) SenderAddress() (common.Address, error) {
// IsEthCompatible returns whether the txn is ethereum compatible // IsEthCompatible returns whether the txn is ethereum compatible
func (tx *EthTransaction) IsEthCompatible() bool { func (tx *EthTransaction) IsEthCompatible() bool {
return true return params.IsEthCompatible(tx.ChainID())
} }
// AsMessage returns the transaction as a core.Message. // AsMessage returns the transaction as a core.Message.

@ -77,7 +77,13 @@ func NewTransaction(
tx *types.EthTransaction, blockHash common.Hash, tx *types.EthTransaction, blockHash common.Hash,
blockNumber uint64, timestamp uint64, index uint64, blockNumber uint64, timestamp uint64, index uint64,
) (*Transaction, error) { ) (*Transaction, error) {
from, err := tx.SenderAddress() from := common.Address{}
var err error
if tx.IsEthCompatible() {
from, err = tx.SenderAddress()
} else {
from, err = tx.ConvertToHmy().SenderAddress()
}
if err != nil { if err != nil {
return nil, err return nil, err
} }

Loading…
Cancel
Save