common

package
v0.0.0-...-7ae82dc Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2020 License: LGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrCodeInternal     = 1
	ErrCodeInvalidParam = 2
)
View Source
const (
	// transaction
	ErrCodeTransactionNotExists = 10000
	ErrCodeInvalidSignature     = 10001
	ErrCodeInvalidAsset         = 10002
)
View Source
const (
	// output
	ErrCodeOutputNotExists    = 10100
	ErrCodeOutputKeyExists    = 10101
	ErrCodeOutputAlreadySpent = 10102
)
View Source
const (
	Operator0   = 0x00
	Operator64  = 0x40
	OperatorSum = 0xfe
	OperatorCmp = 0xff
)
View Source
const Precision = 8

Variables

This section is empty.

Functions

func MarshalMsgpack

func MarshalMsgpack(v interface{}) ([]byte, error)

func ParseFloat64

func ParseFloat64(value interface{}, args ...float64) float64

ParseFloat64 parse interface to float64

func ParseInt

func ParseInt(value interface{}, args ...int) int

ParseInt parse interface to int

func ParseInt64

func ParseInt64(value interface{}, args ...int64) int64

ParseInt64 parse interface to int64

func UnmarshalMsgpack

func UnmarshalMsgpack(data []byte, val interface{}) error

Types

type Input

type Input struct {
	Hash    *crypto.Hash `json:"hash,omitempty"`
	Index   int          `json:"index"`
	Genesis []byte       `json:"-"`
	Deposit interface{}  `json:"-"`
	Mint    interface{}  `json:"-"`
}

type Integer

type Integer struct {
	// contains filtered or unexported fields
}
var Zero Integer

func NewInteger

func NewInteger(x uint64) (v Integer)

func NewIntegerFromString

func NewIntegerFromString(x string) (v Integer)

func (Integer) Add

func (x Integer) Add(y Integer) (v Integer)

func (Integer) Cmp

func (x Integer) Cmp(y Integer) int

func (Integer) Div

func (x Integer) Div(y int) (v Integer)

func (Integer) MarshalJSON

func (x Integer) MarshalJSON() ([]byte, error)

func (Integer) MarshalMsgpack

func (x Integer) MarshalMsgpack() ([]byte, error)

func (Integer) Mul

func (x Integer) Mul(y int) (v Integer)

func (Integer) Sign

func (x Integer) Sign() int

func (Integer) String

func (x Integer) String() string

func (Integer) Sub

func (x Integer) Sub(y Integer) (v Integer)

func (*Integer) UnmarshalJSON

func (x *Integer) UnmarshalJSON(b []byte) error

func (*Integer) UnmarshalMsgpack

func (x *Integer) UnmarshalMsgpack(data []byte) error

type KernelService

type KernelService interface {
	SubmitTransaction(ctx context.Context, tx *Transaction) (crypto.Hash, error)
	ReadTransaction(ctx context.Context, txHash crypto.Hash) (*Transaction, error)
	ReadUTXO(ctx context.Context, txHash crypto.Hash, index int) (*UTXO, error)
	ReadSnapshots(ctx context.Context, from, count int) ([]*Snapshot, error)
}

type Output

type Output struct {
	Type   uint8        `json:"type"`
	Amount Integer      `json:"amount"`
	Keys   []crypto.Key `json:"keys,omitempty"`
	Script Script       `json:"script,omitempty"`
	Mask   crypto.Key   `json:"mask,omitempty"`
}

type Script

type Script []uint8

func NewThresholdScript

func NewThresholdScript(threshold uint8) Script

func (Script) MarshalJSON

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

func (Script) String

func (s Script) String() string

func (*Script) UnmarshalJSON

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

func (Script) Validate

func (s Script) Validate(sum int) error

func (Script) VerifyFormat

func (s Script) VerifyFormat() error

type Snapshot

type Snapshot struct {
	Hash        string       `json:"hash"`
	Transaction *Transaction `json:"transaction"`
	Topology    int64        `json:"topology"`
	Timestamp   int64        `json:"timestamp"`
	Signature   string       `json:"signature"` // snapshot signature, co-sign by kernel nodes
}

type Transaction

type Transaction struct {
	Hash       *crypto.Hash         `json:"hash,omitempty" msgpack:"-"`
	Version    uint8                `json:"version"`
	Asset      crypto.Hash          `json:"asset"`
	Inputs     []*Input             `json:"inputs"`
	Outputs    []*Output            `json:"outputs"`
	Extra      []byte               `json:"extra,omitempty"`
	Signatures [][]crypto.Signature `json:"signatures,omitempty" msgpack:",omitempty"`
	Snapshot   *crypto.Hash         `json:"snapshot,omitempty" msgpack:"-"`
}

func (*Transaction) MsgpackMarshal

func (t *Transaction) MsgpackMarshal() ([]byte, error)

func (*Transaction) MsgpackMarshalPayload

func (t *Transaction) MsgpackMarshalPayload() ([]byte, error)

func (*Transaction) TransactionHash

func (t *Transaction) TransactionHash() (crypto.Hash, error)

type UTXO

type UTXO struct {
	Input
	Output
	Lock crypto.Hash `json:"lock,omitempty"`
}

Jump to

Keyboard shortcuts

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