common

package
v0.5.8 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2019 License: GPL-3.0 Imports: 17 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
	OutputTypeWithdrawalSubmit = 0xa1
	OutputTypeWithdrawalFuel   = 0xa2
	OutputTypeNodePledge       = 0xa3
	OutputTypeNodeAccept       = 0xa4
	OutputTypeNodeDepart       = 0xa5
	OutputTypeNodeRemove       = 0xa6
	OutputTypeDomainAccept     = 0xa7
	OutputTypeDomainRemove     = 0xa8
	OutputTypeWithdrawalClaim  = 0xa9

	TransactionTypeScript           = 0x00
	TransactionTypeMint             = 0x01
	TransactionTypeDeposit          = 0x02
	TransactionTypeWithdrawalSubmit = 0x03
	TransactionTypeWithdrawalFuel   = 0x04
	TransactionTypeWithdrawalClaim  = 0x05
	TransactionTypeNodePledge       = 0x06
	TransactionTypeNodeAccept       = 0x07
	TransactionTypeNodeDepart       = 0x08
	TransactionTypeNodeRemove       = 0x09
	TransactionTypeDomainAccept     = 0x10
	TransactionTypeDomainRemove     = 0x11
	TransactionTypeUnknown          = 0xff
)
View Source
const MainNetworkId = "XIN"
View Source
const (
	MintGroupKernelNode = "KERNELNODE"
)
View Source
const Precision = 8
View Source
const (
	SnapshotVersion = 1
)

Variables

View Source
var (
	EthereumChainId crypto.Hash

	XINAssetId crypto.Hash
)
View Source
var (
	CompressionVersionZero   = []byte{0, 0, 0, 0}
	CompressionVersionLatest = CompressionVersionZero
)

Functions

func CompressMsgpackMarshalPanic added in v0.2.7

func CompressMsgpackMarshalPanic(val interface{}) []byte

func DecompressMsgpackUnmarshal added in v0.2.7

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

func MsgpackMarshalPanic

func MsgpackMarshalPanic(val interface{}) []byte

func MsgpackUnmarshal added in v0.1.13

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

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

type Asset struct {
	ChainId  crypto.Hash
	AssetKey string
}

func (*Asset) AssetId added in v0.1.14

func (a *Asset) AssetId() crypto.Hash

func (*Asset) FeeAssetId added in v0.1.14

func (a *Asset) FeeAssetId() crypto.Hash

func (*Asset) Verify added in v0.2.1

func (a *Asset) Verify() error

type DepositData

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

func (*DepositData) Asset added in v0.1.14

func (d *DepositData) Asset() *Asset

func (*DepositData) UniqueKey added in v0.1.4

func (d *DepositData) UniqueKey() crypto.Hash

type DeprecatedSnapshot added in v0.5.0

type DeprecatedSnapshot struct {
	NodeId      crypto.Hash
	Transaction crypto.Hash
	References  *RoundLink
	RoundNumber uint64
	Timestamp   uint64
	Signatures  []*crypto.Signature
}

type Domain

type Domain struct {
	Account Address
}

type DomainReader

type DomainReader interface {
	ReadDomains() []Domain
}

type GenesisHackInput added in v0.1.14

type GenesisHackInput struct {
	Hash    crypto.Hash
	Index   int
	Genesis []byte
	Deposit *DepositData
	Rebate  []byte
	Mint    []byte
}

type GenesisHackTransaction added in v0.1.14

type GenesisHackTransaction struct {
	Version uint8
	Asset   crypto.Hash
	Inputs  []*GenesisHackInput
	Outputs []*Output
	Extra   []byte
}

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
	Transaction crypto.Hash
	Timestamp   uint64
	// contains filtered or unexported fields
}

func (*Node) IdForNetwork added in v0.5.2

func (n *Node) IdForNetwork(networkId crypto.Hash) crypto.Hash

type NodeReader

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

type Output

type Output struct {
	Type       uint8           `json:"type"`
	Amount     Integer         `json:"amount"`
	Keys       []crypto.Key    `json:"keys,omitempty"`
	Withdrawal *WithdrawalData `msgpack:",omitempty"json:"withdrawal,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 SignedGenesisHackTransaction added in v0.1.14

type SignedGenesisHackTransaction struct {
	GenesisHackTransaction
	Signatures [][]crypto.Signature
}

type SignedTransaction

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

func (*SignedTransaction) AsLatestVersion added in v0.4.1

func (tx *SignedTransaction) AsLatestVersion() *VersionedTransaction

func (*SignedTransaction) DepositData added in v0.1.14

func (tx *SignedTransaction) DepositData() *DepositData

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) TransactionType added in v0.2.0

func (tx *SignedTransaction) TransactionType() uint8

type Snapshot

type Snapshot struct {
	Version     uint8                 `json:"version"`
	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"msgpack:",omitempty"`
	Signature   *crypto.CosiSignature `json:"signature,omitempty"msgpack:",omitempty"`
	Hash        crypto.Hash           `msgpack:"-"json:"hash"`
	Commitment  *crypto.Key           `msgpack:"-"json:"-"`
}

func (*Snapshot) PayloadHash

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

func (*Snapshot) VersionedPayload added in v0.5.0

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

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) AddOutputWithType added in v0.2.0

func (tx *Transaction) AddOutputWithType(ot uint8, accounts []Address, s Script, amount Integer, seed []byte)

func (*Transaction) AddRandomScriptOutput added in v0.2.0

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

func (*Transaction) AddScriptOutput

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

func (*Transaction) AsLatestVersion added in v0.1.14

func (tx *Transaction) AsLatestVersion() *VersionedTransaction

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) 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) (*UTXOWithLock, error)
	CheckDepositInput(deposit *DepositData, tx crypto.Hash) error
	ReadLastMintDistribution(group string) (*MintDistribution, error)
}

type UTXOWithLock

type UTXOWithLock struct {
	UTXO
	LockHash crypto.Hash
}

type VersionedTransaction added in v0.1.14

type VersionedTransaction struct {
	SignedTransaction
	BadGenesis *SignedGenesisHackTransaction
}

func DecompressUnmarshalVersionedTransaction added in v0.2.7

func DecompressUnmarshalVersionedTransaction(val []byte) (*VersionedTransaction, error)

func UnmarshalVersionedTransaction added in v0.1.14

func UnmarshalVersionedTransaction(val []byte) (*VersionedTransaction, error)

func (*VersionedTransaction) CompressMarshal added in v0.2.7

func (ver *VersionedTransaction) CompressMarshal() []byte

func (*VersionedTransaction) LockInputs added in v0.1.14

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

func (*VersionedTransaction) Marshal added in v0.1.14

func (ver *VersionedTransaction) Marshal() []byte

func (*VersionedTransaction) PayloadHash added in v0.1.14

func (ver *VersionedTransaction) PayloadHash() crypto.Hash

func (*VersionedTransaction) PayloadMarshal added in v0.1.14

func (ver *VersionedTransaction) PayloadMarshal() []byte

func (*VersionedTransaction) UnspentOutputs added in v0.1.14

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

func (*VersionedTransaction) Validate added in v0.1.14

func (ver *VersionedTransaction) Validate(store DataStore) error

type WithdrawalData added in v0.2.0

type WithdrawalData struct {
	Chain    crypto.Hash `json:"chain"`
	AssetKey string      `json:"asset"`
	Address  string      `json:"address"`
	Tag      string      `json:"tag"`
}

func (*WithdrawalData) Asset added in v0.2.0

func (w *WithdrawalData) Asset() *Asset

Jump to

Keyboard shortcuts

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