Skip to content

Commit 987a533

Browse files
committed
rpc: update rpc cmd requests to support multi-account
Most of the updates add optional arguments with default values.
1 parent 6bc9a2b commit 987a533

File tree

6 files changed

+224
-126
lines changed

6 files changed

+224
-126
lines changed

btcjson/walletsvrcmds.go

Lines changed: 43 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -176,25 +176,27 @@ func NewGetAccountCmd(address string) *GetAccountCmd {
176176

177177
// GetAccountAddressCmd defines the getaccountaddress JSON-RPC command.
178178
type GetAccountAddressCmd struct {
179-
Account string
179+
Account *string `jsonrpcdefault:"\"default\""`
180+
AddressType *string `jsonrpcdefault:"\"legacy\""`
180181
}
181182

182183
// NewGetAccountAddressCmd returns a new instance which can be used to issue a
183184
// getaccountaddress JSON-RPC command.
184-
func NewGetAccountAddressCmd(account string) *GetAccountAddressCmd {
185+
func NewGetAccountAddressCmd(account *string) *GetAccountAddressCmd {
185186
return &GetAccountAddressCmd{
186187
Account: account,
187188
}
188189
}
189190

190191
// GetAddressesByAccountCmd defines the getaddressesbyaccount JSON-RPC command.
191192
type GetAddressesByAccountCmd struct {
192-
Account string
193+
Account *string `jsonrpcdefault:"\"default\""`
194+
AddressType *string `jsonrpcdefault:"\"*\""`
193195
}
194196

195197
// NewGetAddressesByAccountCmd returns a new instance which can be used to issue
196198
// a getaddressesbyaccount JSON-RPC command.
197-
func NewGetAddressesByAccountCmd(account string) *GetAddressesByAccountCmd {
199+
func NewGetAddressesByAccountCmd(account *string) *GetAddressesByAccountCmd {
198200
return &GetAddressesByAccountCmd{
199201
Account: account,
200202
}
@@ -215,8 +217,9 @@ func NewGetAddressInfoCmd(address string) *GetAddressInfoCmd {
215217

216218
// GetBalanceCmd defines the getbalance JSON-RPC command.
217219
type GetBalanceCmd struct {
218-
Account *string
219-
MinConf *int `jsonrpcdefault:"1"`
220+
Account *string `jsonrpcdefault:"\"default\""`
221+
MinConf *int `jsonrpcdefault:"1"`
222+
AddressType *string `jsonrpcdefault:"\"*\""`
220223
}
221224

222225
// NewGetBalanceCmd returns a new instance which can be used to issue a
@@ -242,8 +245,8 @@ func NewGetBalancesCmd() *GetBalancesCmd {
242245

243246
// GetNewAddressCmd defines the getnewaddress JSON-RPC command.
244247
type GetNewAddressCmd struct {
245-
Account *string
246-
AddressType *string // must be one of legacy / p2pkh or p2sh-p2wkh / p2sh-segwit, or p2wkh / bech32
248+
Account *string `jsonrpcdefault:"\"default\""`
249+
AddressType *string `jsonrpcdefault:"\"legacy\""`
247250
}
248251

249252
// NewGetNewAddressCmd returns a new instance which can be used to issue a
@@ -259,7 +262,8 @@ func NewGetNewAddressCmd(account *string) *GetNewAddressCmd {
259262

260263
// GetRawChangeAddressCmd defines the getrawchangeaddress JSON-RPC command.
261264
type GetRawChangeAddressCmd struct {
262-
Account *string
265+
Account *string `jsonrpcdefault:"\"default\""`
266+
AddressType *string `jsonrpcdefault:"\"legacy\""`
263267
}
264268

265269
// NewGetRawChangeAddressCmd returns a new instance which can be used to issue a
@@ -275,16 +279,16 @@ func NewGetRawChangeAddressCmd(account *string) *GetRawChangeAddressCmd {
275279

276280
// GetReceivedByAccountCmd defines the getreceivedbyaccount JSON-RPC command.
277281
type GetReceivedByAccountCmd struct {
278-
Account string
279-
MinConf *int `jsonrpcdefault:"1"`
282+
Account *string `jsonrpcdefault:"\"default\""`
283+
MinConf *int `jsonrpcdefault:"1"`
280284
}
281285

282286
// NewGetReceivedByAccountCmd returns a new instance which can be used to issue
283287
// a getreceivedbyaccount JSON-RPC command.
284288
//
285289
// The parameters which are pointers indicate they are optional. Passing nil
286290
// for optional parameters will use the default value.
287-
func NewGetReceivedByAccountCmd(account string, minConf *int) *GetReceivedByAccountCmd {
291+
func NewGetReceivedByAccountCmd(account *string, minConf *int) *GetReceivedByAccountCmd {
288292
return &GetReceivedByAccountCmd{
289293
Account: account,
290294
MinConf: minConf,
@@ -407,7 +411,8 @@ func NewKeyPoolRefillCmd(newSize *uint) *KeyPoolRefillCmd {
407411

408412
// ListAccountsCmd defines the listaccounts JSON-RPC command.
409413
type ListAccountsCmd struct {
410-
MinConf *int `jsonrpcdefault:"1"`
414+
MinConf *int `jsonrpcdefault:"1"`
415+
AddressType *string `jsonrpcdefault:"\"*\""`
411416
}
412417

413418
// NewListAccountsCmd returns a new instance which can be used to issue a
@@ -501,10 +506,10 @@ func NewListSinceBlockCmd(blockHash *string, targetConfirms *int, includeWatchOn
501506

502507
// ListTransactionsCmd defines the listtransactions JSON-RPC command.
503508
type ListTransactionsCmd struct {
504-
Account *string
505-
Count *int `jsonrpcdefault:"10"`
506-
From *int `jsonrpcdefault:"0"`
507-
IncludeWatchOnly *bool `jsonrpcdefault:"false"`
509+
Account *string `jsonrpcdefault:"\"default\""`
510+
Count *int `jsonrpcdefault:"10"`
511+
From *int `jsonrpcdefault:"0"`
512+
IncludeWatchOnly *bool `jsonrpcdefault:"false"`
508513
}
509514

510515
// NewListTransactionsCmd returns a new instance which can be used to issue a
@@ -562,6 +567,7 @@ type SendFromCmd struct {
562567
ToAddress string
563568
Amount float64 // In BTC
564569
MinConf *int `jsonrpcdefault:"1"`
570+
AddressType *string `jsonrpcdefault:"\"*\""`
565571
Comment *string
566572
CommentTo *string
567573
}
@@ -571,12 +577,15 @@ type SendFromCmd struct {
571577
//
572578
// The parameters which are pointers indicate they are optional. Passing nil
573579
// for optional parameters will use the default value.
574-
func NewSendFromCmd(fromAccount, toAddress string, amount float64, minConf *int, comment, commentTo *string) *SendFromCmd {
580+
func NewSendFromCmd(fromAccount, toAddress string, amount float64,
581+
minConf *int, addrType *string, comment, commentTo *string) *SendFromCmd {
582+
575583
return &SendFromCmd{
576584
FromAccount: fromAccount,
577585
ToAddress: toAddress,
578586
Amount: amount,
579587
MinConf: minConf,
588+
AddressType: addrType,
580589
Comment: comment,
581590
CommentTo: commentTo,
582591
}
@@ -587,6 +596,7 @@ type SendManyCmd struct {
587596
FromAccount string
588597
Amounts map[string]float64 `jsonrpcusage:"{\"address\":amount,...}"` // In BTC
589598
MinConf *int `jsonrpcdefault:"1"`
599+
AddressType *string `jsonrpcdefault:"\"*\""`
590600
Comment *string
591601
}
592602

@@ -595,34 +605,39 @@ type SendManyCmd struct {
595605
//
596606
// The parameters which are pointers indicate they are optional. Passing nil
597607
// for optional parameters will use the default value.
598-
func NewSendManyCmd(fromAccount string, amounts map[string]float64, minConf *int, comment *string) *SendManyCmd {
608+
func NewSendManyCmd(fromAccount string, amounts map[string]float64,
609+
minConf *int, addrType *string, comment *string) *SendManyCmd {
599610
return &SendManyCmd{
600611
FromAccount: fromAccount,
601612
Amounts: amounts,
602613
MinConf: minConf,
614+
AddressType: addrType,
603615
Comment: comment,
604616
}
605617
}
606618

607619
// SendToAddressCmd defines the sendtoaddress JSON-RPC command.
608620
type SendToAddressCmd struct {
609-
Address string
610-
Amount float64
611-
Comment *string
612-
CommentTo *string
621+
Address string
622+
Amount float64
623+
AddressType *string `jsonrpcdefault:"\"*\""`
624+
Comment *string
625+
CommentTo *string
613626
}
614627

615628
// NewSendToAddressCmd returns a new instance which can be used to issue a
616629
// sendtoaddress JSON-RPC command.
617630
//
618631
// The parameters which are pointers indicate they are optional. Passing nil
619632
// for optional parameters will use the default value.
620-
func NewSendToAddressCmd(address string, amount float64, comment, commentTo *string) *SendToAddressCmd {
633+
func NewSendToAddressCmd(address string, amount float64, addrType *string,
634+
comment, commentTo *string) *SendToAddressCmd {
621635
return &SendToAddressCmd{
622-
Address: address,
623-
Amount: amount,
624-
Comment: comment,
625-
CommentTo: commentTo,
636+
Address: address,
637+
Amount: amount,
638+
AddressType: addrType,
639+
Comment: comment,
640+
CommentTo: commentTo,
626641
}
627642
}
628643

0 commit comments

Comments
 (0)