diff --git a/jsonapi.go b/jsonapi.go index 271bae90..af347d90 100644 --- a/jsonapi.go +++ b/jsonapi.go @@ -273,8 +273,7 @@ func CreateMessageWithId(message string, id interface{}, args ...interface{}) ([ } finalMessage, err = jsonWithArgs(message, id, args) // Two required strings - case "setaccount", "signmessage", "walletpassphrase", - "walletpassphrasechange": + case "setaccount", "signmessage", "walletpassphrasechange": if len(args) != 2 { err = fmt.Errorf("Missing arguments for %s", message) return finalMessage, err @@ -286,6 +285,19 @@ func CreateMessageWithId(message string, id interface{}, args ...interface{}) ([ return finalMessage, err } finalMessage, err = jsonWithArgs(message, id, args) + // One required string, one required int + case "walletpassphrase": + if len(args) != 2 { + err = fmt.Errorf("Missing arguments for %s", message) + return finalMessage, err + } + _, ok1 := args[0].(string) + _, ok2 := args[1].(int) + if !ok1 || !ok2 { + err = fmt.Errorf("Arguments must be string and int for %s", message) + return finalMessage, err + } + finalMessage, err = jsonWithArgs(message, id, args) // Three required strings case "verifymessage": if len(args) != 3 { diff --git a/jsonapi_test.go b/jsonapi_test.go index 108b032c..e243d2dd 100644 --- a/jsonapi_test.go +++ b/jsonapi_test.go @@ -168,6 +168,9 @@ var cmdtests = []struct { {"listsinceblock", []interface{}{"test"}, true}, {"listsinceblock", []interface{}{}, true}, {"listsinceblock", []interface{}{1, "test"}, false}, + {"walletpassphrase", []interface{}{"test", 1}, true}, + {"walletpassphrase", []interface{}{"test"}, false}, + {"walletpassphrase", []interface{}{"test", "test"}, false}, {"fakecommand", nil, false}, } diff --git a/test_coverage.txt b/test_coverage.txt index 2b77f721..34190458 100644 --- a/test_coverage.txt +++ b/test_coverage.txt @@ -1,5 +1,5 @@ -github.com/conformal/btcjson/jsonapi.go CreateMessageWithId 100.00% (323/323) +github.com/conformal/btcjson/jsonapi.go CreateMessageWithId 100.00% (332/332) github.com/conformal/btcjson/jsonapi.go ReadResultCmd 100.00% (63/63) github.com/conformal/btcjson/jsonapi.go JSONToAmount 100.00% (15/15) github.com/conformal/btcjson/jsonapi.go JSONGetMethod 100.00% (14/14) @@ -11,5 +11,5 @@ github.com/conformal/btcjson/jsonapi.go IsValidIdType 100.00% (3/3) github.com/conformal/btcjson/jsonapi.go CreateMessage 100.00% (2/2) github.com/conformal/btcjson/jsonapi.go RpcCommand 61.54% (8/13) github.com/conformal/btcjson/jsonapi.go RpcRawCommand 53.33% (8/15) -github.com/conformal/btcjson ------------------- 97.46% (461/473) +github.com/conformal/btcjson ------------------- 97.51% (470/482)