Skip to content

Commit

Permalink
Change options to single parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
vctt94 committed Jul 12, 2018
1 parent 2c9d3bb commit 1bdf1cc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
27 changes: 15 additions & 12 deletions dcrjson/walletsvrcmds.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,27 +240,30 @@ func NewEstimatePriorityCmd(numBlocks int64) *EstimatePriorityCmd {
}
}

// FundRawTransactionCmd is a type handling custom marshaling and
// unmarshaling of fundrawtransaction JSON wallet extension commands.
type FundRawTransactionCmd struct {
HexString string
FundAccount string
// FundRawTransactionOptions represents the optional inputs to fund
// a raw transaction.
type FundRawTransactionOptions struct {
ChangeAccount *string
LockUnspents *bool `jsonrpcdefault:"false"`
FeeRate *float64
RequiredConfirmations *int32
}

// FundRawTransactionCmd is a type handling custom marshaling and
// unmarshaling of fundrawtransaction JSON wallet extension commands.
type FundRawTransactionCmd struct {
HexString string
FundAccount string
Options *FundRawTransactionOptions
}

// NewFundRawTransactionCmd returns a new instance which can be used to issue a
// fundrawtransaction JSON-RPC command.
func NewFundRawTransactionCmd(hexString string, fundAccount string, changeAccount *string, lockUnspents *bool, feeRate *float64, requiredConfirmations *int32) *FundRawTransactionCmd {
func NewFundRawTransactionCmd(hexString string, fundAccount string, options *FundRawTransactionOptions) *FundRawTransactionCmd {
return &FundRawTransactionCmd{
HexString: hexString,
FundAccount: fundAccount,
ChangeAccount: changeAccount,
LockUnspents: lockUnspents,
FeeRate: feeRate,
RequiredConfirmations: requiredConfirmations,
HexString: hexString,
FundAccount: fundAccount,
Options: options,
}
}

Expand Down
8 changes: 4 additions & 4 deletions rpcclient/wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -2765,15 +2765,15 @@ func (r FutureFundRawTransactionResult) Receive() (*dcrjson.FundRawTransactionRe
// returned instance.
//
// See FundRawTransaction for the blocking version and more details.
func (c *Client) FundRawTransactionAsync(rawhex string, fundAccount string, changeAccount string, lockUnspents bool, feeRate float64, requiredConfirmations int32) FutureFundRawTransactionResult {
cmd := dcrjson.NewFundRawTransactionCmd(rawhex, fundAccount, &changeAccount, &lockUnspents, &feeRate, &requiredConfirmations)
func (c *Client) FundRawTransactionAsync(rawhex string, fundAccount string, options dcrjson.FundRawTransactionOptions) FutureFundRawTransactionResult {
cmd := dcrjson.NewFundRawTransactionCmd(rawhex, fundAccount, &options)
return c.sendCmd(cmd)
}

// FundRawTransaction Add inputs to a transaction until it has enough
// in value to meet its out value.
func (c *Client) FundRawTransaction(rawhex string, fundAccount string, changeAccount string, lockUnspents bool, feeRate float64, requiredConfirmations int32) (*dcrjson.FundRawTransactionResult, error) {
return c.FundRawTransactionAsync(rawhex, fundAccount, changeAccount, lockUnspents, feeRate, requiredConfirmations).Receive()
func (c *Client) FundRawTransaction(rawhex string, fundAccount string, options dcrjson.FundRawTransactionOptions) (*dcrjson.FundRawTransactionResult, error) {
return c.FundRawTransactionAsync(rawhex, fundAccount, options).Receive()
}

// FutureGenerateVoteResult is a future promise to deliver the result of a
Expand Down

0 comments on commit 1bdf1cc

Please sign in to comment.