Various changes to make golint happier.

This commit is contained in:
John C. Vernaleo 2014-07-15 10:09:35 -04:00
parent 033b00dd1c
commit 6aea36c550
7 changed files with 325 additions and 325 deletions

View file

@ -770,5 +770,5 @@ func GetHelpString(cmdName string) (string, error) {
if c, ok := customCmds[cmdName]; ok { if c, ok := customCmds[cmdName]; ok {
return c.helpString, nil return c.helpString, nil
} }
return helpstr, errors.New("Invalid command specified") return helpstr, errors.New("invalid command specified")
} }

View file

@ -94,20 +94,20 @@ func CreateMessageWithId(message string, id interface{}, args ...interface{}) ([
"stop", "walletlock", "getbestblockhash", "getblockchaininfo", "stop", "walletlock", "getbestblockhash", "getblockchaininfo",
"getnetworkinfo": "getnetworkinfo":
if len(args) > 0 { if len(args) > 0 {
err = fmt.Errorf("Too many arguments for %s", message) err = fmt.Errorf("too many arguments for %s", message)
return finalMessage, err return finalMessage, err
} }
finalMessage, err = jsonWithArgs(message, id, args) finalMessage, err = jsonWithArgs(message, id, args)
// One optional int // One optional int
case "listaccounts": case "listaccounts":
if len(args) > 1 { if len(args) > 1 {
err = fmt.Errorf("Too many arguments for %s", message) err = fmt.Errorf("too many arguments for %s", message)
return finalMessage, err return finalMessage, err
} }
if len(args) == 1 { if len(args) == 1 {
_, ok := args[0].(int) _, ok := args[0].(int)
if !ok { if !ok {
err = fmt.Errorf("Argument must be int for %s", message) err = fmt.Errorf("argument must be int for %s", message)
return finalMessage, err return finalMessage, err
} }
} }
@ -115,24 +115,24 @@ func CreateMessageWithId(message string, id interface{}, args ...interface{}) ([
// One required int // One required int
case "getblockhash", "estimatefee", "estimatepriority": case "getblockhash", "estimatefee", "estimatepriority":
if len(args) != 1 { if len(args) != 1 {
err = fmt.Errorf("Missing argument for %s", message) err = fmt.Errorf("missing argument for %s", message)
return finalMessage, err return finalMessage, err
} }
_, ok := args[0].(int) _, ok := args[0].(int)
if !ok { if !ok {
err = fmt.Errorf("Argument must be int for %s", message) err = fmt.Errorf("argument must be int for %s", message)
return finalMessage, err return finalMessage, err
} }
finalMessage, err = jsonWithArgs(message, id, args) finalMessage, err = jsonWithArgs(message, id, args)
// One required float // One required float
case "settxfee": case "settxfee":
if len(args) != 1 { if len(args) != 1 {
err = fmt.Errorf("Missing argument for %s", message) err = fmt.Errorf("missing argument for %s", message)
return finalMessage, err return finalMessage, err
} }
_, ok := args[0].(float64) _, ok := args[0].(float64)
if !ok { if !ok {
err = fmt.Errorf("Argument must be float64 for %s", message) err = fmt.Errorf("argument must be float64 for %s", message)
return finalMessage, err return finalMessage, err
} }
finalMessage, err = jsonWithArgs(message, id, args) finalMessage, err = jsonWithArgs(message, id, args)
@ -140,13 +140,13 @@ func CreateMessageWithId(message string, id interface{}, args ...interface{}) ([
case "getmemorypool", "getnewaddress", "getwork", "help", case "getmemorypool", "getnewaddress", "getwork", "help",
"getrawchangeaddress": "getrawchangeaddress":
if len(args) > 1 { if len(args) > 1 {
err = fmt.Errorf("Too many arguments for %s", message) err = fmt.Errorf("too many arguments for %s", message)
return finalMessage, err return finalMessage, err
} }
if len(args) == 1 { if len(args) == 1 {
_, ok := args[0].(string) _, ok := args[0].(string)
if !ok { if !ok {
err = fmt.Errorf("Optional argument must be string for %s", message) err = fmt.Errorf("optional argument must be string for %s", message)
return finalMessage, err return finalMessage, err
} }
} }
@ -162,54 +162,54 @@ func CreateMessageWithId(message string, id interface{}, args ...interface{}) ([
} }
_, ok := args[0].(string) _, ok := args[0].(string)
if !ok { if !ok {
err = fmt.Errorf("Argument must be string for %s", message) err = fmt.Errorf("argument must be string for %s", message)
return finalMessage, err return finalMessage, err
} }
finalMessage, err = jsonWithArgs(message, id, args) finalMessage, err = jsonWithArgs(message, id, args)
// Two required strings // Two required strings
case "setaccount", "signmessage", "walletpassphrasechange", "addnode": case "setaccount", "signmessage", "walletpassphrasechange", "addnode":
if len(args) != 2 { if len(args) != 2 {
err = fmt.Errorf("Missing arguments for %s", message) err = fmt.Errorf("missing arguments for %s", message)
return finalMessage, err return finalMessage, err
} }
_, ok1 := args[0].(string) _, ok1 := args[0].(string)
_, ok2 := args[1].(string) _, ok2 := args[1].(string)
if !ok1 || !ok2 { if !ok1 || !ok2 {
err = fmt.Errorf("Arguments must be string for %s", message) err = fmt.Errorf("arguments must be string for %s", message)
return finalMessage, err return finalMessage, err
} }
finalMessage, err = jsonWithArgs(message, id, args) finalMessage, err = jsonWithArgs(message, id, args)
// One required string, one required int // One required string, one required int
case "walletpassphrase": case "walletpassphrase":
if len(args) != 2 { if len(args) != 2 {
err = fmt.Errorf("Missing arguments for %s", message) err = fmt.Errorf("missing arguments for %s", message)
return finalMessage, err return finalMessage, err
} }
_, ok1 := args[0].(string) _, ok1 := args[0].(string)
_, ok2 := args[1].(int) _, ok2 := args[1].(int)
if !ok1 || !ok2 { if !ok1 || !ok2 {
err = fmt.Errorf("Arguments must be string and int for %s", message) err = fmt.Errorf("arguments must be string and int for %s", message)
return finalMessage, err return finalMessage, err
} }
finalMessage, err = jsonWithArgs(message, id, args) finalMessage, err = jsonWithArgs(message, id, args)
// Three required strings // Three required strings
case "verifymessage": case "verifymessage":
if len(args) != 3 { if len(args) != 3 {
err = fmt.Errorf("Three arguments required for %s", message) err = fmt.Errorf("three arguments required for %s", message)
return finalMessage, err return finalMessage, err
} }
_, ok1 := args[0].(string) _, ok1 := args[0].(string)
_, ok2 := args[1].(string) _, ok2 := args[1].(string)
_, ok3 := args[2].(string) _, ok3 := args[2].(string)
if !ok1 || !ok2 || !ok3 { if !ok1 || !ok2 || !ok3 {
err = fmt.Errorf("Arguments must be string for %s", message) err = fmt.Errorf("arguments must be string for %s", message)
return finalMessage, err return finalMessage, err
} }
finalMessage, err = jsonWithArgs(message, id, args) finalMessage, err = jsonWithArgs(message, id, args)
// One required bool, one optional string // One required bool, one optional string
case "getaddednodeinfo": case "getaddednodeinfo":
if len(args) > 2 || len(args) == 0 { if len(args) > 2 || len(args) == 0 {
err = fmt.Errorf("Wrong number of arguments for %s", message) err = fmt.Errorf("wrong number of arguments for %s", message)
return finalMessage, err return finalMessage, err
} }
_, ok1 := args[0].(bool) _, ok1 := args[0].(bool)
@ -218,14 +218,14 @@ func CreateMessageWithId(message string, id interface{}, args ...interface{}) ([
_, ok2 = args[1].(string) _, ok2 = args[1].(string)
} }
if !ok1 || !ok2 { if !ok1 || !ok2 {
err = fmt.Errorf("Arguments must be bool and optionally string for %s", message) err = fmt.Errorf("arguments must be bool and optionally string for %s", message)
return finalMessage, err return finalMessage, err
} }
finalMessage, err = jsonWithArgs(message, id, args) finalMessage, err = jsonWithArgs(message, id, args)
// One required bool, one optional int // One required bool, one optional int
case "setgenerate": case "setgenerate":
if len(args) > 2 || len(args) == 0 { if len(args) > 2 || len(args) == 0 {
err = fmt.Errorf("Wrong number of argument for %s", message) err = fmt.Errorf("wrong number of argument for %s", message)
return finalMessage, err return finalMessage, err
} }
_, ok1 := args[0].(bool) _, ok1 := args[0].(bool)
@ -234,14 +234,14 @@ func CreateMessageWithId(message string, id interface{}, args ...interface{}) ([
_, ok2 = args[1].(int) _, ok2 = args[1].(int)
} }
if !ok1 || !ok2 { if !ok1 || !ok2 {
err = fmt.Errorf("Arguments must be bool and optionally int for %s", message) err = fmt.Errorf("arguments must be bool and optionally int for %s", message)
return finalMessage, err return finalMessage, err
} }
finalMessage, err = jsonWithArgs(message, id, args) finalMessage, err = jsonWithArgs(message, id, args)
// One optional string, one optional int // One optional string, one optional int
case "getbalance", "getreceivedbyaccount": case "getbalance", "getreceivedbyaccount":
if len(args) > 2 { if len(args) > 2 {
err = fmt.Errorf("Wrong number of arguments for %s", message) err = fmt.Errorf("wrong number of arguments for %s", message)
return finalMessage, err return finalMessage, err
} }
ok1 := true ok1 := true
@ -253,14 +253,14 @@ func CreateMessageWithId(message string, id interface{}, args ...interface{}) ([
_, ok2 = args[1].(int) _, ok2 = args[1].(int)
} }
if !ok1 || !ok2 { if !ok1 || !ok2 {
err = fmt.Errorf("Optional arguments must be string and int for %s", message) err = fmt.Errorf("optional arguments must be string and int for %s", message)
return finalMessage, err return finalMessage, err
} }
finalMessage, err = jsonWithArgs(message, id, args) finalMessage, err = jsonWithArgs(message, id, args)
// One required string, one optional int // One required string, one optional int
case "getrawtransaction", "getreceivedbyaddress": case "getrawtransaction", "getreceivedbyaddress":
if len(args) > 2 || len(args) == 0 { if len(args) > 2 || len(args) == 0 {
err = fmt.Errorf("Wrong number of argument for %s", message) err = fmt.Errorf("wrong number of argument for %s", message)
return finalMessage, err return finalMessage, err
} }
_, ok1 := args[0].(string) _, ok1 := args[0].(string)
@ -269,7 +269,7 @@ func CreateMessageWithId(message string, id interface{}, args ...interface{}) ([
_, ok2 = args[1].(int) _, ok2 = args[1].(int)
} }
if !ok1 || !ok2 { if !ok1 || !ok2 {
err = fmt.Errorf("Arguments must be string and optionally int for %s", message) err = fmt.Errorf("arguments must be string and optionally int for %s", message)
return finalMessage, err return finalMessage, err
} }
finalMessage, err = jsonWithArgs(message, id, args) finalMessage, err = jsonWithArgs(message, id, args)
@ -279,7 +279,7 @@ func CreateMessageWithId(message string, id interface{}, args ...interface{}) ([
// support for it is complete. // support for it is complete.
case "submitblock": case "submitblock":
if len(args) > 2 || len(args) == 0 { if len(args) > 2 || len(args) == 0 {
err = fmt.Errorf("Wrong number of argument for %s", message) err = fmt.Errorf("wrong number of argument for %s", message)
return finalMessage, err return finalMessage, err
} }
_, ok1 := args[0].(string) _, ok1 := args[0].(string)
@ -288,14 +288,14 @@ func CreateMessageWithId(message string, id interface{}, args ...interface{}) ([
_, ok2 = args[1].(string) _, ok2 = args[1].(string)
} }
if !ok1 || !ok2 { if !ok1 || !ok2 {
err = fmt.Errorf("Arguments must be string and optionally string for %s", message) err = fmt.Errorf("arguments must be string and optionally string for %s", message)
return finalMessage, err return finalMessage, err
} }
finalMessage, err = jsonWithArgs(message, id, args) finalMessage, err = jsonWithArgs(message, id, args)
// One optional int, one optional bool // One optional int, one optional bool
case "listreceivedbyaccount", "listreceivedbyaddress": case "listreceivedbyaccount", "listreceivedbyaddress":
if len(args) > 2 { if len(args) > 2 {
err = fmt.Errorf("Wrong number of argument for %s", message) err = fmt.Errorf("wrong number of argument for %s", message)
return finalMessage, err return finalMessage, err
} }
ok1 := true ok1 := true
@ -307,14 +307,14 @@ func CreateMessageWithId(message string, id interface{}, args ...interface{}) ([
_, ok2 = args[1].(bool) _, ok2 = args[1].(bool)
} }
if !ok1 || !ok2 { if !ok1 || !ok2 {
err = fmt.Errorf("Optional arguments must be int and bool for %s", message) err = fmt.Errorf("optional arguments must be int and bool for %s", message)
return finalMessage, err return finalMessage, err
} }
finalMessage, err = jsonWithArgs(message, id, args) finalMessage, err = jsonWithArgs(message, id, args)
// One optional string, two optional ints // One optional string, two optional ints
case "listtransactions": case "listtransactions":
if len(args) > 3 { if len(args) > 3 {
err = fmt.Errorf("Wrong number of arguments for %s", message) err = fmt.Errorf("wrong number of arguments for %s", message)
return finalMessage, err return finalMessage, err
} }
ok1 := true ok1 := true
@ -330,14 +330,14 @@ func CreateMessageWithId(message string, id interface{}, args ...interface{}) ([
_, ok3 = args[2].(int) _, ok3 = args[2].(int)
} }
if !ok1 || !ok2 || !ok3 { if !ok1 || !ok2 || !ok3 {
err = fmt.Errorf("Optional arguments must be string and up to two ints for %s", message) err = fmt.Errorf("optional arguments must be string and up to two ints for %s", message)
return finalMessage, err return finalMessage, err
} }
finalMessage, err = jsonWithArgs(message, id, args) finalMessage, err = jsonWithArgs(message, id, args)
// One required string, one optional string, one optional bool // One required string, one optional string, one optional bool
case "importprivkey": case "importprivkey":
if len(args) > 3 || len(args) == 0 { if len(args) > 3 || len(args) == 0 {
err = fmt.Errorf("Wrong number of arguments for %s", message) err = fmt.Errorf("wrong number of arguments for %s", message)
return finalMessage, err return finalMessage, err
} }
_, ok1 := args[0].(string) _, ok1 := args[0].(string)
@ -350,14 +350,14 @@ func CreateMessageWithId(message string, id interface{}, args ...interface{}) ([
_, ok3 = args[2].(bool) _, ok3 = args[2].(bool)
} }
if !ok1 || !ok2 || !ok3 { if !ok1 || !ok2 || !ok3 {
err = fmt.Errorf("Arguments must be string and optionally string and bool for %s", message) err = fmt.Errorf("arguments must be string and optionally string and bool for %s", message)
return finalMessage, err return finalMessage, err
} }
finalMessage, err = jsonWithArgs(message, id, args) finalMessage, err = jsonWithArgs(message, id, args)
// Two optional ints // Two optional ints
case "listunspent": case "listunspent":
if len(args) > 2 { if len(args) > 2 {
err = fmt.Errorf("Wrong number of arguments for %s", message) err = fmt.Errorf("wrong number of arguments for %s", message)
return finalMessage, err return finalMessage, err
} }
ok1 := true ok1 := true
@ -369,14 +369,14 @@ func CreateMessageWithId(message string, id interface{}, args ...interface{}) ([
_, ok2 = args[1].(int) _, ok2 = args[1].(int)
} }
if !ok1 || !ok2 { if !ok1 || !ok2 {
err = fmt.Errorf("Optional arguments must be ints for %s", message) err = fmt.Errorf("optional arguments must be ints for %s", message)
return finalMessage, err return finalMessage, err
} }
finalMessage, err = jsonWithArgs(message, id, args) finalMessage, err = jsonWithArgs(message, id, args)
// Two optional strings // Two optional strings
case "listsinceblock": case "listsinceblock":
if len(args) > 2 { if len(args) > 2 {
err = fmt.Errorf("Wrong number of arguments for %s", message) err = fmt.Errorf("wrong number of arguments for %s", message)
return finalMessage, err return finalMessage, err
} }
ok1 := true ok1 := true
@ -388,7 +388,7 @@ func CreateMessageWithId(message string, id interface{}, args ...interface{}) ([
_, ok2 = args[1].(string) _, ok2 = args[1].(string)
} }
if !ok1 || !ok2 { if !ok1 || !ok2 {
err = fmt.Errorf("Optional arguments must be strings for %s", message) err = fmt.Errorf("optional arguments must be strings for %s", message)
return finalMessage, err return finalMessage, err
} }
finalMessage, err = jsonWithArgs(message, id, args) finalMessage, err = jsonWithArgs(message, id, args)
@ -397,7 +397,7 @@ func CreateMessageWithId(message string, id interface{}, args ...interface{}) ([
// two optional strings. // two optional strings.
case "sendfrom": case "sendfrom":
if len(args) > 6 || len(args) < 3 { if len(args) > 6 || len(args) < 3 {
err = fmt.Errorf("Wrong number of arguments for %s", message) err = fmt.Errorf("wrong number of arguments for %s", message)
return finalMessage, err return finalMessage, err
} }
_, ok1 := args[0].(string) _, ok1 := args[0].(string)
@ -416,7 +416,7 @@ func CreateMessageWithId(message string, id interface{}, args ...interface{}) ([
_, ok6 = args[5].(string) _, ok6 = args[5].(string)
} }
if !ok1 || !ok2 || !ok3 || !ok4 || !ok5 || !ok6 { if !ok1 || !ok2 || !ok3 || !ok4 || !ok5 || !ok6 {
err = fmt.Errorf("Arguments must be string, string, float64 and optionally int and two strings for %s", message) err = fmt.Errorf("arguments must be string, string, float64 and optionally int and two strings for %s", message)
return finalMessage, err return finalMessage, err
} }
finalMessage, err = jsonWithArgs(message, id, args) finalMessage, err = jsonWithArgs(message, id, args)
@ -424,7 +424,7 @@ func CreateMessageWithId(message string, id interface{}, args ...interface{}) ([
// one optional string. // one optional string.
case "move": case "move":
if len(args) > 5 || len(args) < 3 { if len(args) > 5 || len(args) < 3 {
err = fmt.Errorf("Wrong number of arguments for %s", message) err = fmt.Errorf("wrong number of arguments for %s", message)
return finalMessage, err return finalMessage, err
} }
_, ok1 := args[0].(string) _, ok1 := args[0].(string)
@ -439,14 +439,14 @@ func CreateMessageWithId(message string, id interface{}, args ...interface{}) ([
_, ok5 = args[4].(string) _, ok5 = args[4].(string)
} }
if !ok1 || !ok2 || !ok3 || !ok4 || !ok5 { if !ok1 || !ok2 || !ok3 || !ok4 || !ok5 {
err = fmt.Errorf("Arguments must be string, string, float64 and optionally int and string for %s", message) err = fmt.Errorf("arguments must be string, string, float64 and optionally int and string for %s", message)
return finalMessage, err return finalMessage, err
} }
finalMessage, err = jsonWithArgs(message, id, args) finalMessage, err = jsonWithArgs(message, id, args)
// One required strings, one required float, two optional strings // One required strings, one required float, two optional strings
case "sendtoaddress": case "sendtoaddress":
if len(args) > 4 || len(args) < 2 { if len(args) > 4 || len(args) < 2 {
err = fmt.Errorf("Wrong number of arguments for %s", message) err = fmt.Errorf("wrong number of arguments for %s", message)
return finalMessage, err return finalMessage, err
} }
_, ok1 := args[0].(string) _, ok1 := args[0].(string)
@ -460,14 +460,14 @@ func CreateMessageWithId(message string, id interface{}, args ...interface{}) ([
_, ok4 = args[3].(string) _, ok4 = args[3].(string)
} }
if !ok1 || !ok2 || !ok3 || !ok4 { if !ok1 || !ok2 || !ok3 || !ok4 {
err = fmt.Errorf("Arguments must be string, float64 and optionally two strings for %s", message) err = fmt.Errorf("arguments must be string, float64 and optionally two strings for %s", message)
return finalMessage, err return finalMessage, err
} }
finalMessage, err = jsonWithArgs(message, id, args) finalMessage, err = jsonWithArgs(message, id, args)
// required int, required pair of keys (string), optional string // required int, required pair of keys (string), optional string
case "addmultisignaddress": case "addmultisignaddress":
if len(args) > 4 || len(args) < 3 { if len(args) > 4 || len(args) < 3 {
err = fmt.Errorf("Wrong number of arguments for %s", message) err = fmt.Errorf("wrong number of arguments for %s", message)
return finalMessage, err return finalMessage, err
} }
_, ok1 := args[0].(int) _, ok1 := args[0].(int)
@ -478,14 +478,14 @@ func CreateMessageWithId(message string, id interface{}, args ...interface{}) ([
_, ok4 = args[2].(string) _, ok4 = args[2].(string)
} }
if !ok1 || !ok2 || !ok3 || !ok4 { if !ok1 || !ok2 || !ok3 || !ok4 {
err = fmt.Errorf("Arguments must be int, two string and optionally one for %s", message) err = fmt.Errorf("arguments must be int, two string and optionally one for %s", message)
return finalMessage, err return finalMessage, err
} }
finalMessage, err = jsonWithArgs(message, id, args) finalMessage, err = jsonWithArgs(message, id, args)
// Must be a set of string, int, string, float (any number of those). // Must be a set of string, int, string, float (any number of those).
case "createrawtransaction": case "createrawtransaction":
if len(args)%4 != 0 || len(args) == 0 { if len(args)%4 != 0 || len(args) == 0 {
err = fmt.Errorf("Wrong number of arguments for %s", message) err = fmt.Errorf("wrong number of arguments for %s", message)
return finalMessage, err return finalMessage, err
} }
type vlist struct { type vlist struct {
@ -494,13 +494,13 @@ func CreateMessageWithId(message string, id interface{}, args ...interface{}) ([
} }
vList := make([]vlist, len(args)/4) vList := make([]vlist, len(args)/4)
addresses := make(map[string]float64) addresses := make(map[string]float64)
for i := 0; i < len(args)/4; i += 1 { for i := 0; i < len(args)/4; i++ {
txid, ok1 := args[(i*4)+0].(string) txid, ok1 := args[(i*4)+0].(string)
vout, ok2 := args[(i*4)+1].(uint32) vout, ok2 := args[(i*4)+1].(uint32)
add, ok3 := args[(i*4)+2].(string) add, ok3 := args[(i*4)+2].(string)
amt, ok4 := args[(i*4)+3].(float64) amt, ok4 := args[(i*4)+3].(float64)
if !ok1 || !ok2 || !ok3 || !ok4 { if !ok1 || !ok2 || !ok3 || !ok4 {
err = fmt.Errorf("Incorrect arguement types.") err = fmt.Errorf("incorrect arguement types")
return finalMessage, err return finalMessage, err
} }
vList[i].Txid = txid vList[i].Txid = txid
@ -511,14 +511,14 @@ func CreateMessageWithId(message string, id interface{}, args ...interface{}) ([
// string, string/float pairs, optional int, and string // string, string/float pairs, optional int, and string
case "sendmany": case "sendmany":
if len(args) < 3 { if len(args) < 3 {
err = fmt.Errorf("Wrong number of arguments for %s", message) err = fmt.Errorf("wrong number of arguments for %s", message)
return finalMessage, err return finalMessage, err
} }
var minconf int var minconf int
var comment string var comment string
_, ok1 := args[0].(string) _, ok1 := args[0].(string)
if !ok1 { if !ok1 {
err = fmt.Errorf("Incorrect arguement types.") err = fmt.Errorf("incorrect arguement types")
return finalMessage, err return finalMessage, err
} }
addresses := make(map[string]float64) addresses := make(map[string]float64)
@ -528,7 +528,7 @@ func CreateMessageWithId(message string, id interface{}, args ...interface{}) ([
if len(args) > i+1 { if len(args) > i+1 {
amt, ok2 := args[i+1].(float64) amt, ok2 := args[i+1].(float64)
if !ok2 { if !ok2 {
err = fmt.Errorf("Incorrect arguement types.") err = fmt.Errorf("incorrect arguement types")
return finalMessage, err return finalMessage, err
} }
// Put a single pair into addresses // Put a single pair into addresses
@ -551,12 +551,12 @@ func CreateMessageWithId(message string, id interface{}, args ...interface{}) ([
// bool and an array of stuff // bool and an array of stuff
case "lockunspent": case "lockunspent":
if len(args) < 2 { if len(args) < 2 {
err = fmt.Errorf("Wrong number of arguments for %s", message) err = fmt.Errorf("wrong number of arguments for %s", message)
return finalMessage, err return finalMessage, err
} }
_, ok1 := args[0].(bool) _, ok1 := args[0].(bool)
if !ok1 { if !ok1 {
err = fmt.Errorf("Incorrect arguement types.") err = fmt.Errorf("incorrect arguement types")
return finalMessage, err return finalMessage, err
} }
finalMessage, err = jsonWithArgs(message, id, args) finalMessage, err = jsonWithArgs(message, id, args)
@ -564,12 +564,12 @@ func CreateMessageWithId(message string, id interface{}, args ...interface{}) ([
// and one string along with another optional string. // and one string along with another optional string.
case "signrawtransaction": case "signrawtransaction":
if len(args) < 1 { if len(args) < 1 {
err = fmt.Errorf("Wrong number of arguments for %s", message) err = fmt.Errorf("wrong number of arguments for %s", message)
return finalMessage, err return finalMessage, err
} }
_, ok1 := args[0].(string) _, ok1 := args[0].(string)
if !ok1 { if !ok1 {
err = fmt.Errorf("Incorrect arguement types.") err = fmt.Errorf("incorrect arguement types")
return finalMessage, err return finalMessage, err
} }
type txlist struct { type txlist struct {
@ -584,7 +584,7 @@ func CreateMessageWithId(message string, id interface{}, args ...interface{}) ([
vout, ok3 := args[2].(uint32) vout, ok3 := args[2].(uint32)
spkey, ok4 := args[3].(string) spkey, ok4 := args[3].(string)
if !ok1 || !ok2 || !ok3 || !ok4 { if !ok1 || !ok2 || !ok3 || !ok4 {
err = fmt.Errorf("Incorrect arguement types.") err = fmt.Errorf("incorrect arguement types")
return finalMessage, err return finalMessage, err
} }
txList[0].Txid = txid txList[0].Txid = txid
@ -612,7 +612,7 @@ func CreateMessageWithId(message string, id interface{}, args ...interface{}) ([
finalMessage, err = jsonWithArgs(message, id, []interface{}{args[0].(string), txList}) finalMessage, err = jsonWithArgs(message, id, []interface{}{args[0].(string), txList})
// Any other message // Any other message
default: default:
err = fmt.Errorf("Not a valid command: %s", message) err = fmt.Errorf("not a valid command: %s", message)
} }
return finalMessage, err return finalMessage, err
} }
@ -626,7 +626,7 @@ func JSONGetMethod(message []byte) (string, error) {
var msg interface{} var msg interface{}
err := json.Unmarshal(message, &msg) err := json.Unmarshal(message, &msg)
if err != nil { if err != nil {
err := fmt.Errorf("Error, message does not appear to be valid json: %v", err) err := fmt.Errorf("error, message does not appear to be valid json: %v", err)
return method, err return method, err
} }
m := msg.(map[string]interface{}) m := msg.(map[string]interface{})
@ -636,7 +636,7 @@ func JSONGetMethod(message []byte) (string, error) {
} }
} }
if method == "" { if method == "" {
err := fmt.Errorf("Error, no method specified.") err := fmt.Errorf("error, no method specified")
return method, err return method, err
} }
return method, err return method, err
@ -669,12 +669,12 @@ func rpcCommand(user string, password string, server string, message []byte,
body, err := rpcRawCommand(user, password, server, message, https, body, err := rpcRawCommand(user, password, server, message, https,
certificates, skipverify) certificates, skipverify)
if err != nil { if err != nil {
err := fmt.Errorf("Error getting json reply: %v", err) err := fmt.Errorf("error getting json reply: %v", err)
return result, err return result, err
} }
result, err = ReadResultCmd(method, body) result, err = ReadResultCmd(method, body)
if err != nil { if err != nil {
err := fmt.Errorf("Error reading json message: %v", err) err := fmt.Errorf("error reading json message: %v", err)
return result, err return result, err
} }
return result, err return result, err
@ -704,18 +704,18 @@ func rpcRawCommand(user string, password string, server string,
var msg interface{} var msg interface{}
err := json.Unmarshal(message, &msg) err := json.Unmarshal(message, &msg)
if err != nil { if err != nil {
err := fmt.Errorf("Error, message does not appear to be valid json: %v", err) err := fmt.Errorf("error, message does not appear to be valid json: %v", err)
return result, err return result, err
} }
resp, err := jsonRpcSend(user, password, server, message, https, resp, err := jsonRpcSend(user, password, server, message, https,
certificates, skipverify) certificates, skipverify)
if err != nil { if err != nil {
err := fmt.Errorf("Error sending json message: " + err.Error()) err := fmt.Errorf("error sending json message: " + err.Error())
return result, err return result, err
} }
result, err = GetRaw(resp.Body) result, err = GetRaw(resp.Body)
if err != nil { if err != nil {
err := fmt.Errorf("Error getting json reply: %v", err) err := fmt.Errorf("error getting json reply: %v", err)
return result, err return result, err
} }
return result, err return result, err
@ -779,11 +779,11 @@ func JSONToAmount(jsonAmount float64) (int64, error) {
var amount int64 var amount int64
var err error var err error
if jsonAmount > 1.797693134862315708145274237317043567981e+300 { if jsonAmount > 1.797693134862315708145274237317043567981e+300 {
err := fmt.Errorf("Error %v is too large to convert", jsonAmount) err := fmt.Errorf("error %v is too large to convert", jsonAmount)
return amount, err return amount, err
} }
if jsonAmount < -1.797693134862315708145274237317043567981e+300 { if jsonAmount < -1.797693134862315708145274237317043567981e+300 {
err := fmt.Errorf("Error %v is too small to convert", jsonAmount) err := fmt.Errorf("error %v is too small to convert", jsonAmount)
return amount, err return amount, err
} }
tempVal := 1e8 * jsonAmount tempVal := 1e8 * jsonAmount

View file

@ -279,7 +279,7 @@ func TestRpcReply(t *testing.T) {
} }
var idtests = []struct { var idtests = []struct {
testId []interface{} testID []interface{}
pass bool pass bool
}{ }{
{[]interface{}{"string test"}, true}, {[]interface{}{"string test"}, true},
@ -293,7 +293,7 @@ var idtests = []struct {
// types). // types).
func TestIsValidIdType(t *testing.T) { func TestIsValidIdType(t *testing.T) {
for _, tt := range idtests { for _, tt := range idtests {
res := btcjson.IsValidIdType(tt.testId[0]) res := btcjson.IsValidIdType(tt.testID[0])
if res != tt.pass { if res != tt.pass {
t.Errorf("Incorrect type result %v.", tt) t.Errorf("Incorrect type result %v.", tt)
} }

View file

@ -533,7 +533,7 @@ func NewAddNodeCmd(id interface{}, addr string, subcmd string) (
case "onetry": case "onetry":
// fine // fine
default: default:
return nil, errors.New("Invalid subcommand for addnode") return nil, errors.New("invalid subcommand for addnode")
} }
return &AddNodeCmd{ return &AddNodeCmd{
@ -1714,7 +1714,7 @@ var _ Cmd = &GetBalanceCmd{}
// and an int for minconf may be provided as arguments. // and an int for minconf may be provided as arguments.
func NewGetBalanceCmd(id interface{}, optArgs ...interface{}) (*GetBalanceCmd, error) { func NewGetBalanceCmd(id interface{}, optArgs ...interface{}) (*GetBalanceCmd, error) {
var account string var account string
var minconf int = 1 var minconf = 1
if len(optArgs) > 2 { if len(optArgs) > 2 {
return nil, ErrWrongNumberOfParams return nil, ErrWrongNumberOfParams
@ -1991,7 +1991,7 @@ type GetBlockChainInfoCmd struct {
// Enforce that GetBlockChainInfoCmd satisifies the Cmd interface. // Enforce that GetBlockChainInfoCmd satisifies the Cmd interface.
var _ Cmd = &GetBlockChainInfoCmd{} var _ Cmd = &GetBlockChainInfoCmd{}
// NewBlockChainInfoCmd creates a new GetBlockChainInfoCmd. // NewGetBlockChainInfoCmd creates a new GetBlockChainInfoCmd.
func NewGetBlockChainInfoCmd(id interface{}) (*GetBlockChainInfoCmd, error) { func NewGetBlockChainInfoCmd(id interface{}) (*GetBlockChainInfoCmd, error) {
return &GetBlockChainInfoCmd{ return &GetBlockChainInfoCmd{
id: id, id: id,
@ -2669,7 +2669,7 @@ type GetNetworkInfoCmd struct {
// Enforce that GetNetworkInfoCmd satisifies the Cmd interface. // Enforce that GetNetworkInfoCmd satisifies the Cmd interface.
var _ Cmd = &GetNetworkInfoCmd{} var _ Cmd = &GetNetworkInfoCmd{}
// NewNetworkInfoCmd creates a new GetNetworkInfoCmd. // NewGetNetworkInfoCmd creates a new GetNetworkInfoCmd.
func NewGetNetworkInfoCmd(id interface{}) (*GetNetworkInfoCmd, error) { func NewGetNetworkInfoCmd(id interface{}) (*GetNetworkInfoCmd, error) {
return &GetNetworkInfoCmd{ return &GetNetworkInfoCmd{
id: id, id: id,
@ -3285,7 +3285,7 @@ func NewGetReceivedByAccountCmd(id interface{}, account string, optArgs ...int)
if len(optArgs) > 1 { if len(optArgs) > 1 {
return nil, ErrTooManyOptArgs return nil, ErrTooManyOptArgs
} }
var minconf int = 1 var minconf = 1
if len(optArgs) > 0 { if len(optArgs) > 0 {
minconf = optArgs[0] minconf = optArgs[0]
} }
@ -3374,7 +3374,7 @@ func NewGetReceivedByAddressCmd(id interface{}, address string, optArgs ...int)
if len(optArgs) > 1 { if len(optArgs) > 1 {
return nil, ErrTooManyOptArgs return nil, ErrTooManyOptArgs
} }
var minconf int = 1 var minconf = 1
if len(optArgs) > 0 { if len(optArgs) > 0 {
minconf = optArgs[0] minconf = optArgs[0]
} }

File diff suppressed because it is too large Load diff

View file

@ -70,7 +70,7 @@ func GetRaw(resp io.ReadCloser) ([]byte, error) {
body, err := ioutil.ReadAll(resp) body, err := ioutil.ReadAll(resp)
resp.Close() resp.Close()
if err != nil { if err != nil {
err = fmt.Errorf("Error reading json reply: %v", err) err = fmt.Errorf("error reading json reply: %v", err)
return body, err return body, err
} }
return body, nil return body, nil

View file

@ -71,7 +71,7 @@ type GetBlockChainInfoResult struct {
ChainWork string `json:"chainwork"` ChainWork string `json:"chainwork"`
} }
// GetBlockTemplateResultTransaction models the transactions field of the // GetBlockTemplateResultTx models the transactions field of the
// getblocktemplate command. // getblocktemplate command.
type GetBlockTemplateResultTx struct { type GetBlockTemplateResultTx struct {
Data string `json:"data"` Data string `json:"data"`
@ -437,9 +437,9 @@ func ReadResultCmd(cmd string, message []byte) (Reply, error) {
err = json.Unmarshal(message, &objmap) err = json.Unmarshal(message, &objmap)
if err != nil { if err != nil {
if strings.Contains(string(message), "401 Unauthorized.") { if strings.Contains(string(message), "401 Unauthorized.") {
err = fmt.Errorf("Authentication error.") err = fmt.Errorf("authentication error")
} else { } else {
err = fmt.Errorf("Error unmarshalling json reply: %v", err) err = fmt.Errorf("error unmarshalling json reply: %v", err)
} }
return result, err return result, err
} }
@ -448,12 +448,12 @@ func ReadResultCmd(cmd string, message []byte) (Reply, error) {
var id interface{} var id interface{}
err = json.Unmarshal(objmap["error"], &jsonErr) err = json.Unmarshal(objmap["error"], &jsonErr)
if err != nil { if err != nil {
err = fmt.Errorf("Error unmarshalling json reply: %v", err) err = fmt.Errorf("error unmarshalling json reply: %v", err)
return result, err return result, err
} }
err = json.Unmarshal(objmap["id"], &id) err = json.Unmarshal(objmap["id"], &id)
if err != nil { if err != nil {
err = fmt.Errorf("Error unmarshalling json reply: %v", err) err = fmt.Errorf("error unmarshalling json reply: %v", err)
return result, err return result, err
} }
@ -709,7 +709,7 @@ func ReadResultCmd(cmd string, message []byte) (Reply, error) {
} }
} }
if err != nil { if err != nil {
err = fmt.Errorf("Error unmarshalling json reply: %v", err) err = fmt.Errorf("error unmarshalling json reply: %v", err)
return result, err return result, err
} }
// Only want the error field when there is an actual error to report. // Only want the error field when there is an actual error to report.