Documentation ¶
Index ¶
- Constants
- Variables
- func ConvertAXCAmountToBCAmount(axcAmount *big.Int) int64
- func ConvertBCAmountToAXCAmount(bcAmount int64) *big.Int
- func HexDecodeNibble(in byte) uint64
- func HexDecodeUint64(input string) (uint64, error)
- func HexEncodeBig(bigint *big.Int) string
- func HexEncodeUint64(i uint64) string
- func Keccak256(data ...[]byte) []byte
- func UnmarshalFixedJSON(typ reflect.Type, input, out []byte) error
- func UnmarshalFixedText(typname string, input, out []byte) error
- func UnmarshalFixedUnprefixedText(typname string, input, out []byte) error
- type Address
- func (a Address) Bytes() []byte
- func (a Address) Format(s fmt.State, c rune)
- func (a Address) Hash() Hash
- func (a Address) Hex() string
- func (a Address) MarshalText() ([]byte, error)
- func (a *Address) Scan(src interface{}) error
- func (a *Address) SetBytes(b []byte)
- func (a Address) String() string
- func (a *Address) UnmarshalJSON(input []byte) error
- func (a *Address) UnmarshalText(input []byte) error
- func (a Address) Value() (driver.Value, error)
- type Big
- func (b Big) ImplementsGraphQLType(name string) bool
- func (b Big) MarshalText() ([]byte, error)
- func (b *Big) String() string
- func (b *Big) ToInt() *big.Int
- func (b *Big) UnmarshalGraphQL(input interface{}) error
- func (b *Big) UnmarshalJSON(input []byte) error
- func (b *Big) UnmarshalText(input []byte) error
- type BlockNonce
- type Bloom
- type Bytes
- type DecError
- type Hash
- func (h Hash) Big() *big.Int
- func (h Hash) Bytes() []byte
- func (h Hash) Cmp(h1 Hash) int
- func (h Hash) Format(s fmt.State, c rune)
- func (h Hash) Generate(rand *rand.Rand, size int) reflect.Value
- func (h Hash) Hex() string
- func (h Hash) MarshalText() ([]byte, error)
- func (h *Hash) Scan(src interface{}) error
- func (h *Hash) SetBytes(b []byte)
- func (h Hash) String() string
- func (h Hash) TerminalString() string
- func (h *Hash) UnmarshalJSON(input []byte) error
- func (h *Hash) UnmarshalText(input []byte) error
- func (h Hash) Value() (driver.Value, error)
- type Header
- type Uint
- type Uint64
Constants ¶
const ( AXCDecimalOnBC = 8 AXCDecimalOnAXC = 18 )
const ( // HashLength is the expected length of the hash HashLength = 32 // AddressLength is the expected length of the address AddressLength = 20 )
Lengths of hashes and addresses in bytes.
const BadNibble = ^uint64(0)
const (
// BloomByteLength represents the number of bytes used in a header log bloom.
BloomByteLength = 256
)
const UintBits = 32 << (uint64(^uint(0)) >> 63)
Variables ¶
var ( ErrEmptyString = &DecError{"empty hex string"} ErrSyntax = &DecError{"invalid hex string"} ErrMissingPrefix = &DecError{"hex string without 0x 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"} ErrBig256Range = &DecError{"hex number > 256 bits"} )
var BigWordNibbles int
Functions ¶
func ConvertAXCAmountToBCAmount ¶
ConvertAXCAmountToBCAmount can only be used to convert AXC decimal
func ConvertBCAmountToAXCAmount ¶
ConvertBCAmountToAXCAmount can only be used to convert AXC decimal
func HexDecodeNibble ¶
func HexDecodeUint64 ¶
DecodeUint64 decodes a hex string with 0x prefix as a quantity.
func HexEncodeBig ¶
EncodeBig encodes bigint as a hex string with 0x prefix. The sign of the integer is ignored.
func HexEncodeUint64 ¶
EncodeUint64 encodes i as a hex string with 0x prefix.
func UnmarshalFixedJSON ¶
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 ¶
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 ¶
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.
Types ¶
type Address ¶
type Address [AddressLength]byte
Address represents the 20 byte address of an Ethereum account.
func (Address) Format ¶
Format implements fmt.Formatter, forcing the byte slice to be formatted as is, without going through the stringer interface used for logging.
func (Address) MarshalText ¶
MarshalText returns the hex representation of a.
func (*Address) SetBytes ¶
SetBytes sets the address to the value of b. If b is larger than len(a) it will panic.
func (*Address) UnmarshalJSON ¶
UnmarshalJSON parses a hash in hex syntax.
func (*Address) UnmarshalText ¶
UnmarshalText parses a hash in hex syntax.
type Big ¶
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) ImplementsGraphQLType ¶
ImplementsGraphQLType returns true if Big implements the provided GraphQL type.
func (Big) MarshalText ¶
MarshalText implements encoding.TextMarshaler
func (*Big) UnmarshalGraphQL ¶
UnmarshalGraphQL unmarshals the provided GraphQL query data.
func (*Big) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
func (*Big) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler
type BlockNonce ¶
type BlockNonce [8]byte
A BlockNonce is a 64-bit hash which proves (combined with the mix-hash) that a sufficient amount of computation has been carried out on a block.
func (BlockNonce) MarshalText ¶
func (n BlockNonce) MarshalText() ([]byte, error)
MarshalText encodes n as a hex string with 0x prefix.
func (BlockNonce) Uint64 ¶
func (n BlockNonce) Uint64() uint64
Uint64 returns the integer value of a block nonce.
func (*BlockNonce) UnmarshalText ¶
func (n *BlockNonce) UnmarshalText(input []byte) error
UnmarshalText implements encoding.TextUnmarshaler.
type Bloom ¶
type Bloom [BloomByteLength]byte
Bloom represents a 2048 bit bloom filter.
func (Bloom) MarshalText ¶
MarshalText encodes b as a hex string with 0x prefix.
func (*Bloom) SetBytes ¶
SetBytes sets the content of b to the given bytes. It panics if d is not of suitable size.
func (*Bloom) UnmarshalText ¶
UnmarshalText b as a hex string with 0x prefix.
type Bytes ¶
type Bytes []byte
Bytes marshals/unmarshals as a JSON string with 0x prefix. The empty slice marshals as "0x".
func (Bytes) ImplementsGraphQLType ¶
ImplementsGraphQLType returns true if Bytes implements the specified GraphQL type.
func (Bytes) MarshalText ¶
MarshalText implements encoding.TextMarshaler
func (*Bytes) UnmarshalGraphQL ¶
UnmarshalGraphQL unmarshals the provided GraphQL query data.
func (*Bytes) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
func (*Bytes) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler.
type Hash ¶
type Hash [HashLength]byte
Hash represents the 32 byte Keccak256 hash of arbitrary data.
func BytesToHash ¶
BytesToHash sets b to hash. If b is larger than len(h), b will be cropped from the left.
func (Hash) Format ¶
Format implements fmt.Formatter, forcing the byte slice to be formatted as is, without going through the stringer interface used for logging.
func (Hash) MarshalText ¶
MarshalText returns the hex representation of h.
func (*Hash) SetBytes ¶
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) String ¶
String implements the stringer interface and is used also by the logger when doing full logging into a file.
func (Hash) TerminalString ¶
TerminalString implements log.TerminalStringer, formatting a string for console output during logging.
func (*Hash) UnmarshalJSON ¶
UnmarshalJSON parses a hash in hex syntax.
func (*Hash) UnmarshalText ¶
UnmarshalText parses a hash in hex syntax.
type Header ¶
type Header struct { ParentHash Hash `json:"parentHash" gencodec:"required"` UncleHash Hash `json:"sha3Uncles" gencodec:"required"` Coinbase Address `json:"miner" gencodec:"required"` Root Hash `json:"stateRoot" gencodec:"required"` TxHash Hash `json:"transactionsRoot" gencodec:"required"` ReceiptHash Hash `json:"receiptsRoot" gencodec:"required"` Bloom Bloom `json:"logsBloom" gencodec:"required"` Difficulty int64 `json:"difficulty" gencodec:"required"` Number int64 `json:"number" gencodec:"required"` GasLimit uint64 `json:"gasLimit" gencodec:"required"` GasUsed uint64 `json:"gasUsed" gencodec:"required"` Time uint64 `json:"timestamp" gencodec:"required"` Extra []byte `json:"extraData" gencodec:"required"` MixDigest Hash `json:"mixHash"` Nonce BlockNonce `json:"nonce"` }
func (*Header) ExtractSignerFromHeader ¶
func (*Header) GetSignature ¶
func (Header) MarshalJSON ¶
MarshalJSON marshals as JSON.
func (*Header) UnmarshalJSON ¶
UnmarshalJSON unmarshals from JSON.
type Uint ¶
type Uint uint
Uint marshals/unmarshals as a JSON string with 0x prefix. The zero value marshals as "0x0".
func (Uint) MarshalText ¶
MarshalText implements encoding.TextMarshaler.
func (*Uint) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
func (*Uint) UnmarshalText ¶
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) ImplementsGraphQLType ¶
ImplementsGraphQLType returns true if Uint64 implements the provided GraphQL type.
func (Uint64) MarshalText ¶
MarshalText implements encoding.TextMarshaler.
func (*Uint64) UnmarshalGraphQL ¶
UnmarshalGraphQL unmarshals the provided GraphQL query data.
func (*Uint64) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
func (*Uint64) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler