Fix optional arg handling for importprivkey.

This commit is contained in:
Josh Rickmar 2013-11-20 11:12:00 -05:00
parent 4a290162ee
commit 0bee8478a9

View file

@ -205,17 +205,15 @@ func makeGetRawTransaction(args []interface{}) (btcjson.Cmd, error) {
// makeImportPrivKey generates the cmd structure for
// importprivkey commands.
func makeImportPrivKey(args []interface{}) (btcjson.Cmd, error) {
var label string
var rescan bool
var optargs = make([]interface{}, 0, 2)
if len(args) > 1 {
label = args[1].(string)
optargs = append(optargs, args[1].(string))
}
if len(args) > 2 {
rescan = args[2].(bool)
optargs = append(optargs, args[2].(bool))
}
return btcjson.NewImportPrivKeyCmd("btcctl", args[0].(string), label,
rescan)
return btcjson.NewImportPrivKeyCmd("btcctl", args[0].(string), optargs...)
}
// makeStop generates the cmd structure for stop comands.