common

package
v1.0.11 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2020 License: GPL-3.0 Imports: 28 Imported by: 3

Documentation

Overview

Package common provides common data structures and common utility functions.

Index

Constants

View Source
const (
	RA  uint64 = 1
	KRA uint64 = 1000
	MRA uint64 = 1000000
	ZVC uint64 = 1000000000
)
View Source
const (
	//Elliptic curve parameters:
	PubKeyLength = 65 //Length of public key,1 bytes curve, 64 bytes x,y。
	SecKeyLength = 97 //length of private key,65 bytes pub, 32 bytes D。
	SignLength   = 65 //length of signature,32 bytes r & 32 bytes s & 1 byte recid.

	AddressLength     = 32 //Length of Address( golang.SHA3,256-bit)
	HashLength        = 32 //Length of Hash (golang.SHA3, 256-bit)。
	MinPasswordLength = 6
	MaxPasswordLength = 50
	DefaultPassword   = "Zvc123"
)
View Source
const (
	// Integer limit values.
	MaxInt8   = 1<<7 - 1
	MinInt8   = -1 << 7
	MaxInt16  = 1<<15 - 1
	MinInt16  = -1 << 15
	MaxInt32  = 1<<31 - 1
	MinInt32  = -1 << 31
	MaxInt64  = 1<<63 - 1
	MinInt64  = -1 << 63
	MaxUint8  = 1<<8 - 1
	MaxUint16 = 1<<16 - 1
	MaxUint32 = 1<<32 - 1
	MaxUint64 = 1<<64 - 1
)
View Source
const AddrPrefix = "zv"
View Source
const ChainDataVersion = 1
View Source
const ConsensusVersion = 1
View Source
const GzvVersion = "v1.0.11"
View Source
const HexPrefix = "0x"
View Source
const ProtocolVersion = 1

Variables

View Source
var (
	ErrEmptyStr   = fmt.Errorf("empty string")
	ErrIllegalStr = fmt.Errorf("illegal gasprice string")
)
View Source
var (
	ErrEmptyString       = &decError{"empty hex string"}
	ErrSyntax            = &decError{"invalid hex string"}
	ErrMissingPrefix     = &decError{"hex string without 0x prefix"}
	ErrMissingAddrPrefix = &decError{"address string without prefix"}
	ErrOddLength         = &decError{"hex string of odd length"}
	ErrEmptyNumber       = &decError{"hex string \"0x\""}
	ErrLeadingZero       = &decError{"hex number with leading zero digits"}
	ErrUint64Range       = &decError{"hex number > 64 bits"}
	ErrUintRange         = &decError{fmt.Sprintf("hex number > %d bits", uintBits)}
	ErrBig256Range       = &decError{"hex number > 256 bits"}
)
View Source
var (
	BonusStorageAddress        = BigToAddress(big.NewInt(0))
	MinerPoolAddr              = BigToAddress(big.NewInt(1)) // The Address storing total stakes of each roles and addresses of all active nodes
	RewardStoreAddr            = BigToAddress(big.NewInt(2)) // The Address storing the block hash corresponding to the reward transaction
	GroupTopAddress            = BigToAddress(big.NewInt(3)) //save the current top group
	MinerPoolTicketsAddr       = BigToAddress(big.NewInt(4)) // The Address storing all miner pool tickets
	FundGuardNodeAddr          = BigToAddress(big.NewInt(5)) // The Address storing all fund gurad nodes
	FullStakeGuardNodeAddr     = BigToAddress(big.NewInt(6)) // The Address storing all full stake guard nodes
	ScanAllFundGuardStatusAddr = BigToAddress(big.NewInt(7)) // The Address mark is scanned all fund guard nodes

)

Special account address Need to access by AccountDBTS for concurrent situations

View Source
var (
	PrefixMiner               = []byte("minfo")
	PrefixDetail              = []byte("dt")
	PrefixPoolProposal        = []byte("p")
	PrefixPoolVerifier        = []byte("v")
	KeyPoolProposalTotalStake = []byte("totalstake")
	KeyVote                   = []byte("votekey")
	KeyTickets                = []byte("tickets")
	KeyGuardNodes             = []byte("guard")
	KeyScanSixAddFiveNodes    = []byte("s1")
	KeyScanSixAddSixNodes     = []byte("s2")
)
View Source
var (
	Big1   = big.NewInt(1)
	Big2   = big.NewInt(2)
	Big3   = big.NewInt(3)
	Big0   = big.NewInt(0)
	Big32  = big.NewInt(32)
	Big256 = big.NewInt(0xff)
	Big257 = big.NewInt(257)

	ErrSelectGroupNil     = errors.New("selectGroupId is nil")
	ErrSelectGroupInequal = errors.New("selectGroupId not equal")
	ErrCreateBlockNil     = errors.New("createBlock is nil")
	ErrGroupNil           = errors.New("group is nil")
)
View Source
var EmptyHash = Hash{}
View Source
var InstanceIndex int
View Source
var (
	MaxBigUint64 = big.NewInt(0).SetUint64(MaxUint64)
)
View Source
var PunishmentDetailAddr = BigToAddress(big.NewInt(0))

Functions

func AbsInt

func AbsInt(x int) int

AbsInt returns the absolute value of the x integer.

Special cases are:

AbsInt(minInt) results in a panic (not representable)

func AddrToHex

func AddrToHex(s string) string

func ByteToInt32

func ByteToInt32(b []byte) int32

func ByteToInt64

func ByteToInt64(b []byte) int64

func ByteToUInt16

func ByteToUInt16(b []byte) uint16

func ByteToUInt32

func ByteToUInt32(b []byte) uint32

func ByteToUInt64

func ByteToUInt64(b []byte) uint64

func ByteToUint64

func ByteToUint64(bs []byte) uint64

ByteToUint64 converts the byte array to a 64-bits unsigned integer

func Bytes2Hex

func Bytes2Hex(d []byte) string

Bytes2Hex converts the input byte array to a hex string

func BytesCombine

func BytesCombine(pBytes ...[]byte) []byte

BytesCombine combines multiple byte arrays into one byte array

func CopyBytes

func CopyBytes(b []byte) (copiedBytes []byte)

Copybytes returns an exact copy of the provided bytes

func Decode

func Decode(input string) ([]byte, error)

Decode decodes a hex string with 0x prefix.

func DecodeBig

func DecodeBig(input string) (*big.Int, error)

DecodeBig decodes a hex string with 0x prefix as a quantity. Numbers larger than 256 bits are not accepted.

func DecodeUint64

func DecodeUint64(input string) (uint64, error)

DecodeUint64 decodes a hex string with 0x prefix as a quantity.

func DecryptWithKey

func DecryptWithKey(Key []byte, Data []byte) (result []byte, err error)

DecryptWithKey implements symmetric decryption with the specified key extract 12 byte nonce from the data and deseal the data if key is incorrect, err return not nil

func Encode

func Encode(b []byte) string

Encode encodes b as a hex string with 0x prefix.

func EncodeBig

func EncodeBig(bigint *big.Int) string

EncodeBig encodes bigint as a hex string with 0x prefix. The sign of the integer is ignored.

func EncodeUint64

func EncodeUint64(i uint64) string

EncodeUint64 encodes i as a hex string with 0x prefix.

func Encrypt

func Encrypt(rand io.Reader, pub *PublicKey, msg []byte) (ct []byte, err error)

Encrypt returns the cipher text of the message

func EncryptWithKey

func EncryptWithKey(Key []byte, Data []byte) (result []byte, err error)

EncryptWithKey implements symmetric encryption with the specified key all data in encrypted within the storage using this function

func FromHex

func FromHex(s string) []byte

FromHex converts the hex string to a byte array

func Hex2Bytes

func Hex2Bytes(str string) []byte

Hex2Bytes converts the hex string to a byte array

func InitConf

func InitConf(path string)

func Int32ToByte

func Int32ToByte(i int32) []byte

func Int64ToByte

func Int64ToByte(i int64) []byte

func IsHex

func IsHex(str string) bool

IsHex checks the input string is a hex string

func IsWeakPassword

func IsWeakPassword(password string) bool

func MustDecode

func MustDecode(input string) []byte

MustDecode decodes a hex string with 0x prefix. It panics for invalid input.

func MustDecodeBig

func MustDecodeBig(input string) *big.Int

MustDecodeBig decodes a hex string with 0x prefix as a quantity. It panics for invalid input.

func MustDecodeUint64

func MustDecodeUint64(input string) uint64

MustDecodeUint64 decodes a hex string with 0x prefix as a quantity. It panics for invalid input.

func MustNewLRUCache

func MustNewLRUCache(size int) *lru.Cache

MustNewLRUCache creates a new lru cache. Caution: if fail, the function will cause panic developer should promise size > 0 when use this function

func MustNewLRUCacheWithEvictCB

func MustNewLRUCacheWithEvictCB(size int, cb func(k, v interface{})) *lru.Cache

MustNewLRUCacheWithEvictCB creates a new lru cache with buffer eviction Caution: if fail, the function will cause panic.

func ParseCoin

func ParseCoin(s string) (uint64, error)

ParseCoin parses string to amount

func RA2TAS

func RA2TAS(v uint64) float64

func Sha256

func Sha256(blockByte []byte) []byte

Sha256 computes Sha256 value of the input byte array

func ShortHex

func ShortHex(hex string) string

func ShortHex12

func ShortHex12(hex string) string

func TAS2RA

func TAS2RA(v uint64) uint64

func ToAddrHex

func ToAddrHex(b []byte) string

ToZvHex converts the input byte array to a hex string

func ToHex

func ToHex(b []byte) string

ToHex converts the input byte array to a hex string

func UInt16ToByte

func UInt16ToByte(i uint16) []byte

func UInt32ToByte

func UInt32ToByte(i uint32) []byte

func UInt64ToByte

func UInt64ToByte(i uint64) []byte

func Uint64ToByte

func Uint64ToByte(i uint64) []byte

Uint64ToByte converts 64-bits unsigned integer to byte array

func UnmarshalAddr

func UnmarshalAddr(typname string, input, out []byte) error

UnmarshalFixedText decodes the input as a string with 0x prefix. The length of out determines the required input length. This function is commonly used to implement the UnmarshalText method for fixed-size types.

func UnmarshalAddrJSON

func UnmarshalAddrJSON(typ reflect.Type, input, out []byte) error

UnmarshalFixedJSON decodes the input as a string with 0x prefix. The length of out determines the required input length. This function is commonly used to implement the UnmarshalJSON method for fixed-size types.

func UnmarshalFixedJSON

func UnmarshalFixedJSON(typ reflect.Type, input, out []byte) error

UnmarshalFixedJSON decodes the input as a string with 0x prefix. The length of out determines the required input length. This function is commonly used to implement the UnmarshalJSON method for fixed-size types.

func UnmarshalFixedText

func UnmarshalFixedText(typname string, input, out []byte) error

UnmarshalFixedText decodes the input as a string with 0x prefix. The length of out determines the required input length. This function is commonly used to implement the UnmarshalText method for fixed-size types.

func UnmarshalFixedUnprefixedText

func UnmarshalFixedUnprefixedText(typname string, input, out []byte) error

UnmarshalFixedUnprefixedText decodes the input as a string with optional 0x prefix. The length of out determines the required input length. This function is commonly used to implement the UnmarshalText method for fixed-size types.

func ValidateAddress

func ValidateAddress(addr string) bool

Types

type AccountData

type AccountData struct {
	// contains filtered or unexported fields
}

type Address

type Address [AddressLength]byte

Address data struct

func BigToAddress

func BigToAddress(b *big.Int) Address

BigToAddress returns the address of the input big integer assignment

func BytesToAddress

func BytesToAddress(b []byte) Address

BytesToAddress returns the Address imported from the input byte array

func HashToAddress

func HashToAddress(h Hash) Address

func StringToAddress

func StringToAddress(s string) Address

StringToAddress returns the address of the input string assignment

func (Address) AddrPrefixString

func (a Address) AddrPrefixString() string

ZvPrefixHex returns the hex string representation of a

func (Address) BigInteger

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

BigInteger returns the big integer representation of a

func (Address) Bytes

func (a Address) Bytes() []byte

Bytes returns the byte array representation of a

func (Address) Hash

func (a Address) Hash() Hash

Hash converts a to hash

func (Address) MarshalJSON

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

MarshalJSON encodes the address as byte array with json format

func (Address) MarshalText

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

MarshalText returns the hex representation of a.

func (*Address) Set

func (a *Address) Set(other Address)

Set sets other to a

func (*Address) SetBytes

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

SetBytes returns the address of the input byte array assignment

func (*Address) SetString

func (a *Address) SetString(s string)

SetString returns the address of the input hex string assignment

func (Address) String

func (a Address) String() string

func (*Address) UnmarshalJSON

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

UnmarshalJSON parses an address in hex syntax with json format.

func (*Address) UnmarshalText

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

UnmarshalText parses an address in hex syntax.

type Big

type Big big.Int

Big marshals/unmarshals as a JSON string with 0x prefix. The zero value marshals as "0x0".

Negative integers are not supported at this time. Attempting to marshal them will return an error. Values larger than 256bits are rejected by Unmarshal but will be marshaled without error.

func (Big) MarshalText

func (b Big) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler

func (*Big) String

func (b *Big) String() string

String returns the hex encoding of b.

func (*Big) ToInt

func (b *Big) ToInt() *big.Int

ToInt converts b to a big.Int.

func (*Big) UnmarshalJSON

func (b *Big) UnmarshalJSON(input []byte) error

UnmarshalJSON implements json.Unmarshaler.

func (*Big) UnmarshalText

func (b *Big) UnmarshalText(input []byte) error

UnmarshalText implements encoding.TextUnmarshaler

type Bytes

type Bytes []byte

Bytes marshals/unmarshals as a JSON string with 0x prefix. The empty slice marshals as "0x".

func (Bytes) MarshalText

func (b Bytes) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler

func (Bytes) String

func (b Bytes) String() string

String returns the hex encoding of b.

func (*Bytes) UnmarshalJSON

func (b *Bytes) UnmarshalJSON(input []byte) error

UnmarshalJSON implements json.Unmarshaler.

func (*Bytes) UnmarshalText

func (b *Bytes) UnmarshalText(input []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

type ConfFileManager

type ConfFileManager struct {
	// contains filtered or unexported fields
}

func (*ConfFileManager) Del

func (cs *ConfFileManager) Del(section string, key string)

func (*ConfFileManager) GetBool

func (cs *ConfFileManager) GetBool(section string, key string, defaultValue bool) bool

func (*ConfFileManager) GetDouble

func (cs *ConfFileManager) GetDouble(section string, key string, defaultValue float64) float64

func (*ConfFileManager) GetInt

func (cs *ConfFileManager) GetInt(section string, key string, defaultValue int) int

func (*ConfFileManager) GetSectionManager

func (cs *ConfFileManager) GetSectionManager(section string) SectionConfManager

func (*ConfFileManager) GetString

func (cs *ConfFileManager) GetString(section string, key string, defaultValue string) string

func (*ConfFileManager) SetBool

func (cs *ConfFileManager) SetBool(section string, key string, value bool)

func (*ConfFileManager) SetDouble

func (cs *ConfFileManager) SetDouble(section string, key string, value float64)

func (*ConfFileManager) SetInt

func (cs *ConfFileManager) SetInt(section string, key string, value int)

func (*ConfFileManager) SetString

func (cs *ConfFileManager) SetString(section string, key string, value string)

type ConfManager

type ConfManager interface {
	//read basic conf from tas.conf file
	//返回section组下的key的值, 若未配置, 则返回默认值defv
	GetString(section string, key string, defaultValue string) string
	GetBool(section string, key string, defaultValue bool) bool
	GetDouble(section string, key string, defaultValue float64) float64
	GetInt(section string, key string, defaultValue int) int

	//set basic conf to tas.conf file
	SetString(section string, key string, value string)
	SetBool(section string, key string, value bool)
	SetDouble(section string, key string, value float64)
	SetInt(section string, key string, value int)

	//delete basic conf
	Del(section string, key string)

	//获取一个section的配置管理
	GetSectionManager(section string) SectionConfManager
}
var GlobalConf ConfManager

func NewConfINIManager

func NewConfINIManager(path string) ConfManager

type FundModeType

type FundModeType byte
const (
	SIXAddFive FundModeType = iota
	SIXAddSix
)

type Hash

type Hash [HashLength]byte

///////////////////////////////////////////////////////////////////////////// Hash data struct (256-bits)

func BigToHash

func BigToHash(b *big.Int) Hash

func BytesToHash

func BytesToHash(b []byte) Hash

BytesToHash

func HexToHash

func HexToHash(s string) Hash

func (Hash) Big

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

func (Hash) Bytes

func (h Hash) Bytes() []byte

Get the string representation of the underlying hash

func (Hash) Generate

func (h Hash) Generate(rand *rand.Rand, size int) reflect.Value

Generate generates implements testing/quick.Generator.

func (Hash) Hex

func (h Hash) Hex() string

func (Hash) IsValid

func (h Hash) IsValid() bool

func (Hash) MarshalText

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

MarshalText returns the hex representation of h.

func (*Hash) Set

func (h *Hash) Set(other Hash)

Set sets h from other

func (*Hash) SetBytes

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

SetBytes sets the hash to the value of b. If b is larger than len(h), 'b' will be cropped (from the left).

func (*Hash) SetString

func (h *Hash) SetString(s string)

SetString sets string `s` to h. If s is larger than len(h) s will be cropped (from left) to fit.

func (Hash) String

func (h Hash) String() string

func (Hash) TerminalString

func (h Hash) TerminalString() string

TerminalString implements log.TerminalStringer, formatting a string for console output during logging.

func (*Hash) UnmarshalJSON

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

UnmarshalJSON parses a hash in hex syntax with json format.

func (*Hash) UnmarshalText

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

UnmarshalText parses a hash in hex syntax.

type Hash256

type Hash256 Hash

type PrivateKey

type PrivateKey struct {
	PrivKey ecdsa.PrivateKey
}

PrivateKey data struct

func BytesToSecKey

func BytesToSecKey(data []byte) (sk *PrivateKey)

BytesToSecKey returns a private key with the byte array imported

func GenerateKey

func GenerateKey(s string) (PrivateKey, error)

GenerateKey creates a Private key by the specified string

func HexToSecKey

func HexToSecKey(s string) (sk *PrivateKey)

HexToSecKey returns a private key with the hex string imported.

func (*PrivateKey) Bytes

func (pk *PrivateKey) Bytes() []byte

Bytes converts the private key to a byte array

func (*PrivateKey) Decrypt

func (pk *PrivateKey) Decrypt(rand io.Reader, ct []byte) (m []byte, err error)

Decrypt returns the plain message

func (*PrivateKey) ExportKey

func (pk *PrivateKey) ExportKey() []byte

ExportKey returns a byte array representation of the secure key of private key

func (*PrivateKey) GetPubKey

func (pk *PrivateKey) GetPubKey() PublicKey

GetPubKey returns the public key mapped to the private key

func (*PrivateKey) Hex

func (pk *PrivateKey) Hex() string

Hex converts the private key to a hex string

func (*PrivateKey) ImportKey

func (pk *PrivateKey) ImportKey(key []byte) bool

ImportKey constructs the private key from the input secure key.

func (PrivateKey) Sign

func (pk PrivateKey) Sign(hash []byte) (Sign, error)

Sign returns the message signature using the private key

type PublicKey

type PublicKey struct {
	PubKey ecdsa.PublicKey
}

PublicKey data struct

func BytesToPublicKey

func BytesToPublicKey(data []byte) (pk *PublicKey)

BytesToPublicKey returns a public key with the byte array imported

func HexToPubKey

func HexToPubKey(s string) (pk *PublicKey)

HexToPubKey returns a public key with the hex string imported

func (PublicKey) Bytes

func (pk PublicKey) Bytes() []byte

Bytes converts the public key to a byte array

func (*PublicKey) Encrypt

func (pk *PublicKey) Encrypt(rand io.Reader, msg []byte) ([]byte, error)

Encrypt returns the cipher text of the message

func (PublicKey) GetAddress

func (pk PublicKey) GetAddress() Address

GetAddress obtains the address mapped from the public key

func (PublicKey) Hex

func (pk PublicKey) Hex() string

Hex converts the public key to a hex string

func (PublicKey) Verify

func (pk PublicKey) Verify(hash []byte, s *Sign) bool

Verify the validation of signature and message

type SectionConfFileManager

type SectionConfFileManager struct {
	// contains filtered or unexported fields
}

func (*SectionConfFileManager) Del

func (sfm *SectionConfFileManager) Del(key string)

func (*SectionConfFileManager) GetBool

func (sfm *SectionConfFileManager) GetBool(key string, defaultValue bool) bool

func (*SectionConfFileManager) GetDouble

func (sfm *SectionConfFileManager) GetDouble(key string, defaultValue float64) float64

func (*SectionConfFileManager) GetInt

func (sfm *SectionConfFileManager) GetInt(key string, defaultValue int) int

func (*SectionConfFileManager) GetString

func (sfm *SectionConfFileManager) GetString(key string, defaultValue string) string

func (*SectionConfFileManager) SetBool

func (sfm *SectionConfFileManager) SetBool(key string, value bool)

func (*SectionConfFileManager) SetDouble

func (sfm *SectionConfFileManager) SetDouble(key string, value float64)

func (*SectionConfFileManager) SetInt

func (sfm *SectionConfFileManager) SetInt(key string, value int)

func (*SectionConfFileManager) SetString

func (sfm *SectionConfFileManager) SetString(key string, value string)

type SectionConfManager

type SectionConfManager interface {
	//read basic conf from tas.conf file
	//返回section组下的key的值, 若未配置, 则返回默认值defv
	GetString(key string, defaultValue string) string
	GetBool(key string, defaultValue bool) bool
	GetDouble(key string, defaultValue float64) float64
	GetInt(key string, defaultValue int) int

	//set basic conf to tas.conf file
	SetString(key string, value string)
	SetBool(key string, value bool)
	SetDouble(key string, value float64)
	SetInt(key string, value int)

	//delete basic conf
	Del(key string)
}

type Sign

type Sign struct {
	// contains filtered or unexported fields
}

Sign Data struct

func BytesToSign

func BytesToSign(b []byte) *Sign

BytesToSign returns a signature with the byte array imported. The length of the byte array must be 65.

func HexToSign

func HexToSign(s string) (si *Sign)

HexToSign returns a signature with the hex string imported

func (Sign) Bytes

func (s Sign) Bytes() []byte

Bytes converts the signature to a byte array.

func (Sign) GetR

func (s Sign) GetR() big.Int

GetR obtains r value

func (Sign) GetS

func (s Sign) GetS() big.Int

GetS obtains s value

func (Sign) Hex

func (s Sign) Hex() string

Hex converts the signature into a hex string

func (Sign) RecoverPubkey

func (s Sign) RecoverPubkey(msg []byte) (pk *PublicKey, err error)

RecoverPubkey returns the public key recovered from the signature

func (*Sign) Set

func (s *Sign) Set(_r, _s *big.Int, recid int)

Set constructs a signature data

func (Sign) Valid

func (s Sign) Valid() bool

Valid Checks the validity of the signature

type SignData

type SignData struct {
	DataHash Hash   //哈希值
	DataSign Sign   //签名
	ID       string //用户ID
}

SignData data struct for message casting

type StorageSize

type StorageSize float64

type TimeMetric

type TimeMetric struct {
	Total int
	Cost  time.Duration
}

type TimeStatCtx

type TimeStatCtx struct {
	Stats map[string]*TimeMetric
	// contains filtered or unexported fields
}

func NewTimeStatCtx

func NewTimeStatCtx() *TimeStatCtx

func (*TimeStatCtx) AddStat

func (ts *TimeStatCtx) AddStat(name string, dur time.Duration)

func (*TimeStatCtx) Output

func (ts *TimeStatCtx) Output() string

type Uint

type Uint uint

Uint marshals/unmarshals as a JSON string with 0x prefix. The zero value marshals as "0x0".

func (Uint) MarshalText

func (b Uint) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler.

func (Uint) String

func (b Uint) String() string

String returns the hex encoding of b.

func (*Uint) UnmarshalJSON

func (b *Uint) UnmarshalJSON(input []byte) error

UnmarshalJSON implements json.Unmarshaler.

func (*Uint) UnmarshalText

func (b *Uint) UnmarshalText(input []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

type Uint64

type Uint64 uint64

Uint64 marshals/unmarshals as a JSON string with 0x prefix. The zero value marshals as "0x0".

func (Uint64) MarshalText

func (b Uint64) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler.

func (Uint64) String

func (b Uint64) String() string

String returns the hex encoding of b.

func (*Uint64) UnmarshalJSON

func (b *Uint64) UnmarshalJSON(input []byte) error

UnmarshalJSON implements json.Unmarshaler.

func (*Uint64) UnmarshalText

func (b *Uint64) UnmarshalText(input []byte) error

UnmarshalText implements encoding.TextUnmarshaler

type UnprefixedHash

type UnprefixedHash Hash

UnprefixedHash allows marshaling a Hash without 0x prefix.

func (UnprefixedHash) MarshalText

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

MarshalText encodes the hash as hex.

func (*UnprefixedHash) UnmarshalText

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

UnmarshalText decodes the hash from hex. The 0x prefix is optional.

Directories

Path Synopsis
Package ecies implements ECIES encryption/decryption algorithm.
Package ecies implements ECIES encryption/decryption algorithm.
Package ed25519 implements the Ed25519 signature algorithm.
Package ed25519 implements the Ed25519 signature algorithm.
Package secp256k1 wraps the bitcoin secp256k1 C library.
Package secp256k1 wraps the bitcoin secp256k1 C library.

Jump to

Keyboard shortcuts

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