mint

package module
v1.2.5 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2020 License: MIT Imports: 7 Imported by: 11

README

Mint (Sumus) blockchain lowlevel methods, transaction types, transactions signing, block data etc.

Structure

Folder Contains
. Primitives and basic functions like parsers, Base58 packer
amount A structure that holds tokens amount
block Block data and parser
fee Fee calculator
serializer Primary data serializer. For instance, block parser untilizes it
signer ED25519 functions wrapped into a single structure
transaction Transaction parser and constructor

Documentation

Index

Constants

View Source
const DigestSize = 32

DigestSize is digest length in bytes

View Source
const PrivateKeySize = 64

PrivateKeySize is private key length in bytes

View Source
const PublicKeySize = 32

PublicKeySize is public key length in bytes

View Source
const SignatureSize = 64

SignatureSize is signature length in bytes

Variables

View Source
var TokenToString = map[Token]string{
	TokenMNT:  "MNT",
	TokenGOLD: "GOLD",
}

TokenToString definition

View Source
var WalletTagToString = map[WalletTag]string{
	WalletTagNode:        "node",
	WalletTagGenesisNode: "gnode",
	WalletTagSupervisor:  "supervisor",
	WalletTagOwner:       "owner",
	WalletTagEmission:    "emission",
	WalletTagNoFee:       "nofee",
	WalletTagApproved:    "approved",
	WalletTagAuthority:   "authority",
	WalletTagDeposital:   "deposital",
	WalletTagExchange:    "exchange",
}

WalletTagToString definition

Functions

func MaskString6P4

func MaskString6P4(s string) string

MaskString6P4 masks a string exposing first 6 and 4 last symbols, like: YeAHCqTJk4aFnHXGV4zaaf3dTqJkdjQzg8TJENmP3zxDMpa97 => YeAHCq***pa97

func MustUnpack58

func MustUnpack58(data string) []byte

MustUnpack58 does the same as Unpack58, but panics on failure

func Pack58

func Pack58(data []byte) string

Pack58 packs bytes into base58 with crc

func StampToTime

func StampToTime(timestamp uint64) time.Time

StampToTime converts mint timestamp to time.Time

func Unpack58

func Unpack58(data string) ([]byte, error)

Unpack58 from string

func ValidToken

func ValidToken(u uint16) bool

ValidToken as uint16

func ValidWalletTag

func ValidWalletTag(u uint8) bool

ValidWalletTag as uint8

Types

type Digest

type Digest [DigestSize]byte

Digest bytes

func BytesToDigest

func BytesToDigest(b []byte) (Digest, error)

BytesToDigest creates an instance from a bytes slice

func MustBytesToDigest added in v1.2.5

func MustBytesToDigest(b []byte) Digest

MustBytesToDigest creates an instance from bytes slice or panics

func MustParseDigest added in v1.2.5

func MustParseDigest(s string) Digest

MustParseDigest parses an instance from Base58 string or panics

func ParseDigest

func ParseDigest(s string) (Digest, error)

ParseDigest parses an instance from Base58 string

func (Digest) Bytes

func (d Digest) Bytes() []byte

Bytes of the instance

func (Digest) MarshalJSON

func (d Digest) MarshalJSON() ([]byte, error)

MarshalJSON impl

func (Digest) String

func (d Digest) String() string

String packs the instance into a Base58 string

func (Digest) StringMask

func (d Digest) StringMask() string

StringMask packs the instance into 6+4 a masked Base58 string

func (*Digest) UnmarshalJSON added in v1.2.1

func (d *Digest) UnmarshalJSON(b []byte) error

UnmarshalJSON impl

type PrivateKey

type PrivateKey [PrivateKeySize]byte

PrivateKey bytes

func BytesToPrivateKey

func BytesToPrivateKey(b []byte) (PrivateKey, error)

BytesToPrivateKey creates an instance from a bytes slice

func MustBytesToPrivateKey added in v1.2.5

func MustBytesToPrivateKey(b []byte) PrivateKey

MustBytesToPrivateKey creates an instance from bytes slice or panics

func MustNewPrivateKey added in v1.2.3

func MustNewPrivateKey() PrivateKey

MustNewPrivateKey generates a new random private key or panics on error

func MustParsePrivateKey added in v1.2.5

func MustParsePrivateKey(s string) PrivateKey

MustParsePrivateKey parses an instance from Base58 string or panics

func NewPrivateKey added in v1.2.3

func NewPrivateKey() (p PrivateKey, err error)

NewPrivateKey generates a new random private key

func ParsePrivateKey

func ParsePrivateKey(s string) (PrivateKey, error)

ParsePrivateKey parses an instance from Base58 string

func (PrivateKey) Bytes

func (p PrivateKey) Bytes() []byte

Bytes of the instance

func (PrivateKey) MarshalJSON

func (p PrivateKey) MarshalJSON() ([]byte, error)

MarshalJSON impl

func (PrivateKey) PublicKey added in v1.2.3

func (p PrivateKey) PublicKey() PublicKey

PublicKey of the private key

func (PrivateKey) String

func (p PrivateKey) String() string

String packs the instance into a Base58 string

func (PrivateKey) StringMask

func (p PrivateKey) StringMask() string

StringMask packs the instance into 6+4 a masked Base58 string

func (*PrivateKey) UnmarshalJSON added in v1.2.1

func (p *PrivateKey) UnmarshalJSON(b []byte) error

UnmarshalJSON impl

type PublicKey

type PublicKey [PublicKeySize]byte

PublicKey bytes

func BytesToPublicKey

func BytesToPublicKey(b []byte) (PublicKey, error)

BytesToPublicKey creates an instance from a bytes slice

func MustBytesToPublicKey added in v1.2.5

func MustBytesToPublicKey(b []byte) PublicKey

MustBytesToPublicKey creates an instance from bytes slice or panics

func MustParsePublicKey added in v1.2.5

func MustParsePublicKey(s string) PublicKey

MustParsePublicKey parses an instance from Base58 string or panics

func ParsePublicKey

func ParsePublicKey(s string) (PublicKey, error)

ParsePublicKey parses an instance from Base58 string

func (PublicKey) Bytes

func (p PublicKey) Bytes() []byte

Bytes of the instance

func (PublicKey) MarshalJSON

func (p PublicKey) MarshalJSON() ([]byte, error)

MarshalJSON impl

func (PublicKey) String

func (p PublicKey) String() string

String packs the instance into a Base58 string

func (PublicKey) StringMask

func (p PublicKey) StringMask() string

StringMask packs the instance into 6+4 a masked Base58 string

func (*PublicKey) UnmarshalJSON added in v1.2.1

func (p *PublicKey) UnmarshalJSON(b []byte) error

UnmarshalJSON impl

type Signature

type Signature [SignatureSize]byte

Signature bytes

func BytesToSignature

func BytesToSignature(b []byte) (Signature, error)

BytesToSignature creates an instance from a bytes slice

func MustBytesToSignature added in v1.2.5

func MustBytesToSignature(b []byte) Signature

MustBytesToSignature creates an instance from bytes slice or panics

func MustParseSignature added in v1.2.5

func MustParseSignature(s string) Signature

MustParseSignature parses an instance from Base58 string or panics

func ParseSignature

func ParseSignature(s string) (Signature, error)

ParseSignature parses an instance from Base58 string

func (Signature) Bytes

func (s Signature) Bytes() []byte

Bytes of the instance

func (Signature) MarshalJSON

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

MarshalJSON impl

func (Signature) String

func (s Signature) String() string

String packs the instance into a Base58 string

func (Signature) StringMask

func (s Signature) StringMask() string

StringMask packs the instance into 6+4 a masked Base58 string

func (*Signature) UnmarshalJSON added in v1.2.1

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

UnmarshalJSON impl

type Token

type Token uint16

Token (asset) in Sumus blockchain

const (
	// TokenMNT is MNT
	TokenMNT Token = iota
	// TokenGOLD is GOLD
	TokenGOLD
)

func ParseToken

func ParseToken(s string) (Token, error)

ParseToken from string

func (Token) String

func (t Token) String() string

String representation

type WalletTag

type WalletTag uint8

WalletTag in Sumus blockchain

const (
	// WalletTagNode is a registered node (by "supervisor")
	WalletTagNode WalletTag = 1
	// WalletTagGenesisNode is registered node (in genesis block)
	WalletTagGenesisNode WalletTag = 2
	// WalletTagSupervisor can set/unset tags, fee-free (system, singleton)
	WalletTagSupervisor WalletTag = 3
	// WalletTagOwner is a fee collector, fee-free (system, singleton)
	WalletTagOwner WalletTag = 4
	// WalletTagEmission can emit/burn tokens, fee-free (system)
	WalletTagEmission WalletTag = 5
	// WalletTagNoFee sends transactions without a fee (system)
	WalletTagNoFee WalletTag = 6
	// WalletTagApproved grants ability to a KYC-proved user to send/receive GOLD
	WalletTagApproved WalletTag = 7
	// WalletTagAuthority can set/unset "approved" tag
	WalletTagAuthority WalletTag = 8
	// WalletTagDeposital grants ability to an exchange to send/received GOLD
	WalletTagDeposital WalletTag = 9
	// WalletTagExchange can set/unset "deposital" tag
	WalletTagExchange WalletTag = 10
)

func ParseWalletTag

func ParseWalletTag(s string) (WalletTag, error)

ParseWalletTag from string

func (WalletTag) String

func (t WalletTag) String() string

String representation

Directories

Path Synopsis
internal
ed25519
Package ed25519 implements the Ed25519 signature algorithm.
Package ed25519 implements the Ed25519 signature algorithm.

Jump to

Keyboard shortcuts

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