@@ -26,6 +26,7 @@ import (
26
26
"github.com/ethereum/go-ethereum/common"
27
27
"github.com/ethereum/go-ethereum/common/natspec"
28
28
"github.com/ethereum/go-ethereum/eth"
29
+ "github.com/ethereum/go-ethereum/rlp"
29
30
"github.com/ethereum/go-ethereum/rpc/codec"
30
31
"github.com/ethereum/go-ethereum/rpc/shared"
31
32
"github.com/ethereum/go-ethereum/xeth"
70
71
"eth_getCode" : (* ethApi ).GetData ,
71
72
"eth_getNatSpec" : (* ethApi ).GetNatSpec ,
72
73
"eth_sign" : (* ethApi ).Sign ,
73
- "eth_sendRawTransaction" : (* ethApi ).SendRawTransaction ,
74
+ "eth_sendRawTransaction" : (* ethApi ).SubmitTransaction ,
75
+ "eth_submitTransaction" : (* ethApi ).SubmitTransaction ,
74
76
"eth_sendTransaction" : (* ethApi ).SendTransaction ,
77
+ "eth_signTransaction" : (* ethApi ).SignTransaction ,
75
78
"eth_transact" : (* ethApi ).SendTransaction ,
76
79
"eth_estimateGas" : (* ethApi ).EstimateGas ,
77
80
"eth_call" : (* ethApi ).Call ,
@@ -285,7 +288,7 @@ func (self *ethApi) Sign(req *shared.Request) (interface{}, error) {
285
288
return v , nil
286
289
}
287
290
288
- func (self * ethApi ) SendRawTransaction (req * shared.Request ) (interface {}, error ) {
291
+ func (self * ethApi ) SubmitTransaction (req * shared.Request ) (interface {}, error ) {
289
292
args := new (NewDataArgs )
290
293
if err := self .codec .Decode (req .Params , & args ); err != nil {
291
294
return nil , shared .NewDecodeParamError (err .Error ())
@@ -298,6 +301,45 @@ func (self *ethApi) SendRawTransaction(req *shared.Request) (interface{}, error)
298
301
return v , nil
299
302
}
300
303
304
+ // JsonTransaction is returned as response by the JSON RPC. It contains the
305
+ // signed RLP encoded transaction as Raw and the signed transaction object as Tx.
306
+ type JsonTransaction struct {
307
+ Raw string `json:"raw"`
308
+ Tx * tx `json:"tx"`
309
+ }
310
+
311
+ func (self * ethApi ) SignTransaction (req * shared.Request ) (interface {}, error ) {
312
+ args := new (NewTxArgs )
313
+ if err := self .codec .Decode (req .Params , & args ); err != nil {
314
+ return nil , shared .NewDecodeParamError (err .Error ())
315
+ }
316
+
317
+ // nonce may be nil ("guess" mode)
318
+ var nonce string
319
+ if args .Nonce != nil {
320
+ nonce = args .Nonce .String ()
321
+ }
322
+
323
+ var gas , price string
324
+ if args .Gas != nil {
325
+ gas = args .Gas .String ()
326
+ }
327
+ if args .GasPrice != nil {
328
+ price = args .GasPrice .String ()
329
+ }
330
+ tx , err := self .xeth .SignTransaction (args .From , args .To , nonce , args .Value .String (), gas , price , args .Data )
331
+ if err != nil {
332
+ return nil , err
333
+ }
334
+
335
+ data , err := rlp .EncodeToBytes (tx )
336
+ if err != nil {
337
+ return nil , err
338
+ }
339
+
340
+ return JsonTransaction {"0x" + common .Bytes2Hex (data ), newTx (tx )}, nil
341
+ }
342
+
301
343
func (self * ethApi ) SendTransaction (req * shared.Request ) (interface {}, error ) {
302
344
args := new (NewTxArgs )
303
345
if err := self .codec .Decode (req .Params , & args ); err != nil {
0 commit comments