diff --git a/jsoncmd.go b/jsoncmd.go index 2d221345..30e1df9c 100644 --- a/jsoncmd.go +++ b/jsoncmd.go @@ -5110,7 +5110,7 @@ func NewSendManyCmd(id interface{}, fromaccount string, amounts map[string]int64 minconf = m } if len(optArgs) > 1 { - c, ok := optArgs[0].(string) + c, ok := optArgs[1].(string) if !ok { return nil, errors.New("second optional parameter comment is not a string") } diff --git a/jsoncmd_test.go b/jsoncmd_test.go index 6c2951c1..9fb011e2 100644 --- a/jsoncmd_test.go +++ b/jsoncmd_test.go @@ -933,6 +933,55 @@ var jsoncmdtests = []struct { CommentTo: "comment to", }, }, + { + name: "basic sendmany", + f: func() (Cmd, error) { + pairs := map[string]int64{ + "address A": 1000, + "address B": 2000, + "address C": 3000, + } + return NewSendManyCmd(float64(1), + "account", + pairs) + }, + result: &SendManyCmd{ + id: float64(1), + FromAccount: "account", + Amounts: map[string]int64{ + "address A": 1000, + "address B": 2000, + "address C": 3000, + }, + MinConf: 1, // the default + }, + }, + { + name: "sendmany + options", + f: func() (Cmd, error) { + pairs := map[string]int64{ + "address A": 1000, + "address B": 2000, + "address C": 3000, + } + return NewSendManyCmd(float64(1), + "account", + pairs, + 10, + "comment") + }, + result: &SendManyCmd{ + id: float64(1), + FromAccount: "account", + Amounts: map[string]int64{ + "address A": 1000, + "address B": 2000, + "address C": 3000, + }, + MinConf: 10, + Comment: "comment", + }, + }, { name: "basic sendrawtransaction", f: func() (Cmd, error) {