aboutsummaryrefslogtreecommitdiffstats
path: root/rpc/api
diff options
context:
space:
mode:
authorJeffrey Wilcke <jeffrey@ethereum.org>2015-07-07 17:55:23 +0800
committerJeffrey Wilcke <jeffrey@ethereum.org>2015-07-07 17:55:23 +0800
commit916d1554675974adb92af4046e1b04ad3b26dca3 (patch)
tree6ab24e55a8b4bd14b3a9c25917d440c03b875bfc /rpc/api
parentd764bd058457cd9eb91d205d1ac187d40c4866d6 (diff)
parentc5cb6e8e70339b6641b7ce46cda04b83936213b3 (diff)
downloadgo-tangerine-916d1554675974adb92af4046e1b04ad3b26dca3.tar.gz
go-tangerine-916d1554675974adb92af4046e1b04ad3b26dca3.tar.zst
go-tangerine-916d1554675974adb92af4046e1b04ad3b26dca3.zip
Merge pull request #1429 from obscuren/rebase-registrar
Rebase registrar
Diffstat (limited to 'rpc/api')
-rw-r--r--rpc/api/admin.go236
-rw-r--r--rpc/api/admin_args.go333
-rw-r--r--rpc/api/admin_js.go99
-rw-r--r--rpc/api/db_js.go28
-rw-r--r--rpc/api/debug_js.go23
-rw-r--r--rpc/api/eth_js.go9
-rw-r--r--rpc/api/miner_js.go21
-rw-r--r--rpc/api/net.go10
-rw-r--r--rpc/api/net_js.go32
-rw-r--r--rpc/api/personal_js.go10
-rw-r--r--rpc/api/ssh_js.go16
-rw-r--r--rpc/api/utils.go71
12 files changed, 687 insertions, 201 deletions
diff --git a/rpc/api/admin.go b/rpc/api/admin.go
index b27482cfe..c5f026090 100644
--- a/rpc/api/admin.go
+++ b/rpc/api/admin.go
@@ -3,10 +3,18 @@ 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 +32,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 +67,7 @@ type adminApi struct {
ethereum *eth.Ethereum
codec codec.Codec
coder codec.ApiCoder
+ ds *docserver.DocServer
}
// create a new admin api instance
@@ -56,6 +77,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 +266,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..532907905 100644
--- a/rpc/api/admin_args.go
+++ b/rpc/api/admin_args.go
@@ -3,6 +3,7 @@ package api
import (
"encoding/json"
+ "github.com/ethereum/go-ethereum/common/compiler"
"github.com/ethereum/go-ethereum/rpc/shared"
)
@@ -113,7 +114,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 +122,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 +130,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 +138,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 +148,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..ddfa2ea04 100644
--- a/rpc/api/admin_js.go
+++ b/rpc/api/admin_js.go
@@ -9,73 +9,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/db_js.go b/rpc/api/db_js.go
index 62cdcd20e..91dc95e5b 100644
--- a/rpc/api/db_js.go
+++ b/rpc/api/db_js.go
@@ -5,34 +5,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_js.go b/rpc/api/debug_js.go
index bd3a6dfb2..93fba537e 100644
--- a/rpc/api/debug_js.go
+++ b/rpc/api/debug_js.go
@@ -9,50 +9,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_js.go b/rpc/api/eth_js.go
index 4512cc147..400eb8e89 100644
--- a/rpc/api/eth_js.go
+++ b/rpc/api/eth_js.go
@@ -12,23 +12,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: [function(obj) { return obj; },web3._extend.formatters.formatInputString,web3._extend.formatters.formatInputString],
- outputFormatter: web3._extend.formatters.formatOutputString
+ inputFormatter: [web3._extend.formatters.inputTransactionFormatter, web3._extend.utils.fromDecimal, web3._extend.utils.fromDecimal]
})
],
properties:
[
new web3._extend.Property({
name: 'pendingTransactions',
- getter: 'eth_pendingTransactions',
- outputFormatter: function(obj) { return obj; }
+ getter: 'eth_pendingTransactions'
})
]
});
diff --git a/rpc/api/miner_js.go b/rpc/api/miner_js.go
index 6290368da..8861a177a 100644
--- a/rpc/api/miner_js.go
+++ b/rpc/api/miner_js.go
@@ -9,50 +9,43 @@ 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: [web3._extend.formatters.formatInputInt],
- outputFormatter: web3._extend.formatters.formatOutputBool
+ inputFormatter: [null]
}),
new web3._extend.Method({
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..b3931ba2d 100644
--- a/rpc/api/net.go
+++ b/rpc/api/net.go
@@ -14,10 +14,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 +68,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 +77,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..2f872393c 100644
--- a/rpc/api/net_js.go
+++ b/rpc/api/net_js.go
@@ -2,46 +2,18 @@ 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/personal_js.go b/rpc/api/personal_js.go
index 463a2c7f5..66014cc02 100644
--- a/rpc/api/personal_js.go
+++ b/rpc/api/personal_js.go
@@ -9,23 +9,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/ssh_js.go b/rpc/api/ssh_js.go
index f401f70f1..c0591bd71 100644
--- a/rpc/api/ssh_js.go
+++ b/rpc/api/ssh_js.go
@@ -5,25 +5,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/utils.go b/rpc/api/utils.go
index 54ca28774..d64cfc7cf 100644
--- a/rpc/api/utils.go
+++ b/rpc/api/utils.go
@@ -36,6 +36,7 @@ var (
"debug": []string{
"dumpBlock",
"getBlockRlp",
+ "metrics",
"printBlock",
"processBlock",
"seedHash",
@@ -44,49 +45,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",
- "sendRawTransaction",
- "sendTransaction",
- "transact",
- "estimateGas",
- "call",
- "flush",
- "getBlockByHash",
- "getBlockByNumber",
- "getTransactionByHash",
- "getTransactionByBlockHashAndIndex",
- "getUncleByBlockHashAndIndex",
- "getUncleByBlockNumberAndIndex",
- "getCompilers",
- "compileSolidity",
- "newFilter",
- "newBlockFilter",
- "newPendingTransactionFilter",
- "uninstallFilter",
- "getFilterChanges",
- "getFilterLogs",
- "getLogs",
+ "getTransactionFromBlock",
+ "getTransactionReceipt",
+ "getUncle",
"hashrate",
- "getWork",
- "submitWork",
+ "mining",
+ "namereg",
"pendingTransactions",
"resend",
- "getTransactionReceipt",
+ "sendRawTransaction",
+ "sendTransaction",
+ "sign",
},
"miner": []string{
"hashrate",
@@ -109,13 +99,12 @@ var (
"unlockAccount",
},
"shh": []string{
- "version",
"post",
+ "newIdentify",
"hasIdentity",
- "newIdentity",
- "newFilter",
- "uninstallFilter",
- "getFilterChanges",
+ "newGroup",
+ "addToGroup",
+ "filter",
},
"txpool": []string{
"status",