aboutsummaryrefslogtreecommitdiffstats
path: root/rpc
diff options
context:
space:
mode:
Diffstat (limited to 'rpc')
-rw-r--r--rpc/api.go11
-rw-r--r--rpc/args.go40
-rw-r--r--rpc/jeth.go2
3 files changed, 51 insertions, 2 deletions
diff --git a/rpc/api.go b/rpc/api.go
index 6a629ce8e..309c161ad 100644
--- a/rpc/api.go
+++ b/rpc/api.go
@@ -158,6 +158,17 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
v := api.xethAtStateNum(args.BlockNumber).CodeAtBytes(args.Address)
*reply = newHexData(v)
+ case "eth_sign":
+ args := new(NewSigArgs)
+ if err := json.Unmarshal(req.Params, &args); err != nil {
+ return err
+ }
+ v, err := api.xeth().Sign(args.From, args.Data, false)
+ if err != nil {
+ return err
+ }
+ *reply = v
+
case "eth_sendTransaction", "eth_transact":
args := new(NewTxArgs)
if err := json.Unmarshal(req.Params, &args); err != nil {
diff --git a/rpc/args.go b/rpc/args.go
index 58a750415..686872a59 100644
--- a/rpc/args.go
+++ b/rpc/args.go
@@ -166,6 +166,46 @@ type NewTxArgs struct {
BlockNumber int64
}
+type NewSigArgs struct {
+ From string
+ Data string
+}
+
+func (args *NewSigArgs) UnmarshalJSON(b []byte) (err error) {
+ var obj []json.RawMessage
+ var ext struct {
+ From string
+ Data string
+ }
+
+ // Decode byte slice to array of RawMessages
+ if err := json.Unmarshal(b, &obj); err != nil {
+ return NewDecodeParamError(err.Error())
+ }
+
+ // Check for sufficient params
+ if len(obj) < 1 {
+ return NewInsufficientParamsError(len(obj), 1)
+ }
+
+ // Decode 0th RawMessage to temporary struct
+ if err := json.Unmarshal(obj[0], &ext); err != nil {
+ return NewDecodeParamError(err.Error())
+ }
+
+ if len(ext.From) == 0 {
+ return NewValidationError("from", "is required")
+ }
+
+ if len(ext.Data) == 0 {
+ return NewValidationError("data", "is required")
+ }
+
+ args.From = ext.From
+ args.Data = ext.Data
+ return nil
+}
+
func (args *NewTxArgs) UnmarshalJSON(b []byte) (err error) {
var obj []json.RawMessage
var ext struct {
diff --git a/rpc/jeth.go b/rpc/jeth.go
index a08f9be8f..2097ac30d 100644
--- a/rpc/jeth.go
+++ b/rpc/jeth.go
@@ -3,7 +3,6 @@ package rpc
import (
"encoding/json"
"fmt"
-
"github.com/ethereum/go-ethereum/jsre"
"github.com/robertkrimen/otto"
)
@@ -36,7 +35,6 @@ func (self *Jeth) Send(call otto.FunctionCall) (response otto.Value) {
}
jsonreq, err := json.Marshal(reqif)
-
var reqs []RpcRequest
batch := true
err = json.Unmarshal(jsonreq, &reqs)