aboutsummaryrefslogtreecommitdiffstats
path: root/rpc/args.go
diff options
context:
space:
mode:
authorTaylor Gerring <taylor.gerring@gmail.com>2015-03-12 21:42:31 +0800
committerTaylor Gerring <taylor.gerring@gmail.com>2015-03-12 21:42:31 +0800
commit4418e4ea6a9b8d648bcb7e7241b887cbab6936bc (patch)
tree5ba3c7d8e936ae1f035b554774cb20e605039f51 /rpc/args.go
parent21fca9385220850d88433f406378f1bd683b25ad (diff)
downloaddexon-4418e4ea6a9b8d648bcb7e7241b887cbab6936bc.tar
dexon-4418e4ea6a9b8d648bcb7e7241b887cbab6936bc.tar.gz
dexon-4418e4ea6a9b8d648bcb7e7241b887cbab6936bc.tar.bz2
dexon-4418e4ea6a9b8d648bcb7e7241b887cbab6936bc.tar.lz
dexon-4418e4ea6a9b8d648bcb7e7241b887cbab6936bc.tar.xz
dexon-4418e4ea6a9b8d648bcb7e7241b887cbab6936bc.tar.zst
dexon-4418e4ea6a9b8d648bcb7e7241b887cbab6936bc.zip
Should on empty params #466
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
}