diff options
author | Péter Szilágyi <peterke@gmail.com> | 2016-11-14 19:03:29 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2016-11-15 00:00:14 +0800 |
commit | 4a439c2359991bdc49463ae66da11da895cc6eb7 (patch) | |
tree | bb5ef79628597c67af9f13c2aa7ddcf59452d482 /mobile | |
parent | 4c16c82500645de83907743555e7256af86a9423 (diff) | |
download | go-tangerine-4a439c2359991bdc49463ae66da11da895cc6eb7.tar.gz go-tangerine-4a439c2359991bdc49463ae66da11da895cc6eb7.tar.zst go-tangerine-4a439c2359991bdc49463ae66da11da895cc6eb7.zip |
mobile: port wrappers to EIP155 and EIP158 fork
Diffstat (limited to 'mobile')
-rw-r--r-- | mobile/bind.go | 4 | ||||
-rw-r--r-- | mobile/geth.go | 16 | ||||
-rw-r--r-- | mobile/params.go (renamed from mobile/core.go) | 38 | ||||
-rw-r--r-- | mobile/types.go | 6 |
4 files changed, 36 insertions, 28 deletions
diff --git a/mobile/bind.go b/mobile/bind.go index 79fb0e0e8..50adc6b0f 100644 --- a/mobile/bind.go +++ b/mobile/bind.go @@ -39,7 +39,7 @@ type signer struct { } func (s *signer) Sign(addr *Address, tx *Transaction) (*Transaction, error) { - sig, err := s.sign(addr.address, tx.tx) + sig, err := s.sign(types.HomesteadSigner{}, addr.address, tx.tx) if err != nil { return nil, err } @@ -89,7 +89,7 @@ func (opts *TransactOpts) GetGasLimit() int64 { return opts.opts.GasLimit.Int6 func (opts *TransactOpts) SetFrom(from *Address) { opts.opts.From = from.address } func (opts *TransactOpts) SetNonce(nonce int64) { opts.opts.Nonce = big.NewInt(nonce) } func (opts *TransactOpts) SetSigner(s Signer) { - opts.opts.Signer = func(addr common.Address, tx *types.Transaction) (*types.Transaction, error) { + opts.opts.Signer = func(signer types.Signer, addr common.Address, tx *types.Transaction) (*types.Transaction, error) { sig, err := s.Sign(&Address{addr}, &Transaction{tx}) if err != nil { return nil, err diff --git a/mobile/geth.go b/mobile/geth.go index 4d1f48ec3..d7f0800e0 100644 --- a/mobile/geth.go +++ b/mobile/geth.go @@ -25,7 +25,6 @@ import ( "path/filepath" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/eth" "github.com/ethereum/go-ethereum/ethclient" @@ -33,6 +32,7 @@ import ( "github.com/ethereum/go-ethereum/light" "github.com/ethereum/go-ethereum/node" "github.com/ethereum/go-ethereum/p2p/nat" + "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/whisper/whisperv2" ) @@ -129,12 +129,14 @@ func NewNode(datadir string, config *NodeConfig) (*Node, error) { // Register the Ethereum protocol if requested if config.EthereumEnabled { ethConf := ð.Config{ - ChainConfig: &core.ChainConfig{ - HomesteadBlock: big.NewInt(config.EthereumChainConfig.HomesteadBlock), - DAOForkBlock: big.NewInt(config.EthereumChainConfig.DAOForkBlock), - DAOForkSupport: config.EthereumChainConfig.DAOForkSupport, - HomesteadGasRepriceBlock: big.NewInt(config.EthereumChainConfig.HomesteadGasRepriceBlock), - HomesteadGasRepriceHash: config.EthereumChainConfig.HomesteadGasRepriceHash.hash, + ChainConfig: ¶ms.ChainConfig{ + HomesteadBlock: big.NewInt(config.EthereumChainConfig.HomesteadBlock), + DAOForkBlock: big.NewInt(config.EthereumChainConfig.DAOForkBlock), + DAOForkSupport: config.EthereumChainConfig.DAOForkSupport, + EIP150Block: big.NewInt(config.EthereumChainConfig.EIP150Block), + EIP150Hash: config.EthereumChainConfig.EIP150Hash.hash, + EIP155Block: big.NewInt(config.EthereumChainConfig.EIP155Block), + EIP158Block: big.NewInt(config.EthereumChainConfig.EIP158Block), }, Genesis: config.EthereumGenesis, LightMode: true, diff --git a/mobile/core.go b/mobile/params.go index a49a4e660..bf0df7014 100644 --- a/mobile/core.go +++ b/mobile/params.go @@ -14,7 +14,7 @@ // You should have received a copy of the GNU Lesser General Public License // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>. -// Contains all the wrappers from the core package. +// Contains all the wrappers from the params package. package geth @@ -26,11 +26,13 @@ import ( // MainnetChainConfig returns the chain configurations for the main Ethereum network. func MainnetChainConfig() *ChainConfig { return &ChainConfig{ - HomesteadBlock: params.MainNetHomesteadBlock.Int64(), - DAOForkBlock: params.MainNetDAOForkBlock.Int64(), - DAOForkSupport: true, - HomesteadGasRepriceBlock: params.MainNetHomesteadGasRepriceBlock.Int64(), - HomesteadGasRepriceHash: Hash{params.MainNetHomesteadGasRepriceHash}, + HomesteadBlock: params.MainNetHomesteadBlock.Int64(), + DAOForkBlock: params.MainNetDAOForkBlock.Int64(), + DAOForkSupport: true, + EIP150Block: params.MainNetHomesteadGasRepriceBlock.Int64(), + EIP150Hash: Hash{params.MainNetHomesteadGasRepriceHash}, + EIP155Block: params.MainNetSpuriousDragon.Int64(), + EIP158Block: params.MainNetSpuriousDragon.Int64(), } } @@ -43,11 +45,13 @@ func MainnetGenesis() string { // TestnetChainConfig returns the chain configurations for the Ethereum test network. func TestnetChainConfig() *ChainConfig { return &ChainConfig{ - HomesteadBlock: params.TestNetHomesteadBlock.Int64(), - DAOForkBlock: 0, - DAOForkSupport: false, - HomesteadGasRepriceBlock: params.TestNetHomesteadGasRepriceBlock.Int64(), - HomesteadGasRepriceHash: Hash{params.TestNetHomesteadGasRepriceHash}, + HomesteadBlock: params.TestNetHomesteadBlock.Int64(), + DAOForkBlock: 0, + DAOForkSupport: false, + EIP150Block: params.TestNetHomesteadGasRepriceBlock.Int64(), + EIP150Hash: Hash{params.TestNetHomesteadGasRepriceHash}, + EIP155Block: params.TestNetSpuriousDragon.Int64(), + EIP158Block: params.TestNetSpuriousDragon.Int64(), } } @@ -58,11 +62,13 @@ func TestnetGenesis() string { // ChainConfig is the core config which determines the blockchain settings. type ChainConfig struct { - HomesteadBlock int64 // Homestead switch block - DAOForkBlock int64 // TheDAO hard-fork switch block - DAOForkSupport bool // Whether the nodes supports or opposes the DAO hard-fork - HomesteadGasRepriceBlock int64 // Homestead gas reprice switch block - HomesteadGasRepriceHash Hash // Homestead gas reprice switch block hash + HomesteadBlock int64 // Homestead switch block + DAOForkBlock int64 // TheDAO hard-fork switch block + DAOForkSupport bool // Whether the nodes supports or opposes the DAO hard-fork + EIP150Block int64 // Homestead gas reprice switch block + EIP150Hash Hash // Homestead gas reprice switch block hash + EIP155Block int64 // Replay protection switch block + EIP158Block int64 // Empty account pruning switch block } // NewChainConfig creates a new chain configuration that transitions immediately diff --git a/mobile/types.go b/mobile/types.go index 8f54d36f0..bb5ccc625 100644 --- a/mobile/types.go +++ b/mobile/types.go @@ -139,11 +139,11 @@ func (tx *Transaction) GetValue() *BigInt { return &BigInt{tx.tx.Value()} } func (tx *Transaction) GetNonce() int64 { return int64(tx.tx.Nonce()) } func (tx *Transaction) GetHash() *Hash { return &Hash{tx.tx.Hash()} } -func (tx *Transaction) GetSigHash() *Hash { return &Hash{tx.tx.SigHash()} } +func (tx *Transaction) GetSigHash() *Hash { return &Hash{tx.tx.SigHash(types.HomesteadSigner{})} } func (tx *Transaction) GetCost() *BigInt { return &BigInt{tx.tx.Cost()} } func (tx *Transaction) GetFrom() (*Address, error) { - from, err := tx.tx.From() + from, err := types.Sender(types.HomesteadSigner{}, tx.tx) return &Address{from}, err } @@ -155,7 +155,7 @@ func (tx *Transaction) GetTo() *Address { } func (tx *Transaction) WithSignature(sig []byte) (*Transaction, error) { - t, err := tx.tx.WithSignature(sig) + t, err := tx.tx.WithSignature(types.HomesteadSigner{}, sig) return &Transaction{t}, err } |