diff options
Diffstat (limited to 'rpc')
-rw-r--r-- | rpc/api/eth_args.go | 16 | ||||
-rw-r--r-- | rpc/xeth.go | 18 |
2 files changed, 21 insertions, 13 deletions
diff --git a/rpc/api/eth_args.go b/rpc/api/eth_args.go index 5a1841cbe..8bd077e20 100644 --- a/rpc/api/eth_args.go +++ b/rpc/api/eth_args.go @@ -908,14 +908,14 @@ func (args *SubmitWorkArgs) UnmarshalJSON(b []byte) (err error) { type tx struct { tx *types.Transaction - To string - From string - Nonce string - Value string - Data string - GasLimit string - GasPrice string - Hash string + To string `json:"to"` + From string `json:"from"` + Nonce string `json:"nonce"` + Value string `json:"value"` + Data string `json:"data"` + GasLimit string `json:"gas"` + GasPrice string `json:"gasPrice"` + Hash string `json:"hash"` } func newTx(t *types.Transaction) *tx { diff --git a/rpc/xeth.go b/rpc/xeth.go index 65a1edeb8..9527a96c0 100644 --- a/rpc/xeth.go +++ b/rpc/xeth.go @@ -53,7 +53,7 @@ func (self *Xeth) Call(method string, params []interface{}) (map[string]interfac Method: method, Params: data, } - // Send the request over and process the response + // Send the request over and retrieve the response if err := self.client.Send(req); err != nil { return nil, err } @@ -61,9 +61,17 @@ func (self *Xeth) Call(method string, params []interface{}) (map[string]interfac if err != nil { return nil, err } - value, ok := res.(map[string]interface{}) - if !ok { - return nil, fmt.Errorf("Invalid response type: have %v, want %v", reflect.TypeOf(res), reflect.TypeOf(make(map[string]interface{}))) + // Ensure the response is valid, and extract the results + success, isSuccessResponse := res.(*shared.SuccessResponse) + failure, isFailureResponse := res.(*shared.ErrorResponse) + switch { + case isFailureResponse: + return nil, fmt.Errorf("Method invocation failed: %v", failure.Error) + + case isSuccessResponse: + return success.Result.(map[string]interface{}), nil + + default: + return nil, fmt.Errorf("Invalid response type: %v", reflect.TypeOf(res)) } - return value, nil } |