From df4f7c867e3035e2154b4408e5decd8af104e050 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 7bb6847b49..a433f8d260 100644 --- a/eth/api.go +++ b/eth/api.go @@ -68,8 +68,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.