Correct bug in walletpassphrase arguements.

Thanks to pureveg and hngchiming for pointing it out.
This commit is contained in:
John C. Vernaleo 2013-08-14 10:15:16 -04:00
parent 7a7fa56407
commit 5d40d51672
3 changed files with 19 additions and 4 deletions

View file

@ -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 {

View file

@ -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},
}

View file

@ -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)