Skip to content

Commit 065b967

Browse files
author
Sef
committed
Add extra field to command struct and tests
1 parent e252157 commit 065b967

File tree

3 files changed

+26
-4
lines changed

3 files changed

+26
-4
lines changed

rpc/jsonrpc/types/walletsvrcmds.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -834,10 +834,11 @@ func NewSendManyCmd(fromAccount string, amounts map[string]float64, minConf *int
834834

835835
// SendToAddressCmd defines the sendtoaddress JSON-RPC command.
836836
type SendToAddressCmd struct {
837-
Address string
838-
Amount float64
839-
Comment *string
840-
CommentTo *string
837+
Address string
838+
Amount float64
839+
Comment *string
840+
CommentTo *string
841+
SubtractFeeFromAmount *bool
841842
}
842843

843844
// NewSendToAddressCmd returns a new instance which can be used to issue a

rpc/jsonrpc/types/walletsvrcmds_test.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -973,6 +973,26 @@ func TestWalletSvrCmds(t *testing.T) {
973973
CommentTo: dcrjson.String("commentto"),
974974
},
975975
},
976+
{
977+
name: "sendtoaddress optional2",
978+
newCmd: func() (interface{}, error) {
979+
return dcrjson.NewCmd("sendtoaddress", "1Address", 0.5, "comment", "commentto", dcrjson.Bool(true))
980+
},
981+
staticCmd: func() interface{} {
982+
val := NewSendToAddressCmd("1Address", 0.5, dcrjson.String("comment"),
983+
dcrjson.String("commentto"))
984+
val.SubtractFeeFromAmount = dcrjson.Bool(true)
985+
return val
986+
},
987+
marshalled: `{"jsonrpc":"1.0","method":"sendtoaddress","params":["1Address",0.5,"comment","commentto",true],"id":1}`,
988+
unmarshalled: &SendToAddressCmd{
989+
Address: "1Address",
990+
Amount: 0.5,
991+
Comment: dcrjson.String("comment"),
992+
CommentTo: dcrjson.String("commentto"),
993+
SubtractFeeFromAmount: dcrjson.Bool(true),
994+
},
995+
},
976996
{
977997
name: "settxfee",
978998
newCmd: func() (interface{}, error) {

rpc/legacyrpc/methods.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import (
3434
"github.com/decred/dcrwallet/p2p"
3535
"github.com/decred/dcrwallet/rpc/jsonrpc/types"
3636
ver "github.com/decred/dcrwallet/version"
37+
"github.com/decred/dcrwallet/wallet/v2"
3738
"github.com/decred/dcrwallet/wallet/v2/txrules"
3839
"github.com/decred/dcrwallet/wallet/v2/udb"
3940
)

0 commit comments

Comments
 (0)