diff --git a/CHANGELOG.md b/CHANGELOG.md index 834a4f815..d5960eaee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ Rolling builds for the master branch may be found at [builds.etcdevteam.com](bui #### Added - JSON-RPC: `debug_traceTransaction` method +- JSON-RPC: `eth_chainId` method; returns configured Ethereum EIP-155 chain id for signing protected txs - P2P: improve peer discovery by allowing "good-will" for peers with unknown HF blocks ## [3.5.86] - 2017-07-19 - db60074 diff --git a/eth/api.go b/eth/api.go index 9cb1e1115..5999f4080 100644 --- a/eth/api.go +++ b/eth/api.go @@ -176,6 +176,15 @@ func (s *PublicEthereumAPI) Syncing() (interface{}, error) { }, nil } +// ChainId returns the chain-configured value for EIP-155 chain id, used in signing protected txs. +// If EIP-155 is not configured it will return 0. +// Number will be returned as a string in hexadecimal format. +// 61 - Mainnet $((0x3d)) +// 62 - Morden $((0x3e)) +func (s *PublicEthereumAPI) ChainId() *big.Int { + return s.e.chainConfig.GetChainID() +} + // PublicMinerAPI provides an API to control the miner. // It offers only methods that operate on data that pose no security risk when it is publicly accessible. type PublicMinerAPI struct { diff --git a/internal/web3ext/web3ext.go b/internal/web3ext/web3ext.go index af601c654..5ca29c4f3 100644 --- a/internal/web3ext/web3ext.go +++ b/internal/web3ext/web3ext.go @@ -340,6 +340,11 @@ web3._extend({ call: 'eth_submitTransaction', params: 1, inputFormatter: [web3._extend.formatters.inputTransactionFormatter] + }), + new web3._extend.Method({ + name: 'chainId', + call: 'eth_chainId', + params: 0 }) ], properties: