Fix parameter for GetNewAddressCmd.

The first parameter for a getnewaddress command is the account, not an
address, so name it properly in the GetNewAddressCmd struct.
This commit is contained in:
Josh Rickmar 2013-11-12 12:36:57 -05:00
parent d3dea375c6
commit f689789be8
2 changed files with 8 additions and 8 deletions

View file

@ -2476,7 +2476,7 @@ func (cmd *GetNetworkHashPSCmd) UnmarshalJSON(b []byte) error {
// unmarshaling of getnewaddress JSON RPC commands. // unmarshaling of getnewaddress JSON RPC commands.
type GetNewAddressCmd struct { type GetNewAddressCmd struct {
id interface{} id interface{}
Address string Account string
} }
// Enforce that GetNewAddressCmd satisifies the Cmd interface. // Enforce that GetNewAddressCmd satisifies the Cmd interface.
@ -2484,17 +2484,17 @@ var _ Cmd = &GetNewAddressCmd{}
// NewGetNewAddressCmd creates a new GetNewAddressCmd. // NewGetNewAddressCmd creates a new GetNewAddressCmd.
func NewGetNewAddressCmd(id interface{}, optArgs ...string) (*GetNewAddressCmd, error) { func NewGetNewAddressCmd(id interface{}, optArgs ...string) (*GetNewAddressCmd, error) {
var address string var account string
if len(optArgs) > 0 { if len(optArgs) > 0 {
if len(optArgs) > 1 { if len(optArgs) > 1 {
return nil, ErrTooManyOptArgs return nil, ErrTooManyOptArgs
} }
address = optArgs[0] account = optArgs[0]
} }
return &GetNewAddressCmd{ return &GetNewAddressCmd{
id: id, id: id,
Address: address, Account: account,
}, nil }, nil
} }
@ -2518,8 +2518,8 @@ func (cmd *GetNewAddressCmd) MarshalJSON() ([]byte, error) {
Params: []interface{}{}, Params: []interface{}{},
} }
if cmd.Address != "" { if cmd.Account != "" {
raw.Params = append(raw.Params, cmd.Address) raw.Params = append(raw.Params, cmd.Account)
} }
return json.Marshal(raw) return json.Marshal(raw)
} }

View file

@ -479,11 +479,11 @@ var jsoncmdtests = []struct {
{ {
name: "basic getnewaddress", name: "basic getnewaddress",
f: func() (Cmd, error) { f: func() (Cmd, error) {
return NewGetNewAddressCmd(float64(1), "address") return NewGetNewAddressCmd(float64(1), "account")
}, },
result: &GetNewAddressCmd{ result: &GetNewAddressCmd{
id: float64(1), id: float64(1),
Address: "address", Account: "account",
}, },
}, },
{ {