diff options
author | obscuren <geffobscura@gmail.com> | 2015-02-18 05:20:47 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-02-18 05:20:47 +0800 |
commit | 7fc9b5b3f9ca0111cc4bc1b2a6b4bb2eccd3e048 (patch) | |
tree | 764d7ebd57cafbae0a12d046aeafd1b823a0f0bb /rpc/args.go | |
parent | 11e12680ebe4f4679083317ee0f2c27b219d44b3 (diff) | |
download | go-tangerine-7fc9b5b3f9ca0111cc4bc1b2a6b4bb2eccd3e048.tar go-tangerine-7fc9b5b3f9ca0111cc4bc1b2a6b4bb2eccd3e048.tar.gz go-tangerine-7fc9b5b3f9ca0111cc4bc1b2a6b4bb2eccd3e048.tar.bz2 go-tangerine-7fc9b5b3f9ca0111cc4bc1b2a6b4bb2eccd3e048.tar.lz go-tangerine-7fc9b5b3f9ca0111cc4bc1b2a6b4bb2eccd3e048.tar.xz go-tangerine-7fc9b5b3f9ca0111cc4bc1b2a6b4bb2eccd3e048.tar.zst go-tangerine-7fc9b5b3f9ca0111cc4bc1b2a6b4bb2eccd3e048.zip |
Changed to ChainEvent and fixed a nil pointer in transact
Diffstat (limited to 'rpc/args.go')
-rw-r--r-- | rpc/args.go | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/rpc/args.go b/rpc/args.go index 9c2c7d7a6..429b385d5 100644 --- a/rpc/args.go +++ b/rpc/args.go @@ -38,6 +38,35 @@ type NewTxArgs struct { Data string `json:"data"` } +func (obj *NewTxArgs) UnmarshalJSON(b []byte) (err error) { + // Data can be either specified as "data" or "code" :-/ + var ext struct { + From string + To string + Value string + Gas string + GasPrice string + Data string + Code string + } + + if err = json.Unmarshal(b, &ext); err == nil { + if len(ext.Data) == 0 { + ext.Data = ext.Code + } + obj.From = ext.From + obj.To = ext.To + obj.Value = ext.Value + obj.Gas = ext.Gas + obj.GasPrice = ext.GasPrice + obj.Data = ext.Data + + return + } + + return NewErrorResponse(ErrorDecodeArgs) +} + type PushTxArgs struct { Tx string `json:"tx"` } |