From f1a4a6e563ea72affe365d89513e5c83a35e4c28 Mon Sep 17 00:00:00 2001 From: Bas van Kervel Date: Wed, 24 Jun 2015 13:53:37 +0200 Subject: added eth.pendingTransactions --- rpc/api/eth.go | 40 +++++++++++++++++++++++++++++++++++----- rpc/api/eth_args.go | 34 ++++++++++++++++++++++++++++++++++ rpc/api/eth_js.go | 8 ++++++++ rpc/api/utils.go | 3 ++- 4 files changed, 79 insertions(+), 6 deletions(-) (limited to 'rpc/api') diff --git a/rpc/api/eth.go b/rpc/api/eth.go index 0dff138c6..77c710fb0 100644 --- a/rpc/api/eth.go +++ b/rpc/api/eth.go @@ -6,9 +6,11 @@ import ( "math/big" "github.com/ethereum/go-ethereum/common" + "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 +20,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 +74,13 @@ var ( "eth_hashrate": (*ethApi).Hashrate, "eth_getWork": (*ethApi).GetWork, "eth_submitWork": (*ethApi).SubmitWork, + "eth_pendingTransactions": (*ethApi).PendingTransactions, } ) // create new ethApi instance -func NewEthApi(xeth *xeth.XEth, codec codec.Codec) *ethApi { - return ðApi{xeth, ethMapping, codec.New(nil)} +func NewEthApi(xeth *xeth.XEth, eth *eth.Ethereum, codec codec.Codec) *ethApi { + return ðApi{xeth, eth, ethMapping, codec.New(nil)} } // collection with supported methods @@ -556,3 +560,29 @@ 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) PendingTransactions(req *shared.Request) (interface{}, error) { + txs := self.ethereum.TxPool().GetTransactions() + + // grab the accounts from the account manager. This will help with determening 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 +} diff --git a/rpc/api/eth_args.go b/rpc/api/eth_args.go index bf8ffead6..39c003f66 100644 --- a/rpc/api/eth_args.go +++ b/rpc/api/eth_args.go @@ -5,8 +5,11 @@ import ( "fmt" "math/big" + "strconv" + "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 +861,34 @@ 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.Amount.String(), + Nonce: strconv.Itoa(int(t.Nonce())), + Data: "0x" + common.Bytes2Hex(t.Data()), + GasLimit: t.GasLimit.String(), + GasPrice: t.GasPrice().String(), + } +} diff --git a/rpc/api/eth_js.go b/rpc/api/eth_js.go index e1268eb76..8d0fe8f0a 100644 --- a/rpc/api/eth_js.go +++ b/rpc/api/eth_js.go @@ -15,6 +15,14 @@ web3._extend({ inputFormatter: [web3._extend.formatters.formatInputString,web3._extend.formatters.formatInputString], outputFormatter: web3._extend.formatters.formatOutputString }) + ], + properties: + [ + new web3._extend.Property({ + name: 'pendingTransactions', + getter: 'eth_pendingTransactions', + outputFormatter: function(obj) { return obj; } + }) ] }); ` diff --git a/rpc/api/utils.go b/rpc/api/utils.go index 6e4835de6..3d46f78d3 100644 --- a/rpc/api/utils.go +++ b/rpc/api/utils.go @@ -84,6 +84,7 @@ var ( "hashrate", "getWork", "submitWork", + "pendingTransactions", }, "miner": []string{ "hashrate", @@ -149,7 +150,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: -- cgit v1.2.3 From dc58568a25e54ea601aefb8e97f427cae0814612 Mon Sep 17 00:00:00 2001 From: Bas van Kervel Date: Wed, 24 Jun 2015 14:56:53 +0200 Subject: added eth.resend --- rpc/api/eth.go | 18 ++++++++++++++++++ rpc/api/eth_args.go | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ rpc/api/eth_js.go | 7 +++++++ rpc/api/utils.go | 1 + 4 files changed, 76 insertions(+) (limited to 'rpc/api') diff --git a/rpc/api/eth.go b/rpc/api/eth.go index 77c710fb0..2bd7e4cdb 100644 --- a/rpc/api/eth.go +++ b/rpc/api/eth.go @@ -6,6 +6,7 @@ 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" @@ -74,6 +75,7 @@ var ( "eth_hashrate": (*ethApi).Hashrate, "eth_getWork": (*ethApi).GetWork, "eth_submitWork": (*ethApi).SubmitWork, + "eth_resend": (*ethApi).Resend, "eth_pendingTransactions": (*ethApi).PendingTransactions, } ) @@ -561,6 +563,22 @@ 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() diff --git a/rpc/api/eth_args.go b/rpc/api/eth_args.go index 39c003f66..a75fdbdee 100644 --- a/rpc/api/eth_args.go +++ b/rpc/api/eth_args.go @@ -892,3 +892,53 @@ func newTx(t *types.Transaction) *tx { GasPrice: t.GasPrice().String(), } } + +type ResendArgs struct { + Tx *tx + GasPrice string + GasLimit string +} + +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.") + } + + 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 8d0fe8f0a..4512cc147 100644 --- a/rpc/api/eth_js.go +++ b/rpc/api/eth_js.go @@ -14,6 +14,13 @@ web3._extend({ params: 2, inputFormatter: [web3._extend.formatters.formatInputString,web3._extend.formatters.formatInputString], outputFormatter: web3._extend.formatters.formatOutputString + }), + 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 }) ], properties: diff --git a/rpc/api/utils.go b/rpc/api/utils.go index 3d46f78d3..e6a01d3d6 100644 --- a/rpc/api/utils.go +++ b/rpc/api/utils.go @@ -85,6 +85,7 @@ var ( "getWork", "submitWork", "pendingTransactions", + "resend", }, "miner": []string{ "hashrate", -- cgit v1.2.3 From ee73f09727004e94a04a396b99151ab79fd187f4 Mon Sep 17 00:00:00 2001 From: Bas van Kervel Date: Wed, 24 Jun 2015 16:07:44 +0200 Subject: fixed unittest compilation issue --- rpc/api/api_test.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'rpc/api') diff --git a/rpc/api/api_test.go b/rpc/api/api_test.go index 7e273ef28..2ac8bcd45 100644 --- a/rpc/api/api_test.go +++ b/rpc/api/api_test.go @@ -76,8 +76,9 @@ func TestCompileSolidity(t *testing.T) { expLanguageVersion := "0" expSource := source - xeth := xeth.NewTest(ð.Ethereum{}, nil) - api := NewEthApi(xeth, codec.JSON) + eth := ð.Ethereum{} + xeth := xeth.NewTest(eth, nil) + api := NewEthApi(xeth, eth, codec.JSON) var rpcRequest shared.Request json.Unmarshal([]byte(jsonstr), &rpcRequest) -- cgit v1.2.3 From a355777ff8531ba91fbdfb093532e7314c15710b Mon Sep 17 00:00:00 2001 From: Bas van Kervel Date: Mon, 29 Jun 2015 11:13:28 +0200 Subject: improved error handling in parsing request --- rpc/api/eth.go | 3 ++- rpc/api/eth_args.go | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'rpc/api') diff --git a/rpc/api/eth.go b/rpc/api/eth.go index 2bd7e4cdb..0735754b5 100644 --- a/rpc/api/eth.go +++ b/rpc/api/eth.go @@ -12,6 +12,7 @@ import ( "github.com/ethereum/go-ethereum/rpc/shared" "github.com/ethereum/go-ethereum/xeth" "gopkg.in/fatih/set.v0" + "fmt" ) const ( @@ -582,7 +583,7 @@ func (self *ethApi) Resend(req *shared.Request) (interface{}, error) { 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 determening which + // 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 { diff --git a/rpc/api/eth_args.go b/rpc/api/eth_args.go index a75fdbdee..88fc00a6c 100644 --- a/rpc/api/eth_args.go +++ b/rpc/api/eth_args.go @@ -917,7 +917,11 @@ func (args *ResendArgs) UnmarshalJSON(b []byte) (err error) { trans := new(tx) err = json.Unmarshal(data, trans) if err != nil { - return shared.NewDecodeParamError("Unable to parse transaction object.") + 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 @@ -936,6 +940,7 @@ func (args *ResendArgs) UnmarshalJSON(b []byte) (err error) { return shared.NewInvalidTypeError("gasLimit", "not a string") } } + args.Tx = trans args.GasPrice = gasPrice args.GasLimit = gasLimit -- cgit v1.2.3 From f9264e87ec4c612f647a05ea11d5640709577a7f Mon Sep 17 00:00:00 2001 From: Bas van Kervel Date: Mon, 29 Jun 2015 12:32:01 +0200 Subject: add json parsing method for resend transaction --- rpc/api/eth.go | 1 - rpc/api/eth_args.go | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 76 insertions(+), 2 deletions(-) (limited to 'rpc/api') diff --git a/rpc/api/eth.go b/rpc/api/eth.go index 0735754b5..6c071569c 100644 --- a/rpc/api/eth.go +++ b/rpc/api/eth.go @@ -12,7 +12,6 @@ import ( "github.com/ethereum/go-ethereum/rpc/shared" "github.com/ethereum/go-ethereum/xeth" "gopkg.in/fatih/set.v0" - "fmt" ) const ( diff --git a/rpc/api/eth_args.go b/rpc/api/eth_args.go index 88fc00a6c..203171d58 100644 --- a/rpc/api/eth_args.go +++ b/rpc/api/eth_args.go @@ -4,8 +4,8 @@ import ( "encoding/json" "fmt" "math/big" - "strconv" + "strings" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/state" @@ -899,6 +899,81 @@ type ResendArgs struct { 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()) + } + + trans := new(types.Transaction) + + if val, found := fields["To"]; found { + if strVal, ok := val.(string); ok && len(strVal) > 0 { + tx.To = strVal + to := common.StringToAddress(strVal) + trans.Recipient = &to + } + } + + 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 trans.AccountNonce, err = strconv.ParseUint(strVal, 10, 64); err != nil { + return shared.NewDecodeParamError(fmt.Sprintf("Unable to decode tx.Nonce - %v", err)) + } + } + } + + var parseOk bool + if val, found := fields["Value"]; found { + if strVal, ok := val.(string); ok { + tx.Value = strVal + if trans.Amount, parseOk = new(big.Int).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") { + trans.Payload = common.Hex2Bytes(strVal[2:]) + } else { + trans.Payload = common.Hex2Bytes(strVal) + } + } + } + + if val, found := fields["GasLimit"]; found { + if strVal, ok := val.(string); ok { + tx.GasLimit = strVal + if trans.GasLimit, parseOk = new(big.Int).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 trans.Price, parseOk = new(big.Int).SetString(strVal, 0); !parseOk { + return shared.NewDecodeParamError(fmt.Sprintf("Unable to decode tx.GasPrice - %v", err)) + } + } + } + + tx.tx = trans + + return nil +} + func (args *ResendArgs) UnmarshalJSON(b []byte) (err error) { var obj []interface{} if err = json.Unmarshal(b, &obj); err != nil { -- cgit v1.2.3 From 61ccc39b569b0d9c1c0c5a51975723621dd312d0 Mon Sep 17 00:00:00 2001 From: Bas van Kervel Date: Mon, 29 Jun 2015 12:42:47 +0200 Subject: initialize fields to prevent nil pointer exception --- rpc/api/eth_args.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'rpc/api') diff --git a/rpc/api/eth_args.go b/rpc/api/eth_args.go index 203171d58..b5507832d 100644 --- a/rpc/api/eth_args.go +++ b/rpc/api/eth_args.go @@ -906,6 +906,9 @@ func (tx *tx) UnmarshalJSON(b []byte) (err error) { } trans := new(types.Transaction) + trans.Amount = new(big.Int) + trans.GasLimit = new(big.Int) + trans.Price = new(big.Int) if val, found := fields["To"]; found { if strVal, ok := val.(string); ok && len(strVal) > 0 { @@ -928,13 +931,15 @@ func (tx *tx) UnmarshalJSON(b []byte) (err error) { 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 trans.Amount, parseOk = new(big.Int).SetString(strVal, 0); !parseOk { + if _, parseOk = trans.Amount.SetString(strVal, 0); !parseOk { return shared.NewDecodeParamError(fmt.Sprintf("Unable to decode tx.Amount - %v", err)) } } @@ -954,7 +959,7 @@ func (tx *tx) UnmarshalJSON(b []byte) (err error) { if val, found := fields["GasLimit"]; found { if strVal, ok := val.(string); ok { tx.GasLimit = strVal - if trans.GasLimit, parseOk = new(big.Int).SetString(strVal, 0); !parseOk { + if _, parseOk = trans.GasLimit.SetString(strVal, 0); !parseOk { return shared.NewDecodeParamError(fmt.Sprintf("Unable to decode tx.GasLimit - %v", err)) } } @@ -963,7 +968,7 @@ func (tx *tx) UnmarshalJSON(b []byte) (err error) { if val, found := fields["GasPrice"]; found { if strVal, ok := val.(string); ok { tx.GasPrice = strVal - if trans.Price, parseOk = new(big.Int).SetString(strVal, 0); !parseOk { + if _, parseOk = trans.Price.SetString(strVal, 0); !parseOk { return shared.NewDecodeParamError(fmt.Sprintf("Unable to decode tx.GasPrice - %v", err)) } } -- cgit v1.2.3 From 056e9dd393eeb7ddb4f6bf3e508228e1874bc94e Mon Sep 17 00:00:00 2001 From: Bas van Kervel Date: Wed, 24 Jun 2015 13:53:37 +0200 Subject: added eth.pendingTransactions --- rpc/api/eth.go | 40 +++++++++++++++++++++++++++++++++++----- rpc/api/eth_args.go | 34 ++++++++++++++++++++++++++++++++++ rpc/api/eth_js.go | 8 ++++++++ rpc/api/utils.go | 3 ++- 4 files changed, 79 insertions(+), 6 deletions(-) (limited to 'rpc/api') diff --git a/rpc/api/eth.go b/rpc/api/eth.go index 962c8d0f9..d77bf9803 100644 --- a/rpc/api/eth.go +++ b/rpc/api/eth.go @@ -6,9 +6,11 @@ import ( "math/big" "github.com/ethereum/go-ethereum/common" + "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 +20,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 +74,13 @@ var ( "eth_hashrate": (*ethApi).Hashrate, "eth_getWork": (*ethApi).GetWork, "eth_submitWork": (*ethApi).SubmitWork, + "eth_pendingTransactions": (*ethApi).PendingTransactions, } ) // create new ethApi instance -func NewEthApi(xeth *xeth.XEth, codec codec.Codec) *ethApi { - return ðApi{xeth, ethMapping, codec.New(nil)} +func NewEthApi(xeth *xeth.XEth, eth *eth.Ethereum, codec codec.Codec) *ethApi { + return ðApi{xeth, eth, ethMapping, codec.New(nil)} } // collection with supported methods @@ -548,3 +552,29 @@ 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) PendingTransactions(req *shared.Request) (interface{}, error) { + txs := self.ethereum.TxPool().GetTransactions() + + // grab the accounts from the account manager. This will help with determening 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 +} diff --git a/rpc/api/eth_args.go b/rpc/api/eth_args.go index bf8ffead6..39c003f66 100644 --- a/rpc/api/eth_args.go +++ b/rpc/api/eth_args.go @@ -5,8 +5,11 @@ import ( "fmt" "math/big" + "strconv" + "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 +861,34 @@ 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.Amount.String(), + Nonce: strconv.Itoa(int(t.Nonce())), + Data: "0x" + common.Bytes2Hex(t.Data()), + GasLimit: t.GasLimit.String(), + GasPrice: t.GasPrice().String(), + } +} diff --git a/rpc/api/eth_js.go b/rpc/api/eth_js.go index e1268eb76..8d0fe8f0a 100644 --- a/rpc/api/eth_js.go +++ b/rpc/api/eth_js.go @@ -15,6 +15,14 @@ web3._extend({ inputFormatter: [web3._extend.formatters.formatInputString,web3._extend.formatters.formatInputString], outputFormatter: web3._extend.formatters.formatOutputString }) + ], + properties: + [ + new web3._extend.Property({ + name: 'pendingTransactions', + getter: 'eth_pendingTransactions', + outputFormatter: function(obj) { return obj; } + }) ] }); ` diff --git a/rpc/api/utils.go b/rpc/api/utils.go index 6e4835de6..3d46f78d3 100644 --- a/rpc/api/utils.go +++ b/rpc/api/utils.go @@ -84,6 +84,7 @@ var ( "hashrate", "getWork", "submitWork", + "pendingTransactions", }, "miner": []string{ "hashrate", @@ -149,7 +150,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: -- cgit v1.2.3 From ec866b066ace5d80c3c6a69349dbb1fac4503b46 Mon Sep 17 00:00:00 2001 From: Bas van Kervel Date: Wed, 24 Jun 2015 14:56:53 +0200 Subject: added eth.resend --- rpc/api/eth.go | 18 ++++++++++++++++++ rpc/api/eth_args.go | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ rpc/api/eth_js.go | 7 +++++++ rpc/api/utils.go | 1 + 4 files changed, 76 insertions(+) (limited to 'rpc/api') diff --git a/rpc/api/eth.go b/rpc/api/eth.go index d77bf9803..1883e363c 100644 --- a/rpc/api/eth.go +++ b/rpc/api/eth.go @@ -6,6 +6,7 @@ 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" @@ -74,6 +75,7 @@ var ( "eth_hashrate": (*ethApi).Hashrate, "eth_getWork": (*ethApi).GetWork, "eth_submitWork": (*ethApi).SubmitWork, + "eth_resend": (*ethApi).Resend, "eth_pendingTransactions": (*ethApi).PendingTransactions, } ) @@ -553,6 +555,22 @@ 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() diff --git a/rpc/api/eth_args.go b/rpc/api/eth_args.go index 39c003f66..a75fdbdee 100644 --- a/rpc/api/eth_args.go +++ b/rpc/api/eth_args.go @@ -892,3 +892,53 @@ func newTx(t *types.Transaction) *tx { GasPrice: t.GasPrice().String(), } } + +type ResendArgs struct { + Tx *tx + GasPrice string + GasLimit string +} + +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.") + } + + 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 8d0fe8f0a..4512cc147 100644 --- a/rpc/api/eth_js.go +++ b/rpc/api/eth_js.go @@ -14,6 +14,13 @@ web3._extend({ params: 2, inputFormatter: [web3._extend.formatters.formatInputString,web3._extend.formatters.formatInputString], outputFormatter: web3._extend.formatters.formatOutputString + }), + 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 }) ], properties: diff --git a/rpc/api/utils.go b/rpc/api/utils.go index 3d46f78d3..e6a01d3d6 100644 --- a/rpc/api/utils.go +++ b/rpc/api/utils.go @@ -85,6 +85,7 @@ var ( "getWork", "submitWork", "pendingTransactions", + "resend", }, "miner": []string{ "hashrate", -- cgit v1.2.3 From 02c6af66bfd04f5eb2e2d48a85615e93ea9c9ddc Mon Sep 17 00:00:00 2001 From: Bas van Kervel Date: Wed, 24 Jun 2015 16:07:44 +0200 Subject: fixed unittest compilation issue --- rpc/api/api_test.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'rpc/api') diff --git a/rpc/api/api_test.go b/rpc/api/api_test.go index 7e273ef28..2ac8bcd45 100644 --- a/rpc/api/api_test.go +++ b/rpc/api/api_test.go @@ -76,8 +76,9 @@ func TestCompileSolidity(t *testing.T) { expLanguageVersion := "0" expSource := source - xeth := xeth.NewTest(ð.Ethereum{}, nil) - api := NewEthApi(xeth, codec.JSON) + eth := ð.Ethereum{} + xeth := xeth.NewTest(eth, nil) + api := NewEthApi(xeth, eth, codec.JSON) var rpcRequest shared.Request json.Unmarshal([]byte(jsonstr), &rpcRequest) -- cgit v1.2.3 From 6fdddc5ac940b6241596e0a2622461148e8a57a0 Mon Sep 17 00:00:00 2001 From: Bas van Kervel Date: Mon, 29 Jun 2015 11:13:28 +0200 Subject: improved error handling in parsing request --- rpc/api/eth.go | 3 ++- rpc/api/eth_args.go | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'rpc/api') diff --git a/rpc/api/eth.go b/rpc/api/eth.go index 1883e363c..8e9647861 100644 --- a/rpc/api/eth.go +++ b/rpc/api/eth.go @@ -12,6 +12,7 @@ import ( "github.com/ethereum/go-ethereum/rpc/shared" "github.com/ethereum/go-ethereum/xeth" "gopkg.in/fatih/set.v0" + "fmt" ) const ( @@ -574,7 +575,7 @@ func (self *ethApi) Resend(req *shared.Request) (interface{}, error) { 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 determening which + // 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 { diff --git a/rpc/api/eth_args.go b/rpc/api/eth_args.go index a75fdbdee..88fc00a6c 100644 --- a/rpc/api/eth_args.go +++ b/rpc/api/eth_args.go @@ -917,7 +917,11 @@ func (args *ResendArgs) UnmarshalJSON(b []byte) (err error) { trans := new(tx) err = json.Unmarshal(data, trans) if err != nil { - return shared.NewDecodeParamError("Unable to parse transaction object.") + 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 @@ -936,6 +940,7 @@ func (args *ResendArgs) UnmarshalJSON(b []byte) (err error) { return shared.NewInvalidTypeError("gasLimit", "not a string") } } + args.Tx = trans args.GasPrice = gasPrice args.GasLimit = gasLimit -- cgit v1.2.3 From 7ffabf1d399989618470794600e25764bdd9954b Mon Sep 17 00:00:00 2001 From: Bas van Kervel Date: Mon, 29 Jun 2015 12:32:01 +0200 Subject: add json parsing method for resend transaction --- rpc/api/eth.go | 1 - rpc/api/eth_args.go | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 76 insertions(+), 2 deletions(-) (limited to 'rpc/api') diff --git a/rpc/api/eth.go b/rpc/api/eth.go index 8e9647861..db0b4b024 100644 --- a/rpc/api/eth.go +++ b/rpc/api/eth.go @@ -12,7 +12,6 @@ import ( "github.com/ethereum/go-ethereum/rpc/shared" "github.com/ethereum/go-ethereum/xeth" "gopkg.in/fatih/set.v0" - "fmt" ) const ( diff --git a/rpc/api/eth_args.go b/rpc/api/eth_args.go index 88fc00a6c..203171d58 100644 --- a/rpc/api/eth_args.go +++ b/rpc/api/eth_args.go @@ -4,8 +4,8 @@ import ( "encoding/json" "fmt" "math/big" - "strconv" + "strings" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/state" @@ -899,6 +899,81 @@ type ResendArgs struct { 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()) + } + + trans := new(types.Transaction) + + if val, found := fields["To"]; found { + if strVal, ok := val.(string); ok && len(strVal) > 0 { + tx.To = strVal + to := common.StringToAddress(strVal) + trans.Recipient = &to + } + } + + 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 trans.AccountNonce, err = strconv.ParseUint(strVal, 10, 64); err != nil { + return shared.NewDecodeParamError(fmt.Sprintf("Unable to decode tx.Nonce - %v", err)) + } + } + } + + var parseOk bool + if val, found := fields["Value"]; found { + if strVal, ok := val.(string); ok { + tx.Value = strVal + if trans.Amount, parseOk = new(big.Int).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") { + trans.Payload = common.Hex2Bytes(strVal[2:]) + } else { + trans.Payload = common.Hex2Bytes(strVal) + } + } + } + + if val, found := fields["GasLimit"]; found { + if strVal, ok := val.(string); ok { + tx.GasLimit = strVal + if trans.GasLimit, parseOk = new(big.Int).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 trans.Price, parseOk = new(big.Int).SetString(strVal, 0); !parseOk { + return shared.NewDecodeParamError(fmt.Sprintf("Unable to decode tx.GasPrice - %v", err)) + } + } + } + + tx.tx = trans + + return nil +} + func (args *ResendArgs) UnmarshalJSON(b []byte) (err error) { var obj []interface{} if err = json.Unmarshal(b, &obj); err != nil { -- cgit v1.2.3 From 57dff6f1d7e8402d2849205cb44daaffcc40cc23 Mon Sep 17 00:00:00 2001 From: Bas van Kervel Date: Mon, 29 Jun 2015 12:42:47 +0200 Subject: initialize fields to prevent nil pointer exception --- rpc/api/eth_args.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'rpc/api') diff --git a/rpc/api/eth_args.go b/rpc/api/eth_args.go index 203171d58..b5507832d 100644 --- a/rpc/api/eth_args.go +++ b/rpc/api/eth_args.go @@ -906,6 +906,9 @@ func (tx *tx) UnmarshalJSON(b []byte) (err error) { } trans := new(types.Transaction) + trans.Amount = new(big.Int) + trans.GasLimit = new(big.Int) + trans.Price = new(big.Int) if val, found := fields["To"]; found { if strVal, ok := val.(string); ok && len(strVal) > 0 { @@ -928,13 +931,15 @@ func (tx *tx) UnmarshalJSON(b []byte) (err error) { 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 trans.Amount, parseOk = new(big.Int).SetString(strVal, 0); !parseOk { + if _, parseOk = trans.Amount.SetString(strVal, 0); !parseOk { return shared.NewDecodeParamError(fmt.Sprintf("Unable to decode tx.Amount - %v", err)) } } @@ -954,7 +959,7 @@ func (tx *tx) UnmarshalJSON(b []byte) (err error) { if val, found := fields["GasLimit"]; found { if strVal, ok := val.(string); ok { tx.GasLimit = strVal - if trans.GasLimit, parseOk = new(big.Int).SetString(strVal, 0); !parseOk { + if _, parseOk = trans.GasLimit.SetString(strVal, 0); !parseOk { return shared.NewDecodeParamError(fmt.Sprintf("Unable to decode tx.GasLimit - %v", err)) } } @@ -963,7 +968,7 @@ func (tx *tx) UnmarshalJSON(b []byte) (err error) { if val, found := fields["GasPrice"]; found { if strVal, ok := val.(string); ok { tx.GasPrice = strVal - if trans.Price, parseOk = new(big.Int).SetString(strVal, 0); !parseOk { + if _, parseOk = trans.Price.SetString(strVal, 0); !parseOk { return shared.NewDecodeParamError(fmt.Sprintf("Unable to decode tx.GasPrice - %v", err)) } } -- cgit v1.2.3 From 61ca780f3ba21ef1e62aab545160de12cbbf45bf Mon Sep 17 00:00:00 2001 From: Jeffrey Wilcke Date: Tue, 30 Jun 2015 11:04:30 +0200 Subject: core: reduce CPU load by reducing calls to checkQueue * Reduced maxQueue count * Added proper deletion past maxQueue limit * Added cheap stats method to txpool queueCheck was called for **every** transaction instead of: 1. add all txs 2. check queue previously 1. add txs[i] 2. check queue 3. if i < len(txs) goto 1. --- rpc/api/txpool.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'rpc/api') diff --git a/rpc/api/txpool.go b/rpc/api/txpool.go index 25ad6e9b2..04faf463c 100644 --- a/rpc/api/txpool.go +++ b/rpc/api/txpool.go @@ -68,8 +68,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 } -- cgit v1.2.3 From a5d5387dee984b0d3712379998c200d2c6fe89e5 Mon Sep 17 00:00:00 2001 From: Bas van Kervel Date: Tue, 30 Jun 2015 15:27:27 +0200 Subject: rebase with develop --- rpc/api/eth.go | 9 +++++++++ rpc/api/eth_args.go | 39 ++++++++++++++++++++++++--------------- 2 files changed, 33 insertions(+), 15 deletions(-) (limited to 'rpc/api') diff --git a/rpc/api/eth.go b/rpc/api/eth.go index db0b4b024..784cd0f48 100644 --- a/rpc/api/eth.go +++ b/rpc/api/eth.go @@ -7,7 +7,9 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/crypto/sha3" "github.com/ethereum/go-ethereum/eth" + "github.com/ethereum/go-ethereum/rlp" "github.com/ethereum/go-ethereum/rpc/codec" "github.com/ethereum/go-ethereum/rpc/shared" "github.com/ethereum/go-ethereum/xeth" @@ -555,6 +557,13 @@ 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 rlpHash(x interface{}) (h common.Hash) { + hw := sha3.NewKeccak256() + rlp.Encode(hw, x) + hw.Sum(h[:0]) + return h +} + func (self *ethApi) Resend(req *shared.Request) (interface{}, error) { args := new(ResendArgs) if err := self.codec.Decode(req.Params, &args); err != nil { diff --git a/rpc/api/eth_args.go b/rpc/api/eth_args.go index b5507832d..8f64280d3 100644 --- a/rpc/api/eth_args.go +++ b/rpc/api/eth_args.go @@ -885,10 +885,10 @@ func newTx(t *types.Transaction) *tx { tx: t, To: to, From: from.Hex(), - Value: t.Amount.String(), + Value: t.Value().String(), Nonce: strconv.Itoa(int(t.Nonce())), Data: "0x" + common.Bytes2Hex(t.Data()), - GasLimit: t.GasLimit.String(), + GasLimit: t.Gas().String(), GasPrice: t.GasPrice().String(), } } @@ -905,16 +905,21 @@ func (tx *tx) UnmarshalJSON(b []byte) (err error) { return shared.NewDecodeParamError(err.Error()) } - trans := new(types.Transaction) - trans.Amount = new(big.Int) - trans.GasLimit = new(big.Int) - trans.Price = new(big.Int) + 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.StringToAddress(strVal) - trans.Recipient = &to + to = common.HexToAddress(strVal) + contractCreation = false } } @@ -927,7 +932,7 @@ func (tx *tx) UnmarshalJSON(b []byte) (err error) { if val, found := fields["Nonce"]; found { if strVal, ok := val.(string); ok { tx.Nonce = strVal - if trans.AccountNonce, err = strconv.ParseUint(strVal, 10, 64); err != nil { + if nonce, err = strconv.ParseUint(strVal, 10, 64); err != nil { return shared.NewDecodeParamError(fmt.Sprintf("Unable to decode tx.Nonce - %v", err)) } } @@ -939,7 +944,7 @@ func (tx *tx) UnmarshalJSON(b []byte) (err error) { if val, found := fields["Value"]; found { if strVal, ok := val.(string); ok { tx.Value = strVal - if _, parseOk = trans.Amount.SetString(strVal, 0); !parseOk { + if _, parseOk = amount.SetString(strVal, 0); !parseOk { return shared.NewDecodeParamError(fmt.Sprintf("Unable to decode tx.Amount - %v", err)) } } @@ -949,9 +954,9 @@ func (tx *tx) UnmarshalJSON(b []byte) (err error) { if strVal, ok := val.(string); ok { tx.Data = strVal if strings.HasPrefix(strVal, "0x") { - trans.Payload = common.Hex2Bytes(strVal[2:]) + data = common.Hex2Bytes(strVal[2:]) } else { - trans.Payload = common.Hex2Bytes(strVal) + data = common.Hex2Bytes(strVal) } } } @@ -959,7 +964,7 @@ func (tx *tx) UnmarshalJSON(b []byte) (err error) { if val, found := fields["GasLimit"]; found { if strVal, ok := val.(string); ok { tx.GasLimit = strVal - if _, parseOk = trans.GasLimit.SetString(strVal, 0); !parseOk { + if _, parseOk = gasLimit.SetString(strVal, 0); !parseOk { return shared.NewDecodeParamError(fmt.Sprintf("Unable to decode tx.GasLimit - %v", err)) } } @@ -968,13 +973,17 @@ func (tx *tx) UnmarshalJSON(b []byte) (err error) { if val, found := fields["GasPrice"]; found { if strVal, ok := val.(string); ok { tx.GasPrice = strVal - if _, parseOk = trans.Price.SetString(strVal, 0); !parseOk { + if _, parseOk = gasPrice.SetString(strVal, 0); !parseOk { return shared.NewDecodeParamError(fmt.Sprintf("Unable to decode tx.GasPrice - %v", err)) } } } - tx.tx = trans + if contractCreation { + tx.tx = types.NewContractCreation(nonce, amount, gasLimit, gasPrice, data) + } else { + tx.tx = types.NewTransaction(nonce, to, amount, gasLimit, gasPrice, data) + } return nil } -- cgit v1.2.3 From d05305473eccc60298efcd858ec30175908b8317 Mon Sep 17 00:00:00 2001 From: ethers Date: Tue, 30 Jun 2015 12:14:16 -0700 Subject: fix logging jsonrpc request #1365 --- rpc/api/mergedapi.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'rpc/api') diff --git a/rpc/api/mergedapi.go b/rpc/api/mergedapi.go index bc4fa32e8..c40716996 100644 --- a/rpc/api/mergedapi.go +++ b/rpc/api/mergedapi.go @@ -42,7 +42,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 -- cgit v1.2.3 From 3a983d2419cdd053f5e03193794d1663c841f4b2 Mon Sep 17 00:00:00 2001 From: Taylor Gerring Date: Fri, 3 Jul 2015 11:20:07 -0500 Subject: Initial getTransactionReceipt support --- rpc/api/eth.go | 20 ++++++++++++++++++++ rpc/api/parsing.go | 23 +++++++++++++++++++++++ 2 files changed, 43 insertions(+) (limited to 'rpc/api') diff --git a/rpc/api/eth.go b/rpc/api/eth.go index db0b4b024..c556c739f 100644 --- a/rpc/api/eth.go +++ b/rpc/api/eth.go @@ -77,6 +77,7 @@ var ( "eth_submitWork": (*ethApi).SubmitWork, "eth_resend": (*ethApi).Resend, "eth_pendingTransactions": (*ethApi).PendingTransactions, + "eth_getTransactionReceipt": (*ethApi).GetTransactionReceipt, } ) @@ -596,3 +597,22 @@ func (self *ethApi) PendingTransactions(req *shared.Request) (interface{}, error 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()) + } + + rec, _ := self.xeth.GetTxReceipt(common.StringToHash(args.Hash)) + // We could have an error of "not found". Should disambiguate + // if err != nil { + // return err, nil + // } + if rec != nil { + v := NewReceiptRes(rec) + return v, nil + } + + return nil, nil +} diff --git a/rpc/api/parsing.go b/rpc/api/parsing.go index 632462c31..d1f9ccac2 100644 --- a/rpc/api/parsing.go +++ b/rpc/api/parsing.go @@ -402,6 +402,29 @@ 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) + // TODO fill out rest of object + v.CumulativeGasUsed = newHexNum(rec.CumulativeGasUsed) + + return v +} + func numString(raw interface{}) (*big.Int, error) { var number *big.Int // Parse as integer -- cgit v1.2.3 From 80eb8f46b7991b80dffe00e52d9fb00a90531bc0 Mon Sep 17 00:00:00 2001 From: Taylor Gerring Date: Fri, 3 Jul 2015 23:46:59 -0500 Subject: Fix hex conversion --- rpc/api/eth.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'rpc/api') diff --git a/rpc/api/eth.go b/rpc/api/eth.go index c556c739f..9d78538fe 100644 --- a/rpc/api/eth.go +++ b/rpc/api/eth.go @@ -604,7 +604,8 @@ func (self *ethApi) GetTransactionReceipt(req *shared.Request) (interface{}, err return nil, shared.NewDecodeParamError(err.Error()) } - rec, _ := self.xeth.GetTxReceipt(common.StringToHash(args.Hash)) + v := common.BytesToHash(common.FromHex(args.Hash)) + rec := self.xeth.GetTxReceipt(v) // We could have an error of "not found". Should disambiguate // if err != nil { // return err, nil -- cgit v1.2.3 From 481b221279be1673832f96e35e3fdc0f82e178bc Mon Sep 17 00:00:00 2001 From: Taylor Gerring Date: Sat, 4 Jul 2015 00:00:23 -0500 Subject: Decode full receipt storage --- rpc/api/parsing.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'rpc/api') diff --git a/rpc/api/parsing.go b/rpc/api/parsing.go index d1f9ccac2..c7edf4325 100644 --- a/rpc/api/parsing.go +++ b/rpc/api/parsing.go @@ -413,15 +413,17 @@ type ReceiptRes struct { Logs *[]interface{} `json:logs` } -func NewReceiptRes(rec *types.Receipt) *ReceiptRes { +func NewReceiptRes(rec *types.ReceiptForStorage) *ReceiptRes { if rec == nil { return nil } var v = new(ReceiptRes) // TODO fill out rest of object + // ContractAddress is all 0 when not a creation tx + v.ContractAddress = newHexData(rec.ContractAddress) v.CumulativeGasUsed = newHexNum(rec.CumulativeGasUsed) - + v.TransactionHash = newHexData(rec.TxHash) return v } -- cgit v1.2.3 From 3be9046c21920abffa3c5ec81d5aabea8e3bab73 Mon Sep 17 00:00:00 2001 From: Taylor Gerring Date: Sat, 4 Jul 2015 10:24:52 -0500 Subject: Rename local variable for clarity --- rpc/api/eth.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'rpc/api') diff --git a/rpc/api/eth.go b/rpc/api/eth.go index 9d78538fe..0f3b14525 100644 --- a/rpc/api/eth.go +++ b/rpc/api/eth.go @@ -604,8 +604,8 @@ func (self *ethApi) GetTransactionReceipt(req *shared.Request) (interface{}, err return nil, shared.NewDecodeParamError(err.Error()) } - v := common.BytesToHash(common.FromHex(args.Hash)) - rec := self.xeth.GetTxReceipt(v) + txhash := common.BytesToHash(common.FromHex(args.Hash)) + rec := self.xeth.GetTxReceipt(txhash) // We could have an error of "not found". Should disambiguate // if err != nil { // return err, nil -- cgit v1.2.3 From cd4cc309ae4ead756cbe58ad564b029e874d9832 Mon Sep 17 00:00:00 2001 From: Taylor Gerring Date: Sat, 4 Jul 2015 11:28:30 -0500 Subject: Remove redundant function --- rpc/api/parsing.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'rpc/api') diff --git a/rpc/api/parsing.go b/rpc/api/parsing.go index c7edf4325..70e9bf942 100644 --- a/rpc/api/parsing.go +++ b/rpc/api/parsing.go @@ -413,7 +413,7 @@ type ReceiptRes struct { Logs *[]interface{} `json:logs` } -func NewReceiptRes(rec *types.ReceiptForStorage) *ReceiptRes { +func NewReceiptRes(rec *types.Receipt) *ReceiptRes { if rec == nil { return nil } -- cgit v1.2.3 From 30afd37604da40416b0dd4fdc8cad322c12651cf Mon Sep 17 00:00:00 2001 From: Taylor Gerring Date: Sat, 4 Jul 2015 12:03:37 -0500 Subject: Compose additional fields --- rpc/api/eth.go | 7 ++++++- rpc/api/parsing.go | 16 ++++++++++++---- 2 files changed, 18 insertions(+), 5 deletions(-) (limited to 'rpc/api') diff --git a/rpc/api/eth.go b/rpc/api/eth.go index 0f3b14525..6d759a087 100644 --- a/rpc/api/eth.go +++ b/rpc/api/eth.go @@ -605,13 +605,18 @@ func (self *ethApi) GetTransactionReceipt(req *shared.Request) (interface{}, err } 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 { + if rec != nil && tx != nil { v := NewReceiptRes(rec) + v.BlockHash = newHexData(bhash) + v.BlockNumber = newHexNum(bnum) + v.GasUsed = newHexNum(tx.Gas().Bytes()) + v.TransactionIndex = newHexNum(txi) return v, nil } diff --git a/rpc/api/parsing.go b/rpc/api/parsing.go index 70e9bf942..cc7f60cad 100644 --- a/rpc/api/parsing.go +++ b/rpc/api/parsing.go @@ -1,6 +1,7 @@ package api import ( + "bytes" "encoding/binary" "encoding/hex" "encoding/json" @@ -419,11 +420,18 @@ func NewReceiptRes(rec *types.Receipt) *ReceiptRes { } var v = new(ReceiptRes) - // TODO fill out rest of object - // ContractAddress is all 0 when not a creation tx - v.ContractAddress = newHexData(rec.ContractAddress) - v.CumulativeGasUsed = newHexNum(rec.CumulativeGasUsed) v.TransactionHash = newHexData(rec.TxHash) + // v.TransactionIndex = newHexNum(input) // transaction + // v.BlockNumber = newHexNum(input) // transaction + // v.BlockHash = newHexData(input) //transaction + v.CumulativeGasUsed = newHexNum(rec.CumulativeGasUsed) + // v.GasUsed = newHexNum(input) // CumulativeGasUsed (blocknum-1) + // 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) + } + // v.Logs = rec.Logs() + return v } -- cgit v1.2.3 From 62559ac3304ff582028a20771c8ef870f24685f5 Mon Sep 17 00:00:00 2001 From: Taylor Gerring Date: Sat, 4 Jul 2015 12:14:06 -0500 Subject: Cleanup --- rpc/api/parsing.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'rpc/api') diff --git a/rpc/api/parsing.go b/rpc/api/parsing.go index cc7f60cad..4209ea7e3 100644 --- a/rpc/api/parsing.go +++ b/rpc/api/parsing.go @@ -421,11 +421,11 @@ func NewReceiptRes(rec *types.Receipt) *ReceiptRes { var v = new(ReceiptRes) v.TransactionHash = newHexData(rec.TxHash) - // v.TransactionIndex = newHexNum(input) // transaction - // v.BlockNumber = newHexNum(input) // transaction - // v.BlockHash = newHexData(input) //transaction + // v.TransactionIndex = newHexNum(input) + // v.BlockNumber = newHexNum(input) + // v.BlockHash = newHexData(input) v.CumulativeGasUsed = newHexNum(rec.CumulativeGasUsed) - // v.GasUsed = newHexNum(input) // CumulativeGasUsed (blocknum-1) + // v.GasUsed = newHexNum(input) // 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) -- cgit v1.2.3 From 6c7f5e3d0e6f4166f161278fdced3d90dfd6f9cc Mon Sep 17 00:00:00 2001 From: Taylor Gerring Date: Sun, 5 Jul 2015 15:42:04 -0500 Subject: Add autocomplete support for console --- rpc/api/utils.go | 1 + 1 file changed, 1 insertion(+) (limited to 'rpc/api') diff --git a/rpc/api/utils.go b/rpc/api/utils.go index e6a01d3d6..54ca28774 100644 --- a/rpc/api/utils.go +++ b/rpc/api/utils.go @@ -86,6 +86,7 @@ var ( "submitWork", "pendingTransactions", "resend", + "getTransactionReceipt", }, "miner": []string{ "hashrate", -- cgit v1.2.3 From 4f7fc7b23f50f3fba4e2fb6815738c4ec2c8fe0a Mon Sep 17 00:00:00 2001 From: Jeffrey Wilcke Date: Mon, 6 Jul 2015 13:43:02 +0200 Subject: rpc, xeth: fixed returned tx hash & receipt logs --- rpc/api/parsing.go | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'rpc/api') diff --git a/rpc/api/parsing.go b/rpc/api/parsing.go index 4209ea7e3..8e25ffffb 100644 --- a/rpc/api/parsing.go +++ b/rpc/api/parsing.go @@ -404,14 +404,14 @@ func NewUncleRes(h *types.Header) *UncleRes { // } 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` + 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 { @@ -430,7 +430,12 @@ func NewReceiptRes(rec *types.Receipt) *ReceiptRes { if bytes.Compare(rec.ContractAddress.Bytes(), bytes.Repeat([]byte{0}, 20)) != 0 { v.ContractAddress = newHexData(rec.ContractAddress) } - // v.Logs = rec.Logs() + + logs := make([]interface{}, len(rec.Logs())) + for i, log := range rec.Logs() { + logs[i] = NewLogRes(log) + } + v.Logs = &logs return v } -- cgit v1.2.3 From 666a7dda369e9a30715f560c8f72b81735a347fc Mon Sep 17 00:00:00 2001 From: Jeffrey Wilcke Date: Mon, 6 Jul 2015 20:59:12 +0200 Subject: core, eth, rpc: proper gas used. Closes #1417 Added some additional backward compatibility code for old receipts --- rpc/api/eth.go | 1 - rpc/api/parsing.go | 8 ++++---- 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'rpc/api') diff --git a/rpc/api/eth.go b/rpc/api/eth.go index 6d759a087..944e96070 100644 --- a/rpc/api/eth.go +++ b/rpc/api/eth.go @@ -615,7 +615,6 @@ func (self *ethApi) GetTransactionReceipt(req *shared.Request) (interface{}, err v := NewReceiptRes(rec) v.BlockHash = newHexData(bhash) v.BlockNumber = newHexNum(bnum) - v.GasUsed = newHexNum(tx.Gas().Bytes()) v.TransactionIndex = newHexNum(txi) return v, nil } diff --git a/rpc/api/parsing.go b/rpc/api/parsing.go index 8e25ffffb..493d196e0 100644 --- a/rpc/api/parsing.go +++ b/rpc/api/parsing.go @@ -421,11 +421,11 @@ func NewReceiptRes(rec *types.Receipt) *ReceiptRes { var v = new(ReceiptRes) v.TransactionHash = newHexData(rec.TxHash) - // v.TransactionIndex = newHexNum(input) - // v.BlockNumber = newHexNum(input) - // v.BlockHash = newHexData(input) + if rec.GasUsed != nil { + v.GasUsed = newHexNum(rec.GasUsed.Bytes()) + } v.CumulativeGasUsed = newHexNum(rec.CumulativeGasUsed) - // v.GasUsed = newHexNum(input) + // 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) -- cgit v1.2.3 From 35cd355c14d9a5266a7d4b11127d25eb7f961494 Mon Sep 17 00:00:00 2001 From: Jeffrey Wilcke Date: Tue, 7 Jul 2015 10:32:05 +0200 Subject: cmd,eth,rpc,tests: default coinbase --- rpc/api/miner.go | 10 ++++++++++ rpc/api/miner_args.go | 26 ++++++++++++++++++++++++++ rpc/api/miner_js.go | 7 +++++++ 3 files changed, 43 insertions(+) (limited to 'rpc/api') diff --git a/rpc/api/miner.go b/rpc/api/miner.go index 7a84cb9ae..4e237751a 100644 --- a/rpc/api/miner.go +++ b/rpc/api/miner.go @@ -19,6 +19,7 @@ var ( "miner_makeDAG": (*minerApi).MakeDAG, "miner_setExtra": (*minerApi).SetExtra, "miner_setGasPrice": (*minerApi).SetGasPrice, + "admin_setEtherbase": (*minerApi).SetEtherbase, "miner_startAutoDAG": (*minerApi).StartAutoDAG, "miner_start": (*minerApi).StartMiner, "miner_stopAutoDAG": (*minerApi).StopAutoDAG, @@ -119,6 +120,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..9da3b95ad 100644 --- a/rpc/api/miner_args.go +++ b/rpc/api/miner_args.go @@ -5,6 +5,7 @@ import ( "math/big" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/rpc/shared" ) @@ -76,6 +77,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..fe4fa939e 100644 --- a/rpc/api/miner_js.go +++ b/rpc/api/miner_js.go @@ -19,6 +19,13 @@ web3._extend({ inputFormatter: [web3._extend.formatters.formatInputInt], outputFormatter: web3._extend.formatters.formatOutputBool }), + new web3._extend.Method({ + name: 'setEtherbase', + call: 'miner_setEtherbase', + params: 1, + inputFormatter: [web3._extend.formatters.formatInputInt], + outputFormatter: web3._extend.formatters.formatOutputBool + }), new web3._extend.Method({ name: 'setExtra', call: 'miner_setExtra', -- cgit v1.2.3 From 83ee39448e0f23d42dff27bccde27f828afa3707 Mon Sep 17 00:00:00 2001 From: zelig Date: Tue, 23 Jun 2015 15:48:33 +0100 Subject: Registrar and contractInfo handling * resolver -> common/registrar * global registrar name registry interface * add Call to resolver backend interface * the hashReg and UrlHing contracts now initialised from global registry * initialization of contracts uniform * improve errors and more econsistent method names * common/registrar/ethreg: versioned registrar * integrate new naming and registrar in natspec * js console api: setGlobalRegistrar, setHashReg, setUrlHint * js test TestContract uses mining - tests fixed all pass * eth/backend: allow PoW test mode (small ethash DAG) * console jsre refers to resolver.abi/addr, * cmd/geth/contracts.go moved to common/registrar --- rpc/api/admin.go | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ rpc/api/admin_args.go | 31 +++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+) (limited to 'rpc/api') diff --git a/rpc/api/admin.go b/rpc/api/admin.go index b27482cfe..78c75a60b 100644 --- a/rpc/api/admin.go +++ b/rpc/api/admin.go @@ -3,7 +3,9 @@ package api import ( "fmt" "io" + "math/big" "os" + "time" "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/types" @@ -244,3 +246,49 @@ 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 +} + +// sec, err := call.Argument(0).ToInteger() +// if err != nil { +// fmt.Println(err) +// return otto.FalseValue() +// } +// time.Sleep(time.Duration(sec) * time.Second) +// return otto.UndefinedValue() +// } diff --git a/rpc/api/admin_args.go b/rpc/api/admin_args.go index 5437971ca..7aee5d678 100644 --- a/rpc/api/admin_args.go +++ b/rpc/api/admin_args.go @@ -147,3 +147,34 @@ func (args *StartRPCArgs) UnmarshalJSON(b []byte) (err error) { 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 { + if n, ok := obj[0].(int64); ok { + args.N = n + } else { + return shared.NewInvalidTypeError("N", "not an integer") + } + } + + if len(obj) >= 2 { + if n, ok := obj[1].(int64); ok { + args.N = n + } else { + return shared.NewInvalidTypeError("Timeout", "not an integer") + } + } + return nil +} -- cgit v1.2.3 From 27392337198b9287e9f6fe615510a1f30099e3d7 Mon Sep 17 00:00:00 2001 From: zelig Date: Tue, 23 Jun 2015 15:48:33 +0100 Subject: Registrar and contractInfo handling * resolver -> common/registrar * global registrar name registry interface * add Call to resolver backend interface * the hashReg and UrlHing contracts now initialised from global registry * initialization of contracts uniform * improve errors and more econsistent method names * common/registrar/ethreg: versioned registrar * integrate new naming and registrar in natspec * js console api: setGlobalRegistrar, setHashReg, setUrlHint * js test TestContract uses mining - tests fixed all pass * eth/backend: allow PoW test mode (small ethash DAG) * console jsre refers to resolver.abi/addr, * cmd/geth/contracts.go moved to common/registrar --- rpc/api/admin.go | 185 ++++++++++++++++++++++++++++++++-- rpc/api/admin_args.go | 272 +++++++++++++++++++++++++++++++++++++++++++++++++- rpc/api/admin_js.go | 64 ++++++++++++ 3 files changed, 508 insertions(+), 13 deletions(-) (limited to 'rpc/api') diff --git a/rpc/api/admin.go b/rpc/api/admin.go index 78c75a60b..40199caa9 100644 --- a/rpc/api/admin.go +++ b/rpc/api/admin.go @@ -7,8 +7,14 @@ import ( "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" @@ -26,17 +32,27 @@ 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, } ) @@ -49,6 +65,7 @@ type adminApi struct { ethereum *eth.Ethereum codec codec.Codec coder codec.ApiCoder + ds *docserver.DocServer } // create a new admin api instance @@ -58,6 +75,7 @@ func NewAdminApi(xeth *xeth.XEth, ethereum *eth.Ethereum, codec codec.Codec) *ad ethereum: ethereum, codec: codec, coder: codec.New(nil), + ds: docserver.New("/"), } } @@ -292,3 +310,148 @@ func sleepBlocks(wait chan *big.Int, height *big.Int, timer <-chan time.Time) (n // time.Sleep(time.Duration(sec) * time.Second) // return otto.UndefinedValue() // } +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) + err := reg.SetGlobalRegistrar(args.NameReg, sender) + if err != nil { + return false, err + } + + return registrar.GlobalRegistrarAddr, 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) + err := reg.SetHashReg(args.HashReg, sender) + if err != nil { + return false, err + } + + return registrar.HashRegAddr, 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) + err := reg.SetUrlHint(urlHint, sender) + if err != nil { + return nil, err + } + + return registrar.UrlHintAddr, 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 7aee5d678..a4d692c0a 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" ) @@ -154,6 +155,7 @@ type SleepBlocksArgs struct { } func (args *SleepBlocksArgs) UnmarshalJSON(b []byte) (err error) { + var obj []interface{} if err := json.Unmarshal(b, &obj); err != nil { return shared.NewDecodeParamError(err.Error()) @@ -171,10 +173,276 @@ func (args *SleepBlocksArgs) UnmarshalJSON(b []byte) (err error) { if len(obj) >= 2 { if n, ok := obj[1].(int64); ok { - args.N = n + args.Timeout = n + } else { + return shared.NewInvalidTypeError("N", "not an integer") + } + } + + 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 { + 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 { + if hashreg, ok := obj[0].(string); ok { + args.HashReg = hashreg + } else { + return shared.NewInvalidTypeError("HashReg", "not a string") + } + } + + if len(obj) >= 2 { + 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 { + if urlhint, ok := obj[0].(string); ok { + args.UrlHint = urlhint + } else { + return shared.NewInvalidTypeError("UrlHint", "not a string") + } + } + + if len(obj) >= 2 { + 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[1].(string); ok { + args.Sender = sender + } else { + return shared.NewInvalidTypeError("Sender", "not a string") + } + } + + 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("Timeout", "not an integer") + 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 { + 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..1f822f2c7 100644 --- a/rpc/api/admin_js.go +++ b/rpc/api/admin_js.go @@ -53,7 +53,71 @@ web3._extend({ params: 0, inputFormatter: [], outputFormatter: web3._extend.formatters.formatOutputBool + }), + new web3._extend.Method({ + name: 'setGlobalRegistrar', + call: 'admin_setGlobalRegistrar', + params: 2, + inputFormatter: [web3._extend.utils.formatInputString,web3._extend.utils.formatInputString], + outputFormatter: web3._extend.formatters.formatOutputString + }), + new web3._extend.Method({ + name: 'setHashReg', + call: 'admin_setHashReg', + params: 2, + inputFormatter: [web3._extend.utils.formatInputString,web3._extend.utils.formatInputString], + outputFormatter: web3._extend.formatters.formatOutputString + }), + new web3._extend.Method({ + name: 'saveInfo', + call: 'admin_saveInfo', + params: 2, + inputFormatter: [function(obj) { return obj; },web3._extend.utils.formatInputString], + outputFormatter: web3._extend.formatters.formatOutputString + }), + new web3._extend.Method({ + name: 'register', + call: 'admin_register', + params: 2, + inputFormatter: [web3._extend.utils.formatInputString,web3._extend.utils.formatInputString], + outputFormatter: web3._extend.formatters.formatOutputBool + }), + new web3._extend.Method({ + name: 'registerUrl', + call: 'admin_registerUrl', + params: 3, + inputFormatter: [web3._extend.utils.formatInputString,web3._extend.utils.formatInputString,web3._extend.utils.formatInputString], + outputFormatter: web3._extend.formatters.formatOutputBool + }), + new web3._extend.Method({ + name: 'StartNatSpec', + call: 'admin_startNatSpec', + params: 0, + inputFormatter: [], + outputFormatter: web3._extend.formatters.formatOutputBool + }), + new web3._extend.Method({ + name: 'StopNatSpec', + call: 'admin_stopNatSpec', + params: 0, + inputFormatter: [], + outputFormatter: web3._extend.formatters.formatOutputBool + }), + new web3._extend.Method({ + name: 'getContractInfo', + call: 'admin_getContractInfo', + params: 1, + inputFormatter: [web3._extend.utils.formatInputString], + outputFormatter: function(obj) { return json.parse(obj); } + }), + new web3._extend.Method({ + name: 'httpGet', + call: 'admin_httpGet', + params: 2, + inputFormatter: [web3._extend.utils.formatInputString,web3._extend.utils.formatInputString], + outputFormatter: web3._extend.formatters.formatOutputString }) + ], properties: [ -- cgit v1.2.3 From 6391ec0c8f5ea645d772ede9f4c6fbda3d84105f Mon Sep 17 00:00:00 2001 From: zelig Date: Tue, 30 Jun 2015 16:39:31 +0100 Subject: add missing method to api/admin --- rpc/api/admin.go | 1 + rpc/api/admin_js.go | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) (limited to 'rpc/api') diff --git a/rpc/api/admin.go b/rpc/api/admin.go index 40199caa9..0230937fa 100644 --- a/rpc/api/admin.go +++ b/rpc/api/admin.go @@ -43,6 +43,7 @@ var ( "admin_datadir": (*adminApi).DataDir, "admin_startRPC": (*adminApi).StartRPC, "admin_stopRPC": (*adminApi).StopRPC, + "admin_sleepBlocks": (*adminApi).SleepBlocks, "admin_setGlobalRegistrar": (*adminApi).SetGlobalRegistrar, "admin_setHashReg": (*adminApi).SetHashReg, "admin_setUrlHint": (*adminApi).SetUrlHint, diff --git a/rpc/api/admin_js.go b/rpc/api/admin_js.go index 1f822f2c7..17be63575 100644 --- a/rpc/api/admin_js.go +++ b/rpc/api/admin_js.go @@ -26,6 +26,13 @@ web3._extend({ inputFormatter: [web3._extend.utils.formatInputString], outputFormatter: function(obj) { return obj; } }), + new web3._extend.Method({ + name: 'sleepBlocks', + call: 'admin_sleepBlocks', + params: 2, + inputFormatter: [web3._extend.utils.formatInputInt,web3._extend.utils.formatInputInt], + outputFormatter: web3._extend.formatters.formatOutputInt + }), new web3._extend.Method({ name: 'verbosity', call: 'admin_verbosity', @@ -68,6 +75,13 @@ web3._extend({ inputFormatter: [web3._extend.utils.formatInputString,web3._extend.utils.formatInputString], outputFormatter: web3._extend.formatters.formatOutputString }), + new web3._extend.Method({ + name: 'setUrlHint', + call: 'admin_setUrlHint', + params: 2, + inputFormatter: [web3._extend.utils.formatInputString,web3._extend.utils.formatInputString], + outputFormatter: web3._extend.formatters.formatOutputString + }), new web3._extend.Method({ name: 'saveInfo', call: 'admin_saveInfo', @@ -90,14 +104,14 @@ web3._extend({ outputFormatter: web3._extend.formatters.formatOutputBool }), new web3._extend.Method({ - name: 'StartNatSpec', + name: 'startNatSpec', call: 'admin_startNatSpec', params: 0, inputFormatter: [], outputFormatter: web3._extend.formatters.formatOutputBool }), new web3._extend.Method({ - name: 'StopNatSpec', + name: 'stopNatSpec', call: 'admin_stopNatSpec', params: 0, inputFormatter: [], -- cgit v1.2.3 From 518dc87db3dd09aed21f255f448f95dcc746dc12 Mon Sep 17 00:00:00 2001 From: zelig Date: Thu, 2 Jul 2015 16:38:48 +0100 Subject: fix sleepBlocks, implement sleep --- rpc/api/admin.go | 20 +++++++++++--------- rpc/api/admin_args.go | 40 ++++++++++++++++++++++++++++++++-------- rpc/api/admin_js.go | 2 +- 3 files changed, 44 insertions(+), 18 deletions(-) (limited to 'rpc/api') diff --git a/rpc/api/admin.go b/rpc/api/admin.go index 0230937fa..5d214e8d8 100644 --- a/rpc/api/admin.go +++ b/rpc/api/admin.go @@ -43,7 +43,6 @@ var ( "admin_datadir": (*adminApi).DataDir, "admin_startRPC": (*adminApi).StartRPC, "admin_stopRPC": (*adminApi).StopRPC, - "admin_sleepBlocks": (*adminApi).SleepBlocks, "admin_setGlobalRegistrar": (*adminApi).SetGlobalRegistrar, "admin_setHashReg": (*adminApi).SetHashReg, "admin_setUrlHint": (*adminApi).SetUrlHint, @@ -54,6 +53,8 @@ var ( "admin_stopNatSpec": (*adminApi).StopNatSpec, "admin_getContractInfo": (*adminApi).GetContractInfo, "admin_httpGet": (*adminApi).HttpGet, + "admin_sleepBlocks": (*adminApi).SleepBlocks, + "admin_sleep": (*adminApi).Sleep, } ) @@ -303,14 +304,15 @@ func sleepBlocks(wait chan *big.Int, height *big.Int, timer <-chan time.Time) (n return } -// sec, err := call.Argument(0).ToInteger() -// if err != nil { -// fmt.Println(err) -// return otto.FalseValue() -// } -// time.Sleep(time.Duration(sec) * time.Second) -// return otto.UndefinedValue() -// } +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 { diff --git a/rpc/api/admin_args.go b/rpc/api/admin_args.go index a4d692c0a..e7548c7be 100644 --- a/rpc/api/admin_args.go +++ b/rpc/api/admin_args.go @@ -149,6 +149,30 @@ 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 @@ -163,19 +187,19 @@ func (args *SleepBlocksArgs) UnmarshalJSON(b []byte) (err error) { args.N = 1 args.Timeout = 0 - if len(obj) >= 1 { - if n, ok := obj[0].(int64); ok { - args.N = n + 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") + return shared.NewInvalidTypeError("N", "not an integer: "+err.Error()) } } - if len(obj) >= 2 { - if n, ok := obj[1].(int64); ok { - args.Timeout = n + if len(obj) >= 2 && obj[1] != nil { + if n, err := numString(obj[1]); err == nil { + args.Timeout = n.Int64() } else { - return shared.NewInvalidTypeError("N", "not an integer") + return shared.NewInvalidTypeError("Timeout", "not an integer: "+err.Error()) } } diff --git a/rpc/api/admin_js.go b/rpc/api/admin_js.go index 17be63575..2a9197da7 100644 --- a/rpc/api/admin_js.go +++ b/rpc/api/admin_js.go @@ -57,7 +57,7 @@ web3._extend({ new web3._extend.Method({ name: 'stopRPC', call: 'admin_stopRPC', - params: 0, + params: 2, inputFormatter: [], outputFormatter: web3._extend.formatters.formatOutputBool }), -- cgit v1.2.3 From aa22cf323ef408f0562817352f68197f8b982f75 Mon Sep 17 00:00:00 2001 From: zelig Date: Sat, 4 Jul 2015 22:12:14 +0100 Subject: fix js arguments and TestContract passes --- rpc/api/admin_args.go | 32 +++++++++++++++++--------------- rpc/api/admin_js.go | 4 ++-- 2 files changed, 19 insertions(+), 17 deletions(-) (limited to 'rpc/api') diff --git a/rpc/api/admin_args.go b/rpc/api/admin_args.go index e7548c7be..532907905 100644 --- a/rpc/api/admin_args.go +++ b/rpc/api/admin_args.go @@ -114,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 { @@ -122,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 { @@ -130,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 { @@ -138,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 { @@ -229,7 +229,7 @@ func (args *SetGlobalRegistrarArgs) UnmarshalJSON(b []byte) (err error) { } } - if len(obj) >= 2 { + if len(obj) >= 2 && obj[1] != nil { if addr, ok := obj[1].(string); ok { args.ContractAddress = addr } else { @@ -251,7 +251,7 @@ func (args *SetHashRegArgs) UnmarshalJSON(b []byte) (err error) { return shared.NewDecodeParamError(err.Error()) } - if len(obj) >= 1 { + if len(obj) >= 1 && obj[0] != nil { if hashreg, ok := obj[0].(string); ok { args.HashReg = hashreg } else { @@ -259,7 +259,7 @@ func (args *SetHashRegArgs) UnmarshalJSON(b []byte) (err error) { } } - if len(obj) >= 2 { + if len(obj) >= 2 && obj[1] != nil { if sender, ok := obj[1].(string); ok { args.Sender = sender } else { @@ -281,7 +281,7 @@ func (args *SetUrlHintArgs) UnmarshalJSON(b []byte) (err error) { return shared.NewDecodeParamError(err.Error()) } - if len(obj) >= 1 { + if len(obj) >= 1 && obj[0] != nil { if urlhint, ok := obj[0].(string); ok { args.UrlHint = urlhint } else { @@ -289,7 +289,7 @@ func (args *SetUrlHintArgs) UnmarshalJSON(b []byte) (err error) { } } - if len(obj) >= 2 { + if len(obj) >= 2 && obj[1] != nil { if sender, ok := obj[1].(string); ok { args.Sender = sender } else { @@ -388,17 +388,19 @@ func (args *RegisterUrlArgs) UnmarshalJSON(b []byte) (err error) { } if len(obj) >= 1 { - if sender, ok := obj[1].(string); ok { + if sender, ok := obj[0].(string); ok { args.Sender = sender } else { return shared.NewInvalidTypeError("Sender", "not a string") } } - if sender, ok := obj[1].(string); ok { - args.ContentHash = sender - } else { - return shared.NewInvalidTypeError("ContentHash", "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 { @@ -460,7 +462,7 @@ func (args *HttpGetArgs) UnmarshalJSON(b []byte) (err error) { } } - if len(obj) >= 2 { + if len(obj) >= 2 && obj[1] != nil { if path, ok := obj[1].(string); ok { args.Path = path } else { diff --git a/rpc/api/admin_js.go b/rpc/api/admin_js.go index 2a9197da7..40c029fd1 100644 --- a/rpc/api/admin_js.go +++ b/rpc/api/admin_js.go @@ -92,8 +92,8 @@ web3._extend({ new web3._extend.Method({ name: 'register', call: 'admin_register', - params: 2, - inputFormatter: [web3._extend.utils.formatInputString,web3._extend.utils.formatInputString], + params: 3, + inputFormatter: [web3._extend.utils.formatInputString,web3._extend.utils.formatInputString,web3._extend.utils.formatInputString], outputFormatter: web3._extend.formatters.formatOutputBool }), new web3._extend.Method({ -- cgit v1.2.3 From 37c1a8f69de44827a60296342189b6719a49dbc3 Mon Sep 17 00:00:00 2001 From: Jeffrey Wilcke Date: Tue, 7 Jul 2015 10:58:47 +0200 Subject: eth,miner,rpc: set coinbase --- rpc/api/miner.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'rpc/api') diff --git a/rpc/api/miner.go b/rpc/api/miner.go index 4e237751a..8d4646a5c 100644 --- a/rpc/api/miner.go +++ b/rpc/api/miner.go @@ -19,7 +19,7 @@ var ( "miner_makeDAG": (*minerApi).MakeDAG, "miner_setExtra": (*minerApi).SetExtra, "miner_setGasPrice": (*minerApi).SetGasPrice, - "admin_setEtherbase": (*minerApi).SetEtherbase, + "miner_setEtherbase": (*minerApi).SetEtherbase, "miner_startAutoDAG": (*minerApi).StartAutoDAG, "miner_start": (*minerApi).StartMiner, "miner_stopAutoDAG": (*minerApi).StopAutoDAG, -- cgit v1.2.3 From ceb0739ba111215d47cc2ff9d80d542fa26d764a Mon Sep 17 00:00:00 2001 From: Bas van Kervel Date: Mon, 6 Jul 2015 13:08:08 +0200 Subject: fixed web3 formatters mismatch --- rpc/api/admin_js.go | 39 +++++++++------------------ rpc/api/db_js.go | 28 ------------------- rpc/api/debug_js.go | 23 ++++++---------- rpc/api/eth_js.go | 9 +++---- rpc/api/miner_js.go | 21 +++++---------- rpc/api/net_js.go | 28 +++---------------- rpc/api/personal_js.go | 10 +++---- rpc/api/ssh_js.go | 16 ++--------- rpc/api/utils.go | 73 ++++++++++++++++++++++---------------------------- 9 files changed, 73 insertions(+), 174 deletions(-) (limited to 'rpc/api') diff --git a/rpc/api/admin_js.go b/rpc/api/admin_js.go index 40c029fd1..e528b8863 100644 --- a/rpc/api/admin_js.go +++ b/rpc/api/admin_js.go @@ -9,22 +9,19 @@ 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', @@ -37,22 +34,19 @@ web3._extend({ name: 'verbosity', call: 'admin_verbosity', params: 1, - inputFormatter: [web3._extend.utils.formatInputInt], - outputFormatter: web3._extend.formatters.formatOutputBool + inputFormatter: [web3._extend.utils.toDecimal] }), 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, web3._extend.utils.toDecimal, null, null] }), new web3._extend.Method({ name: 'stopRPC', @@ -114,22 +108,19 @@ web3._extend({ name: 'stopNatSpec', call: 'admin_stopNatSpec', params: 0, - inputFormatter: [], - outputFormatter: web3._extend.formatters.formatOutputBool + inputFormatter: [] }), new web3._extend.Method({ name: 'getContractInfo', call: 'admin_getContractInfo', params: 1, - inputFormatter: [web3._extend.utils.formatInputString], - outputFormatter: function(obj) { return json.parse(obj); } + inputFormatter: [null], }), new web3._extend.Method({ name: 'httpGet', call: 'admin_httpGet', params: 2, - inputFormatter: [web3._extend.utils.formatInputString,web3._extend.utils.formatInputString], - outputFormatter: web3._extend.formatters.formatOutputString + inputFormatter: [null, null] }) ], @@ -137,23 +128,19 @@ web3._extend({ [ 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..4c3e9e4db 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: [null, null, null] }) ], 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..6474166e7 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: [null] }), 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_js.go b/rpc/api/net_js.go index 1677d9fa6..cc8d7f46e 100644 --- a/rpc/api/net_js.go +++ b/rpc/api/net_js.go @@ -2,45 +2,25 @@ 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; } + getter: 'net_peers' }), new web3._extend.Property({ name: 'version', - getter: 'net_version', - outputFormatter: web3._extend.formatters.formatOutputString + getter: 'net_version' }) ] }); 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..a96d105fb 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", @@ -101,6 +91,8 @@ var ( "net": []string{ "peerCount", "listening", + "version", + "peers", }, "personal": []string{ "listAccounts", @@ -109,13 +101,12 @@ var ( "unlockAccount", }, "shh": []string{ - "version", "post", + "newIdentify", "hasIdentity", - "newIdentity", - "newFilter", - "uninstallFilter", - "getFilterChanges", + "newGroup", + "addToGroup", + "filter", }, "txpool": []string{ "status", -- cgit v1.2.3 From 7e6c1f8024d0cc0f381c615cab3c97b57fc9515e Mon Sep 17 00:00:00 2001 From: Bas van Kervel Date: Mon, 6 Jul 2015 15:59:36 +0200 Subject: corrected input formatters as suggested during review --- rpc/api/admin_js.go | 4 ++-- rpc/api/eth_js.go | 2 +- rpc/api/miner_js.go | 2 +- rpc/api/net.go | 10 ---------- rpc/api/net_js.go | 8 -------- rpc/api/utils.go | 2 -- 6 files changed, 4 insertions(+), 24 deletions(-) (limited to 'rpc/api') diff --git a/rpc/api/admin_js.go b/rpc/api/admin_js.go index e528b8863..86a4f6a4c 100644 --- a/rpc/api/admin_js.go +++ b/rpc/api/admin_js.go @@ -34,7 +34,7 @@ web3._extend({ name: 'verbosity', call: 'admin_verbosity', params: 1, - inputFormatter: [web3._extend.utils.toDecimal] + inputFormatter: [web3._extend.utils.fromDecimal] }), new web3._extend.Method({ name: 'setSolc', @@ -46,7 +46,7 @@ web3._extend({ name: 'startRPC', call: 'admin_startRPC', params: 4, - inputFormatter: [null, web3._extend.utils.toDecimal, null, null] + inputFormatter: [null, null, null, null] }), new web3._extend.Method({ name: 'stopRPC', diff --git a/rpc/api/eth_js.go b/rpc/api/eth_js.go index 4c3e9e4db..400eb8e89 100644 --- a/rpc/api/eth_js.go +++ b/rpc/api/eth_js.go @@ -18,7 +18,7 @@ web3._extend({ name: 'resend', call: 'eth_resend', params: 3, - inputFormatter: [null, null, null] + inputFormatter: [web3._extend.formatters.inputTransactionFormatter, web3._extend.utils.fromDecimal, web3._extend.utils.fromDecimal] }) ], properties: diff --git a/rpc/api/miner_js.go b/rpc/api/miner_js.go index 6474166e7..8861a177a 100644 --- a/rpc/api/miner_js.go +++ b/rpc/api/miner_js.go @@ -27,7 +27,7 @@ web3._extend({ name: 'setGasPrice', call: 'miner_setGasPrice', params: 1, - inputFormatter: [null] + inputFormatter: [web3._extend.utils.fromDecial] }), new web3._extend.Method({ name: 'startAutoDAG', 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 cc8d7f46e..2f872393c 100644 --- a/rpc/api/net_js.go +++ b/rpc/api/net_js.go @@ -14,14 +14,6 @@ web3._extend({ ], properties: [ - new web3._extend.Property({ - name: 'peers', - getter: 'net_peers' - }), - new web3._extend.Property({ - name: 'version', - getter: 'net_version' - }) ] }); ` diff --git a/rpc/api/utils.go b/rpc/api/utils.go index a96d105fb..d64cfc7cf 100644 --- a/rpc/api/utils.go +++ b/rpc/api/utils.go @@ -91,8 +91,6 @@ var ( "net": []string{ "peerCount", "listening", - "version", - "peers", }, "personal": []string{ "listAccounts", -- cgit v1.2.3 From 3791831081eb2d6e0dbfb3aa96f181dbb645c394 Mon Sep 17 00:00:00 2001 From: Bas van Kervel Date: Mon, 6 Jul 2015 18:13:06 +0200 Subject: rebase with zelig/frontier/registrar --- rpc/api/admin_js.go | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) (limited to 'rpc/api') diff --git a/rpc/api/admin_js.go b/rpc/api/admin_js.go index 86a4f6a4c..ddfa2ea04 100644 --- a/rpc/api/admin_js.go +++ b/rpc/api/admin_js.go @@ -27,8 +27,7 @@ web3._extend({ name: 'sleepBlocks', call: 'admin_sleepBlocks', params: 2, - inputFormatter: [web3._extend.utils.formatInputInt,web3._extend.utils.formatInputInt], - outputFormatter: web3._extend.formatters.formatOutputInt + inputFormatter: [null, null] }), new web3._extend.Method({ name: 'verbosity', @@ -51,58 +50,50 @@ web3._extend({ new web3._extend.Method({ name: 'stopRPC', call: 'admin_stopRPC', - params: 2, - inputFormatter: [], - outputFormatter: web3._extend.formatters.formatOutputBool + params: 0, + inputFormatter: [] }), new web3._extend.Method({ name: 'setGlobalRegistrar', call: 'admin_setGlobalRegistrar', params: 2, - inputFormatter: [web3._extend.utils.formatInputString,web3._extend.utils.formatInputString], - outputFormatter: web3._extend.formatters.formatOutputString + inputFormatter: [null,null] }), new web3._extend.Method({ name: 'setHashReg', call: 'admin_setHashReg', params: 2, - inputFormatter: [web3._extend.utils.formatInputString,web3._extend.utils.formatInputString], - outputFormatter: web3._extend.formatters.formatOutputString + inputFormatter: [null,null] }), new web3._extend.Method({ name: 'setUrlHint', call: 'admin_setUrlHint', params: 2, - inputFormatter: [web3._extend.utils.formatInputString,web3._extend.utils.formatInputString], - outputFormatter: web3._extend.formatters.formatOutputString + inputFormatter: [null,null] }), new web3._extend.Method({ name: 'saveInfo', call: 'admin_saveInfo', params: 2, - inputFormatter: [function(obj) { return obj; },web3._extend.utils.formatInputString], - outputFormatter: web3._extend.formatters.formatOutputString + inputFormatter: [null,null] }), new web3._extend.Method({ name: 'register', call: 'admin_register', params: 3, - inputFormatter: [web3._extend.utils.formatInputString,web3._extend.utils.formatInputString,web3._extend.utils.formatInputString], - outputFormatter: web3._extend.formatters.formatOutputBool + inputFormatter: [null,null,null] }), new web3._extend.Method({ name: 'registerUrl', call: 'admin_registerUrl', params: 3, - inputFormatter: [web3._extend.utils.formatInputString,web3._extend.utils.formatInputString,web3._extend.utils.formatInputString], - outputFormatter: web3._extend.formatters.formatOutputBool + inputFormatter: [null,null,null] }), new web3._extend.Method({ name: 'startNatSpec', call: 'admin_startNatSpec', params: 0, - inputFormatter: [], - outputFormatter: web3._extend.formatters.formatOutputBool + inputFormatter: [] }), new web3._extend.Method({ name: 'stopNatSpec', @@ -122,7 +113,6 @@ web3._extend({ params: 2, inputFormatter: [null, null] }) - ], properties: [ -- cgit v1.2.3 From c5cb6e8e70339b6641b7ce46cda04b83936213b3 Mon Sep 17 00:00:00 2001 From: zelig Date: Tue, 7 Jul 2015 06:00:58 +0100 Subject: fix/skip tests, adapt registrar to no contract address registry initialisers now return the txhash which caller can use to retrieve receipt --- rpc/api/admin.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'rpc/api') diff --git a/rpc/api/admin.go b/rpc/api/admin.go index 5d214e8d8..c5f026090 100644 --- a/rpc/api/admin.go +++ b/rpc/api/admin.go @@ -322,12 +322,12 @@ func (self *adminApi) SetGlobalRegistrar(req *shared.Request) (interface{}, erro sender := common.HexToAddress(args.ContractAddress) reg := registrar.New(self.xeth) - err := reg.SetGlobalRegistrar(args.NameReg, sender) + txhash, err := reg.SetGlobalRegistrar(args.NameReg, sender) if err != nil { return false, err } - return registrar.GlobalRegistrarAddr, nil + return txhash, nil } func (self *adminApi) SetHashReg(req *shared.Request) (interface{}, error) { @@ -338,12 +338,12 @@ func (self *adminApi) SetHashReg(req *shared.Request) (interface{}, error) { reg := registrar.New(self.xeth) sender := common.HexToAddress(args.Sender) - err := reg.SetHashReg(args.HashReg, sender) + txhash, err := reg.SetHashReg(args.HashReg, sender) if err != nil { return false, err } - return registrar.HashRegAddr, nil + return txhash, nil } func (self *adminApi) SetUrlHint(req *shared.Request) (interface{}, error) { @@ -356,12 +356,12 @@ func (self *adminApi) SetUrlHint(req *shared.Request) (interface{}, error) { sender := common.HexToAddress(args.Sender) reg := registrar.New(self.xeth) - err := reg.SetUrlHint(urlHint, sender) + txhash, err := reg.SetUrlHint(urlHint, sender) if err != nil { return nil, err } - return registrar.UrlHintAddr, nil + return txhash, nil } func (self *adminApi) SaveInfo(req *shared.Request) (interface{}, error) { -- cgit v1.2.3 From ea54283b304a1d308141d21e3ef75b7de0f4519d Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Tue, 7 Jul 2015 02:54:22 +0200 Subject: all: update license information --- rpc/api/admin.go | 16 ++++++++++++++++ rpc/api/admin_args.go | 16 ++++++++++++++++ rpc/api/admin_js.go | 16 ++++++++++++++++ rpc/api/api.go | 16 ++++++++++++++++ rpc/api/api_test.go | 16 ++++++++++++++++ rpc/api/args.go | 16 ++++++++++++++++ rpc/api/args_test.go | 16 ++++++++++++++++ rpc/api/db.go | 16 ++++++++++++++++ rpc/api/db_args.go | 16 ++++++++++++++++ rpc/api/db_js.go | 16 ++++++++++++++++ rpc/api/debug.go | 16 ++++++++++++++++ rpc/api/debug_args.go | 16 ++++++++++++++++ rpc/api/debug_js.go | 16 ++++++++++++++++ rpc/api/eth.go | 16 ++++++++++++++++ rpc/api/eth_args.go | 16 ++++++++++++++++ rpc/api/eth_js.go | 16 ++++++++++++++++ rpc/api/mergedapi.go | 16 ++++++++++++++++ rpc/api/miner.go | 16 ++++++++++++++++ rpc/api/miner_args.go | 16 ++++++++++++++++ rpc/api/miner_js.go | 16 ++++++++++++++++ rpc/api/net.go | 16 ++++++++++++++++ rpc/api/net_js.go | 16 ++++++++++++++++ rpc/api/parsing.go | 16 ++++++++++++++++ rpc/api/personal.go | 16 ++++++++++++++++ rpc/api/personal_args.go | 16 ++++++++++++++++ rpc/api/personal_js.go | 16 ++++++++++++++++ rpc/api/shh.go | 16 ++++++++++++++++ rpc/api/shh_args.go | 16 ++++++++++++++++ rpc/api/ssh_js.go | 16 ++++++++++++++++ rpc/api/txpool.go | 16 ++++++++++++++++ rpc/api/txpool_js.go | 16 ++++++++++++++++ rpc/api/utils.go | 16 ++++++++++++++++ rpc/api/web3.go | 16 ++++++++++++++++ rpc/api/web3_args.go | 16 ++++++++++++++++ 34 files changed, 544 insertions(+) (limited to 'rpc/api') diff --git a/rpc/api/admin.go b/rpc/api/admin.go index c5f026090..f226434ad 100644 --- a/rpc/api/admin.go +++ b/rpc/api/admin.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 . + package api import ( diff --git a/rpc/api/admin_args.go b/rpc/api/admin_args.go index 532907905..60a1fb496 100644 --- a/rpc/api/admin_args.go +++ b/rpc/api/admin_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 . + package api import ( diff --git a/rpc/api/admin_js.go b/rpc/api/admin_js.go index ddfa2ea04..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 . + package api const Admin_JS = ` 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 . + package api import ( diff --git a/rpc/api/api_test.go b/rpc/api/api_test.go index 2ac8bcd45..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 . + package api import ( 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 . + 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 . + 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 . + 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 . + package api import ( diff --git a/rpc/api/db_js.go b/rpc/api/db_js.go index 91dc95e5b..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 . + package api const Db_JS = ` 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 . + 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 . + package api import ( diff --git a/rpc/api/debug_js.go b/rpc/api/debug_js.go index 93fba537e..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 . + package api const Debug_JS = ` diff --git a/rpc/api/eth.go b/rpc/api/eth.go index 944e96070..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 . + package api import ( diff --git a/rpc/api/eth_args.go b/rpc/api/eth_args.go index 8f64280d3..f63b43334 100644 --- a/rpc/api/eth_args.go +++ b/rpc/api/eth_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 . + package api import ( diff --git a/rpc/api/eth_js.go b/rpc/api/eth_js.go index 400eb8e89..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 . + package api // JS api provided by web3.js diff --git a/rpc/api/mergedapi.go b/rpc/api/mergedapi.go index c40716996..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 . + package api import ( diff --git a/rpc/api/miner.go b/rpc/api/miner.go index 8d4646a5c..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 . + package api import ( diff --git a/rpc/api/miner_args.go b/rpc/api/miner_args.go index 9da3b95ad..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 . + package api import ( diff --git a/rpc/api/miner_js.go b/rpc/api/miner_js.go index c205f6712..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 . + package api const Miner_JS = ` diff --git a/rpc/api/net.go b/rpc/api/net.go index b3931ba2d..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 . + package api import ( diff --git a/rpc/api/net_js.go b/rpc/api/net_js.go index 2f872393c..391039eea 100644 --- a/rpc/api/net_js.go +++ b/rpc/api/net_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 . + package api const Net_JS = ` diff --git a/rpc/api/parsing.go b/rpc/api/parsing.go index 493d196e0..6e97d8a2d 100644 --- a/rpc/api/parsing.go +++ b/rpc/api/parsing.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 . + package api import ( 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 . + 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 . + package api import ( diff --git a/rpc/api/personal_js.go b/rpc/api/personal_js.go index 66014cc02..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 . + package api const Personal_JS = ` 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 . + 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 . + package api import ( diff --git a/rpc/api/ssh_js.go b/rpc/api/ssh_js.go index c0591bd71..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 . + package api const Shh_JS = ` diff --git a/rpc/api/txpool.go b/rpc/api/txpool.go index 04faf463c..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 . + package api import ( 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 . + package api const TxPool_JS = ` diff --git a/rpc/api/utils.go b/rpc/api/utils.go index d64cfc7cf..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 . + package api import ( 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 . + 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 . + package api import ( -- cgit v1.2.3