|
|
@@ -529,9 +529,13 @@ func NewPublicBlockChainAPI(b Backend) *PublicBlockChainAPI {
|
|
|
return &PublicBlockChainAPI{b}
|
|
|
}
|
|
|
|
|
|
-// ChainId returns the chainID value for transaction replay protection.
|
|
|
-func (s *PublicBlockChainAPI) ChainId() *hexutil.Big {
|
|
|
- return (*hexutil.Big)(s.b.ChainConfig().ChainID)
|
|
|
+// ChainId is the EIP-155 replay-protection chain id for the current ethereum chain config.
|
|
|
+func (api *PublicBlockChainAPI) ChainId() (*hexutil.Big, error) {
|
|
|
+ // if current block is at or past the EIP-155 replay-protection fork block, return chainID from config
|
|
|
+ if config := api.b.ChainConfig(); config.IsEIP155(api.b.CurrentBlock().Number()) {
|
|
|
+ return (*hexutil.Big)(config.ChainID), nil
|
|
|
+ }
|
|
|
+ return nil, fmt.Errorf("chain not synced beyond EIP-155 replay-protection fork block")
|
|
|
}
|
|
|
|
|
|
// BlockNumber returns the block number of the chain head.
|