common

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2019 License: GPL-3.0 Imports: 14 Imported by: 37

Documentation

Index

Constants

View Source
const (
	NodeStatePledging  = "PLEDGING"
	NodeStateAccepted  = "ACCEPTED"
	NodeStateDeparting = "DEPARTING"
)
View Source
const (
	Operator0   = 0x00
	Operator64  = 0x40
	OperatorSum = 0xfe
	OperatorCmp = 0xff
)
View Source
const (
	TxVersion      = 0x01
	ExtraSizeLimit = 256

	OutputTypeScript       = 0x00
	OutputTypeWithdrawal   = 0xa1
	OutputTypeSlash        = 0xa2
	OutputTypeNodePledge   = 0xa3
	OutputTypeNodeAccept   = 0xa4
	OutputTypeNodeDepart   = 0xa5
	OutputTypeNodeRemove   = 0xa6
	OutputTypeDomainAccept = 0xa7
	OutputTypeDomainRemove = 0xa8
)
View Source
const MainNetworkId = "XIN"
View Source
const (
	MintGroupKernelNode = "KERNELNODE"
)
View Source
const Precision = 8

Variables

View Source
var (
	XINAssetId crypto.Hash
)

Functions

func MsgpackMarshalPanic

func MsgpackMarshalPanic(val interface{}) []byte

Types

type Address

type Address struct {
	PrivateSpendKey crypto.Key
	PrivateViewKey  crypto.Key
	PublicSpendKey  crypto.Key
	PublicViewKey   crypto.Key
}

func NewAddressFromSeed

func NewAddressFromSeed(seed []byte) Address

func NewAddressFromString

func NewAddressFromString(s string) (Address, error)

func (Address) Hash

func (a Address) Hash() crypto.Hash

func (Address) MarshalJSON

func (a Address) MarshalJSON() ([]byte, error)

func (Address) String

func (a Address) String() string

func (*Address) UnmarshalJSON

func (a *Address) UnmarshalJSON(b []byte) error

type DepositData

type DepositData struct {
	Chain           crypto.Hash `json:"chain"`
	AssetKey        string      `json:"asset"`
	TransactionHash string      `json:"transaction"`
	Amount          Integer     `json:"amount"`
}

type Domain

type Domain struct {
	Account Address
}

type DomainReader

type DomainReader interface {
	ReadDomains() []Domain
}

type GhostChecker

type GhostChecker interface {
	CheckGhost(key crypto.Key) (bool, error)
}

type Input

type Input struct {
	Hash    crypto.Hash  `json:"hash,omitempty"`
	Index   int          `json:"index,omitempty"`
	Genesis []byte       `json:"genesis,omitempty"`
	Deposit *DepositData `json:"deposit,omitempty"`
	Mint    *MintData    `json:"mint,omitempty"`
}

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 added in v0.1.1

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 added in v0.1.1

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 MintData added in v0.1.1

type MintData struct {
	Group  string  `json:"group"`
	Batch  uint64  `json:"batch"`
	Amount Integer `json:"amount"`
}

func (*MintData) Distribute added in v0.1.1

func (m *MintData) Distribute(tx crypto.Hash) *MintDistribution

type MintDistribution added in v0.1.1

type MintDistribution struct {
	Group       string      `json:"group"`
	Batch       uint64      `json:"batch"`
	Amount      Integer     `json:"amount"`
	Transaction crypto.Hash `json:"transaction"`
}

type Node

type Node struct {
	Signer Address
	Payee  Address
	State  string
}

func (*Node) IsAccepted

func (n *Node) IsAccepted() bool

type NodeReader

type NodeReader interface {
	ReadConsensusNodes() []*Node
	ReadTransaction(hash crypto.Hash) (*SignedTransaction, error)
}

type Output

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

	// OutputTypeScript fields
	Script Script     `json:"script,omitempty"`
	Mask   crypto.Key `json:"mask,omitempty"`
}

type Round

type Round struct {
	Hash       crypto.Hash `json:"hash"`
	NodeId     crypto.Hash `json:"node"`
	Number     uint64      `json:"number"`
	Timestamp  uint64      `json:"timestamp"`
	References *RoundLink  `json:"references"`
}
type RoundLink struct {
	Self     crypto.Hash `json:"self"`
	External crypto.Hash `json:"external"`
}

func (*RoundLink) Equal

func (m *RoundLink) Equal(n *RoundLink) bool

type Script

type Script []uint8

func NewThresholdScript added in v0.1.1

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 SignedTransaction

type SignedTransaction struct {
	Transaction
	Signatures [][]crypto.Signature `json:"signatures,omitempty"`
}

func (*SignedTransaction) CheckMint added in v0.1.1

func (tx *SignedTransaction) CheckMint() bool

func (*SignedTransaction) LockInputs

func (tx *SignedTransaction) LockInputs(locker UTXOLocker, fork bool) error

func (*SignedTransaction) Marshal

func (tx *SignedTransaction) Marshal() []byte

func (*SignedTransaction) SignInput

func (signed *SignedTransaction) SignInput(reader UTXOReader, index int, accounts []Address) error

func (*SignedTransaction) SignRaw

func (signed *SignedTransaction) SignRaw(key crypto.Key) error

func (*SignedTransaction) Validate

func (tx *SignedTransaction) Validate(store DataStore) error

type Snapshot

type Snapshot struct {
	NodeId      crypto.Hash         `json:"node"`
	Transaction crypto.Hash         `json:"transaction"`
	References  *RoundLink          `json:"references"`
	RoundNumber uint64              `json:"round"`
	Timestamp   uint64              `json:"timestamp"`
	Signatures  []*crypto.Signature `json:"signatures,omitempty"`
	Hash        crypto.Hash         `msgpack:"-"json:"hash"`
}

func (*Snapshot) Payload

func (s *Snapshot) Payload() []byte

func (*Snapshot) PayloadHash

func (s *Snapshot) PayloadHash() crypto.Hash

type SnapshotWithTopologicalOrder

type SnapshotWithTopologicalOrder struct {
	Snapshot
	TopologicalOrder uint64 `json:"topology"`
}

type Transaction

type Transaction struct {
	Version uint8       `json:"version"`
	Asset   crypto.Hash `json:"asset"`
	Inputs  []*Input    `json:"inputs"`
	Outputs []*Output   `json:"outputs"`
	Extra   []byte      `json:"extra,omitempty"`
}

func NewTransaction

func NewTransaction(asset crypto.Hash) *Transaction

func (*Transaction) AddDepositInput

func (tx *Transaction) AddDepositInput(data *DepositData)

func (*Transaction) AddInput

func (tx *Transaction) AddInput(hash crypto.Hash, index int)

func (*Transaction) AddKernelNodeMintInput added in v0.1.1

func (tx *Transaction) AddKernelNodeMintInput(batch uint64, amount Integer)

func (*Transaction) AddScriptOutput

func (tx *Transaction) AddScriptOutput(accounts []Address, s Script, amount Integer) error

func (*Transaction) PayloadHash

func (tx *Transaction) PayloadHash() crypto.Hash

func (*Transaction) UnspentOutputs

func (tx *Transaction) UnspentOutputs() []*UTXO

func (*Transaction) ViewGhostKey

func (tx *Transaction) ViewGhostKey(a *crypto.Key) []*Output

type UTXO

type UTXO struct {
	Input
	Output
	Asset crypto.Hash
}

type UTXOLocker

type UTXOLocker interface {
	LockUTXO(hash crypto.Hash, index int, tx crypto.Hash, fork bool) (*UTXO, error)
	LockDepositInput(deposit *DepositData, tx crypto.Hash, fork bool) error
	LockMintInput(mint *MintData, tx crypto.Hash, fork bool) error
}

type UTXOReader

type UTXOReader interface {
	ReadUTXO(hash crypto.Hash, index int) (*UTXO, error)
	CheckDepositInput(deposit *DepositData, tx crypto.Hash) error
	ReadLastMintDistribution(group string) (*MintDistribution, error)
}

type UTXOWithLock

type UTXOWithLock struct {
	UTXO
	LockHash crypto.Hash
}

Jump to

Keyboard shortcuts

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