aboutsummaryrefslogtreecommitdiffstats
path: root/xeth
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2015-03-07 19:38:33 +0800
committerFelix Lange <fjl@twurst.com>2015-03-07 19:38:33 +0800
commitd66f93cecdbae6a88bfb710e0d95d62340bf2460 (patch)
tree8e270614345c87d3ea724387ba3baf2acdfa8972 /xeth
parentbc45e5c6de3052a4c853387dea0af5cd9207f1f7 (diff)
downloaddexon-d66f93cecdbae6a88bfb710e0d95d62340bf2460.tar
dexon-d66f93cecdbae6a88bfb710e0d95d62340bf2460.tar.gz
dexon-d66f93cecdbae6a88bfb710e0d95d62340bf2460.tar.bz2
dexon-d66f93cecdbae6a88bfb710e0d95d62340bf2460.tar.lz
dexon-d66f93cecdbae6a88bfb710e0d95d62340bf2460.tar.xz
dexon-d66f93cecdbae6a88bfb710e0d95d62340bf2460.tar.zst
dexon-d66f93cecdbae6a88bfb710e0d95d62340bf2460.zip
accounts, core, eth, xeth: use account manager for everything
The account manager is now responsible for picking the default account and the coinbase.
Diffstat (limited to 'xeth')
-rw-r--r--xeth/xeth.go18
1 files changed, 12 insertions, 6 deletions
diff --git a/xeth/xeth.go b/xeth/xeth.go
index 91bd35f8e..1ad62a7bf 100644
--- a/xeth/xeth.go
+++ b/xeth/xeth.go
@@ -32,7 +32,6 @@ type Backend interface {
PeerCount() int
IsListening() bool
Peers() []*p2p.Peer
- KeyManager() *crypto.KeyManager
Db() ethutil.Database
EventMux() *event.TypeMux
Whisper() *whisper.Whisper
@@ -142,7 +141,8 @@ func (self *XEth) IsListening() bool {
}
func (self *XEth) Coinbase() string {
- return toHex(self.eth.KeyManager().Address())
+ cb, _ := self.eth.AccountManager().Coinbase()
+ return toHex(cb)
}
func (self *XEth) NumberToHuman(balance string) string {
@@ -251,10 +251,13 @@ func (self *XEth) Call(toStr, valueStr, gasStr, gasPriceStr, dataStr string) (st
gasPriceStr = "1"
}
+ acct, err := self.accountManager.Default()
+ if err != nil {
+ return "", err
+ }
var (
statedb = self.State().State() //self.chainManager.TransState()
- key = self.eth.KeyManager().KeyPair()
- from = statedb.GetOrNewStateObject(key.Address())
+ from = statedb.GetOrNewStateObject(acct.Address)
block = self.chainManager.CurrentBlock()
to = statedb.GetOrNewStateObject(fromHex(toStr))
data = fromHex(dataStr)
@@ -264,9 +267,12 @@ func (self *XEth) Call(toStr, valueStr, gasStr, gasPriceStr, dataStr string) (st
)
msg := types.NewTransactionMessage(fromHex(toStr), value, gas, price, data)
- msg.Sign(key.PrivateKey)
+ sig, err := self.accountManager.Sign(acct, msg.Hash())
+ if err != nil {
+ return "", err
+ }
+ msg.SetSignatureValues(sig)
vmenv := core.NewEnv(statedb, self.chainManager, msg, block)
-
res, err := vmenv.Call(from, to.Address(), data, gas, price, value)
if err != nil {
return "", err