Skip to content
This repository has been archived by the owner on Aug 7, 2023. It is now read-only.

Commit

Permalink
dcrjson: Remove unnecessary verbose optional parameters.
Browse files Browse the repository at this point in the history
  • Loading branch information
jrick committed Jun 6, 2017
1 parent a3083e1 commit b154254
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 21 deletions.
9 changes: 2 additions & 7 deletions dcrjson/walletsvrcmds.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,37 +142,32 @@ func NewGetBalanceCmd(account *string, minConf *int) *GetBalanceCmd {
// GetNewAddressCmd defines the getnewaddress JSON-RPC command.
type GetNewAddressCmd struct {
Account *string
Verbose *bool `jsonrpcdefault:"false"`
}

// NewGetNewAddressCmd returns a new instance which can be used to issue a
// getnewaddress JSON-RPC command.
//
// The parameters which are pointers indicate they are optional. Passing nil
// for optional parameters will use the default value.
func NewGetNewAddressCmd(account *string, verbose *bool) *GetNewAddressCmd {
func NewGetNewAddressCmd(account *string) *GetNewAddressCmd {
return &GetNewAddressCmd{
Account: account,
Verbose: verbose,
}
}

// GetRawChangeAddressCmd defines the getrawchangeaddress JSON-RPC command.
type GetRawChangeAddressCmd struct {
Account *string
Verbose *bool `jsonrpcdefault:"false"`
}

// NewGetRawChangeAddressCmd returns a new instance which can be used to issue a
// getrawchangeaddress JSON-RPC command.
//
// The parameters which are pointers indicate they are optional. Passing nil
// for optional parameters will use the default value.
func NewGetRawChangeAddressCmd(account *string,
verbose *bool) *GetRawChangeAddressCmd {
func NewGetRawChangeAddressCmd(account *string) *GetRawChangeAddressCmd {
return &GetRawChangeAddressCmd{
Account: account,
Verbose: verbose,
}
}

Expand Down
20 changes: 8 additions & 12 deletions dcrjson/walletsvrcmds_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,26 +216,24 @@ func TestWalletSvrCmds(t *testing.T) {
return dcrjson.NewCmd("getnewaddress")
},
staticCmd: func() interface{} {
return dcrjson.NewGetNewAddressCmd(nil, nil)
return dcrjson.NewGetNewAddressCmd(nil)
},
marshalled: `{"jsonrpc":"1.0","method":"getnewaddress","params":[],"id":1}`,
unmarshalled: &dcrjson.GetNewAddressCmd{
Account: nil,
Verbose: dcrjson.Bool(false),
},
},
{
name: "getnewaddress optional",
newCmd: func() (interface{}, error) {
return dcrjson.NewCmd("getnewaddress", "acct", "true")
return dcrjson.NewCmd("getnewaddress", "acct")
},
staticCmd: func() interface{} {
return dcrjson.NewGetNewAddressCmd(dcrjson.String("acct"), dcrjson.Bool(true))
return dcrjson.NewGetNewAddressCmd(dcrjson.String("acct"))
},
marshalled: `{"jsonrpc":"1.0","method":"getnewaddress","params":["acct",true],"id":1}`,
marshalled: `{"jsonrpc":"1.0","method":"getnewaddress","params":["acct"],"id":1}`,
unmarshalled: &dcrjson.GetNewAddressCmd{
Account: dcrjson.String("acct"),
Verbose: dcrjson.Bool(true),
},
},
{
Expand All @@ -244,26 +242,24 @@ func TestWalletSvrCmds(t *testing.T) {
return dcrjson.NewCmd("getrawchangeaddress")
},
staticCmd: func() interface{} {
return dcrjson.NewGetRawChangeAddressCmd(nil, nil)
return dcrjson.NewGetRawChangeAddressCmd(nil)
},
marshalled: `{"jsonrpc":"1.0","method":"getrawchangeaddress","params":[],"id":1}`,
unmarshalled: &dcrjson.GetRawChangeAddressCmd{
Account: nil,
Verbose: dcrjson.Bool(false),
},
},
{
name: "getrawchangeaddress optional",
newCmd: func() (interface{}, error) {
return dcrjson.NewCmd("getrawchangeaddress", "acct", "true")
return dcrjson.NewCmd("getrawchangeaddress", "acct")
},
staticCmd: func() interface{} {
return dcrjson.NewGetRawChangeAddressCmd(dcrjson.String("acct"), dcrjson.Bool(true))
return dcrjson.NewGetRawChangeAddressCmd(dcrjson.String("acct"))
},
marshalled: `{"jsonrpc":"1.0","method":"getrawchangeaddress","params":["acct",true],"id":1}`,
marshalled: `{"jsonrpc":"1.0","method":"getrawchangeaddress","params":["acct"],"id":1}`,
unmarshalled: &dcrjson.GetRawChangeAddressCmd{
Account: dcrjson.String("acct"),
Verbose: dcrjson.Bool(true),
},
},
{
Expand Down
4 changes: 2 additions & 2 deletions glide.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b154254

Please sign in to comment.