aboutsummaryrefslogtreecommitdiffstats
path: root/rpc/args.go
diff options
context:
space:
mode:
Diffstat (limited to 'rpc/args.go')
-rw-r--r--rpc/args.go26
1 files changed, 25 insertions, 1 deletions
diff --git a/rpc/args.go b/rpc/args.go
index 2e4e2c7a9..40f8575b2 100644
--- a/rpc/args.go
+++ b/rpc/args.go
@@ -188,10 +188,34 @@ type GetBalanceArgs struct {
}
func (args *GetBalanceArgs) UnmarshalJSON(b []byte) (err error) {
- if err = UnmarshalRawMessages(b, &args.Address, &args.BlockNumber); err != nil {
+ var obj []interface{}
+ r := bytes.NewReader(b)
+ if err := json.NewDecoder(r).Decode(&obj); err != nil {
return errDecodeArgs
}
+ if len(obj) < 1 {
+ return errArguments
+ }
+
+ addstr, ok := obj[0].(string)
+ if !ok {
+ return errDecodeArgs
+ }
+ args.Address = addstr
+
+ if len(obj) > 1 {
+ if obj[1].(string) == "latest" {
+ args.BlockNumber = -1
+ } else {
+ args.BlockNumber = ethutil.Big(obj[1].(string)).Int64()
+ }
+ }
+
+ // if err = UnmarshalRawMessages(b, &args.Address, &args.BlockNumber); err != nil {
+ // return errDecodeArgs
+ // }
+
return nil
}