diff --git a/jsoncmd.go b/jsoncmd.go index fd7b9e02..2d221345 100644 --- a/jsoncmd.go +++ b/jsoncmd.go @@ -4391,7 +4391,7 @@ func NewListTransactionsCmd(id interface{}, optArgs ...interface{}) (*ListTransa account = ac } if len(optArgs) > 1 { - cnt, ok := optArgs[0].(int) + cnt, ok := optArgs[1].(int) if !ok { return nil, errors.New("second optional argument count is not an int") } @@ -4399,7 +4399,7 @@ func NewListTransactionsCmd(id interface{}, optArgs ...interface{}) (*ListTransa count = cnt } if len(optArgs) > 2 { - frm, ok := optArgs[0].(int) + frm, ok := optArgs[2].(int) if !ok { return nil, errors.New("third optional argument from is not an int") } diff --git a/jsoncmd_test.go b/jsoncmd_test.go index 5f59ce2f..6c2951c1 100644 --- a/jsoncmd_test.go +++ b/jsoncmd_test.go @@ -770,6 +770,54 @@ var jsoncmdtests = []struct { MinConf: 1, }, }, + { + name: "basic listtransactions", + f: func() (Cmd, error) { + return NewListTransactionsCmd(float64(1)) + }, + result: &ListTransactionsCmd{ + id: float64(1), + Account: "", + Count: 10, + From: 0, + }, + }, + { + name: "listtransactions 1 optarg", + f: func() (Cmd, error) { + return NewListTransactionsCmd(float64(1), "abcde") + }, + result: &ListTransactionsCmd{ + id: float64(1), + Account: "abcde", + Count: 10, + From: 0, + }, + }, + { + name: "listtransactions 2 optargs", + f: func() (Cmd, error) { + return NewListTransactionsCmd(float64(1), "abcde", 123) + }, + result: &ListTransactionsCmd{ + id: float64(1), + Account: "abcde", + Count: 123, + From: 0, + }, + }, + { + name: "listtransactions 3 optargs", + f: func() (Cmd, error) { + return NewListTransactionsCmd(float64(1), "abcde", 123, 456) + }, + result: &ListTransactionsCmd{ + id: float64(1), + Account: "abcde", + Count: 123, + From: 456, + }, + }, { name: "basic listunspent", f: func() (Cmd, error) {