diff --git a/jsoncmd.go b/jsoncmd.go index 41a8b831..dda08fd5 100644 --- a/jsoncmd.go +++ b/jsoncmd.go @@ -1453,9 +1453,7 @@ func (cmd *GetBalanceCmd) MarshalJSON() ([]byte, error) { Jsonrpc: "1.0", Method: "getbalance", Id: cmd.id, - Params: []interface{}{ - cmd.Account, - }, + Params: []interface{}{}, } if cmd.Account != "" || cmd.Minconf != 1 { @@ -1493,7 +1491,7 @@ func (cmd *GetBalanceCmd) UnmarshalJSON(b []byte) error { if len(r.Params) > 1 { minconf, ok := r.Params[1].(float64) if !ok { - return errors.New("first optional parameter minconf must be a number") + return errors.New("second optional parameter minconf must be a number") } optArgs = append(optArgs, int(minconf)) } diff --git a/jsoncmd_test.go b/jsoncmd_test.go index 27dd40c6..41ed52a9 100644 --- a/jsoncmd_test.go +++ b/jsoncmd_test.go @@ -222,6 +222,59 @@ var jsoncmdtests = []struct { Node: "thisisanode", }, }, + { + name: "basic getaddressesbyaccount", + f: func() (Cmd, error) { + return NewGetAddressesByAccountCmd(float64(1), + "account") + }, + result: &GetAddressesByAccountCmd{ + id: float64(1), + Account: "account", + }, + }, + { + name: "basic getbalance", + f: func() (Cmd, error) { + return NewGetBalanceCmd(float64(1)) + }, + result: &GetBalanceCmd{ + id: float64(1), + Minconf: 1, // the default + }, + }, + { + name: "basic getbalance + account", + f: func() (Cmd, error) { + return NewGetBalanceCmd(float64(1), "account") + }, + result: &GetBalanceCmd{ + id: float64(1), + Account: "account", + Minconf: 1, // the default + }, + }, + { + name: "basic getbalance + minconf", + f: func() (Cmd, error) { + return NewGetBalanceCmd(float64(1), "", 2) + }, + result: &GetBalanceCmd{ + id: float64(1), + Minconf: 2, + }, + }, + { + name: "basic getbalance + account + minconf", + f: func() (Cmd, error) { + return NewGetBalanceCmd(float64(1), "account", 2) + }, + result: &GetBalanceCmd{ + id: float64(1), + Account: "account", + Minconf: 2, + }, + }, { name: "basic ping", f: func() (Cmd, error) {