diff options
author | Jeffrey Wilcke <jeffrey@ethereum.org> | 2015-05-11 22:43:43 +0800 |
---|---|---|
committer | Jeffrey Wilcke <jeffrey@ethereum.org> | 2015-05-11 22:43:43 +0800 |
commit | 0329e058231cd92e052ca7bb425ec28dd542aaee (patch) | |
tree | 48da8cd9ed6eb169df988fcfb6c2773ea410c955 /rpc/args.go | |
parent | 5176fbc6faaa5e7f0305ad7f2b896c092781deaa (diff) | |
parent | 51d4566cbf5c91e429313f1765d5a7d2afc13634 (diff) | |
download | dexon-0329e058231cd92e052ca7bb425ec28dd542aaee.tar dexon-0329e058231cd92e052ca7bb425ec28dd542aaee.tar.gz dexon-0329e058231cd92e052ca7bb425ec28dd542aaee.tar.bz2 dexon-0329e058231cd92e052ca7bb425ec28dd542aaee.tar.lz dexon-0329e058231cd92e052ca7bb425ec28dd542aaee.tar.xz dexon-0329e058231cd92e052ca7bb425ec28dd542aaee.tar.zst dexon-0329e058231cd92e052ca7bb425ec28dd542aaee.zip |
Merge pull request #914 from ethersphere/develop
Signature on arbitrary data using the private keys of an account
Diffstat (limited to 'rpc/args.go')
-rw-r--r-- | rpc/args.go | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/rpc/args.go b/rpc/args.go index 58a750415..686872a59 100644 --- a/rpc/args.go +++ b/rpc/args.go @@ -166,6 +166,46 @@ type NewTxArgs struct { BlockNumber int64 } +type NewSigArgs struct { + From string + 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 { |