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

Commit

Permalink
dcrjson: Add gap policy option to getnewaddress.
Browse files Browse the repository at this point in the history
  • Loading branch information
jrick committed Jun 6, 2017
1 parent 72a40b7 commit f01a8bf
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
8 changes: 5 additions & 3 deletions dcrjson/walletsvrcmds.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,17 +141,19 @@ func NewGetBalanceCmd(account *string, minConf *int) *GetBalanceCmd {

// GetNewAddressCmd defines the getnewaddress JSON-RPC command.
type GetNewAddressCmd struct {
Account *string
Account *string
GapPolicy *string
}

// 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) *GetNewAddressCmd {
func NewGetNewAddressCmd(account *string, gapPolicy *string) *GetNewAddressCmd {
return &GetNewAddressCmd{
Account: account,
Account: account,
GapPolicy: gapPolicy,
}
}

Expand Down
14 changes: 8 additions & 6 deletions dcrjson/walletsvrcmds_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,24 +216,26 @@ func TestWalletSvrCmds(t *testing.T) {
return dcrjson.NewCmd("getnewaddress")
},
staticCmd: func() interface{} {
return dcrjson.NewGetNewAddressCmd(nil)
return dcrjson.NewGetNewAddressCmd(nil, nil)
},
marshalled: `{"jsonrpc":"1.0","method":"getnewaddress","params":[],"id":1}`,
unmarshalled: &dcrjson.GetNewAddressCmd{
Account: nil,
Account: nil,
GapPolicy: nil,
},
},
{
name: "getnewaddress optional",
newCmd: func() (interface{}, error) {
return dcrjson.NewCmd("getnewaddress", "acct")
return dcrjson.NewCmd("getnewaddress", "acct", "ignore")
},
staticCmd: func() interface{} {
return dcrjson.NewGetNewAddressCmd(dcrjson.String("acct"))
return dcrjson.NewGetNewAddressCmd(dcrjson.String("acct"), dcrjson.String("ignore"))
},
marshalled: `{"jsonrpc":"1.0","method":"getnewaddress","params":["acct"],"id":1}`,
marshalled: `{"jsonrpc":"1.0","method":"getnewaddress","params":["acct","ignore"],"id":1}`,
unmarshalled: &dcrjson.GetNewAddressCmd{
Account: dcrjson.String("acct"),
Account: dcrjson.String("acct"),
GapPolicy: dcrjson.String("ignore"),
},
},
{
Expand Down
8 changes: 4 additions & 4 deletions glide.lock

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

0 comments on commit f01a8bf

Please sign in to comment.