From acc65d681d51ae9a50958d5c2f66ede10137b179 Mon Sep 17 00:00:00 2001 From: ia Date: Wed, 6 Sep 2017 11:08:06 -0500 Subject: [PATCH] eth: improve getting chainID with existence check and hexutil --- eth/api.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/eth/api.go b/eth/api.go index 74b607b6d5..35ab327ab0 100644 --- a/eth/api.go +++ b/eth/api.go @@ -72,8 +72,12 @@ func (api *PublicEthereumAPI) Hashrate() hexutil.Uint64 { } // ChainId is the EIP-155 replay-protection chain id for the current ethereum chain config. -func (api *PublicEthereumAPI) ChainId() *big.Int { - return api.e.chainConfig.ChainId +func (api *PublicEthereumAPI) ChainId() hexutil.Uint { + chainID := new(big.Int) + if config := api.e.chainConfig; config.IsEIP155(api.e.blockchain.CurrentBlock().Number()) { + chainID = config.ChainId + } + return hexutil.Uint(chainID) } // PublicMinerAPI provides an API to control the miner.