constraints

package
v0.0.0-...-1c999d7 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TransactionBranch = byte(iota)
	ConsumedBranch
)

Top level branches

View Source
const (
	TxUnlockParams = byte(iota)
	TxInputIDs
	TxOutputs
	TxSignature
	TxTimestamp
	TxInputCommitment
	TxEndorsements
	TxLocalLibraries
	TxTreeIndexMax
)

Transaction tree

View Source
const (
	ConstraintIndexAmount = byte(iota)
	ConstraintIndexTimestamp
	ConstraintIndexLock
)

Mandatory output block indices

View Source
const AddressED25519ConstraintSource = `` /* 2112-byte string literal not displayed */
View Source
const (
	AmountConstraintName = "amount"
)
View Source
const (
	ChainConstraintName = "chain"
)
View Source
const ChainLockConstraintSource = `` /* 905-byte string literal not displayed */
View Source
const (
	ChainLockName = "chainLock"
)
View Source
const (
	CommitToSiblingName = "commitToSibling"
)
View Source
const CommitToSiblingSource = `` /* 337-byte string literal not displayed */
View Source
const (
	ConsumedOutputsBranch = byte(iota)
)
View Source
const ImmutableDataSource = `` /* 1968-byte string literal not displayed */
View Source
const (
	ImmutableName = "immutable"
)
View Source
const MaxNumberOfEndorsements = 4

MaxNumberOfEndorsements is equivalent to 2 parents in the original Tangle. Here it can be any number from 0 to MaxNumberOfEndorsements inclusive

View Source
const (
	RoyaltiesED25519Name = "royaltiesED25519"
)
View Source
const RoyaltiesED25519Source = `` /* 625-byte string literal not displayed */
View Source
const (
	SenderAddressED25519Name = "senderAddressED25519"
)
View Source
const (
	StateIndexName = "stateIndex"
)
View Source
const StateIndexSource = `
func stateIndex : concat($0, $1, !!!implement_me_StateIndexConstraint)
`
View Source
const (
	TimestampConstraintName = "timestamp"
)

Variables

Functions

func CompileLocalLibrary

func CompileLocalLibrary(source string) ([]byte, error)

CompileLocalLibrary compiles local library and serializes it as lazy array

func Equal

func Equal(l1, l2 Constraint) bool

func MinimumStorageDeposit

func MinimumStorageDeposit(outputByteSize, extraWeight uint32) uint64

func NameByPrefix

func NameByPrefix(prefix []byte) (string, bool)

func NewChainLockUnlockParams

func NewChainLockUnlockParams(chainOutputIndex, chainConstraintIndex byte) []byte

Types

type AccountID

type AccountID []byte

func (AccountID) Bytes

func (acc AccountID) Bytes() []byte

type Accountable

type Accountable interface {
	Constraint
	AccountID() AccountID
	AsLock() Lock
}

func AccountableFromBytes

func AccountableFromBytes(data []byte) (Accountable, error)

type AddressED25519

type AddressED25519 []byte

func AddressED25519FromBytes

func AddressED25519FromBytes(data []byte) (AddressED25519, error)

func AddressED25519FromPrivateKey

func AddressED25519FromPrivateKey(privateKey ed25519.PrivateKey) AddressED25519

func AddressED25519FromPublicKey

func AddressED25519FromPublicKey(pubKey ed25519.PublicKey) AddressED25519

func AddressED25519Null

func AddressED25519Null() AddressED25519

func (AddressED25519) AccountID

func (a AddressED25519) AccountID() AccountID

func (AddressED25519) AsLock

func (a AddressED25519) AsLock() Lock

func (AddressED25519) Bytes

func (a AddressED25519) Bytes() []byte

func (AddressED25519) IndexableTags

func (a AddressED25519) IndexableTags() []Accountable

func (AddressED25519) Name

func (a AddressED25519) Name() string

func (AddressED25519) String

func (a AddressED25519) String() string

func (AddressED25519) UnlockableWith

func (a AddressED25519) UnlockableWith(acc AccountID, ts uint32) bool

type Amount

type Amount uint64

func AmountFromBytes

func AmountFromBytes(data []byte) (Amount, error)

func NewAmount

func NewAmount(a uint64) Amount

func (Amount) Amount

func (a Amount) Amount() uint64

func (Amount) Bytes

func (a Amount) Bytes() []byte

func (Amount) Name

func (a Amount) Name() string

func (Amount) String

func (a Amount) String() string

type ChainConstraint

type ChainConstraint struct {
	// ID all-0 for origin
	ID             [32]byte
	TransitionMode byte
	// Previous index of the consumed chain input with the same ID. Must be 0xFF for the origin
	PreviousOutput byte
	PreviousBlock  byte
}

ChainConstraint is a chain constraint

func ChainConstraintFromBytes

func ChainConstraintFromBytes(data []byte) (*ChainConstraint, error)

func NewChainConstraint

func NewChainConstraint(id [32]byte, prevOut, prevBlock, mode byte) *ChainConstraint

func NewChainOrigin

func NewChainOrigin() *ChainConstraint

func (*ChainConstraint) Bytes

func (ch *ChainConstraint) Bytes() []byte

func (*ChainConstraint) ChainLock

func (ch *ChainConstraint) ChainLock() ChainLock

func (*ChainConstraint) IsOrigin

func (ch *ChainConstraint) IsOrigin() bool

func (*ChainConstraint) Name

func (ch *ChainConstraint) Name() string

func (*ChainConstraint) String

func (ch *ChainConstraint) String() string

type ChainLock

type ChainLock []byte

func ChainLockFromBytes

func ChainLockFromBytes(data []byte) (ChainLock, error)

func ChainLockFromChainID

func ChainLockFromChainID(chainID []byte) (ChainLock, error)

func ChainLockNull

func ChainLockNull() ChainLock

func (ChainLock) AccountID

func (cl ChainLock) AccountID() AccountID

func (ChainLock) AsLock

func (cl ChainLock) AsLock() Lock

func (ChainLock) Bytes

func (cl ChainLock) Bytes() []byte

func (ChainLock) ChainID

func (cl ChainLock) ChainID() []byte

func (ChainLock) IndexableTags

func (cl ChainLock) IndexableTags() []Accountable

func (ChainLock) Name

func (cl ChainLock) Name() string

func (ChainLock) String

func (cl ChainLock) String() string

func (ChainLock) UnlockableWith

func (cl ChainLock) UnlockableWith(acc AccountID, _ uint32) bool

type CommitToSibling

type CommitToSibling struct {
	SiblingIndex byte
	SiblingHash  []byte
}

func CommitToSiblingFromBytes

func CommitToSiblingFromBytes(data []byte) (*CommitToSibling, error)

func NewCommitToSibling

func NewCommitToSibling(siblingIndex byte, siblingHash []byte) *CommitToSibling

func (*CommitToSibling) Bytes

func (cs *CommitToSibling) Bytes() []byte

func (*CommitToSibling) Name

func (cs *CommitToSibling) Name() string

func (*CommitToSibling) String

func (cs *CommitToSibling) String() string

type Constraint

type Constraint interface {
	Name() string
	Bytes() []byte
	String() string
}

func FromBytes

func FromBytes(data []byte) (Constraint, error)

type DataContext

type DataContext struct {
	// contains filtered or unexported fields
}

DataContext is the data structure passed to the eval call. It contains: - tree: all validation context of the transaction, all data which is to be validated - path: a path in the validation context of the constraint being validated in the eval call

func NewDataContext

func NewDataContext(tree *lazyslice.Tree) *DataContext

func (*DataContext) DataTree

func (c *DataContext) DataTree() *lazyslice.Tree

func (*DataContext) Path

func (c *DataContext) Path() lazyslice.TreePath

func (*DataContext) SetPath

func (c *DataContext) SetPath(path lazyslice.TreePath)

type DeadlineLock

type DeadlineLock struct {
	Deadline         uint32
	ConstraintMain   Accountable
	ConstraintExpiry Accountable
}

func DeadlineLockFromBytes

func DeadlineLockFromBytes(data []byte) (*DeadlineLock, error)

func NewDeadlineLock

func NewDeadlineLock(deadline uint32, main, expiry Accountable) *DeadlineLock

func (*DeadlineLock) Bytes

func (dl *DeadlineLock) Bytes() []byte

func (*DeadlineLock) IndexableTags

func (dl *DeadlineLock) IndexableTags() []Accountable

func (*DeadlineLock) Name

func (dl *DeadlineLock) Name() string

func (*DeadlineLock) String

func (dl *DeadlineLock) String() string

func (*DeadlineLock) UnlockableWith

func (dl *DeadlineLock) UnlockableWith(acc AccountID, ts uint32) bool

type GeneralScript

type GeneralScript []byte

func NewGeneralScript

func NewGeneralScript(data []byte) GeneralScript

func NewGeneralScriptFromSource

func NewGeneralScriptFromSource(src string) (GeneralScript, error)

func (GeneralScript) Bytes

func (u GeneralScript) Bytes() []byte

func (GeneralScript) Name

func (u GeneralScript) Name() string

func (GeneralScript) String

func (u GeneralScript) String() string

type Immutable

type Immutable struct {
	ChainBlockIndex byte
	DataBlockIndex  byte
}

func ImmutableFromBytes

func ImmutableFromBytes(data []byte) (*Immutable, error)

func NewImmutable

func NewImmutable(chainBlockIndex, dataBlockIndex byte) *Immutable

func (*Immutable) Bytes

func (d *Immutable) Bytes() []byte

func (*Immutable) Name

func (d *Immutable) Name() string

func (*Immutable) String

func (d *Immutable) String() string

type Lock

type Lock interface {
	Constraint
	IndexableTags() []Accountable
	UnlockableWith(acc AccountID, ts uint32) bool
}

func LockFromBytes

func LockFromBytes(data []byte) (Lock, error)

type Parser

type Parser func([]byte) (Constraint, error)

type RoyaltiesED25519

type RoyaltiesED25519 struct {
	Address AddressED25519
	Amount  uint64
}

func NewRoyalties

func NewRoyalties(addr AddressED25519, amount uint64) *RoyaltiesED25519

func RoyaltiesED25519FromBytes

func RoyaltiesED25519FromBytes(data []byte) (*RoyaltiesED25519, error)

func (*RoyaltiesED25519) Bytes

func (cl *RoyaltiesED25519) Bytes() []byte

func (*RoyaltiesED25519) Name

func (cl *RoyaltiesED25519) Name() string

func (RoyaltiesED25519) String

func (cl RoyaltiesED25519) String() string

type SenderAddressED25519

type SenderAddressED25519 struct {
	Address AddressED25519
}

func NewSenderAddressED25519

func NewSenderAddressED25519(addr AddressED25519) *SenderAddressED25519

func SenderAddressED25519FromBytes

func SenderAddressED25519FromBytes(data []byte) (*SenderAddressED25519, error)

func (*SenderAddressED25519) Bytes

func (s *SenderAddressED25519) Bytes() []byte

func (*SenderAddressED25519) Name

func (s *SenderAddressED25519) Name() string

func (*SenderAddressED25519) String

func (s *SenderAddressED25519) String() string

type StateIndex

type StateIndex struct {
	ChainBlockIndex byte
	StateIndex      uint32
}

func NewStateIndex

func NewStateIndex(chainBlockIndex byte, stateIndex uint32) *StateIndex

func StateIndexFromBytes

func StateIndexFromBytes(data []byte) (*StateIndex, error)

func (*StateIndex) Bytes

func (s *StateIndex) Bytes() []byte

func (*StateIndex) Name

func (_ *StateIndex) Name() string

func (*StateIndex) String

func (s *StateIndex) String() string

type Timelock

type Timelock uint32

func NewTimelock

func NewTimelock(unixSec uint32) Timelock

func TimelockFromBytes

func TimelockFromBytes(data []byte) (Timelock, error)

func (Timelock) Bytes

func (t Timelock) Bytes() []byte

func (Timelock) Name

func (t Timelock) Name() string

func (Timelock) String

func (t Timelock) String() string

type Timestamp

type Timestamp uint32

func NewTimestamp

func NewTimestamp(unixSec uint32) Timestamp

func TimestampFromBytes

func TimestampFromBytes(data []byte) (Timestamp, error)

func (Timestamp) Bytes

func (t Timestamp) Bytes() []byte

func (Timestamp) Name

func (t Timestamp) Name() string

func (Timestamp) String

func (t Timestamp) String() string

Jump to

Keyboard shortcuts

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