From 1bdf1cce5ceb6664d48ab4e33cc6bc193b9331c5 Mon Sep 17 00:00:00 2001 From: vctt94 Date: Thu, 12 Jul 2018 08:37:53 -0300 Subject: [PATCH] Change options to single parameter --- dcrjson/walletsvrcmds.go | 27 +++++++++++++++------------ rpcclient/wallet.go | 8 ++++---- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/dcrjson/walletsvrcmds.go b/dcrjson/walletsvrcmds.go index 93239b8477..c4370310b2 100644 --- a/dcrjson/walletsvrcmds.go +++ b/dcrjson/walletsvrcmds.go @@ -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, } } diff --git a/rpcclient/wallet.go b/rpcclient/wallet.go index c7fe2873fe..6edca00711 100644 --- a/rpcclient/wallet.go +++ b/rpcclient/wallet.go @@ -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