aboutsummaryrefslogtreecommitdiffstats
path: root/xeth
diff options
context:
space:
mode:
Diffstat (limited to 'xeth')
-rw-r--r--xeth/frontend.go16
-rw-r--r--xeth/state.go16
-rw-r--r--xeth/types.go31
-rw-r--r--xeth/whisper.go16
-rw-r--r--xeth/whisper_filter.go16
-rw-r--r--xeth/whisper_message.go16
-rw-r--r--xeth/xeth.go91
7 files changed, 133 insertions, 69 deletions
diff --git a/xeth/frontend.go b/xeth/frontend.go
index fe1d57c50..967ccbaf5 100644
--- a/xeth/frontend.go
+++ b/xeth/frontend.go
@@ -1,3 +1,19 @@
+// Copyright 2015 The go-ethereum Authors
+// This file is part of go-ethereum.
+//
+// go-ethereum is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// go-ethereum is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+
package xeth
// Frontend should be implemented by users of XEth. Its methods are
diff --git a/xeth/state.go b/xeth/state.go
index 669cf91e6..434c4aae9 100644
--- a/xeth/state.go
+++ b/xeth/state.go
@@ -1,3 +1,19 @@
+// Copyright 2015 The go-ethereum Authors
+// This file is part of go-ethereum.
+//
+// go-ethereum is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// go-ethereum is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+
package xeth
import (
diff --git a/xeth/types.go b/xeth/types.go
index ed64dc45e..f584b69ba 100644
--- a/xeth/types.go
+++ b/xeth/types.go
@@ -1,3 +1,19 @@
+// Copyright 2014 The go-ethereum Authors
+// This file is part of go-ethereum.
+//
+// go-ethereum is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// go-ethereum is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+
package xeth
import (
@@ -60,7 +76,7 @@ type Block struct {
Hash string `json:"hash"`
Transactions *common.List `json:"transactions"`
Uncles *common.List `json:"uncles"`
- Time int64 `json:"time"`
+ Time uint64 `json:"time"`
Coinbase string `json:"coinbase"`
Name string `json:"name"`
GasLimit string `json:"gasLimit"`
@@ -149,7 +165,8 @@ func NewTx(tx *types.Transaction) *Transaction {
if to := tx.To(); to != nil {
receiver = to.Hex()
} else {
- receiver = core.AddressFromMessage(tx).Hex()
+ from, _ := tx.From()
+ receiver = crypto.CreateAddress(from, tx.Nonce()).Hex()
}
createsContract := core.MessageCreatesContract(tx)
@@ -167,16 +184,6 @@ func (self *Transaction) ToString() string {
return self.ref.String()
}
-type Key struct {
- Address string `json:"address"`
- PrivateKey string `json:"privateKey"`
- PublicKey string `json:"publicKey"`
-}
-
-func NewKey(key *crypto.KeyPair) *Key {
- return &Key{common.ToHex(key.Address()), common.ToHex(key.PrivateKey), common.ToHex(key.PublicKey)}
-}
-
type PReceipt struct {
CreatedContract bool `json:"createdContract"`
Address string `json:"address"`
diff --git a/xeth/whisper.go b/xeth/whisper.go
index edb62c748..6deae4e5c 100644
--- a/xeth/whisper.go
+++ b/xeth/whisper.go
@@ -1,3 +1,19 @@
+// Copyright 2015 The go-ethereum Authors
+// This file is part of go-ethereum.
+//
+// go-ethereum is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// go-ethereum is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+
// Contains the external API to the whisper sub-protocol.
package xeth
diff --git a/xeth/whisper_filter.go b/xeth/whisper_filter.go
index 52e70e041..b6c94ef83 100644
--- a/xeth/whisper_filter.go
+++ b/xeth/whisper_filter.go
@@ -1,3 +1,19 @@
+// Copyright 2015 The go-ethereum Authors
+// This file is part of go-ethereum.
+//
+// go-ethereum is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// go-ethereum is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+
// Contains the external API side message filter for watching, pooling and polling
// matched whisper messages, also serializing data access to avoid duplications.
diff --git a/xeth/whisper_message.go b/xeth/whisper_message.go
index c8195cec1..3c48561ec 100644
--- a/xeth/whisper_message.go
+++ b/xeth/whisper_message.go
@@ -1,3 +1,19 @@
+// Copyright 2015 The go-ethereum Authors
+// This file is part of go-ethereum.
+//
+// go-ethereum is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// go-ethereum is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+
// Contains the external API representation of a whisper message.
package xeth
diff --git a/xeth/xeth.go b/xeth/xeth.go
index 0dbedff43..d1085dc92 100644
--- a/xeth/xeth.go
+++ b/xeth/xeth.go
@@ -1,4 +1,20 @@
-// eXtended ETHereum
+// Copyright 2014 The go-ethereum Authors
+// This file is part of go-ethereum.
+//
+// go-ethereum is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// go-ethereum is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+
+// Package xeth is the interface to all Ethereum functionality.
package xeth
import (
@@ -203,34 +219,6 @@ func (self *XEth) AtStateNum(num int64) *XEth {
return self.WithState(st)
}
-// applies queued transactions originating from address onto the latest state
-// and creates a block
-// only used in tests
-// - could be removed in favour of mining on testdag (natspec e2e + networking)
-// + filters
-func (self *XEth) ApplyTestTxs(statedb *state.StateDB, address common.Address, txc uint64) (uint64, *XEth) {
- chain := self.backend.ChainManager()
- header := chain.CurrentBlock().Header()
- coinbase := statedb.GetStateObject(address)
- coinbase.SetGasLimit(big.NewInt(10000000))
- txs := self.backend.TxPool().GetQueuedTransactions()
-
- for i := 0; i < len(txs); i++ {
- for _, tx := range txs {
- if tx.Nonce() == txc {
- _, _, err := core.ApplyMessage(core.NewEnv(statedb, self.backend.ChainManager(), tx, header), tx, coinbase)
- if err != nil {
- panic(err)
- }
- txc++
- }
- }
- }
-
- xeth := self.WithState(statedb)
- return txc, xeth
-}
-
func (self *XEth) WithState(statedb *state.StateDB) *XEth {
xeth := &XEth{
backend: self.backend,
@@ -364,22 +352,12 @@ func (self *XEth) CurrentBlock() *types.Block {
return self.backend.ChainManager().CurrentBlock()
}
-func (self *XEth) GetBlockReceipts(bhash common.Hash) (receipts types.Receipts, err error) {
+func (self *XEth) GetBlockReceipts(bhash common.Hash) types.Receipts {
return self.backend.BlockProcessor().GetBlockReceipts(bhash)
}
-func (self *XEth) GetTxReceipt(txhash common.Hash) (receipt *types.Receipt, err error) {
- _, bhash, _, txi := self.EthTransactionByHash(common.ToHex(txhash[:]))
- var receipts types.Receipts
- receipts, err = self.backend.BlockProcessor().GetBlockReceipts(bhash)
- if err == nil {
- if txi < uint64(len(receipts)) {
- receipt = receipts[txi]
- } else {
- err = fmt.Errorf("Invalid tx index")
- }
- }
- return
+func (self *XEth) GetTxReceipt(txhash common.Hash) *types.Receipt {
+ return core.GetReceipt(self.backend.ExtraDb(), txhash)
}
func (self *XEth) GasLimit() *big.Int {
@@ -477,7 +455,10 @@ func (self *XEth) IsListening() bool {
}
func (self *XEth) Coinbase() string {
- eb, _ := self.backend.Etherbase()
+ eb, err := self.backend.Etherbase()
+ if err != nil {
+ return "0x0"
+ }
return eb.Hex()
}
@@ -511,15 +492,6 @@ func (self *XEth) IsContract(address string) bool {
return len(self.State().SafeGet(address).Code()) > 0
}
-func (self *XEth) SecretToAddress(key string) string {
- pair, err := crypto.NewKeyPairFromSec(common.FromHex(key))
- if err != nil {
- return ""
- }
-
- return common.ToHex(pair.Address())
-}
-
func (self *XEth) UninstallFilter(id int) bool {
defer self.filterManager.UninstallFilter(id)
@@ -802,7 +774,12 @@ func (self *XEth) PushTx(encodedTx string) (string, error) {
}
if tx.To() == nil {
- addr := core.AddressFromMessage(tx)
+ from, err := tx.From()
+ if err != nil {
+ return "", err
+ }
+
+ addr := crypto.CreateAddress(from, tx.Nonce())
glog.V(logger.Info).Infof("Tx(%x) created: %x\n", tx.Hash(), addr)
return addr.Hex(), nil
} else {
@@ -969,17 +946,17 @@ func (self *XEth) Transact(fromStr, toStr, nonceStr, valueStr, gasStr, gasPriceS
}
if contractCreation {
- addr := core.AddressFromMessage(tx)
+ addr := crypto.CreateAddress(from, nonce)
glog.V(logger.Info).Infof("Tx(%x) created: %x\n", tx.Hash(), addr)
- return addr.Hex(), nil
} else {
glog.V(logger.Info).Infof("Tx(%x) to: %x\n", tx.Hash(), tx.To())
}
- return tx.Hash().Hex(), nil
+
+ return signed.Hash().Hex(), nil
}
func (self *XEth) sign(tx *types.Transaction, from common.Address, didUnlock bool) (*types.Transaction, error) {
- hash := tx.Hash()
+ hash := tx.SigHash()
sig, err := self.doSign(from, hash, didUnlock)
if err != nil {
return tx, err