aboutsummaryrefslogtreecommitdiffstats
path: root/rpc/api
diff options
context:
space:
mode:
authorJeffrey Wilcke <geffobscura@gmail.com>2015-07-07 21:12:56 +0800
committerJeffrey Wilcke <geffobscura@gmail.com>2015-07-07 21:12:56 +0800
commit193c62fdba3bb5c40daad6652c18d81d43518235 (patch)
tree4b77244b1ce72160a1434036977c7a473781665c /rpc/api
parenta2ce7b99501b3273b4cee65cd6784c7d1c4645f7 (diff)
parentd673c34c8d4ae83a3765ed44ae9d0fb7ce1aa3c9 (diff)
downloaddexon-193c62fdba3bb5c40daad6652c18d81d43518235.tar
dexon-193c62fdba3bb5c40daad6652c18d81d43518235.tar.gz
dexon-193c62fdba3bb5c40daad6652c18d81d43518235.tar.bz2
dexon-193c62fdba3bb5c40daad6652c18d81d43518235.tar.lz
dexon-193c62fdba3bb5c40daad6652c18d81d43518235.tar.xz
dexon-193c62fdba3bb5c40daad6652c18d81d43518235.tar.zst
dexon-193c62fdba3bb5c40daad6652c18d81d43518235.zip
Merge branch 'release/0.9.36'
Diffstat (limited to 'rpc/api')
-rw-r--r--rpc/api/admin.go252
-rw-r--r--rpc/api/admin_args.go349
-rw-r--r--rpc/api/admin_js.go115
-rw-r--r--rpc/api/api.go16
-rw-r--r--rpc/api/api_test.go21
-rw-r--r--rpc/api/args.go16
-rw-r--r--rpc/api/args_test.go16
-rw-r--r--rpc/api/db.go16
-rw-r--r--rpc/api/db_args.go16
-rw-r--r--rpc/api/db_js.go44
-rw-r--r--rpc/api/debug.go16
-rw-r--r--rpc/api/debug_args.go16
-rw-r--r--rpc/api/debug_js.go39
-rw-r--r--rpc/api/eth.go99
-rw-r--r--rpc/api/eth_args.go194
-rw-r--r--rpc/api/eth_js.go32
-rw-r--r--rpc/api/mergedapi.go18
-rw-r--r--rpc/api/miner.go26
-rw-r--r--rpc/api/miner_args.go42
-rw-r--r--rpc/api/miner_js.go40
-rw-r--r--rpc/api/net.go26
-rw-r--r--rpc/api/net_js.go48
-rw-r--r--rpc/api/parsing.go54
-rw-r--r--rpc/api/personal.go16
-rw-r--r--rpc/api/personal_args.go16
-rw-r--r--rpc/api/personal_js.go26
-rw-r--r--rpc/api/shh.go16
-rw-r--r--rpc/api/shh_args.go16
-rw-r--r--rpc/api/ssh_js.go32
-rw-r--r--rpc/api/txpool.go21
-rw-r--r--rpc/api/txpool_js.go16
-rw-r--r--rpc/api/utils.go88
-rw-r--r--rpc/api/web3.go16
-rw-r--r--rpc/api/web3_args.go16
34 files changed, 1586 insertions, 204 deletions
diff --git a/rpc/api/admin.go b/rpc/api/admin.go
index b27482cfe..f226434ad 100644
--- a/rpc/api/admin.go
+++ b/rpc/api/admin.go
@@ -1,12 +1,36 @@
+// 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 api
import (
"fmt"
"io"
+ "math/big"
"os"
+ "time"
+ "github.com/ethereum/go-ethereum/common"
+ "github.com/ethereum/go-ethereum/common/compiler"
+ "github.com/ethereum/go-ethereum/common/docserver"
+ "github.com/ethereum/go-ethereum/common/natspec"
+ "github.com/ethereum/go-ethereum/common/registrar"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/types"
+ "github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/eth"
"github.com/ethereum/go-ethereum/logger/glog"
"github.com/ethereum/go-ethereum/rlp"
@@ -24,17 +48,29 @@ const (
var (
// mapping between methods and handlers
AdminMapping = map[string]adminhandler{
- "admin_addPeer": (*adminApi).AddPeer,
- "admin_peers": (*adminApi).Peers,
- "admin_nodeInfo": (*adminApi).NodeInfo,
- "admin_exportChain": (*adminApi).ExportChain,
- "admin_importChain": (*adminApi).ImportChain,
- "admin_verbosity": (*adminApi).Verbosity,
- "admin_chainSyncStatus": (*adminApi).ChainSyncStatus,
- "admin_setSolc": (*adminApi).SetSolc,
- "admin_datadir": (*adminApi).DataDir,
- "admin_startRPC": (*adminApi).StartRPC,
- "admin_stopRPC": (*adminApi).StopRPC,
+ "admin_addPeer": (*adminApi).AddPeer,
+ "admin_peers": (*adminApi).Peers,
+ "admin_nodeInfo": (*adminApi).NodeInfo,
+ "admin_exportChain": (*adminApi).ExportChain,
+ "admin_importChain": (*adminApi).ImportChain,
+ "admin_verbosity": (*adminApi).Verbosity,
+ "admin_chainSyncStatus": (*adminApi).ChainSyncStatus,
+ "admin_setSolc": (*adminApi).SetSolc,
+ "admin_datadir": (*adminApi).DataDir,
+ "admin_startRPC": (*adminApi).StartRPC,
+ "admin_stopRPC": (*adminApi).StopRPC,
+ "admin_setGlobalRegistrar": (*adminApi).SetGlobalRegistrar,
+ "admin_setHashReg": (*adminApi).SetHashReg,
+ "admin_setUrlHint": (*adminApi).SetUrlHint,
+ "admin_saveInfo": (*adminApi).SaveInfo,
+ "admin_register": (*adminApi).Register,
+ "admin_registerUrl": (*adminApi).RegisterUrl,
+ "admin_startNatSpec": (*adminApi).StartNatSpec,
+ "admin_stopNatSpec": (*adminApi).StopNatSpec,
+ "admin_getContractInfo": (*adminApi).GetContractInfo,
+ "admin_httpGet": (*adminApi).HttpGet,
+ "admin_sleepBlocks": (*adminApi).SleepBlocks,
+ "admin_sleep": (*adminApi).Sleep,
}
)
@@ -47,6 +83,7 @@ type adminApi struct {
ethereum *eth.Ethereum
codec codec.Codec
coder codec.ApiCoder
+ ds *docserver.DocServer
}
// create a new admin api instance
@@ -56,6 +93,7 @@ func NewAdminApi(xeth *xeth.XEth, ethereum *eth.Ethereum, codec codec.Codec) *ad
ethereum: ethereum,
codec: codec,
coder: codec.New(nil),
+ ds: docserver.New("/"),
}
}
@@ -244,3 +282,195 @@ func (self *adminApi) StopRPC(req *shared.Request) (interface{}, error) {
comms.StopHttp()
return true, nil
}
+
+func (self *adminApi) SleepBlocks(req *shared.Request) (interface{}, error) {
+ args := new(SleepBlocksArgs)
+ if err := self.coder.Decode(req.Params, &args); err != nil {
+ return nil, shared.NewDecodeParamError(err.Error())
+ }
+ var timer <-chan time.Time
+ var height *big.Int
+ var err error
+ if args.Timeout > 0 {
+ timer = time.NewTimer(time.Duration(args.Timeout) * time.Second).C
+ }
+
+ height = new(big.Int).Add(self.xeth.CurrentBlock().Number(), big.NewInt(args.N))
+ height, err = sleepBlocks(self.xeth.UpdateState(), height, timer)
+ if err != nil {
+ return nil, err
+ }
+ return height.Uint64(), nil
+}
+
+func sleepBlocks(wait chan *big.Int, height *big.Int, timer <-chan time.Time) (newHeight *big.Int, err error) {
+ wait <- height
+ select {
+ case <-timer:
+ // if times out make sure the xeth loop does not block
+ go func() {
+ select {
+ case wait <- nil:
+ case <-wait:
+ }
+ }()
+ return nil, fmt.Errorf("timeout")
+ case newHeight = <-wait:
+ }
+ return
+}
+
+func (self *adminApi) Sleep(req *shared.Request) (interface{}, error) {
+ args := new(SleepArgs)
+ if err := self.coder.Decode(req.Params, &args); err != nil {
+ return nil, shared.NewDecodeParamError(err.Error())
+ }
+ time.Sleep(time.Duration(args.S) * time.Second)
+ return nil, nil
+}
+
+func (self *adminApi) SetGlobalRegistrar(req *shared.Request) (interface{}, error) {
+ args := new(SetGlobalRegistrarArgs)
+ if err := self.coder.Decode(req.Params, &args); err != nil {
+ return nil, shared.NewDecodeParamError(err.Error())
+ }
+
+ sender := common.HexToAddress(args.ContractAddress)
+
+ reg := registrar.New(self.xeth)
+ txhash, err := reg.SetGlobalRegistrar(args.NameReg, sender)
+ if err != nil {
+ return false, err
+ }
+
+ return txhash, nil
+}
+
+func (self *adminApi) SetHashReg(req *shared.Request) (interface{}, error) {
+ args := new(SetHashRegArgs)
+ if err := self.coder.Decode(req.Params, &args); err != nil {
+ return nil, shared.NewDecodeParamError(err.Error())
+ }
+
+ reg := registrar.New(self.xeth)
+ sender := common.HexToAddress(args.Sender)
+ txhash, err := reg.SetHashReg(args.HashReg, sender)
+ if err != nil {
+ return false, err
+ }
+
+ return txhash, nil
+}
+
+func (self *adminApi) SetUrlHint(req *shared.Request) (interface{}, error) {
+ args := new(SetUrlHintArgs)
+ if err := self.coder.Decode(req.Params, &args); err != nil {
+ return nil, shared.NewDecodeParamError(err.Error())
+ }
+
+ urlHint := args.UrlHint
+ sender := common.HexToAddress(args.Sender)
+
+ reg := registrar.New(self.xeth)
+ txhash, err := reg.SetUrlHint(urlHint, sender)
+ if err != nil {
+ return nil, err
+ }
+
+ return txhash, nil
+}
+
+func (self *adminApi) SaveInfo(req *shared.Request) (interface{}, error) {
+ args := new(SaveInfoArgs)
+ if err := self.coder.Decode(req.Params, &args); err != nil {
+ return nil, shared.NewDecodeParamError(err.Error())
+ }
+
+ contenthash, err := compiler.SaveInfo(&args.ContractInfo, args.Filename)
+ if err != nil {
+ return nil, err
+ }
+
+ return contenthash.Hex(), nil
+}
+
+func (self *adminApi) Register(req *shared.Request) (interface{}, error) {
+ args := new(RegisterArgs)
+ if err := self.coder.Decode(req.Params, &args); err != nil {
+ return nil, shared.NewDecodeParamError(err.Error())
+ }
+
+ sender := common.HexToAddress(args.Sender)
+ // sender and contract address are passed as hex strings
+ codeb := self.xeth.CodeAtBytes(args.Address)
+ codeHash := common.BytesToHash(crypto.Sha3(codeb))
+ contentHash := common.HexToHash(args.ContentHashHex)
+ registry := registrar.New(self.xeth)
+
+ _, err := registry.SetHashToHash(sender, codeHash, contentHash)
+ if err != nil {
+ return false, err
+ }
+
+ return true, nil
+}
+
+func (self *adminApi) RegisterUrl(req *shared.Request) (interface{}, error) {
+ args := new(RegisterUrlArgs)
+ if err := self.coder.Decode(req.Params, &args); err != nil {
+ return nil, shared.NewDecodeParamError(err.Error())
+ }
+
+ sender := common.HexToAddress(args.Sender)
+ registry := registrar.New(self.xeth)
+ _, err := registry.SetUrlToHash(sender, common.HexToHash(args.ContentHash), args.Url)
+ if err != nil {
+ return false, err
+ }
+
+ return true, nil
+}
+
+func (self *adminApi) StartNatSpec(req *shared.Request) (interface{}, error) {
+ self.ethereum.NatSpec = true
+ return true, nil
+}
+
+func (self *adminApi) StopNatSpec(req *shared.Request) (interface{}, error) {
+ self.ethereum.NatSpec = false
+ return true, nil
+}
+
+func (self *adminApi) GetContractInfo(req *shared.Request) (interface{}, error) {
+ args := new(GetContractInfoArgs)
+ if err := self.coder.Decode(req.Params, &args); err != nil {
+ return nil, shared.NewDecodeParamError(err.Error())
+ }
+
+ infoDoc, err := natspec.FetchDocsForContract(args.Contract, self.xeth, self.ds)
+ if err != nil {
+ return nil, err
+ }
+
+ var info interface{}
+ err = self.coder.Decode(infoDoc, &info)
+ if err != nil {
+ return nil, err
+ }
+
+ return info, nil
+}
+
+func (self *adminApi) HttpGet(req *shared.Request) (interface{}, error) {
+ args := new(HttpGetArgs)
+ if err := self.coder.Decode(req.Params, &args); err != nil {
+ return nil, shared.NewDecodeParamError(err.Error())
+ }
+
+ resp, err := self.ds.Get(args.Uri, args.Path)
+ if err != nil {
+ return nil, err
+ }
+
+ return string(resp), nil
+}
diff --git a/rpc/api/admin_args.go b/rpc/api/admin_args.go
index 5437971ca..60a1fb496 100644
--- a/rpc/api/admin_args.go
+++ b/rpc/api/admin_args.go
@@ -1,8 +1,25 @@
+// 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 api
import (
"encoding/json"
+ "github.com/ethereum/go-ethereum/common/compiler"
"github.com/ethereum/go-ethereum/rpc/shared"
)
@@ -113,7 +130,7 @@ func (args *StartRPCArgs) UnmarshalJSON(b []byte) (err error) {
args.ListenPort = 8545
args.Apis = "net,eth,web3"
- if len(obj) >= 1 {
+ if len(obj) >= 1 && obj[0] != nil {
if addr, ok := obj[0].(string); ok {
args.ListenAddress = addr
} else {
@@ -121,7 +138,7 @@ func (args *StartRPCArgs) UnmarshalJSON(b []byte) (err error) {
}
}
- if len(obj) >= 2 {
+ if len(obj) >= 2 && obj[1] != nil {
if port, ok := obj[1].(float64); ok && port >= 0 && port <= 64*1024 {
args.ListenPort = uint(port)
} else {
@@ -129,7 +146,7 @@ func (args *StartRPCArgs) UnmarshalJSON(b []byte) (err error) {
}
}
- if len(obj) >= 3 {
+ if len(obj) >= 3 && obj[2] != nil {
if corsDomain, ok := obj[2].(string); ok {
args.CorsDomain = corsDomain
} else {
@@ -137,7 +154,7 @@ func (args *StartRPCArgs) UnmarshalJSON(b []byte) (err error) {
}
}
- if len(obj) >= 4 {
+ if len(obj) >= 4 && obj[3] != nil {
if apis, ok := obj[3].(string); ok {
args.Apis = apis
} else {
@@ -147,3 +164,327 @@ func (args *StartRPCArgs) UnmarshalJSON(b []byte) (err error) {
return nil
}
+
+type SleepArgs struct {
+ S int
+}
+
+func (args *SleepArgs) UnmarshalJSON(b []byte) (err error) {
+
+ var obj []interface{}
+ if err := json.Unmarshal(b, &obj); err != nil {
+ return shared.NewDecodeParamError(err.Error())
+ }
+ if len(obj) >= 1 {
+ if obj[0] != nil {
+ if n, err := numString(obj[0]); err == nil {
+ args.S = int(n.Int64())
+ } else {
+ return shared.NewInvalidTypeError("N", "not an integer: "+err.Error())
+ }
+ } else {
+ return shared.NewInsufficientParamsError(0, 1)
+ }
+ }
+ return nil
+}
+
+type SleepBlocksArgs struct {
+ N int64
+ Timeout int64
+}
+
+func (args *SleepBlocksArgs) UnmarshalJSON(b []byte) (err error) {
+
+ var obj []interface{}
+ if err := json.Unmarshal(b, &obj); err != nil {
+ return shared.NewDecodeParamError(err.Error())
+ }
+
+ args.N = 1
+ args.Timeout = 0
+ if len(obj) >= 1 && obj[0] != nil {
+ if n, err := numString(obj[0]); err == nil {
+ args.N = n.Int64()
+ } else {
+ return shared.NewInvalidTypeError("N", "not an integer: "+err.Error())
+ }
+ }
+
+ if len(obj) >= 2 && obj[1] != nil {
+ if n, err := numString(obj[1]); err == nil {
+ args.Timeout = n.Int64()
+ } else {
+ return shared.NewInvalidTypeError("Timeout", "not an integer: "+err.Error())
+ }
+ }
+
+ return nil
+}
+
+type SetGlobalRegistrarArgs struct {
+ NameReg string
+ ContractAddress string
+}
+
+func (args *SetGlobalRegistrarArgs) UnmarshalJSON(b []byte) (err error) {
+ var obj []interface{}
+ if err := json.Unmarshal(b, &obj); err != nil {
+ return shared.NewDecodeParamError(err.Error())
+ }
+
+ if len(obj) == 0 {
+ return shared.NewDecodeParamError("Expected namereg address")
+ }
+
+ if len(obj) >= 1 {
+ if namereg, ok := obj[0].(string); ok {
+ args.NameReg = namereg
+ } else {
+ return shared.NewInvalidTypeError("NameReg", "not a string")
+ }
+ }
+
+ if len(obj) >= 2 && obj[1] != nil {
+ if addr, ok := obj[1].(string); ok {
+ args.ContractAddress = addr
+ } else {
+ return shared.NewInvalidTypeError("ContractAddress", "not a string")
+ }
+ }
+
+ return nil
+}
+
+type SetHashRegArgs struct {
+ HashReg string
+ Sender string
+}
+
+func (args *SetHashRegArgs) UnmarshalJSON(b []byte) (err error) {
+ var obj []interface{}
+ if err := json.Unmarshal(b, &obj); err != nil {
+ return shared.NewDecodeParamError(err.Error())
+ }
+
+ if len(obj) >= 1 && obj[0] != nil {
+ if hashreg, ok := obj[0].(string); ok {
+ args.HashReg = hashreg
+ } else {
+ return shared.NewInvalidTypeError("HashReg", "not a string")
+ }
+ }
+
+ if len(obj) >= 2 && obj[1] != nil {
+ if sender, ok := obj[1].(string); ok {
+ args.Sender = sender
+ } else {
+ return shared.NewInvalidTypeError("Sender", "not a string")
+ }
+ }
+
+ return nil
+}
+
+type SetUrlHintArgs struct {
+ UrlHint string
+ Sender string
+}
+
+func (args *SetUrlHintArgs) UnmarshalJSON(b []byte) (err error) {
+ var obj []interface{}
+ if err := json.Unmarshal(b, &obj); err != nil {
+ return shared.NewDecodeParamError(err.Error())
+ }
+
+ if len(obj) >= 1 && obj[0] != nil {
+ if urlhint, ok := obj[0].(string); ok {
+ args.UrlHint = urlhint
+ } else {
+ return shared.NewInvalidTypeError("UrlHint", "not a string")
+ }
+ }
+
+ if len(obj) >= 2 && obj[1] != nil {
+ if sender, ok := obj[1].(string); ok {
+ args.Sender = sender
+ } else {
+ return shared.NewInvalidTypeError("Sender", "not a string")
+ }
+ }
+
+ return nil
+}
+
+type SaveInfoArgs struct {
+ ContractInfo compiler.ContractInfo
+ Filename string
+}
+
+func (args *SaveInfoArgs) UnmarshalJSON(b []byte) (err error) {
+ var obj []interface{}
+ if err := json.Unmarshal(b, &obj); err != nil {
+ return shared.NewDecodeParamError(err.Error())
+ }
+
+ if len(obj) < 2 {
+ return shared.NewInsufficientParamsError(len(obj), 2)
+ }
+
+ if jsonraw, err := json.Marshal(obj[0]); err == nil {
+ if err = json.Unmarshal(jsonraw, &args.ContractInfo); err != nil {
+ return err
+ }
+ } else {
+ return err
+ }
+
+ if filename, ok := obj[1].(string); ok {
+ args.Filename = filename
+ } else {
+ return shared.NewInvalidTypeError("Filename", "not a string")
+ }
+
+ return nil
+}
+
+type RegisterArgs struct {
+ Sender string
+ Address string
+ ContentHashHex string
+}
+
+func (args *RegisterArgs) UnmarshalJSON(b []byte) (err error) {
+ var obj []interface{}
+ if err := json.Unmarshal(b, &obj); err != nil {
+ return shared.NewDecodeParamError(err.Error())
+ }
+
+ if len(obj) < 3 {
+ return shared.NewInsufficientParamsError(len(obj), 3)
+ }
+
+ if len(obj) >= 1 {
+ if sender, ok := obj[0].(string); ok {
+ args.Sender = sender
+ } else {
+ return shared.NewInvalidTypeError("Sender", "not a string")
+ }
+ }
+
+ if len(obj) >= 2 {
+ if address, ok := obj[1].(string); ok {
+ args.Address = address
+ } else {
+ return shared.NewInvalidTypeError("Address", "not a string")
+ }
+ }
+
+ if len(obj) >= 3 {
+ if hex, ok := obj[2].(string); ok {
+ args.ContentHashHex = hex
+ } else {
+ return shared.NewInvalidTypeError("ContentHashHex", "not a string")
+ }
+ }
+
+ return nil
+}
+
+type RegisterUrlArgs struct {
+ Sender string
+ ContentHash string
+ Url string
+}
+
+func (args *RegisterUrlArgs) UnmarshalJSON(b []byte) (err error) {
+ var obj []interface{}
+ if err := json.Unmarshal(b, &obj); err != nil {
+ return shared.NewDecodeParamError(err.Error())
+ }
+
+ if len(obj) >= 1 {
+ if sender, ok := obj[0].(string); ok {
+ args.Sender = sender
+ } else {
+ return shared.NewInvalidTypeError("Sender", "not a string")
+ }
+ }
+
+ if len(obj) >= 2 {
+ if sender, ok := obj[1].(string); ok {
+ args.ContentHash = sender
+ } else {
+ return shared.NewInvalidTypeError("ContentHash", "not a string")
+ }
+ }
+
+ if len(obj) >= 3 {
+ if sender, ok := obj[2].(string); ok {
+ args.Url = sender
+ } else {
+ return shared.NewInvalidTypeError("Url", "not a string")
+ }
+ }
+
+ return nil
+}
+
+type GetContractInfoArgs struct {
+ Contract string
+}
+
+func (args *GetContractInfoArgs) UnmarshalJSON(b []byte) (err error) {
+ var obj []interface{}
+ if err := json.Unmarshal(b, &obj); err != nil {
+ return shared.NewDecodeParamError(err.Error())
+ }
+
+ if len(obj) < 1 {
+ return shared.NewInsufficientParamsError(len(obj), 1)
+ }
+
+ if len(obj) >= 1 {
+ if contract, ok := obj[0].(string); ok {
+ args.Contract = contract
+ } else {
+ return shared.NewInvalidTypeError("Contract", "not a string")
+ }
+ }
+
+ return nil
+}
+
+type HttpGetArgs struct {
+ Uri string
+ Path string
+}
+
+func (args *HttpGetArgs) UnmarshalJSON(b []byte) (err error) {
+ var obj []interface{}
+ if err := json.Unmarshal(b, &obj); err != nil {
+ return shared.NewDecodeParamError(err.Error())
+ }
+
+ if len(obj) < 1 {
+ return shared.NewInsufficientParamsError(len(obj), 1)
+ }
+
+ if len(obj) >= 1 {
+ if uri, ok := obj[0].(string); ok {
+ args.Uri = uri
+ } else {
+ return shared.NewInvalidTypeError("Uri", "not a string")
+ }
+ }
+
+ if len(obj) >= 2 && obj[1] != nil {
+ if path, ok := obj[1].(string); ok {
+ args.Path = path
+ } else {
+ return shared.NewInvalidTypeError("Path", "not a string")
+ }
+ }
+
+ return nil
+}
diff --git a/rpc/api/admin_js.go b/rpc/api/admin_js.go
index 97642ade7..b0ba6febb 100644
--- a/rpc/api/admin_js.go
+++ b/rpc/api/admin_js.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 api
const Admin_JS = `
@@ -9,73 +25,128 @@ web3._extend({
name: 'addPeer',
call: 'admin_addPeer',
params: 1,
- inputFormatter: [web3._extend.utils.formatInputString],
- outputFormatter: web3._extend.formatters.formatOutputBool
+ inputFormatter: [null]
}),
new web3._extend.Method({
name: 'exportChain',
call: 'admin_exportChain',
params: 1,
- inputFormatter: [web3._extend.utils.formatInputString],
- outputFormatter: function(obj) { return obj; }
+ inputFormatter: [null]
}),
new web3._extend.Method({
name: 'importChain',
call: 'admin_importChain',
params: 1,
- inputFormatter: [web3._extend.utils.formatInputString],
- outputFormatter: function(obj) { return obj; }
+ inputFormatter: [null]
+ }),
+ new web3._extend.Method({
+ name: 'sleepBlocks',
+ call: 'admin_sleepBlocks',
+ params: 2,
+ inputFormatter: [null, null]
}),
new web3._extend.Method({
name: 'verbosity',
call: 'admin_verbosity',
params: 1,
- inputFormatter: [web3._extend.utils.formatInputInt],
- outputFormatter: web3._extend.formatters.formatOutputBool
+ inputFormatter: [web3._extend.utils.fromDecimal]
}),
new web3._extend.Method({
name: 'setSolc',
call: 'admin_setSolc',
params: 1,
- inputFormatter: [web3._extend.utils.formatInputString],
- outputFormatter: web3._extend.formatters.formatOutputString
+ inputFormatter: [null]
}),
new web3._extend.Method({
name: 'startRPC',
call: 'admin_startRPC',
params: 4,
- inputFormatter: [web3._extend.utils.formatInputString,web3._extend.utils.formatInputInteger,web3._extend.utils.formatInputString,web3._extend.utils.formatInputString],
- outputFormatter: web3._extend.formatters.formatOutputBool
+ inputFormatter: [null, null, null, null]
}),
new web3._extend.Method({
name: 'stopRPC',
call: 'admin_stopRPC',
params: 0,
- inputFormatter: [],
- outputFormatter: web3._extend.formatters.formatOutputBool
+ inputFormatter: []
+ }),
+ new web3._extend.Method({
+ name: 'setGlobalRegistrar',
+ call: 'admin_setGlobalRegistrar',
+ params: 2,
+ inputFormatter: [null,null]
+ }),
+ new web3._extend.Method({
+ name: 'setHashReg',
+ call: 'admin_setHashReg',
+ params: 2,
+ inputFormatter: [null,null]
+ }),
+ new web3._extend.Method({
+ name: 'setUrlHint',
+ call: 'admin_setUrlHint',
+ params: 2,
+ inputFormatter: [null,null]
+ }),
+ new web3._extend.Method({
+ name: 'saveInfo',
+ call: 'admin_saveInfo',
+ params: 2,
+ inputFormatter: [null,null]
+ }),
+ new web3._extend.Method({
+ name: 'register',
+ call: 'admin_register',
+ params: 3,
+ inputFormatter: [null,null,null]
+ }),
+ new web3._extend.Method({
+ name: 'registerUrl',
+ call: 'admin_registerUrl',
+ params: 3,
+ inputFormatter: [null,null,null]
+ }),
+ new web3._extend.Method({
+ name: 'startNatSpec',
+ call: 'admin_startNatSpec',
+ params: 0,
+ inputFormatter: []
+ }),
+ new web3._extend.Method({
+ name: 'stopNatSpec',
+ call: 'admin_stopNatSpec',
+ params: 0,
+ inputFormatter: []
+ }),
+ new web3._extend.Method({
+ name: 'getContractInfo',
+ call: 'admin_getContractInfo',
+ params: 1,
+ inputFormatter: [null],
+ }),
+ new web3._extend.Method({
+ name: 'httpGet',
+ call: 'admin_httpGet',
+ params: 2,
+ inputFormatter: [null, null]
})
],
properties:
[
new web3._extend.Property({
name: 'nodeInfo',
- getter: 'admin_nodeInfo',
- outputFormatter: web3._extend.formatters.formatOutputString
+ getter: 'admin_nodeInfo'
}),
new web3._extend.Property({
name: 'peers',
- getter: 'admin_peers',
- outputFormatter: function(obj) { return obj; }
+ getter: 'admin_peers'
}),
new web3._extend.Property({
name: 'datadir',
- getter: 'admin_datadir',
- outputFormatter: web3._extend.formatters.formatOutputString
+ getter: 'admin_datadir'
}),
new web3._extend.Property({
name: 'chainSyncStatus',
- getter: 'admin_chainSyncStatus',
- outputFormatter: function(obj) { return obj; }
+ getter: 'admin_chainSyncStatus'
})
]
});
diff --git a/rpc/api/api.go b/rpc/api/api.go
index ca1ccb9a5..81e1e9cb2 100644
--- a/rpc/api/api.go
+++ b/rpc/api/api.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 api
import (
diff --git a/rpc/api/api_test.go b/rpc/api/api_test.go
index 7e273ef28..8ef1d57e0 100644
--- a/rpc/api/api_test.go
+++ b/rpc/api/api_test.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 api
import (
@@ -76,8 +92,9 @@ func TestCompileSolidity(t *testing.T) {
expLanguageVersion := "0"
expSource := source
- xeth := xeth.NewTest(&eth.Ethereum{}, nil)
- api := NewEthApi(xeth, codec.JSON)
+ eth := &eth.Ethereum{}
+ xeth := xeth.NewTest(eth, nil)
+ api := NewEthApi(xeth, eth, codec.JSON)
var rpcRequest shared.Request
json.Unmarshal([]byte(jsonstr), &rpcRequest)
diff --git a/rpc/api/args.go b/rpc/api/args.go
index fc85448e6..3b746a50a 100644
--- a/rpc/api/args.go
+++ b/rpc/api/args.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 api
import (
diff --git a/rpc/api/args_test.go b/rpc/api/args_test.go
index a30f247bc..73d97f659 100644
--- a/rpc/api/args_test.go
+++ b/rpc/api/args_test.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 api
import (
diff --git a/rpc/api/db.go b/rpc/api/db.go
index 6f10d6447..eb206c4d7 100644
--- a/rpc/api/db.go
+++ b/rpc/api/db.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 api
import (
diff --git a/rpc/api/db_args.go b/rpc/api/db_args.go
index 459616d87..7e0a37078 100644
--- a/rpc/api/db_args.go
+++ b/rpc/api/db_args.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 api
import (
diff --git a/rpc/api/db_js.go b/rpc/api/db_js.go
index 62cdcd20e..20001883d 100644
--- a/rpc/api/db_js.go
+++ b/rpc/api/db_js.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 api
const Db_JS = `
@@ -5,34 +21,6 @@ web3._extend({
property: 'db',
methods:
[
- new web3._extend.Method({
- name: 'getString',
- call: 'db_getString',
- params: 2,
- inputFormatter: [web3._extend.formatters.formatInputString, web3._extend.formatters.formatInputString],
- outputFormatter: web3._extend.formatters.formatOutputString
- }),
- new web3._extend.Method({
- name: 'putString',
- call: 'db_putString',
- params: 3,
- inputFormatter: [web3._extend.formatters.formatInputString, web3._extend.formatters.formatInputString, web3._extend.formatters.formatInputString],
- outputFormatter: web3._extend.formatters.formatOutputBool
- }),
- new web3._extend.Method({
- name: 'getHex',
- call: 'db_getHex',
- params: 2,
- inputFormatter: [web3._extend.formatters.formatInputString, web3._extend.formatters.formatInputString],
- outputFormatter: web3._extend.formatters.formatOutputString
- }),
- new web3._extend.Method({
- name: 'putHex',
- call: 'db_putHex',
- params: 3,
- inputFormatter: [web3._extend.formatters.formatInputString, web3._extend.formatters.formatInputString, web3._extend.formatters.formatInputString],
- outputFormatter: web3._extend.formatters.formatOutputBool
- }),
],
properties:
[
diff --git a/rpc/api/debug.go b/rpc/api/debug.go
index f16f62d2e..2a3cda6c6 100644
--- a/rpc/api/debug.go
+++ b/rpc/api/debug.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 api
import (
diff --git a/rpc/api/debug_args.go b/rpc/api/debug_args.go
index b72fb03ae..acac53413 100644
--- a/rpc/api/debug_args.go
+++ b/rpc/api/debug_args.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 api
import (
diff --git a/rpc/api/debug_js.go b/rpc/api/debug_js.go
index bd3a6dfb2..faedefb27 100644
--- a/rpc/api/debug_js.go
+++ b/rpc/api/debug_js.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 api
const Debug_JS = `
@@ -9,50 +25,43 @@ web3._extend({
name: 'printBlock',
call: 'debug_printBlock',
params: 1,
- inputFormatter: [web3._extend.formatters.formatInputInt],
- outputFormatter: web3._extend.formatters.formatOutputString
+ inputFormatter: [web3._extend.formatters.inputBlockNumberFormatter]
}),
new web3._extend.Method({
name: 'getBlockRlp',
call: 'debug_getBlockRlp',
params: 1,
- inputFormatter: [web3._extend.formatters.formatInputInt],
- outputFormatter: web3._extend.formatters.formatOutputString
+ inputFormatter: [web3._extend.formatters.inputBlockNumberFormatter]
}),
new web3._extend.Method({
name: 'setHead',
call: 'debug_setHead',
params: 1,
- inputFormatter: [web3._extend.formatters.formatInputInt],
- outputFormatter: web3._extend.formatters.formatOutputBool
+ inputFormatter: [web3._extend.formatters.inputBlockNumberFormatter]
}),
new web3._extend.Method({
name: 'processBlock',
call: 'debug_processBlock',
params: 1,
- inputFormatter: [web3._extend.formatters.formatInputInt],
- outputFormatter: function(obj) { return obj; }
+ inputFormatter: [web3._extend.formatters.inputBlockNumberFormatter]
}),
new web3._extend.Method({
name: 'seedHash',
call: 'debug_seedHash',
params: 1,
- inputFormatter: [web3._extend.formatters.formatInputInt],
- outputFormatter: web3._extend.formatters.formatOutputString
- }) ,
+ inputFormatter: [web3._extend.formatters.inputBlockNumberFormatter]
+ }),
new web3._extend.Method({
name: 'dumpBlock',
call: 'debug_dumpBlock',
params: 1,
- inputFormatter: [web3._extend.formatters.formatInputInt],
- outputFormatter: function(obj) { return obj; }
+ inputFormatter: [web3._extend.formatters.inputBlockNumberFormatter]
}),
new web3._extend.Method({
name: 'metrics',
call: 'debug_metrics',
params: 1,
- inputFormatter: [web3._extend.formatters.formatInputBool],
- outputFormatter: function(obj) { return obj; }
+ inputFormatter: [null]
})
],
properties:
diff --git a/rpc/api/eth.go b/rpc/api/eth.go
index 962c8d0f9..6c4745504 100644
--- a/rpc/api/eth.go
+++ b/rpc/api/eth.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 api
import (
@@ -6,9 +22,12 @@ import (
"math/big"
"github.com/ethereum/go-ethereum/common"
+ "github.com/ethereum/go-ethereum/core/types"
+ "github.com/ethereum/go-ethereum/eth"
"github.com/ethereum/go-ethereum/rpc/codec"
"github.com/ethereum/go-ethereum/rpc/shared"
"github.com/ethereum/go-ethereum/xeth"
+ "gopkg.in/fatih/set.v0"
)
const (
@@ -18,9 +37,10 @@ const (
// eth api provider
// See https://github.com/ethereum/wiki/wiki/JSON-RPC
type ethApi struct {
- xeth *xeth.XEth
- methods map[string]ethhandler
- codec codec.ApiCoder
+ xeth *xeth.XEth
+ ethereum *eth.Ethereum
+ methods map[string]ethhandler
+ codec codec.ApiCoder
}
// eth callback handler
@@ -71,12 +91,15 @@ var (
"eth_hashrate": (*ethApi).Hashrate,
"eth_getWork": (*ethApi).GetWork,
"eth_submitWork": (*ethApi).SubmitWork,
+ "eth_resend": (*ethApi).Resend,
+ "eth_pendingTransactions": (*ethApi).PendingTransactions,
+ "eth_getTransactionReceipt": (*ethApi).GetTransactionReceipt,
}
)
// create new ethApi instance
-func NewEthApi(xeth *xeth.XEth, codec codec.Codec) *ethApi {
- return &ethApi{xeth, ethMapping, codec.New(nil)}
+func NewEthApi(xeth *xeth.XEth, eth *eth.Ethereum, codec codec.Codec) *ethApi {
+ return &ethApi{xeth, eth, ethMapping, codec.New(nil)}
}
// collection with supported methods
@@ -548,3 +571,69 @@ func (self *ethApi) SubmitWork(req *shared.Request) (interface{}, error) {
}
return self.xeth.RemoteMining().SubmitWork(args.Nonce, common.HexToHash(args.Digest), common.HexToHash(args.Header)), nil
}
+
+func (self *ethApi) Resend(req *shared.Request) (interface{}, error) {
+ args := new(ResendArgs)
+ if err := self.codec.Decode(req.Params, &args); err != nil {
+ return nil, shared.NewDecodeParamError(err.Error())
+ }
+
+ ret, err := self.xeth.Transact(args.Tx.From, args.Tx.To, args.Tx.Nonce, args.Tx.Value, args.GasLimit, args.GasPrice, args.Tx.Data)
+ if err != nil {
+ return nil, err
+ }
+
+ self.ethereum.TxPool().RemoveTransactions(types.Transactions{args.Tx.tx})
+
+ return ret, nil
+}
+
+func (self *ethApi) PendingTransactions(req *shared.Request) (interface{}, error) {
+ txs := self.ethereum.TxPool().GetTransactions()
+
+ // grab the accounts from the account manager. This will help with determining which
+ // transactions should be returned.
+ accounts, err := self.ethereum.AccountManager().Accounts()
+ if err != nil {
+ return nil, err
+ }
+
+ // Add the accouns to a new set
+ accountSet := set.New()
+ for _, account := range accounts {
+ accountSet.Add(account.Address)
+ }
+
+ var ltxs []*tx
+ for _, tx := range txs {
+ if from, _ := tx.From(); accountSet.Has(from) {
+ ltxs = append(ltxs, newTx(tx))
+ }
+ }
+
+ return ltxs, nil
+}
+
+func (self *ethApi) GetTransactionReceipt(req *shared.Request) (interface{}, error) {
+ args := new(HashArgs)
+ if err := self.codec.Decode(req.Params, &args); err != nil {
+ return nil, shared.NewDecodeParamError(err.Error())
+ }
+
+ txhash := common.BytesToHash(common.FromHex(args.Hash))
+ tx, bhash, bnum, txi := self.xeth.EthTransactionByHash(args.Hash)
+ rec := self.xeth.GetTxReceipt(txhash)
+ // We could have an error of "not found". Should disambiguate
+ // if err != nil {
+ // return err, nil
+ // }
+ if rec != nil && tx != nil {
+ v := NewReceiptRes(rec)
+ v.BlockHash = newHexData(bhash)
+ v.BlockNumber = newHexNum(bnum)
+ v.TransactionIndex = newHexNum(txi)
+ return v, nil
+ }
+
+ return nil, nil
+}
diff --git a/rpc/api/eth_args.go b/rpc/api/eth_args.go
index bf8ffead6..f63b43334 100644
--- a/rpc/api/eth_args.go
+++ b/rpc/api/eth_args.go
@@ -1,12 +1,31 @@
+// 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 api
import (
"encoding/json"
"fmt"
"math/big"
+ "strconv"
+ "strings"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/state"
+ "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/rpc/shared"
)
@@ -858,3 +877,178 @@ func (args *SubmitWorkArgs) UnmarshalJSON(b []byte) (err error) {
return nil
}
+
+type tx struct {
+ tx *types.Transaction
+
+ To string
+ From string
+ Nonce string
+ Value string
+ Data string
+ GasLimit string
+ GasPrice string
+}
+
+func newTx(t *types.Transaction) *tx {
+ from, _ := t.From()
+ var to string
+ if t := t.To(); t != nil {
+ to = t.Hex()
+ }
+
+ return &tx{
+ tx: t,
+ To: to,
+ From: from.Hex(),
+ Value: t.Value().String(),
+ Nonce: strconv.Itoa(int(t.Nonce())),
+ Data: "0x" + common.Bytes2Hex(t.Data()),
+ GasLimit: t.Gas().String(),
+ GasPrice: t.GasPrice().String(),
+ }
+}
+
+type ResendArgs struct {
+ Tx *tx
+ GasPrice string
+ GasLimit string
+}
+
+func (tx *tx) UnmarshalJSON(b []byte) (err error) {
+ var fields map[string]interface{}
+ if err := json.Unmarshal(b, &fields); err != nil {
+ return shared.NewDecodeParamError(err.Error())
+ }
+
+ var (
+ nonce uint64
+ to common.Address
+ amount = new(big.Int).Set(common.Big0)
+ gasLimit = new(big.Int).Set(common.Big0)
+ gasPrice = new(big.Int).Set(common.Big0)
+ data []byte
+ contractCreation = true
+ )
+
+ if val, found := fields["To"]; found {
+ if strVal, ok := val.(string); ok && len(strVal) > 0 {
+ tx.To = strVal
+ to = common.HexToAddress(strVal)
+ contractCreation = false
+ }
+ }
+
+ if val, found := fields["From"]; found {
+ if strVal, ok := val.(string); ok {
+ tx.From = strVal
+ }
+ }
+
+ if val, found := fields["Nonce"]; found {
+ if strVal, ok := val.(string); ok {
+ tx.Nonce = strVal
+ if nonce, err = strconv.ParseUint(strVal, 10, 64); err != nil {
+ return shared.NewDecodeParamError(fmt.Sprintf("Unable to decode tx.Nonce - %v", err))
+ }
+ }
+ } else {
+ return shared.NewDecodeParamError("tx.Nonce not found")
+ }
+
+ var parseOk bool
+ if val, found := fields["Value"]; found {
+ if strVal, ok := val.(string); ok {
+ tx.Value = strVal
+ if _, parseOk = amount.SetString(strVal, 0); !parseOk {
+ return shared.NewDecodeParamError(fmt.Sprintf("Unable to decode tx.Amount - %v", err))
+ }
+ }
+ }
+
+ if val, found := fields["Data"]; found {
+ if strVal, ok := val.(string); ok {
+ tx.Data = strVal
+ if strings.HasPrefix(strVal, "0x") {
+ data = common.Hex2Bytes(strVal[2:])
+ } else {
+ data = common.Hex2Bytes(strVal)
+ }
+ }
+ }
+
+ if val, found := fields["GasLimit"]; found {
+ if strVal, ok := val.(string); ok {
+ tx.GasLimit = strVal
+ if _, parseOk = gasLimit.SetString(strVal, 0); !parseOk {
+ return shared.NewDecodeParamError(fmt.Sprintf("Unable to decode tx.GasLimit - %v", err))
+ }
+ }
+ }
+
+ if val, found := fields["GasPrice"]; found {
+ if strVal, ok := val.(string); ok {
+ tx.GasPrice = strVal
+ if _, parseOk = gasPrice.SetString(strVal, 0); !parseOk {
+ return shared.NewDecodeParamError(fmt.Sprintf("Unable to decode tx.GasPrice - %v", err))
+ }
+ }
+ }
+
+ if contractCreation {
+ tx.tx = types.NewContractCreation(nonce, amount, gasLimit, gasPrice, data)
+ } else {
+ tx.tx = types.NewTransaction(nonce, to, amount, gasLimit, gasPrice, data)
+ }
+
+ return nil
+}
+
+func (args *ResendArgs) UnmarshalJSON(b []byte) (err error) {
+ var obj []interface{}
+ if err = json.Unmarshal(b, &obj); err != nil {
+ return shared.NewDecodeParamError(err.Error())
+ }
+
+ if len(obj) < 1 {
+ return shared.NewInsufficientParamsError(len(obj), 1)
+ }
+
+ data, err := json.Marshal(obj[0])
+ if err != nil {
+ return shared.NewDecodeParamError("Unable to parse transaction object")
+ }
+
+ trans := new(tx)
+ err = json.Unmarshal(data, trans)
+ if err != nil {
+ return shared.NewDecodeParamError("Unable to parse transaction object")
+ }
+
+ if trans == nil || trans.tx == nil {
+ return shared.NewDecodeParamError("Unable to parse transaction object")
+ }
+
+ gasLimit, gasPrice := trans.GasLimit, trans.GasPrice
+
+ if len(obj) > 1 && obj[1] != nil {
+ if gp, ok := obj[1].(string); ok {
+ gasPrice = gp
+ } else {
+ return shared.NewInvalidTypeError("gasPrice", "not a string")
+ }
+ }
+ if len(obj) > 2 && obj[2] != nil {
+ if gl, ok := obj[2].(string); ok {
+ gasLimit = gl
+ } else {
+ return shared.NewInvalidTypeError("gasLimit", "not a string")
+ }
+ }
+
+ args.Tx = trans
+ args.GasPrice = gasPrice
+ args.GasLimit = gasLimit
+
+ return nil
+}
diff --git a/rpc/api/eth_js.go b/rpc/api/eth_js.go
index e1268eb76..1a0810a55 100644
--- a/rpc/api/eth_js.go
+++ b/rpc/api/eth_js.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 api
// JS api provided by web3.js
@@ -12,8 +28,20 @@ web3._extend({
name: 'sign',
call: 'eth_sign',
params: 2,
- inputFormatter: [web3._extend.formatters.formatInputString,web3._extend.formatters.formatInputString],
- outputFormatter: web3._extend.formatters.formatOutputString
+ inputFormatter: [web3._extend.utils.toAddress, null]
+ }),
+ new web3._extend.Method({
+ name: 'resend',
+ call: 'eth_resend',
+ params: 3,
+ inputFormatter: [web3._extend.formatters.inputTransactionFormatter, web3._extend.utils.fromDecimal, web3._extend.utils.fromDecimal]
+ })
+ ],
+ properties:
+ [
+ new web3._extend.Property({
+ name: 'pendingTransactions',
+ getter: 'eth_pendingTransactions'
})
]
});
diff --git a/rpc/api/mergedapi.go b/rpc/api/mergedapi.go
index bc4fa32e8..13230f8c0 100644
--- a/rpc/api/mergedapi.go
+++ b/rpc/api/mergedapi.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 api
import (
@@ -42,7 +58,7 @@ func (self *MergedApi) Methods() []string {
// Call the correct API's Execute method for the given request
func (self *MergedApi) Execute(req *shared.Request) (interface{}, error) {
- glog.V(logger.Detail).Infof("rpc method: %s", req.Method)
+ glog.V(logger.Detail).Infof("%s %s", req.Method, req.Params)
if res, _ := self.handle(req); res != nil {
return res, nil
diff --git a/rpc/api/miner.go b/rpc/api/miner.go
index 7a84cb9ae..91dbc148f 100644
--- a/rpc/api/miner.go
+++ b/rpc/api/miner.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 api
import (
@@ -19,6 +35,7 @@ var (
"miner_makeDAG": (*minerApi).MakeDAG,
"miner_setExtra": (*minerApi).SetExtra,
"miner_setGasPrice": (*minerApi).SetGasPrice,
+ "miner_setEtherbase": (*minerApi).SetEtherbase,
"miner_startAutoDAG": (*minerApi).StartAutoDAG,
"miner_start": (*minerApi).StartMiner,
"miner_stopAutoDAG": (*minerApi).StopAutoDAG,
@@ -119,6 +136,15 @@ func (self *minerApi) SetGasPrice(req *shared.Request) (interface{}, error) {
return true, nil
}
+func (self *minerApi) SetEtherbase(req *shared.Request) (interface{}, error) {
+ args := new(SetEtherbaseArgs)
+ if err := self.codec.Decode(req.Params, &args); err != nil {
+ return false, err
+ }
+ self.ethereum.SetEtherbase(args.Etherbase)
+ return nil, nil
+}
+
func (self *minerApi) StartAutoDAG(req *shared.Request) (interface{}, error) {
self.ethereum.StartAutoDAG()
return true, nil
diff --git a/rpc/api/miner_args.go b/rpc/api/miner_args.go
index 7b0560c16..15741b092 100644
--- a/rpc/api/miner_args.go
+++ b/rpc/api/miner_args.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 api
import (
@@ -5,6 +21,7 @@ import (
"math/big"
+ "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/rpc/shared"
)
@@ -76,6 +93,31 @@ func (args *GasPriceArgs) UnmarshalJSON(b []byte) (err error) {
return shared.NewInvalidTypeError("Price", "not a string")
}
+type SetEtherbaseArgs struct {
+ Etherbase common.Address
+}
+
+func (args *SetEtherbaseArgs) UnmarshalJSON(b []byte) (err error) {
+ var obj []interface{}
+ if err := json.Unmarshal(b, &obj); err != nil {
+ return shared.NewDecodeParamError(err.Error())
+ }
+
+ if len(obj) < 1 {
+ return shared.NewInsufficientParamsError(len(obj), 1)
+ }
+
+ if addr, ok := obj[0].(string); ok {
+ args.Etherbase = common.HexToAddress(addr)
+ if (args.Etherbase == common.Address{}) {
+ return shared.NewInvalidTypeError("Etherbase", "not a valid address")
+ }
+ return nil
+ }
+
+ return shared.NewInvalidTypeError("Etherbase", "not a string")
+}
+
type MakeDAGArgs struct {
BlockNumber int64
}
diff --git a/rpc/api/miner_js.go b/rpc/api/miner_js.go
index 6290368da..a9eb4901d 100644
--- a/rpc/api/miner_js.go
+++ b/rpc/api/miner_js.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 api
const Miner_JS = `
@@ -9,13 +25,18 @@ web3._extend({
name: 'start',
call: 'miner_start',
params: 1,
- inputFormatter: [web3._extend.formatters.formatInputInt],
- outputFormatter: web3._extend.formatters.formatOutputBool
+ inputFormatter: [null]
}),
new web3._extend.Method({
name: 'stop',
call: 'miner_stop',
params: 1,
+ inputFormatter: [null]
+ }),
+ new web3._extend.Method({
+ name: 'setEtherbase',
+ call: 'miner_setEtherbase',
+ params: 1,
inputFormatter: [web3._extend.formatters.formatInputInt],
outputFormatter: web3._extend.formatters.formatOutputBool
}),
@@ -23,36 +44,31 @@ web3._extend({
name: 'setExtra',
call: 'miner_setExtra',
params: 1,
- inputFormatter: [web3._extend.utils.formatInputString],
- outputFormatter: web3._extend.formatters.formatOutputBool
+ inputFormatter: [null]
}),
new web3._extend.Method({
name: 'setGasPrice',
call: 'miner_setGasPrice',
params: 1,
- inputFormatter: [web3._extend.utils.formatInputString],
- outputFormatter: web3._extend.formatters.formatOutputBool
+ inputFormatter: [web3._extend.utils.fromDecial]
}),
new web3._extend.Method({
name: 'startAutoDAG',
call: 'miner_startAutoDAG',
params: 0,
- inputFormatter: [],
- outputFormatter: web3._extend.formatters.formatOutputBool
+ inputFormatter: []
}),
new web3._extend.Method({
name: 'stopAutoDAG',
call: 'miner_stopAutoDAG',
params: 0,
- inputFormatter: [],
- outputFormatter: web3._extend.formatters.formatOutputBool
+ inputFormatter: []
}),
new web3._extend.Method({
name: 'makeDAG',
call: 'miner_makeDAG',
params: 1,
- inputFormatter: [web3._extend.formatters.inputDefaultBlockNumberFormatter],
- outputFormatter: web3._extend.formatters.formatOutputBool
+ inputFormatter: [web3._extend.formatters.inputDefaultBlockNumberFormatter]
})
],
properties:
diff --git a/rpc/api/net.go b/rpc/api/net.go
index 761654661..dbed9e11e 100644
--- a/rpc/api/net.go
+++ b/rpc/api/net.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 api
import (
@@ -14,10 +30,8 @@ const (
var (
// mapping between methods and handlers
netMapping = map[string]nethandler{
- "net_version": (*netApi).Version,
"net_peerCount": (*netApi).PeerCount,
"net_listening": (*netApi).IsListening,
- "net_peers": (*netApi).Peers,
}
)
@@ -70,11 +84,6 @@ func (self *netApi) ApiVersion() string {
return NetApiVersion
}
-// Network version
-func (self *netApi) Version(req *shared.Request) (interface{}, error) {
- return self.xeth.NetworkVersion(), nil
-}
-
// Number of connected peers
func (self *netApi) PeerCount(req *shared.Request) (interface{}, error) {
return newHexNum(self.xeth.PeerCount()), nil
@@ -84,6 +93,3 @@ func (self *netApi) IsListening(req *shared.Request) (interface{}, error) {
return self.xeth.IsListening(), nil
}
-func (self *netApi) Peers(req *shared.Request) (interface{}, error) {
- return self.ethereum.PeersInfo(), nil
-}
diff --git a/rpc/api/net_js.go b/rpc/api/net_js.go
index 1677d9fa6..391039eea 100644
--- a/rpc/api/net_js.go
+++ b/rpc/api/net_js.go
@@ -1,47 +1,35 @@
+// 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 api
const Net_JS = `
web3._extend({
- property: 'network',
+ property: 'net',
methods:
[
new web3._extend.Method({
name: 'addPeer',
call: 'net_addPeer',
params: 1,
- inputFormatter: [web3._extend.utils.formatInputString],
- outputFormatter: web3._extend.formatters.formatOutputBool
- }),
- new web3._extend.Method({
- name: 'getPeerCount',
- call: 'net_peerCount',
- params: 0,
- inputFormatter: [],
- outputFormatter: web3._extend.formatters.formatOutputString
+ inputFormatter: [null]
})
],
properties:
[
- new web3._extend.Property({
- name: 'listening',
- getter: 'net_listening',
- outputFormatter: web3._extend.formatters.formatOutputBool
- }),
- new web3._extend.Property({
- name: 'peerCount',
- getter: 'net_peerCount',
- outputFormatter: web3._extend.utils.toDecimal
- }),
- new web3._extend.Property({
- name: 'peers',
- getter: 'net_peers',
- outputFormatter: function(obj) { return obj; }
- }),
- new web3._extend.Property({
- name: 'version',
- getter: 'net_version',
- outputFormatter: web3._extend.formatters.formatOutputString
- })
]
});
`
diff --git a/rpc/api/parsing.go b/rpc/api/parsing.go
index 632462c31..6e97d8a2d 100644
--- a/rpc/api/parsing.go
+++ b/rpc/api/parsing.go
@@ -1,6 +1,23 @@
+// 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 api
import (
+ "bytes"
"encoding/binary"
"encoding/hex"
"encoding/json"
@@ -402,6 +419,43 @@ func NewUncleRes(h *types.Header) *UncleRes {
// WorkProved string `json:"workProved"`
// }
+type ReceiptRes struct {
+ TransactionHash *hexdata `json:"transactionHash"`
+ TransactionIndex *hexnum `json:"transactionIndex"`
+ BlockNumber *hexnum `json:"blockNumber"`
+ BlockHash *hexdata `json:"blockHash"`
+ CumulativeGasUsed *hexnum `json:"cumulativeGasUsed"`
+ GasUsed *hexnum `json:"gasUsed"`
+ ContractAddress *hexdata `json:"contractAddress"`
+ Logs *[]interface{} `json:"logs"`
+}
+
+func NewReceiptRes(rec *types.Receipt) *ReceiptRes {
+ if rec == nil {
+ return nil
+ }
+
+ var v = new(ReceiptRes)
+ v.TransactionHash = newHexData(rec.TxHash)
+ if rec.GasUsed != nil {
+ v.GasUsed = newHexNum(rec.GasUsed.Bytes())
+ }
+ v.CumulativeGasUsed = newHexNum(rec.CumulativeGasUsed)
+
+ // If the ContractAddress is 20 0x0 bytes, assume it is not a contract creation
+ if bytes.Compare(rec.ContractAddress.Bytes(), bytes.Repeat([]byte{0}, 20)) != 0 {
+ v.ContractAddress = newHexData(rec.ContractAddress)
+ }
+
+ logs := make([]interface{}, len(rec.Logs()))
+ for i, log := range rec.Logs() {
+ logs[i] = NewLogRes(log)
+ }
+ v.Logs = &logs
+
+ return v
+}
+
func numString(raw interface{}) (*big.Int, error) {
var number *big.Int
// Parse as integer
diff --git a/rpc/api/personal.go b/rpc/api/personal.go
index b4a63ea7a..bfb12a203 100644
--- a/rpc/api/personal.go
+++ b/rpc/api/personal.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 api
import (
diff --git a/rpc/api/personal_args.go b/rpc/api/personal_args.go
index b3e683638..8c4718d09 100644
--- a/rpc/api/personal_args.go
+++ b/rpc/api/personal_args.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 api
import (
diff --git a/rpc/api/personal_js.go b/rpc/api/personal_js.go
index 463a2c7f5..aaa5f4f44 100644
--- a/rpc/api/personal_js.go
+++ b/rpc/api/personal_js.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 api
const Personal_JS = `
@@ -9,23 +25,21 @@ web3._extend({
name: 'newAccount',
call: 'personal_newAccount',
params: 1,
- inputFormatter: [web3._extend.formatters.formatInputString],
- outputFormatter: web3._extend.formatters.formatOutputString
+ inputFormatter: [null],
+ outputFormatter: web3._extend.utils.toAddress
}),
new web3._extend.Method({
name: 'unlockAccount',
call: 'personal_unlockAccount',
params: 3,
- inputFormatter: [web3._extend.formatters.formatInputString,web3._extend.formatters.formatInputString,web3._extend.formatters.formatInputInt],
- outputFormatter: web3._extend.formatters.formatOutputBool
+ inputFormatter: [null, null, null]
})
],
properties:
[
new web3._extend.Property({
name: 'listAccounts',
- getter: 'personal_listAccounts',
- outputFormatter: function(obj) { return obj; }
+ getter: 'personal_listAccounts'
})
]
});
diff --git a/rpc/api/shh.go b/rpc/api/shh.go
index 18a8fd15d..02513f8f7 100644
--- a/rpc/api/shh.go
+++ b/rpc/api/shh.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 api
import (
diff --git a/rpc/api/shh_args.go b/rpc/api/shh_args.go
index 00abac232..516765287 100644
--- a/rpc/api/shh_args.go
+++ b/rpc/api/shh_args.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 api
import (
diff --git a/rpc/api/ssh_js.go b/rpc/api/ssh_js.go
index f401f70f1..9fe6294ea 100644
--- a/rpc/api/ssh_js.go
+++ b/rpc/api/ssh_js.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 api
const Shh_JS = `
@@ -5,25 +21,13 @@ web3._extend({
property: 'shh',
methods:
[
- new web3._extend.Method({
- name: 'post',
- call: 'shh_post',
- params: 6,
- inputFormatter: [web3._extend.formatters.formatInputString,
- web3._extend.formatters.formatInputString,
- web3._extend.formatters.formatInputString,
- ,
- , web3._extend.formatters.formatInputInt
- , web3._extend.formatters.formatInputInt],
- outputFormatter: web3._extend.formatters.formatOutputBool
- }),
+
],
properties:
[
new web3._extend.Property({
name: 'version',
- getter: 'shh_version',
- outputFormatter: web3._extend.formatters.formatOutputInt
+ getter: 'shh_version'
})
]
});
diff --git a/rpc/api/txpool.go b/rpc/api/txpool.go
index 25ad6e9b2..14934ae13 100644
--- a/rpc/api/txpool.go
+++ b/rpc/api/txpool.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 api
import (
@@ -68,8 +84,9 @@ func (self *txPoolApi) ApiVersion() string {
}
func (self *txPoolApi) Status(req *shared.Request) (interface{}, error) {
+ pending, queue := self.ethereum.TxPool().Stats()
return map[string]int{
- "pending": self.ethereum.TxPool().GetTransactions().Len(),
- "queued": self.ethereum.TxPool().GetQueuedTransactions().Len(),
+ "pending": pending,
+ "queued": queue,
}, nil
}
diff --git a/rpc/api/txpool_js.go b/rpc/api/txpool_js.go
index 06528d1c4..ef9a0487c 100644
--- a/rpc/api/txpool_js.go
+++ b/rpc/api/txpool_js.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 api
const TxPool_JS = `
diff --git a/rpc/api/utils.go b/rpc/api/utils.go
index 6e4835de6..a9ad3f153 100644
--- a/rpc/api/utils.go
+++ b/rpc/api/utils.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 api
import (
@@ -36,6 +52,7 @@ var (
"debug": []string{
"dumpBlock",
"getBlockRlp",
+ "metrics",
"printBlock",
"processBlock",
"seedHash",
@@ -44,46 +61,38 @@ var (
"eth": []string{
"accounts",
"blockNumber",
- "getBalance",
- "protocolVersion",
+ "call",
+ "contract",
"coinbase",
- "mining",
+ "compile.lll",
+ "compile.serpent",
+ "compile.solidity",
+ "contract",
+ "defaultAccount",
+ "defaultBlock",
+ "estimateGas",
+ "filter",
+ "getBalance",
+ "getBlock",
+ "getBlockTransactionCount",
+ "getBlockUncleCount",
+ "getCode",
+ "getCompilers",
"gasPrice",
- "getStorage",
- "storageAt",
"getStorageAt",
+ "getTransaction",
"getTransactionCount",
- "getBlockTransactionCountByHash",
- "getBlockTransactionCountByNumber",
- "getUncleCountByBlockHash",
- "getUncleCountByBlockNumber",
- "getData",
- "getCode",
- "sign",
+ "getTransactionFromBlock",
+ "getTransactionReceipt",
+ "getUncle",
+ "hashrate",
+ "mining",
+ "namereg",
+ "pendingTransactions",
+ "resend",
"sendRawTransaction",
"sendTransaction",
- "transact",
- "estimateGas",
- "call",
- "flush",
- "getBlockByHash",
- "getBlockByNumber",
- "getTransactionByHash",
- "getTransactionByBlockHashAndIndex",
- "getUncleByBlockHashAndIndex",
- "getUncleByBlockNumberAndIndex",
- "getCompilers",
- "compileSolidity",
- "newFilter",
- "newBlockFilter",
- "newPendingTransactionFilter",
- "uninstallFilter",
- "getFilterChanges",
- "getFilterLogs",
- "getLogs",
- "hashrate",
- "getWork",
- "submitWork",
+ "sign",
},
"miner": []string{
"hashrate",
@@ -106,13 +115,12 @@ var (
"unlockAccount",
},
"shh": []string{
- "version",
"post",
+ "newIdentify",
"hasIdentity",
- "newIdentity",
- "newFilter",
- "uninstallFilter",
- "getFilterChanges",
+ "newGroup",
+ "addToGroup",
+ "filter",
},
"txpool": []string{
"status",
@@ -149,7 +157,7 @@ func ParseApiString(apistr string, codec codec.Codec, xeth *xeth.XEth, eth *eth.
case shared.DbApiName:
apis[i] = NewDbApi(xeth, eth, codec)
case shared.EthApiName:
- apis[i] = NewEthApi(xeth, codec)
+ apis[i] = NewEthApi(xeth, eth, codec)
case shared.MinerApiName:
apis[i] = NewMinerApi(eth, codec)
case shared.NetApiName:
diff --git a/rpc/api/web3.go b/rpc/api/web3.go
index 4c20baa25..77b8fda6b 100644
--- a/rpc/api/web3.go
+++ b/rpc/api/web3.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 api
import (
diff --git a/rpc/api/web3_args.go b/rpc/api/web3_args.go
index 38af7191e..30b4a5c1f 100644
--- a/rpc/api/web3_args.go
+++ b/rpc/api/web3_args.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 api
import (