From e94aa421c69b8eee2f2e06654f9a288cdfe4f546 Mon Sep 17 00:00:00 2001 From: "Daniel A. Nagy" Date: Fri, 8 May 2015 16:17:19 +0200 Subject: New API call for signatures. --- rpc/args.go | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'rpc/args.go') diff --git a/rpc/args.go b/rpc/args.go index 58a750415..6c98d1267 100644 --- a/rpc/args.go +++ b/rpc/args.go @@ -166,6 +166,11 @@ type NewTxArgs struct { BlockNumber int64 } +type NewSigArgs struct { + From string + Data string +} + func (args *NewTxArgs) UnmarshalJSON(b []byte) (err error) { var obj []json.RawMessage var ext struct { -- cgit v1.2.3 From 3a01e3e39b9ce83ecb7444319407ee8bb00e3bf6 Mon Sep 17 00:00:00 2001 From: "Daniel A. Nagy" Date: Fri, 8 May 2015 17:52:44 +0200 Subject: Signing (almost) works. --- rpc/args.go | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'rpc/args.go') diff --git a/rpc/args.go b/rpc/args.go index 6c98d1267..686872a59 100644 --- a/rpc/args.go +++ b/rpc/args.go @@ -171,6 +171,41 @@ type NewSigArgs struct { 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 { -- cgit v1.2.3