Documentation
¶
Overview ¶
Package utils is used for generic methods and values that are used across all packages
Index ¶
- Constants
- Variables
- func DeriveAddresses(hdKey *bip32.ExtendedKey, num uint32) (external, internal string, err error)
- func DeriveChildKeyFromHex(hdKey *bip32.ExtendedKey, hexHash string) (*bip32.ExtendedKey, error)
- func DerivePrivateKeyFromHex(hdKey *bip32.ExtendedKey, hexString string) (*bec.PrivateKey, error)
- func DerivePublicKey(hdKey *bip32.ExtendedKey, chain uint32, num uint32) (*bec.PublicKey, error)
- func DerivePublicKeyFromHex(hdKey *bip32.ExtendedKey, hexString string) (*bec.PublicKey, error)
- func GetChildNumsFromHex(hexHash string) ([]uint32, error)
- func GetDestinationType(lockingScript string) string
- func GetInputSizeForType(inputType string) uint64
- func GetModelBoolAttribute(model interface{}, attribute string) *bool
- func GetModelName(model interface{}) *string
- func GetModelStringAttribute(model interface{}, attribute string) *string
- func GetModelTableName(model interface{}) *string
- func GetModelType(model interface{}) reflect.Type
- func GetModelUnset(model interface{}) map[string]bool
- func GetOutputSize(lockingScript string) uint64
- func GetTransactionIDFromHex(hex string) (string, error)
- func Hash(data string) string
- func IsMetanet(lockingScript string) bool
- func IsModelSlice(model interface{}) bool
- func IsMultiSig(lockingScript string) bool
- func IsOpReturn(lockingScript string) bool
- func IsP2PKH(lockingScript string) bool
- func IsP2SH(lockingScript string) bool
- func MarshalNullString(x NullString) graphql.Marshaler
- func MarshalNullTime(x NullTime) graphql.Marshaler
- func RandomHex(n int) (string, error)
- func StringInSlice(a string, list []string) bool
- func ValidateXPub(rawKey string) (*bip32.ExtendedKey, error)
- type FeeUnit
- type NullString
- type NullTime
Constants ¶
const ( // ChainInternal internal chain num ChainInternal = uint32(1) // ChainExternal external chain num ChainExternal = uint32(0) )
const ScriptHashType = "scripthash"
ScriptHashType is the type for the deprecated script hash
const ScriptMetanet = "metanet"
ScriptMetanet is the type for a metanet transaction
const ScriptTypeMultiSig = bscript2.ScriptTypeMultiSig
ScriptTypeMultiSig alias from bscript
const ScriptTypeNonStandard = bscript2.ScriptTypeNonStandard
ScriptTypeNonStandard alias from bscript
const ScriptTypeNullData = bscript2.ScriptTypeNullData
ScriptTypeNullData alias from bscript
const ScriptTypePubKeyHash = bscript2.ScriptTypePubKeyHash
ScriptTypePubKeyHash alias from bscript
Variables ¶
var ErrDeriveFailed = errors.New("derive addresses failed, missing addresses")
ErrDeriveFailed is when the address derivation failed
var ErrHDKeyNil = errors.New("hd key is nil")
ErrHDKeyNil is when the HD Key is nil
var ErrXpubInvalidLength = errors.New("xpub is an invalid length")
ErrXpubInvalidLength is when the length of the xpub does not match the desired length
var ErrXpubNoMatch = errors.New("xpub key does not match raw key")
ErrXpubNoMatch is when the derived xpub key does not match the key given
Functions ¶
func DeriveAddresses ¶
func DeriveAddresses(hdKey *bip32.ExtendedKey, num uint32) (external, internal string, err error)
DeriveAddresses will derive the internal and external address from a key
func DeriveChildKeyFromHex ¶
func DeriveChildKeyFromHex(hdKey *bip32.ExtendedKey, hexHash string) (*bip32.ExtendedKey, error)
DeriveChildKeyFromHex derive the child extended key from the hex string
func DerivePrivateKeyFromHex ¶
func DerivePrivateKeyFromHex(hdKey *bip32.ExtendedKey, hexString string) (*bec.PrivateKey, error)
DerivePrivateKeyFromHex will derive the private key from the extended key using the hex as the derivation paths
func DerivePublicKey ¶
DerivePublicKey will derive the internal and external address from a key
func DerivePublicKeyFromHex ¶
DerivePublicKeyFromHex will derive the public key from the extended key using the hex as the derivation paths
func GetChildNumsFromHex ¶
GetChildNumsFromHex get an array of uint32 numbers from the hex string
func GetDestinationType ¶
GetDestinationType Get the type of output script destination
func GetInputSizeForType ¶
GetInputSizeForType get an estimated size for the input based on the type
func GetModelBoolAttribute ¶
GetModelBoolAttribute the attribute from the model as a bool
func GetModelName ¶
func GetModelName(model interface{}) *string
GetModelName get the name of the model via reflection
func GetModelStringAttribute ¶
GetModelStringAttribute the attribute from the model as a string
func GetModelTableName ¶
func GetModelTableName(model interface{}) *string
GetModelTableName get the db table name of the model via reflection
func GetModelType ¶
GetModelType get the model type of the model interface via reflection
func GetModelUnset ¶
GetModelUnset gets any empty values on the model and makes sure the update actually unsets those values in the database, otherwise this never happens, and we cannot unset
func GetOutputSize ¶
GetOutputSize get an estimated size for the output based on the type
func GetTransactionIDFromHex ¶
GetTransactionIDFromHex get the transaction ID from the given transaction hex
func IsModelSlice ¶
func IsModelSlice(model interface{}) bool
IsModelSlice returns true if the given interface is a slice of models
func IsMultiSig ¶
IsMultiSig Check whether the given string is a multi-sig locking script
func IsOpReturn ¶
IsOpReturn Check whether the given string is an op_return
func MarshalNullString ¶
func MarshalNullString(x NullString) graphql.Marshaler
MarshalNullString is used by graphql to marshal into a string
func MarshalNullTime ¶
MarshalNullTime is used by GraphQL to marshal the value
func StringInSlice ¶
StringInSlice check whether the string already is in the slice
func ValidateXPub ¶
func ValidateXPub(rawKey string) (*bip32.ExtendedKey, error)
ValidateXPub will check the xPub key for length & validation
Types ¶
type NullString ¶
type NullString struct {
sql.NullString
}
NullString wrapper around sql.NullString
func UnmarshalNullString ¶
func UnmarshalNullString(s interface{}) (NullString, error)
UnmarshalNullString is used by graphql to unmarshal from a NullString into a string
func (NullString) IsZero ¶
func (x NullString) IsZero() bool
IsZero method is called by bson.IsZero in Mongo for type = NullTime
func (*NullString) MarshalBSONValue ¶
func (x *NullString) MarshalBSONValue() (bsontype.Type, []byte, error)
MarshalBSONValue method is called by bson.Marshal in Mongo for type = NullString
func (*NullString) MarshalJSON ¶
func (x *NullString) MarshalJSON() ([]byte, error)
MarshalJSON method is called by the JSON marshaller
func (*NullString) UnmarshalBSONValue ¶
func (x *NullString) UnmarshalBSONValue(t bsontype.Type, data []byte) error
UnmarshalBSONValue method is called by bson.Unmarshal in Mongo for type = NullString
func (*NullString) UnmarshalJSON ¶
func (x *NullString) UnmarshalJSON(data []byte) error
UnmarshalJSON method is called by the JSON unmarshaller
type NullTime ¶
NullTime wrapper around sql.NullTime
func UnmarshalNullTime ¶
UnmarshalNullTime is used by GraphQL to unmarshal the value
func (*NullTime) MarshalBSONValue ¶
MarshalBSONValue method is called by bson.Marshal in Mongo for type = NullTime
func (*NullTime) MarshalJSON ¶
MarshalJSON method is called by the JSON marshaller
func (*NullTime) UnmarshalBSONValue ¶
UnmarshalBSONValue method is called by bson.Unmarshal in Mongo for type = NullTime
func (*NullTime) UnmarshalJSON ¶
UnmarshalJSON method is called by the JSON unmarshaller