aboutsummaryrefslogtreecommitdiffstats
path: root/rpc/args.go
diff options
context:
space:
mode:
authorDaniel A. Nagy <nagy.da@gmail.com>2015-05-08 23:52:44 +0800
committerDaniel A. Nagy <nagy.da@gmail.com>2015-05-08 23:52:44 +0800
commit3a01e3e39b9ce83ecb7444319407ee8bb00e3bf6 (patch)
treecf7379f422284b4a0e6b6c8bd0b1ca621c8c9a91 /rpc/args.go
parenta487396b764c8dac409f9ee1ef32c29c4cefb7d9 (diff)
downloadgo-tangerine-3a01e3e39b9ce83ecb7444319407ee8bb00e3bf6.tar.gz
go-tangerine-3a01e3e39b9ce83ecb7444319407ee8bb00e3bf6.tar.zst
go-tangerine-3a01e3e39b9ce83ecb7444319407ee8bb00e3bf6.zip
Signing (almost) works.
Diffstat (limited to 'rpc/args.go')
-rw-r--r--rpc/args.go35
1 files changed, 35 insertions, 0 deletions
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 {