diff --git a/jsonapi.go b/jsonapi.go index ebd47a17..16fff664 100644 --- a/jsonapi.go +++ b/jsonapi.go @@ -262,7 +262,7 @@ func CreateMessage(message string, args ...interface{}) ([]byte, error) { } finalMessage, err = jsonWithArgs(message, args) // Two required strings - case "listsinceblock", "setaccount", "signmessage", "walletpassphrase", + case "setaccount", "signmessage", "walletpassphrase", "walletpassphrasechange": if len(args) != 2 { err = fmt.Errorf("Missing arguments for %s", message) @@ -437,6 +437,26 @@ func CreateMessage(message string, args ...interface{}) ([]byte, error) { return finalMessage, err } finalMessage, err = jsonWithArgs(message, args) + // Two optional strings + case "listsinceblock": + if len(args) > 2 { + err = fmt.Errorf("Wrong number of arguments for %s", message) + return finalMessage, err + } + ok1 := true + ok2 := true + if len(args) >= 1 { + _, ok1 = args[0].(string) + } + if len(args) == 2 { + _, ok2 = args[1].(string) + } + if !ok1 || !ok2 { + err = fmt.Errorf("Optional arguments must be strings for %s", message) + return finalMessage, err + } + finalMessage, err = jsonWithArgs(message, args) + // Two required strings, one required float, one optional int, // two optional strings. case "sendfrom": diff --git a/jsonapi_test.go b/jsonapi_test.go index d767edfd..66e8a2cc 100644 --- a/jsonapi_test.go +++ b/jsonapi_test.go @@ -162,6 +162,11 @@ var cmdtests = []struct { {"signrawtransaction", []interface{}{"hexstring", 1, "test2", "test3", "test4"}, false}, {"signrawtransaction", []interface{}{"hexstring", "test", 2, "test3", "test4"}, false}, {"signrawtransaction", []interface{}{"hexstring", "test", "test2", 3, "test4"}, false}, + {"listsinceblock", []interface{}{"test", "test"}, true}, + {"listsinceblock", []interface{}{"test", "test", "test"}, false}, + {"listsinceblock", []interface{}{"test"}, true}, + {"listsinceblock", []interface{}{}, true}, + {"listsinceblock", []interface{}{1, "test"}, false}, {"fakecommand", nil, false}, }