common

package
v0.0.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 29, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// HashLength is the expected length of the hash
	HashLength = 32
	// AddressLength is the expected length of the address
	AddressLength = 32
	// SignatureLength is the expected length of the signature
	SignatureLength = 64
)

Lengths of signatures and addresses in bytes.

Variables

This section is empty.

Functions

This section is empty.

Types

type Address

type Address [AddressLength]byte

Address The address

func Base58ToAddress

func Base58ToAddress(b string) Address

Base58ToAddress returns Address with byte values of b.

func Base64ToAddress added in v0.0.3

func Base64ToAddress(b string) Address

Base64ToAddress returns Address with byte values of b.

func BigToAddress

func BigToAddress(b *big.Int) Address

BigToAddress returns Address with byte values of b.

func BytesToAddress

func BytesToAddress(b []byte) (a Address)

BytesToAddress returns Address with value b.

func StrToAddress added in v0.0.3

func StrToAddress(b string) Address

StrToAddress returns Address with byte values of b. Notice: only support base58/base64 str

func (Address) Base58

func (a Address) Base58() string

Base58 return base58 account

func (Address) Big

func (a Address) Big() *big.Int

Big return Address to *big.Int

func (Address) Bytes

func (a Address) Bytes() []byte

Bytes return Address bytes

func (Address) Cmp

func (a Address) Cmp(other Address) int

Cmp compares two addresses.

func (Address) ImplementsGraphQLType

func (a Address) ImplementsGraphQLType(name string) bool

ImplementsGraphQLType returns true if Hash implements the specified GraphQL type.

func (Address) IsEmpty added in v0.0.7

func (a Address) IsEmpty() bool

func (Address) MarshalText

func (a Address) MarshalText() ([]byte, error)

MarshalText returns base58 str account

func (*Address) Scan

func (a *Address) Scan(src interface{}) error

Scan implements Scanner for database/sql.

func (*Address) SetBytes

func (a *Address) SetBytes(b []byte)

SetBytes sets the address to the value of b.

func (Address) String

func (a Address) String() string

String return base58 account

func (*Address) UnmarshalGraphQL

func (a *Address) UnmarshalGraphQL(input interface{}) error

UnmarshalGraphQL unmarshals the provided GraphQL query data.

func (*Address) UnmarshalJSON

func (a *Address) UnmarshalJSON(input []byte) error

UnmarshalJSON parses an account in base58 syntax.

func (*Address) UnmarshalText

func (a *Address) UnmarshalText(input []byte) error

UnmarshalText parses an account in base58 syntax.

func (Address) Value

func (a Address) Value() (driver.Value, error)

Value implements valuer for database/sql.

type Hash

type Hash [HashLength]byte

Hash The Hash

func Base58ToHash

func Base58ToHash(b string) Hash

Base58ToHash returns Hash with byte values of b.

func Base64ToHash added in v0.0.3

func Base64ToHash(b string) Hash

Base64ToHash returns Hash with byte values of b.

func BigToHash

func BigToHash(b *big.Int) Hash

BigToHash returns Hash with byte values of b.

func BytesToHash

func BytesToHash(b []byte) (h Hash)

BytesToHash returns Hash with value b.

func StrToHash added in v0.0.3

func StrToHash(b string) Hash

StrToHash returns Hash with byte values of b. Notice: only support base58/base64 str

func (Hash) Base58

func (h Hash) Base58() string

Base58 return base58 account

func (Hash) Big

func (h Hash) Big() *big.Int

Big return Hash to *big.Int

func (Hash) Bytes

func (h Hash) Bytes() []byte

Bytes return Hash bytes

func (Hash) Cmp

func (h Hash) Cmp(other Hash) int

Cmp compares two Hashes.

func (Hash) ImplementsGraphQLType

func (h Hash) ImplementsGraphQLType(name string) bool

ImplementsGraphQLType returns true if Hash implements the specified GraphQL type.

func (Hash) MarshalText

func (h Hash) MarshalText() ([]byte, error)

MarshalText returns base58 str hash

func (*Hash) Scan

func (h *Hash) Scan(src interface{}) error

Scan implements Scanner for database/sql.

func (*Hash) SetBytes

func (h *Hash) SetBytes(b []byte)

SetBytes sets the Hash to the value of b.

func (Hash) String

func (h Hash) String() string

String return base58 account

func (*Hash) UnmarshalGraphQL

func (h *Hash) UnmarshalGraphQL(input interface{}) error

UnmarshalGraphQL unmarshals the provided GraphQL query data.

func (*Hash) UnmarshalJSON

func (h *Hash) UnmarshalJSON(input []byte) error

UnmarshalJSON parses a hash in base58 syntax.

func (*Hash) UnmarshalText

func (h *Hash) UnmarshalText(input []byte) error

UnmarshalText parses a hash in base58 syntax.

func (Hash) Value

func (h Hash) Value() (driver.Value, error)

Value implements valuer for database/sql.

type Signature

type Signature [SignatureLength]byte

Signature The signature

func Base58ToSignature

func Base58ToSignature(b string) Signature

Base58ToSignature returns Signature with byte values of b.

func BigToSignature

func BigToSignature(b *big.Int) Signature

BigToSignature returns Signature with byte values of b.

func BytesToSignature

func BytesToSignature(b []byte) (a Signature)

BytesToSignature returns Signature with value b.

func (Signature) Base58

func (s Signature) Base58() string

Base58 return base58 account

func (Signature) Big

func (s Signature) Big() *big.Int

Big return Signature to *big.Int

func (Signature) Bytes

func (s Signature) Bytes() []byte

Bytes return Signature bytes

func (Signature) Cmp

func (s Signature) Cmp(other Signature) int

Cmp compares two addresses.

func (Signature) ImplementsGraphQLType

func (s Signature) ImplementsGraphQLType(name string) bool

ImplementsGraphQLType returns true if Hash implements the specified GraphQL type.

func (Signature) MarshalText

func (s Signature) MarshalText() ([]byte, error)

MarshalText returns base58 str account

func (*Signature) Scan

func (s *Signature) Scan(src interface{}) error

Scan implements Scanner for database/sql.

func (*Signature) SetBytes

func (s *Signature) SetBytes(b []byte)

SetBytes sets the address to the value of b.

func (Signature) Sign added in v0.0.3

func (s Signature) Sign(message []byte) []byte

func (Signature) String

func (s Signature) String() string

String return base58 account

func (*Signature) UnmarshalGraphQL

func (s *Signature) UnmarshalGraphQL(input interface{}) error

UnmarshalGraphQL unmarshals the provided GraphQL query dats.

func (*Signature) UnmarshalJSON

func (s *Signature) UnmarshalJSON(input []byte) error

UnmarshalJSON parses an account in base58 syntax.

func (*Signature) UnmarshalText

func (s *Signature) UnmarshalText(input []byte) error

UnmarshalText parses an account in base58 syntax.

func (Signature) Value

func (s Signature) Value() (driver.Value, error)

Value implements valuer for database/sql.

type SolData

type SolData struct {
	RawData  []byte
	Encoding string
}

SolData base58, base64 data

func (SolData) Base58

func (sd SolData) Base58() string

Base58 return base58 str

func (SolData) Base64

func (sd SolData) Base64() string

func (SolData) MarshalText

func (sd SolData) MarshalText() ([]byte, error)

MarshalText returns base58/base64 str

func (*SolData) SetBytes

func (sd *SolData) SetBytes(input []byte)

SetBytes sets the SolData to the value of sd. (default base58)

func (*SolData) SetSolData

func (sd *SolData) SetSolData(data []byte, encoding string)

SetSolData sets the SolData

func (SolData) String

func (sd SolData) String() string

String return base58 str

func (*SolData) UnmarshalJSON

func (sd *SolData) UnmarshalJSON(input []byte) error

UnmarshalJSON parses data in base58 syntax.

func (*SolData) UnmarshalText

func (sd *SolData) UnmarshalText(input []byte) error

UnmarshalText parses data in base58 syntax.

func (SolData) Value

func (sd SolData) Value() (driver.Value, error)

Value implements valuer for database/sql.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL