types

package
v0.0.0-...-4502c18 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2018 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HasAddr

func HasAddr(addr []byte) bool

Types

type Coin

type Coin uint64

Coin is the type for safe interaction with the values of the number of coins.

func NewCoin

func NewCoin(u uint64) Coin

NewCoin creates a type of coins, as an argument expects to get a cipher representation of the sum. For example 100 000 000 is 1 coin, 10 000 000 is 0.1 coin.

func (Coin) String

func (c Coin) String() string

String returns a string with the number of coins understandable to the user.

func (Coin) Uint64

func (c Coin) Uint64() uint64

Uint64 return the root view of the coin in uint64.

type Hash

type Hash []byte

Hash a type for storing hashes.

func NewHash

func NewHash(b []byte) Hash

NewHash converts a byte array to Hash.

func (Hash) Equals

func (h Hash) Equals(h2 Hash) bool

Equals checks the equivalence of two hashes.

func (*Hash) MarshalJSON

func (h *Hash) MarshalJSON() ([]byte, error)

MarshalJSON required for serialization and correction of standard byte processing in GO.

func (Hash) String

func (h Hash) String() string

String is the implementation of the Stringer interface.

func (Hash) ToBytes

func (h Hash) ToBytes() []byte

ToBytes it simply helps to convert the Hash to bytes when needed.

func (Hash) ToHex

func (h Hash) ToHex() string

ToHex gets an array of bytes or Hash and returns its text representation.

func (*Hash) UnmarshalJSON

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

UnmarshalJSON required for deserialization and correction of standard byte processing in GO.

func (Hash) WriteToBuff

func (h Hash) WriteToBuff(buff *bytes.Buffer, defaultSize int) error

WriteToBuff writes the hash to the buffer. If the hash len equals 0 then defaultSize zeros will be written to the buffer. To avoid defaultSize, specify 0.

type KeyPair

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

KeyPair this is a pair of keys: private and public.

func NewKeyPair

func NewKeyPair(seed []byte) *KeyPair

NewKeyPair creates and returns a pointer to a key pair (public, private).

func (*KeyPair) Public

func (k *KeyPair) Public() *PublicKey

Public is getter for public key.

func (KeyPair) Secret

func (k KeyPair) Secret() *SecretKey

Secret is getter for private key.

type PublicKey

type PublicKey Hash

PublicKey this is a public key.

func NewPublicKeyByHex

func NewPublicKeyByHex(s string) PublicKey

NewPublicKeyByHex creates a public key for the string representation.

func (*PublicKey) Address

func (k *PublicKey) Address() string

Address creates address by public key.

type SecretKey

type SecretKey Hash

SecretKey this is a private key.

type Tx

type Tx struct {
	Id              Hash   `json:"id"`
	SenderPublicKey Hash   `json:"senderPublicKey"`
	SenderId        Hash   `json:"senderId"`
	RecipientId     Hash   `json:"recipientId"`
	Amount          Coin   `json:"amount"`
	Fee             Coin   `json:"fee"`
	Signature       Hash   `json:"signature"`
	Timestamp       int64  `json:"timestamp"`
	Nonce           uint32 `json:"nonce"`
	Height          uint32 `json:"height"`
	Chain           Hash   `json:"chain"`
	PreviousTx      Hash   `json:"previousTx"`
}

Tx determines the structure of the transaction.

func NewTx

func NewTx() *Tx

NewTx creates new empty transaction.

func (*Tx) GenerateId

func (t *Tx) GenerateId()

GenerateId generatates id and fills in Id field.

func (*Tx) GetBytes

func (t *Tx) GetBytes() []byte

GetBytes gets byte array by tx object.

func (*Tx) Mine deprecated

func (t *Tx) Mine()

Mine generates a nonce field and automatically fills in the nonce and id fields. To make a transaction, you will need to spend a little bit of processing power, But it will be so fast that it will be almost unnoticeable, because quite low complexity is used. Look constant `complexity`.

Deprecated: Use GenerateId.

Jump to

Keyboard shortcuts

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