diff options
Diffstat (limited to 'rpc/args.go')
-rw-r--r-- | rpc/args.go | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/rpc/args.go b/rpc/args.go index 806efb9cc..78cbca5a9 100644 --- a/rpc/args.go +++ b/rpc/args.go @@ -166,7 +166,14 @@ type NewTxArgs struct { func (args *NewTxArgs) UnmarshalJSON(b []byte) (err error) { var obj []json.RawMessage - var ext struct{ From, To, Value, Gas, GasPrice, Data string } + var ext struct { + From string + To string + Value interface{} + Gas interface{} + GasPrice interface{} + Data string + } // Decode byte slice to array of RawMessages if err := json.Unmarshal(b, &obj); err != nil { @@ -189,11 +196,36 @@ func (args *NewTxArgs) UnmarshalJSON(b []byte) (err error) { args.From = ext.From args.To = ext.To - args.Value = common.String2Big(ext.Value) - args.Gas = common.String2Big(ext.Gas) - args.GasPrice = common.String2Big(ext.GasPrice) args.Data = ext.Data + var num int64 + if ext.Value == nil { + return NewValidationError("value", "is required") + } else { + if err := numString(ext.Value, &num); err != nil { + return err + } + } + args.Value = big.NewInt(num) + + if ext.Gas == nil { + return NewValidationError("gas", "is required") + } else { + if err := numString(ext.Gas, &num); err != nil { + return err + } + } + args.Gas = big.NewInt(num) + + if ext.GasPrice == nil { + return NewValidationError("gasprice", "is required") + } else { + if err := numString(ext.GasPrice, &num); err != nil { + return err + } + } + args.GasPrice = big.NewInt(num) + // Check for optional BlockNumber param if len(obj) > 1 { if err := blockHeightFromJson(obj[1], &args.BlockNumber); err != nil { |