sumuslib

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2019 License: MIT Imports: 6 Imported by: 0

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 (
	// PublicKeySize is public key length in bytes
	PublicKeySize = 32
	// PrivateKeySize is private key length in bytes
	PrivateKeySize = 64
	// DigestSize is digest length in bytes
	DigestSize = 32
	// SignatureSize is signature length in bytes
	SignatureSize = 64
)

Variables

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

TokenToString definition

View Source
var TransactionToString = map[Transaction]string{
	TransactionRegisterNode:           "RegisterNodeTransaction",
	TransactionUnregisterNode:         "UnregisterNodeTransaction",
	TransactionTransferAssets:         "TransferAssetsTransaction",
	TransactionRegisterSystemWallet:   "RegisterSystemWalletTransaction",
	TransactionUnregisterSystemWallet: "UnregisterSystemWalletTransaction",
	TransactionUserData:               "UserDataTransaction",
	TransactionDistributionFee:        "DistributionFeeTransaction",
}

TransactionToString definition

View Source
var WalletTagToString = map[WalletTag]string{
	WalletTagNode:        "Node",
	WalletTagGenesisNode: "GenesisNode",
	WalletTagSupervisor:  "SupervisorWallet",
	WalletTagOwner:       "OwnerWallet",
	WalletTagEmission:    "EmissionWallet",
	WalletTagData:        "DataWallet",
}

WalletTagToString definition

Functions

func DateToStamp added in v1.1.0

func DateToStamp(timestamp uint64) time.Time

DateToStamp (Sumus timestamp)

func MaskString6P4 added in v1.1.0

func MaskString6P4(s string) string

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

func MustUnpack58 added in v1.1.0

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 Unpack58

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

Unpack58 from string

func ValidToken

func ValidToken(u uint16) bool

ValidToken as uint16

func ValidTransaction

func ValidTransaction(u uint16) bool

ValidTransaction as uint16

func ValidWalletTag

func ValidWalletTag(u uint8) bool

ValidWalletTag as uint8

Types

type Digest

type Digest [DigestSize]byte

Digest bytes

func BytesToDigest added in v1.1.0

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

BytesToDigest creates an instance from a bytes slice

func ParseDigest added in v1.1.0

func ParseDigest(s string) (Digest, error)

ParseDigest parses an instance from Base58 string

func (Digest) Bytes added in v1.1.0

func (d Digest) Bytes() []byte

Bytes of the instance

func (Digest) MarshalJSON added in v1.0.3

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

MarshalJSON implements Json marshal

func (Digest) String added in v1.0.3

func (d Digest) String() string

String packs the instance into a Base58 string

func (Digest) StringMask added in v1.1.0

func (d Digest) StringMask() string

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

type PrivateKey

type PrivateKey [PrivateKeySize]byte

PrivateKey bytes

func BytesToPrivateKey added in v1.1.0

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

BytesToPrivateKey creates an instance from a bytes slice

func ParsePrivateKey added in v1.1.0

func ParsePrivateKey(s string) (PrivateKey, error)

ParsePrivateKey parses an instance from Base58 string

func (PrivateKey) Bytes added in v1.1.0

func (p PrivateKey) Bytes() []byte

Bytes of the instance

func (PrivateKey) MarshalJSON added in v1.0.3

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

MarshalJSON implements Json marshal

func (PrivateKey) String added in v1.0.3

func (p PrivateKey) String() string

String packs the instance into a Base58 string

func (PrivateKey) StringMask added in v1.1.0

func (p PrivateKey) StringMask() string

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

type PublicKey

type PublicKey [PublicKeySize]byte

PublicKey bytes

func BytesToPublicKey added in v1.1.0

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

BytesToPublicKey creates an instance from a bytes slice

func ParsePublicKey added in v1.1.0

func ParsePublicKey(s string) (PublicKey, error)

ParsePublicKey parses an instance from Base58 string

func (PublicKey) Bytes added in v1.1.0

func (p PublicKey) Bytes() []byte

Bytes of the instance

func (PublicKey) MarshalJSON added in v1.0.3

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

MarshalJSON implements Json marshal

func (PublicKey) String added in v1.0.3

func (p PublicKey) String() string

String packs the instance into a Base58 string

func (PublicKey) StringMask added in v1.1.0

func (p PublicKey) StringMask() string

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

type Signature

type Signature [SignatureSize]byte

Signature bytes

func BytesToSignature added in v1.1.0

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

BytesToSignature creates an instance from a bytes slice

func ParseSignature added in v1.1.0

func ParseSignature(s string) (Signature, error)

ParseSignature parses an instance from Base58 string

func (Signature) Bytes added in v1.1.0

func (s Signature) Bytes() []byte

Bytes of the instance

func (Signature) MarshalJSON added in v1.0.3

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

MarshalJSON implements Json marshal

func (Signature) String added in v1.0.3

func (s Signature) String() string

String packs the instance into a Base58 string

func (Signature) StringMask added in v1.1.0

func (s Signature) StringMask() string

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

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 Transaction

type Transaction uint16

Transaction in Sumus blockchain

const (
	// TransactionRegisterNode registers a new node
	TransactionRegisterNode Transaction = 1
	// TransactionUnregisterNode unregisters existing node
	TransactionUnregisterNode Transaction = 2
	// TransactionTransferAssets sends token between wallets
	TransactionTransferAssets Transaction = 10
	// TransactionRegisterSystemWallet registers system wallet
	TransactionRegisterSystemWallet Transaction = 3
	// TransactionUnregisterSystemWallet unregisters system wallet
	TransactionUnregisterSystemWallet Transaction = 4
	// TransactionUserData contains custom payload
	TransactionUserData Transaction = 7
	// TransactionDistributionFee sends block fee to owner
	TransactionDistributionFee Transaction = 11
)

func ParseTransaction

func ParseTransaction(s string) (Transaction, error)

ParseTransaction from string

func (Transaction) String

func (t Transaction) String() string

String representation

type WalletTag

type WalletTag uint8

WalletTag in Sumus blockchain

const (
	// WalletTagNode is node wallet
	WalletTagNode WalletTag = iota + 1
	// WalletTagGenesisNode is node wallet (TODO: clarify)
	WalletTagGenesisNode
	// WalletTagSupervisor is controller wallet who can tag other wallets
	WalletTagSupervisor
	// WalletTagOwner is a fee accumulator
	WalletTagOwner
	// WalletTagEmission emits token without a fee
	WalletTagEmission
	// WalletTagData can send UserData transactions without a fee
	WalletTagData
)

func ParseWalletTag

func ParseWalletTag(s string) (WalletTag, error)

ParseWalletTag from string

func (WalletTag) String

func (t WalletTag) String() string

String representation

Directories

Path Synopsis
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