aboutsummaryrefslogtreecommitdiffstats
path: root/rpc
diff options
context:
space:
mode:
authorJeffrey Wilcke <geffobscura@gmail.com>2015-11-24 20:48:47 +0800
committerJeffrey Wilcke <geffobscura@gmail.com>2015-11-24 20:48:47 +0800
commit5490437942967638bcc6198035315f6811febaa8 (patch)
treeec4fbee454bacbf2b80b5a7ff402fb48dd2c10cf /rpc
parente5532154a50114d5ffb1ffd850b746cab00cb899 (diff)
parentb0fb48c389460193d9fc0a5118d79ff6dec48ce0 (diff)
downloadgo-tangerine-5490437942967638bcc6198035315f6811febaa8.tar
go-tangerine-5490437942967638bcc6198035315f6811febaa8.tar.gz
go-tangerine-5490437942967638bcc6198035315f6811febaa8.tar.bz2
go-tangerine-5490437942967638bcc6198035315f6811febaa8.tar.lz
go-tangerine-5490437942967638bcc6198035315f6811febaa8.tar.xz
go-tangerine-5490437942967638bcc6198035315f6811febaa8.tar.zst
go-tangerine-5490437942967638bcc6198035315f6811febaa8.zip
Merge branch 'develop' into release/1.3.2v1.3.2
Conflicts: VERSION cmd/geth/main.go
Diffstat (limited to 'rpc')
-rw-r--r--rpc/api/admin.go4
-rw-r--r--rpc/api/args_test.go12
-rw-r--r--rpc/api/debug.go28
-rw-r--r--rpc/api/eth.go46
-rw-r--r--rpc/api/eth_args.go7
-rw-r--r--rpc/api/eth_js.go22
-rw-r--r--rpc/api/utils.go2
7 files changed, 100 insertions, 21 deletions
diff --git a/rpc/api/admin.go b/rpc/api/admin.go
index eb08fbc5d..c11662577 100644
--- a/rpc/api/admin.go
+++ b/rpc/api/admin.go
@@ -137,11 +137,11 @@ func (self *adminApi) AddPeer(req *shared.Request) (interface{}, error) {
}
func (self *adminApi) Peers(req *shared.Request) (interface{}, error) {
- return self.ethereum.PeersInfo(), nil
+ return self.ethereum.Network().PeersInfo(), nil
}
func (self *adminApi) NodeInfo(req *shared.Request) (interface{}, error) {
- return self.ethereum.NodeInfo(), nil
+ return self.ethereum.Network().NodeInfo(), nil
}
func (self *adminApi) DataDir(req *shared.Request) (interface{}, error) {
diff --git a/rpc/api/args_test.go b/rpc/api/args_test.go
index 23ae2930d..130315bd9 100644
--- a/rpc/api/args_test.go
+++ b/rpc/api/args_test.go
@@ -1394,13 +1394,10 @@ func TestBlockFilterArgsDefaults(t *testing.T) {
}
func TestBlockFilterArgsWords(t *testing.T) {
- input := `[{
- "fromBlock": "latest",
- "toBlock": "pending"
- }]`
+ input := `[{"fromBlock": "latest", "toBlock": "latest"}]`
expected := new(BlockFilterArgs)
expected.Earliest = -1
- expected.Latest = -2
+ expected.Latest = -1
args := new(BlockFilterArgs)
if err := json.Unmarshal([]byte(input), &args); err != nil {
@@ -1411,8 +1408,9 @@ func TestBlockFilterArgsWords(t *testing.T) {
t.Errorf("Earliest shoud be %#v but is %#v", expected.Earliest, args.Earliest)
}
- if expected.Latest != args.Latest {
- t.Errorf("Latest shoud be %#v but is %#v", expected.Latest, args.Latest)
+ input = `[{"toBlock": "pending"}]`
+ if err := json.Unmarshal([]byte(input), &args); err == nil {
+ t.Errorf("Pending isn't currently supported and should raise an unsupported error")
}
}
diff --git a/rpc/api/debug.go b/rpc/api/debug.go
index d2cbc7f19..a6faa335e 100644
--- a/rpc/api/debug.go
+++ b/rpc/api/debug.go
@@ -22,6 +22,7 @@ import (
"time"
"github.com/ethereum/ethash"
+ "github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/eth"
@@ -166,11 +167,30 @@ func (self *debugApi) ProcessBlock(req *shared.Request) (interface{}, error) {
defer func() { vm.Debug = old }()
vm.Debug = true
- _, err := self.ethereum.BlockProcessor().RetryProcess(block)
- if err == nil {
- return true, nil
+ var (
+ blockchain = self.ethereum.BlockChain()
+ validator = blockchain.Validator()
+ processor = blockchain.Processor()
+ )
+
+ err := core.ValidateHeader(blockchain.AuxValidator(), block.Header(), blockchain.GetHeader(block.ParentHash()), true, false)
+ if err != nil {
+ return false, err
}
- return false, err
+ statedb, err := state.New(blockchain.GetBlock(block.ParentHash()).Root(), self.ethereum.ChainDb())
+ if err != nil {
+ return false, err
+ }
+ receipts, _, usedGas, err := processor.Process(block, statedb)
+ if err != nil {
+ return false, err
+ }
+ err = validator.ValidateState(block, blockchain.GetBlock(block.ParentHash()), statedb, receipts, usedGas)
+ if err != nil {
+ return false, err
+ }
+
+ return true, nil
}
func (self *debugApi) SeedHash(req *shared.Request) (interface{}, error) {
diff --git a/rpc/api/eth.go b/rpc/api/eth.go
index b84ae31da..db7a643d8 100644
--- a/rpc/api/eth.go
+++ b/rpc/api/eth.go
@@ -26,6 +26,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/natspec"
"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"
@@ -70,8 +71,10 @@ var (
"eth_getCode": (*ethApi).GetData,
"eth_getNatSpec": (*ethApi).GetNatSpec,
"eth_sign": (*ethApi).Sign,
- "eth_sendRawTransaction": (*ethApi).SendRawTransaction,
+ "eth_sendRawTransaction": (*ethApi).SubmitTransaction,
+ "eth_submitTransaction": (*ethApi).SubmitTransaction,
"eth_sendTransaction": (*ethApi).SendTransaction,
+ "eth_signTransaction": (*ethApi).SignTransaction,
"eth_transact": (*ethApi).SendTransaction,
"eth_estimateGas": (*ethApi).EstimateGas,
"eth_call": (*ethApi).Call,
@@ -285,7 +288,7 @@ func (self *ethApi) Sign(req *shared.Request) (interface{}, error) {
return v, nil
}
-func (self *ethApi) SendRawTransaction(req *shared.Request) (interface{}, error) {
+func (self *ethApi) SubmitTransaction(req *shared.Request) (interface{}, error) {
args := new(NewDataArgs)
if err := self.codec.Decode(req.Params, &args); err != nil {
return nil, shared.NewDecodeParamError(err.Error())
@@ -298,6 +301,45 @@ func (self *ethApi) SendRawTransaction(req *shared.Request) (interface{}, error)
return v, nil
}
+// JsonTransaction is returned as response by the JSON RPC. It contains the
+// signed RLP encoded transaction as Raw and the signed transaction object as Tx.
+type JsonTransaction struct {
+ Raw string `json:"raw"`
+ Tx *tx `json:"tx"`
+}
+
+func (self *ethApi) SignTransaction(req *shared.Request) (interface{}, error) {
+ args := new(NewTxArgs)
+ if err := self.codec.Decode(req.Params, &args); err != nil {
+ return nil, shared.NewDecodeParamError(err.Error())
+ }
+
+ // nonce may be nil ("guess" mode)
+ var nonce string
+ if args.Nonce != nil {
+ nonce = args.Nonce.String()
+ }
+
+ var gas, price string
+ if args.Gas != nil {
+ gas = args.Gas.String()
+ }
+ if args.GasPrice != nil {
+ price = args.GasPrice.String()
+ }
+ tx, err := self.xeth.SignTransaction(args.From, args.To, nonce, args.Value.String(), gas, price, args.Data)
+ if err != nil {
+ return nil, err
+ }
+
+ data, err := rlp.EncodeToBytes(tx)
+ if err != nil {
+ return nil, err
+ }
+
+ return JsonTransaction{"0x" + common.Bytes2Hex(data), newTx(tx)}, nil
+}
+
func (self *ethApi) SendTransaction(req *shared.Request) (interface{}, error) {
args := new(NewTxArgs)
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 457350d74..ed3d761f1 100644
--- a/rpc/api/eth_args.go
+++ b/rpc/api/eth_args.go
@@ -722,6 +722,13 @@ func (args *BlockFilterArgs) UnmarshalJSON(b []byte) (err error) {
return err
}
}
+
+ if num == -2 {
+ return fmt.Errorf("\"pending\" is unsupported")
+ } else if num < -2 {
+ return fmt.Errorf("Invalid to block number")
+ }
+
args.Latest = num
if obj[0].Limit == nil {
diff --git a/rpc/api/eth_js.go b/rpc/api/eth_js.go
index 75c103c9d..dfc104ad8 100644
--- a/rpc/api/eth_js.go
+++ b/rpc/api/eth_js.go
@@ -36,11 +36,23 @@ web3._extend({
params: 3,
inputFormatter: [web3._extend.formatters.inputTransactionFormatter, web3._extend.utils.fromDecimal, web3._extend.utils.fromDecimal]
}),
- new web3._extend.Method({
- name: 'getNatSpec',
- call: 'eth_getNatSpec',
- params: 1,
- inputFormatter: [web3._extend.formatters.inputTransactionFormatter]
+ new web3._extend.Method({
+ name: 'getNatSpec',
+ call: 'eth_getNatSpec',
+ params: 1,
+ inputFormatter: [web3._extend.formatters.inputTransactionFormatter]
+ }),
+ new web3._extend.Method({
+ name: 'signTransaction',
+ call: 'eth_signTransaction',
+ params: 1,
+ inputFormatter: [web3._extend.formatters.inputTransactionFormatter]
+ }),
+ new web3._extend.Method({
+ name: 'submitTransaction',
+ call: 'eth_submitTransaction',
+ params: 1,
+ inputFormatter: [web3._extend.formatters.inputTransactionFormatter]
})
],
properties:
diff --git a/rpc/api/utils.go b/rpc/api/utils.go
index 5a3ade46b..8351e88d3 100644
--- a/rpc/api/utils.go
+++ b/rpc/api/utils.go
@@ -130,7 +130,7 @@ var (
},
"shh": []string{
"post",
- "newIdentify",
+ "newIdentity",
"hasIdentity",
"newGroup",
"addToGroup",