Replace common error with defined value.
This commit is contained in:
parent
6aea36c550
commit
766d571317
2 changed files with 14 additions and 16 deletions
26
jsonapi.go
26
jsonapi.go
|
@ -6,9 +6,14 @@ package btcjson
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// ErrIncorrectArgTypes describes an error where the wrong argument types
|
||||
// are present.
|
||||
var ErrIncorrectArgTypes = errors.New("incorrect arguement types")
|
||||
|
||||
// Message contains a message to be sent to the bitcoin client.
|
||||
type Message struct {
|
||||
Jsonrpc string `json:"jsonrpc"`
|
||||
|
@ -500,8 +505,7 @@ func CreateMessageWithId(message string, id interface{}, args ...interface{}) ([
|
|||
add, ok3 := args[(i*4)+2].(string)
|
||||
amt, ok4 := args[(i*4)+3].(float64)
|
||||
if !ok1 || !ok2 || !ok3 || !ok4 {
|
||||
err = fmt.Errorf("incorrect arguement types")
|
||||
return finalMessage, err
|
||||
return finalMessage, ErrIncorrectArgTypes
|
||||
}
|
||||
vList[i].Txid = txid
|
||||
vList[i].Vout = vout
|
||||
|
@ -518,8 +522,7 @@ func CreateMessageWithId(message string, id interface{}, args ...interface{}) ([
|
|||
var comment string
|
||||
_, ok1 := args[0].(string)
|
||||
if !ok1 {
|
||||
err = fmt.Errorf("incorrect arguement types")
|
||||
return finalMessage, err
|
||||
return finalMessage, ErrIncorrectArgTypes
|
||||
}
|
||||
addresses := make(map[string]float64)
|
||||
for i := 1; i < len(args); i += 2 {
|
||||
|
@ -528,8 +531,7 @@ func CreateMessageWithId(message string, id interface{}, args ...interface{}) ([
|
|||
if len(args) > i+1 {
|
||||
amt, ok2 := args[i+1].(float64)
|
||||
if !ok2 {
|
||||
err = fmt.Errorf("incorrect arguement types")
|
||||
return finalMessage, err
|
||||
return finalMessage, ErrIncorrectArgTypes
|
||||
}
|
||||
// Put a single pair into addresses
|
||||
addresses[add] = amt
|
||||
|
@ -556,8 +558,7 @@ func CreateMessageWithId(message string, id interface{}, args ...interface{}) ([
|
|||
}
|
||||
_, ok1 := args[0].(bool)
|
||||
if !ok1 {
|
||||
err = fmt.Errorf("incorrect arguement types")
|
||||
return finalMessage, err
|
||||
return finalMessage, ErrIncorrectArgTypes
|
||||
}
|
||||
finalMessage, err = jsonWithArgs(message, id, args)
|
||||
// one required string (hex) and optional sets of one string, one int,
|
||||
|
@ -569,8 +570,7 @@ func CreateMessageWithId(message string, id interface{}, args ...interface{}) ([
|
|||
}
|
||||
_, ok1 := args[0].(string)
|
||||
if !ok1 {
|
||||
err = fmt.Errorf("incorrect arguement types")
|
||||
return finalMessage, err
|
||||
return finalMessage, ErrIncorrectArgTypes
|
||||
}
|
||||
type txlist struct {
|
||||
Txid string `json:"txid"`
|
||||
|
@ -584,8 +584,7 @@ func CreateMessageWithId(message string, id interface{}, args ...interface{}) ([
|
|||
vout, ok3 := args[2].(uint32)
|
||||
spkey, ok4 := args[3].(string)
|
||||
if !ok1 || !ok2 || !ok3 || !ok4 {
|
||||
err = fmt.Errorf("incorrect arguement types")
|
||||
return finalMessage, err
|
||||
return finalMessage, ErrIncorrectArgTypes
|
||||
}
|
||||
txList[0].Txid = txid
|
||||
txList[0].Vout = vout
|
||||
|
@ -600,8 +599,7 @@ func CreateMessageWithId(message string, id interface{}, args ...interface{}) ([
|
|||
spkey, ok3 := args[(i*4)+3].(string)
|
||||
pkey, ok4 := args[(i*4)+4].(string)
|
||||
if !ok1 || !ok2 || !ok3 || !ok4 {
|
||||
err = fmt.Errorf("Incorrect arguement types.")
|
||||
return finalMessage, err
|
||||
return finalMessage, ErrIncorrectArgTypes
|
||||
}
|
||||
txList[i].Txid = txid
|
||||
txList[i].Vout = vout
|
||||
|
|
|
@ -202,7 +202,7 @@ github.com/conformal/btcjson/jsoncmd.go GetNetTotalsCmd.Method 100.00% (1/1
|
|||
github.com/conformal/btcjson/jsoncmd.go ListReceivedByAccountCmd.Id 100.00% (1/1)
|
||||
github.com/conformal/btcjson/jsoncmd.go ListLockUnspentCmd.Method 100.00% (1/1)
|
||||
github.com/conformal/btcjson/jsoncmd.go GetNetworkHashPSCmd.Id 100.00% (1/1)
|
||||
github.com/conformal/btcjson/jsonapi.go CreateMessageWithId 96.18% (327/340)
|
||||
github.com/conformal/btcjson/jsonapi.go CreateMessageWithId 96.11% (321/334)
|
||||
github.com/conformal/btcjson/jsoncmd.go SendFromCmd.MarshalJSON 92.86% (13/14)
|
||||
github.com/conformal/btcjson/jsoncmd.go SendManyCmd.MarshalJSON 92.86% (13/14)
|
||||
github.com/conformal/btcjson/jsoncmd.go MoveCmd.MarshalJSON 91.67% (11/12)
|
||||
|
@ -410,5 +410,5 @@ github.com/conformal/btcjson/jsoncmd.go RegisterCustomCmd 0.00% (0/1)
|
|||
github.com/conformal/btcjson/jsonapi.go TlsRpcRawCommand 0.00% (0/1)
|
||||
github.com/conformal/btcjson/jsonresults.go Vin.IsCoinBase 0.00% (0/1)
|
||||
github.com/conformal/btcjson/jsonapi.go RpcRawCommand 0.00% (0/1)
|
||||
github.com/conformal/btcjson --------------------------------------- 77.82% (2365/3039)
|
||||
github.com/conformal/btcjson --------------------------------------- 77.78% (2359/3033)
|
||||
|
||||
|
|
Loading…
Reference in a new issue