devnetvm

package
v0.9.8 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2022 License: Apache-2.0, BSD-2-Clause Imports: 30 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// UTXOInputType is the type of an Input that references an UTXO Output.
	UTXOInputType InputType = iota

	// MinInputCount defines the minimum amount of Inputs in a Transaction.
	MinInputCount = 1

	// MaxInputCount defines the maximum amount of Inputs in a Transaction.
	MaxInputCount = 127
)
View Source
const (
	// MinOutputCount defines the minimum amount of Outputs in a Transaction.
	MinOutputCount = 1

	// MaxOutputCount defines the maximum amount of Outputs in a Transaction.
	MaxOutputCount = 127

	// MinOutputBalance defines the minimum balance per Output.
	MinOutputBalance = 1

	// MaxOutputBalance defines the maximum balance on an Output (the supply).
	MaxOutputBalance = 2779530283277761
)
View Source
const AddressLength = 33

AddressLength contains the length of an address (type length = 1, Digest2 length = 32).

View Source
const AliasAddressDigestSize = 32

AliasAddressDigestSize defines the length of the alias address Digest2 in bytes.

View Source
const ColorLength = 32

ColorLength represents the length of a Color (amount of bytes).

View Source
const DustThresholdAliasOutputIOTA = uint64(100)

DustThresholdAliasOutputIOTA is minimum number of iotas enforced for the output to be correct TODO protocol-wide dust threshold configuration.

View Source
const MaxOutputPayloadSize = 4 * 1024

MaxOutputPayloadSize size limit on the data payload in the output.

Variables

View Source
var ColorIOTA = Color{}

ColorIOTA is the zero value of the Color and represents uncolored tokens.

View Source
var ColorMint = Color{255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}

ColorMint represents a placeholder Color that indicates that tokens should be "colored" in their Output.

View Source
var ErrTransactionInvalid = errors.New("transaction invalid")

ErrTransactionInvalid is returned if a Transaction or any of its building blocks is considered to be invalid.

View Source
var InputTypeNames = [...]string{
	"UTXOInputType",
}

InputTypeNames contains the names of the existing InputTypes.

View Source
var TransactionType payload.Type

TransactionType represents the payload Type of Transaction.

Functions

func AliasInitialStateValid

func AliasInitialStateValid(inputs Outputs, transaction *Transaction) bool

AliasInitialStateValid is an internal utility function that checks if aliases are created by the transaction with valid initial states. Initial state of an alias is valid, if and only if:

  • there is no "chained" alias with the same ID on the input side
  • the alias itself has the origin flag set, and state index is 0.

func IsAboveDustThreshold

func IsAboveDustThreshold(m map[Color]uint64) bool

IsAboveDustThreshold internal utility to check if balances pass dust constraint.

func IsExactDustMinimum

func IsExactDustMinimum(b *ColoredBalances) bool

IsExactDustMinimum checks if colored balances are exactly what is required by dust constraint.

func OutputFromBytes

func OutputFromBytes(data []byte) (output utxo.Output, err error)

OutputFromBytes is the factory function for Outputs.

func SafeAddUint64

func SafeAddUint64(a uint64, b uint64) (result uint64, valid bool)

SafeAddUint64 adds two uint64 values. It returns the result and a valid flag that indicates whether the addition is valid without causing an overflow.

func SafeSubUint64

func SafeSubUint64(a uint64, b uint64) (result uint64, valid bool)

SafeSubUint64 subtracts two uint64 values. It returns the result and a valid flag that indicates whether the subtraction is valid without causing an overflow.

func SetOutputID

func SetOutputID(essence *TransactionEssence, transactionID utxo.TransactionID)

SetOutputID assigns TransactionID to all outputs in TransactionEssence

func TransactionBalancesValid

func TransactionBalancesValid(inputs Outputs, outputs Outputs) (valid bool)

TransactionBalancesValid is an internal utility function that checks if the sum of the balance changes equals to 0.

func UnlockBlocksValid

func UnlockBlocksValid(inputs Outputs, transaction *Transaction) (valid bool)

UnlockBlocksValid is an internal utility function that checks if the UnlockBlocks are matching the referenced Inputs.

func UnlockBlocksValidWithError

func UnlockBlocksValidWithError(inputs Outputs, transaction *Transaction) (bool, error)

UnlockBlocksValidWithError is an internal utility function that checks if the UnlockBlocks are matching the referenced Inputs. In case an unlockblock is invalid, it returns the error that caused it.

Types

type Address

type Address interface {
	// Type returns the AddressType of the Address.
	Type() AddressType

	// Digest returns the hashed version of the Addresses public key.
	Digest() []byte

	// Clone creates a copy of the Address.
	Clone() Address

	// Equals returns true if the two Addresses are equal.
	Equals(other Address) bool

	// Bytes returns a marshaled version of the Address.
	Bytes() []byte

	// Array returns an array of bytes that contains the marshaled version of the Address.
	Array() [AddressLength]byte

	// Base58 returns a base58 encoded version of the Address.
	Base58() string

	// String returns a human readable version of the Address for debug purposes.
	String() string
}

Address is an interface for the different kind of Addresses that are supported by the ledger state.

func AddressFromBase58EncodedString

func AddressFromBase58EncodedString(base58String string) (address Address, err error)

AddressFromBase58EncodedString creates an Address from a base58 encoded string.

func AddressFromBytes

func AddressFromBytes(bytes []byte) (address Address, consumedBytes int, err error)

AddressFromBytes unmarshals an Address from a sequence of bytes.

func AddressFromSignature

func AddressFromSignature(sig Signature) (Address, error)

AddressFromSignature returns address corresponding to the signature if it has one (for ed25519 and BLS).

type AddressType

type AddressType byte

AddressType represents the type of the Address (different types encode different signature schemes).

const (
	// ED25519AddressType represents an Address secured by the ED25519 signature scheme.
	ED25519AddressType AddressType = iota

	// BLSAddressType represents an Address secured by the BLS signature scheme.
	BLSAddressType

	// AliasAddressType represents ID used in AliasOutput and AliasLockOutput.
	AliasAddressType
)

func (AddressType) String

func (a AddressType) String() string

String returns a human readable representation of the AddressType.

type AliasAddress

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

AliasAddress represents a special type of Address which is not backed by a private key directly, but is indirectly backed by a private key defined by corresponding AliasOutput parameters.

func AliasAddressFromBase58EncodedString

func AliasAddressFromBase58EncodedString(base58String string) (address *AliasAddress, err error)

AliasAddressFromBase58EncodedString creates an AliasAddress from a base58 encoded string.

func AliasAddressFromBytes

func AliasAddressFromBytes(data []byte) (address *AliasAddress, consumedBytes int, err error)

AliasAddressFromBytes unmarshals an AliasAddress from a sequence of bytes.

func NewAliasAddress

func NewAliasAddress(data []byte) *AliasAddress

NewAliasAddress creates a new AliasAddress from the given bytes used as seed. Normally the seed is an OutputID.

func (*AliasAddress) Array

func (a *AliasAddress) Array() (array [AddressLength]byte)

Array returns an array of bytes that contains the marshaled version of the Address.

func (*AliasAddress) Base58

func (a *AliasAddress) Base58() string

Base58 returns a base58 encoded version of the Address.

func (*AliasAddress) Bytes

func (a *AliasAddress) Bytes() []byte

Bytes returns a marshaled version of the Address.

func (*AliasAddress) Clone

func (a *AliasAddress) Clone() Address

Clone creates a copy of the Address.

func (*AliasAddress) Digest

func (a *AliasAddress) Digest() []byte

Digest returns the hashed version of the Addresses public key.

func (*AliasAddress) Equals

func (a *AliasAddress) Equals(other Address) bool

Equals returns true if the two Addresses are equal.

func (*AliasAddress) IsNil

func (a *AliasAddress) IsNil() bool

IsNil returns if the alias address is zero value (uninitialized).

func (*AliasAddress) String

func (a *AliasAddress) String() string

String returns a human readable version of the addresses for debug purposes.

func (*AliasAddress) Type

func (a *AliasAddress) Type() AddressType

Type returns the AddressType of the Address.

type AliasOutput

type AliasOutput struct {
	objectstorage.StorableObjectFlags
	// contains filtered or unexported fields
}

AliasOutput represents output which defines as AliasAddress. It can only be used in a chained manner.

func NewAliasOutputMint

func NewAliasOutputMint(balances map[Color]uint64, stateAddr Address, immutableData ...[]byte) (*AliasOutput, error)

NewAliasOutputMint creates new AliasOutput as minting output, i.e. the one which does not contain corresponding input.

func (*AliasOutput) Address

func (a *AliasOutput) Address() Address

Address AliasOutput is searchable in the ledger through its AliasAddress.

func (*AliasOutput) Balances

func (a *AliasOutput) Balances() *ColoredBalances

Balances return colored balances of the output.

func (*AliasOutput) Bytes

func (a *AliasOutput) Bytes() ([]byte, error)

Bytes serialized form.

func (*AliasOutput) Clone

func (a *AliasOutput) Clone() Output

Clone clones the structure.

func (*AliasOutput) Compare

func (a *AliasOutput) Compare(other Output) int

Compare the two outputs.

func (*AliasOutput) Decode

func (a *AliasOutput) Decode(b []byte) (int, error)

func (*AliasOutput) DelegationTimeLockedNow

func (a *AliasOutput) DelegationTimeLockedNow(nowis time.Time) bool

DelegationTimeLockedNow determines if the alias output is delegation timelocked at a given time.

func (*AliasOutput) DelegationTimelock

func (a *AliasOutput) DelegationTimelock() time.Time

DelegationTimelock returns the delegation timelock. If the output is not delegated, or delegation timelock is not set, it returns the zero time object.

func (*AliasOutput) Encode

func (a *AliasOutput) Encode() ([]byte, error)

func (*AliasOutput) FromBytes

func (a *AliasOutput) FromBytes(data []byte) error

FromBytes creates an AliasOutput from sequences of bytes.

func (*AliasOutput) FromObjectStorage

func (a *AliasOutput) FromObjectStorage(key, data []byte) (err error)

FromObjectStorage creates an AliasOutput from sequences of key and bytes.

func (*AliasOutput) GetAliasAddress

func (a *AliasOutput) GetAliasAddress() *AliasAddress

GetAliasAddress calculates new ID if it is a minting output. Otherwise it takes stored value.

func (*AliasOutput) GetGovernanceMetadata

func (a *AliasOutput) GetGovernanceMetadata() []byte

GetGovernanceMetadata gets the governance metadata.

func (*AliasOutput) GetGoverningAddress

func (a *AliasOutput) GetGoverningAddress() Address

GetGoverningAddress return governing address. If self-governed, it is the same as state controlling address.

func (*AliasOutput) GetImmutableData

func (a *AliasOutput) GetImmutableData() []byte

GetImmutableData gets the state data.

func (*AliasOutput) GetIsGovernanceUpdated

func (a *AliasOutput) GetIsGovernanceUpdated() bool

GetIsGovernanceUpdated returns if the output was unlocked for governance in the transaction.

func (*AliasOutput) GetStateAddress

func (a *AliasOutput) GetStateAddress() Address

GetStateAddress return state controlling address.

func (*AliasOutput) GetStateData

func (a *AliasOutput) GetStateData() []byte

GetStateData gets the state data.

func (*AliasOutput) GetStateIndex

func (a *AliasOutput) GetStateIndex() uint32

GetStateIndex returns the state index.

func (*AliasOutput) ID

func (a *AliasOutput) ID() utxo.OutputID

ID is the ID of the output.

func (*AliasOutput) Input

func (a *AliasOutput) Input() Input

Input makes input from the output.

func (*AliasOutput) IsDelegated

func (a *AliasOutput) IsDelegated() bool

IsDelegated returns true if the output is delegated.

func (*AliasOutput) IsOrigin

func (a *AliasOutput) IsOrigin() bool

IsOrigin returns true if it starts the chain.

func (*AliasOutput) IsSelfGoverned

func (a *AliasOutput) IsSelfGoverned() bool

IsSelfGoverned returns if governing address is not set which means that stateAddress is same as governingAddress.

func (*AliasOutput) NewAliasOutputNext

func (a *AliasOutput) NewAliasOutputNext(governanceUpdate ...bool) *AliasOutput

NewAliasOutputNext creates new AliasOutput as state transition from the previous one.

func (*AliasOutput) ObjectStorageKey

func (a *AliasOutput) ObjectStorageKey() []byte

ObjectStorageKey a key.

func (*AliasOutput) ObjectStorageValue

func (a *AliasOutput) ObjectStorageValue() []byte

ObjectStorageValue binary form.

func (*AliasOutput) SetAliasAddress

func (a *AliasOutput) SetAliasAddress(addr *AliasAddress)

SetAliasAddress sets the alias address of the alias output.

func (*AliasOutput) SetBalances

func (a *AliasOutput) SetBalances(balances map[Color]uint64) error

SetBalances sets colored balances of the output.

func (*AliasOutput) SetDelegationTimelock

func (a *AliasOutput) SetDelegationTimelock(timelock time.Time) error

SetDelegationTimelock sets the delegation timelock. An error is returned if the output is not a delegated.

func (*AliasOutput) SetGovernanceMetadata

func (a *AliasOutput) SetGovernanceMetadata(data []byte) error

SetGovernanceMetadata sets governance metadata.

func (*AliasOutput) SetGoverningAddress

func (a *AliasOutput) SetGoverningAddress(addr Address)

SetGoverningAddress sets the governing address or nil for self-governing.

func (*AliasOutput) SetID

func (a *AliasOutput) SetID(outputID utxo.OutputID)

SetID set the output ID after unmarshalling.

func (*AliasOutput) SetImmutableData

func (a *AliasOutput) SetImmutableData(data []byte) error

SetImmutableData sets the immutable data field of the alias output.

func (*AliasOutput) SetIsDelegated

func (a *AliasOutput) SetIsDelegated(isDelegated bool)

SetIsDelegated sets the isDelegated field of the output.

func (*AliasOutput) SetIsGovernanceUpdated

func (a *AliasOutput) SetIsGovernanceUpdated(i bool)

SetIsGovernanceUpdated sets the isGovernanceUpdated flag.

func (*AliasOutput) SetIsOrigin

func (a *AliasOutput) SetIsOrigin(isOrigin bool)

SetIsOrigin sets the isOrigin field of the output.

func (*AliasOutput) SetStateAddress

func (a *AliasOutput) SetStateAddress(addr Address) error

SetStateAddress sets the state controlling address.

func (*AliasOutput) SetStateData

func (a *AliasOutput) SetStateData(data []byte) error

SetStateData sets state data.

func (*AliasOutput) SetStateIndex

func (a *AliasOutput) SetStateIndex(index uint32)

SetStateIndex sets the state index in the input. It is enforced to increment by 1 with each state transition.

func (*AliasOutput) String

func (a *AliasOutput) String() string

String human readable form.

func (*AliasOutput) Type

func (a *AliasOutput) Type() OutputType

Type return the type of the output.

func (*AliasOutput) UnlockValid

func (a *AliasOutput) UnlockValid(tx *Transaction, unlockBlock UnlockBlock, inputs []Output) (bool, error)

UnlockValid check unlock and validates chain.

func (*AliasOutput) UpdateMintingColor

func (a *AliasOutput) UpdateMintingColor() Output

UpdateMintingColor replaces minting code with computed color code, and calculates the alias address if it is a freshly minted alias output.

func (*AliasOutput) WithDelegation

func (a *AliasOutput) WithDelegation() *AliasOutput

WithDelegation returns the output as a delegateds alias output.

func (*AliasOutput) WithDelegationAndTimelock

func (a *AliasOutput) WithDelegationAndTimelock(lockUntil time.Time) *AliasOutput

WithDelegationAndTimelock returns the output as a delegated alias output and a set delegation timelock.

type AliasUnlockBlock

type AliasUnlockBlock struct {
	model.Immutable[AliasUnlockBlock, *AliasUnlockBlock, aliasUnlockBlockModel] `serix:"0"`
}

AliasUnlockBlock defines an UnlockBlock which contains an index of corresponding AliasOutput.

func NewAliasUnlockBlock

func NewAliasUnlockBlock(chainInputIndex uint16) *AliasUnlockBlock

NewAliasUnlockBlock is the constructor for AliasUnlockBlocks.

func (*AliasUnlockBlock) AliasInputIndex

func (r *AliasUnlockBlock) AliasInputIndex() uint16

AliasInputIndex returns the index of the input, the AliasOutput which contains AliasAddress.

func (*AliasUnlockBlock) Type

Type returns the UnlockBlockType of the UnlockBlock.

type BLSAddress

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

BLSAddress represents an Address that is secured by the BLS signature scheme.

func BLSAddressFromBytes

func BLSAddressFromBytes(bytes []byte) (address *BLSAddress, consumedBytes int, err error)

BLSAddressFromBytes unmarshals an BLSAddress from a sequence of bytes.

func NewBLSAddress

func NewBLSAddress(publicKey []byte) *BLSAddress

NewBLSAddress creates a new BLSAddress from the given public key.

func (*BLSAddress) Array

func (b *BLSAddress) Array() (array [AddressLength]byte)

Array returns an array of bytes that contains the marshaled version of the Address.

func (*BLSAddress) Base58

func (b *BLSAddress) Base58() string

Base58 returns a base58 encoded version of the Address.

func (*BLSAddress) Bytes

func (b *BLSAddress) Bytes() []byte

Bytes returns a marshaled version of the Address.

func (*BLSAddress) Clone

func (b *BLSAddress) Clone() Address

Clone creates a copy of the Address.

func (*BLSAddress) Digest

func (b *BLSAddress) Digest() []byte

Digest returns the hashed version of the Addresses public key.

func (*BLSAddress) Equals

func (b *BLSAddress) Equals(other Address) bool

Equals returns true if the two Addresses are equal.

func (*BLSAddress) String

func (b *BLSAddress) String() string

String returns a human readable version of the addresses for debug purposes.

func (*BLSAddress) Type

func (b *BLSAddress) Type() AddressType

Type returns the AddressType of the Address.

type BLSSignature

type BLSSignature struct {
	Signature bls.SignatureWithPublicKey `serix:"0"`
}

BLSSignature represents a Signature created with the BLS signature scheme.

func BLSSignatureFromBytes

func BLSSignatureFromBytes(bytes []byte) (signature *BLSSignature, consumedBytes int, err error)

BLSSignatureFromBytes unmarshals a BLSSignature from a sequence of bytes.

func NewBLSSignature

func NewBLSSignature(signature bls.SignatureWithPublicKey) *BLSSignature

NewBLSSignature is the constructor of a BLSSignature.

func (*BLSSignature) AddressSignatureValid

func (b *BLSSignature) AddressSignatureValid(address Address, data []byte) bool

AddressSignatureValid returns true if the Signature signs the given Address.

func (*BLSSignature) Base58

func (b *BLSSignature) Base58() string

Base58 returns a base58 encoded version of the Signature.

func (*BLSSignature) Bytes

func (b *BLSSignature) Bytes() []byte

Bytes returns a marshaled version of the Signature.

func (*BLSSignature) SignatureValid

func (b *BLSSignature) SignatureValid(data []byte) bool

SignatureValid returns true if the Signature signs the given data.

func (*BLSSignature) String

func (b *BLSSignature) String() string

String returns a human readable version of the Signature.

func (*BLSSignature) Type

func (b *BLSSignature) Type() SignatureType

Type returns the SignatureType of this Signature.

type Color

type Color [ColorLength]byte

Color represents a marker that is associated to a token balance and that can give tokens a certain "meaning".

func ColorFromBase58EncodedString

func ColorFromBase58EncodedString(base58String string) (color Color, err error)

ColorFromBase58EncodedString creates a Color from a base58 encoded string.

func ColorFromBytes

func ColorFromBytes(data []byte) (color Color, consumedBytes int, err error)

ColorFromBytes unmarshals a Color from a sequence of bytes.

func (Color) Base58

func (c Color) Base58() string

Base58 returns a base58 encoded version of the Color.

func (Color) Bytes

func (c Color) Bytes() []byte

Bytes marshals the Color into a sequence of bytes.

func (Color) Compare

func (c Color) Compare(otherColor Color) int

Compare offers a comparator for Colors which returns -1 if otherColor is bigger, 1 if it is smaller and 0 if they are the same.

func (Color) String

func (c Color) String() string

String creates a human-readable string of the Color.

type ColoredBalances

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

ColoredBalances represents a collection of balances associated to their respective Color that maintains a deterministic order of the present Colors.

func ColoredBalancesFromBytes

func ColoredBalancesFromBytes(bytes []byte) (coloredBalances *ColoredBalances, consumedBytes int, err error)

ColoredBalancesFromBytes unmarshals ColoredBalances from a sequence of bytes.

func NewColoredBalances

func NewColoredBalances(balances map[Color]uint64) (coloredBalances *ColoredBalances)

NewColoredBalances returns a new deterministically ordered collection of ColoredBalances.

func (*ColoredBalances) Bytes

func (c *ColoredBalances) Bytes() []byte

Bytes returns a marshaled version of the Marker.

func (*ColoredBalances) Clone

func (c *ColoredBalances) Clone() *ColoredBalances

Clone returns a copy of the ColoredBalances.

func (*ColoredBalances) ForEach

func (c *ColoredBalances) ForEach(consumer func(color Color, balance uint64) bool)

ForEach calls the consumer for each element in the collection and aborts the iteration if the consumer returns false.

func (*ColoredBalances) Get

func (c *ColoredBalances) Get(color Color) (uint64, bool)

Get returns the balance of the given Color and a boolean value indicating if the requested Color existed.

func (*ColoredBalances) Map

func (c *ColoredBalances) Map() (balances map[Color]uint64)

Map returns a vanilla golang map (unordered) containing the existing balances. Since the ColoredBalances are immutable to ensure the deterministic ordering, this method can be used to retrieve a copy of the current values prior to some modification (like setting the updated colors of a minting transaction) which can then be used to create a new ColoredBalances object.

func (*ColoredBalances) Size

func (c *ColoredBalances) Size() int

Size returns the amount of individual balances in the ColoredBalances.

func (*ColoredBalances) String

func (c *ColoredBalances) String() string

String returns a human-readable version of the ColoredBalances.

type ED25519Address

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

ED25519Address represents an Address that is secured by the ED25519 signature scheme.

func ED25519AddressFromBytes

func ED25519AddressFromBytes(bytes []byte) (address *ED25519Address, consumedBytes int, err error)

ED25519AddressFromBytes unmarshals an ED25519Address from a sequence of bytes.

func NewED25519Address

func NewED25519Address(publicKey ed25519.PublicKey) *ED25519Address

NewED25519Address creates a new ED25519Address from the given public key.

func (*ED25519Address) Array

func (e *ED25519Address) Array() (array [AddressLength]byte)

Array returns an array of bytes that contains the marshaled version of the Address.

func (*ED25519Address) Base58

func (e *ED25519Address) Base58() string

Base58 returns a base58 encoded version of the address.

func (*ED25519Address) Bytes

func (e *ED25519Address) Bytes() []byte

Bytes returns a marshaled version of the Address.

func (*ED25519Address) Clone

func (e *ED25519Address) Clone() Address

Clone creates a copy of the Address.

func (*ED25519Address) Digest

func (e *ED25519Address) Digest() []byte

Digest returns the hashed version of the Addresses public key.

func (*ED25519Address) Equals

func (e *ED25519Address) Equals(other Address) bool

Equals returns true if the two Addresses are equal.

func (*ED25519Address) String

func (e *ED25519Address) String() string

String returns a human readable version of the addresses for debug purposes.

func (*ED25519Address) Type

func (e *ED25519Address) Type() AddressType

Type returns the AddressType of the Address.

type ED25519Signature

type ED25519Signature struct {
	PublicKey ed25519.PublicKey `serix:"0"`
	Signature ed25519.Signature `serix:"1"`
}

ED25519Signature represents a Signature created with the ed25519 signature scheme.

func ED25519SignatureFromBytes

func ED25519SignatureFromBytes(bytes []byte) (signature *ED25519Signature, consumedBytes int, err error)

ED25519SignatureFromBytes unmarshals a ED25519Signature from a sequence of bytes.

func NewED25519Signature

func NewED25519Signature(publicKey ed25519.PublicKey, signature ed25519.Signature) *ED25519Signature

NewED25519Signature is the constructor of an ED25519Signature.

func (*ED25519Signature) AddressSignatureValid

func (e *ED25519Signature) AddressSignatureValid(address Address, data []byte) bool

AddressSignatureValid returns true if the Signature signs the given Address.

func (*ED25519Signature) Base58

func (e *ED25519Signature) Base58() string

Base58 returns a base58 encoded version of the Signature.

func (*ED25519Signature) Bytes

func (e *ED25519Signature) Bytes() []byte

Bytes returns a marshaled version of the Signature.

func (*ED25519Signature) SignatureValid

func (e *ED25519Signature) SignatureValid(data []byte) bool

SignatureValid returns true if the Signature signs the given data.

func (*ED25519Signature) String

func (e *ED25519Signature) String() string

String returns a human readable version of the Signature.

func (*ED25519Signature) Type

func (e *ED25519Signature) Type() SignatureType

Type returns the SignatureType of this Signature.

type ExtendedLockedOutput

type ExtendedLockedOutput struct {
	objectstorage.StorableObjectFlags
	// contains filtered or unexported fields
}

ExtendedLockedOutput is an Extension of SigLockedColoredOutput. If extended options not enabled, it behaves as SigLockedColoredOutput. In addition it has options: - fallback address and fallback timeout - can be unlocked by AliasUnlockBlock (if address is of AliasAddress type) - can be time locked until deadline - data payload for arbitrary metadata (size limits apply).

func NewExtendedLockedOutput

func NewExtendedLockedOutput(balances map[Color]uint64, address Address) *ExtendedLockedOutput

NewExtendedLockedOutput is the constructor for a ExtendedLockedOutput.

func (*ExtendedLockedOutput) Address

func (o *ExtendedLockedOutput) Address() Address

Address returns the Address that the Output is associated to.

func (*ExtendedLockedOutput) Balances

func (o *ExtendedLockedOutput) Balances() *ColoredBalances

Balances returns the funds that are associated with the Output.

func (*ExtendedLockedOutput) Bytes

func (o *ExtendedLockedOutput) Bytes() ([]byte, error)

Bytes returns a marshaled version of the Output.

func (*ExtendedLockedOutput) Clone

func (o *ExtendedLockedOutput) Clone() Output

Clone creates a copy of the Output.

func (*ExtendedLockedOutput) Compare

func (o *ExtendedLockedOutput) Compare(other Output) int

Compare offers a comparator for Outputs which returns -1 if the other Output is bigger, 1 if it is smaller and 0 if they are the same.

func (*ExtendedLockedOutput) Decode

func (o *ExtendedLockedOutput) Decode(b []byte) (int, error)

func (*ExtendedLockedOutput) Encode

func (o *ExtendedLockedOutput) Encode() ([]byte, error)

func (*ExtendedLockedOutput) FallbackAddress

func (o *ExtendedLockedOutput) FallbackAddress() (addy Address)

FallbackAddress returns the fallback address that the Output is associated to.

func (*ExtendedLockedOutput) FallbackOptions

func (o *ExtendedLockedOutput) FallbackOptions() (Address, time.Time)

FallbackOptions returns fallback options of the output. The address is nil if fallback options are not set.

func (*ExtendedLockedOutput) FromBytes

func (o *ExtendedLockedOutput) FromBytes(data []byte) error

FromBytes creates an AliasOutput from sequences of bytes.

func (*ExtendedLockedOutput) FromObjectStorage

func (o *ExtendedLockedOutput) FromObjectStorage(key, value []byte) (err error)

FromObjectStorage creates an ExtendedLockedOutput from sequences of key and bytes.

func (*ExtendedLockedOutput) GetPayload

func (o *ExtendedLockedOutput) GetPayload() []byte

GetPayload return a data payload associated with the output.

func (*ExtendedLockedOutput) ID

ID returns the identifier of the Output that is used to address the Output in the UTXODAG.

func (*ExtendedLockedOutput) Input

func (o *ExtendedLockedOutput) Input() Input

Input returns an Input that references the Output.

func (*ExtendedLockedOutput) ObjectStorageKey

func (o *ExtendedLockedOutput) ObjectStorageKey() []byte

ObjectStorageKey a key.

func (*ExtendedLockedOutput) ObjectStorageValue

func (o *ExtendedLockedOutput) ObjectStorageValue() []byte

ObjectStorageValue binary form.

func (*ExtendedLockedOutput) SetID

func (o *ExtendedLockedOutput) SetID(outputID utxo.OutputID)

SetID allows to set the identifier of the Output. We offer a setter for the property since Outputs that are created to become part of a transaction usually do not have an identifier, yet as their identifier depends on the TransactionID that is only determinable after the Transaction has been fully constructed. The ID is therefore only accessed when the Output is supposed to be persisted by the node.

func (*ExtendedLockedOutput) SetPayload

func (o *ExtendedLockedOutput) SetPayload(data []byte) error

SetPayload sets the payload field of the output.

func (*ExtendedLockedOutput) String

func (o *ExtendedLockedOutput) String() string

String returns a human readable version of the Output.

func (*ExtendedLockedOutput) TimeLock

func (o *ExtendedLockedOutput) TimeLock() time.Time

TimeLock is a time after which output can be unlocked.

func (*ExtendedLockedOutput) TimeLockedNow

func (o *ExtendedLockedOutput) TimeLockedNow(nowis time.Time) bool

TimeLockedNow checks if output is unlocked for the specific moment.

func (*ExtendedLockedOutput) Type

func (o *ExtendedLockedOutput) Type() OutputType

Type returns the type of the Output which allows us to generically handle Outputs of different types.

func (*ExtendedLockedOutput) UnlockAddressNow

func (o *ExtendedLockedOutput) UnlockAddressNow(nowis time.Time) Address

UnlockAddressNow return unlock address which is valid for the specific moment of time.

func (*ExtendedLockedOutput) UnlockValid

func (o *ExtendedLockedOutput) UnlockValid(tx *Transaction, unlockBlock UnlockBlock, inputs []Output) (unlockValid bool, err error)

UnlockValid determines if the given Transaction and the corresponding UnlockBlock are allowed to spend the Output.

func (*ExtendedLockedOutput) UpdateMintingColor

func (o *ExtendedLockedOutput) UpdateMintingColor() Output

UpdateMintingColor replaces the ColorMint in the balances of the Output with the hash of the OutputID. It returns a copy of the original Output with the modified balances.

func (*ExtendedLockedOutput) WithFallbackOptions

func (o *ExtendedLockedOutput) WithFallbackOptions(addr Address, deadline time.Time) *ExtendedLockedOutput

WithFallbackOptions adds fallback options to the output and returns the updated version.

func (*ExtendedLockedOutput) WithTimeLock

func (o *ExtendedLockedOutput) WithTimeLock(timelock time.Time) *ExtendedLockedOutput

WithTimeLock adds timelock to the output and returns the updated version.

type Input

type Input interface {
	// Type returns the type of the Input.
	Type() InputType

	// Bytes returns a marshaled version of the Input.
	Bytes() ([]byte, error)

	// String returns a human readable version of the Input.
	String() string

	// Base58 returns the base58 encoded input.
	Base58() string

	// Compare offers a comparator for Inputs which returns -1 if other Input is bigger, 1 if it is smaller and 0 if they
	// are the same.
	Compare(other Input) int
}

Input is a generic interface for different kinds of Inputs.

type InputType

type InputType uint8

InputType represents the type of an Input.

func (InputType) String

func (i InputType) String() string

String returns a human readable representation of the InputType.

type Inputs

type Inputs []Input

Inputs represents a collection of Inputs that ensures a deterministic order.

func NewInputs

func NewInputs(optionalInputs ...Input) (inputs Inputs)

NewInputs returns a deterministically ordered collection of Inputs removing existing duplicates.

func (Inputs) Clone

func (i Inputs) Clone() (clonedInputs Inputs)

Clone creates a copy of the Inputs.

func (Inputs) String

func (i Inputs) String() string

String returns a human-readable version of the Inputs.

func (Inputs) Strings

func (i Inputs) Strings() (result []string)

Strings returns the Inputs in the form []transactionID:index.

type Output

type Output interface {
	// ID returns the identifier of the Output that is used to address the Output in the UTXODAG.
	ID() utxo.OutputID

	// SetID allows to set the identifier of the Output. We offer a setter for the property since Outputs that are
	// created to become part of a transaction usually do not have an identifier, yet as their identifier depends on
	// the TransactionID that is only determinable after the Transaction has been fully constructed. The ID is therefore
	// only accessed when the Output is supposed to be persisted.
	SetID(outputID utxo.OutputID)

	// Type returns the OutputType which allows us to generically handle Outputs of different types.
	Type() OutputType

	// Balances returns the funds that are associated with the Output.
	Balances() *ColoredBalances

	// Address returns the address that is associated to the output.
	Address() Address

	// UnlockValid determines if the given Transaction and the corresponding UnlockBlock are allowed to spend the
	// Output.
	UnlockValid(tx *Transaction, unlockBlock UnlockBlock, inputs []Output) (bool, error)

	// UpdateMintingColor replaces the ColorMint in the balances of the Output with the hash of the OutputID. It returns a
	// copy of the original Output with the modified balances.
	UpdateMintingColor() Output

	// Input returns an Input that references the Output.
	Input() Input

	// Clone creates a copy of the Output.
	Clone() Output

	// Bytes returns a serialized version of the Output.
	Bytes() (serialized []byte, err error)

	// String returns a human-readable version of the Output for debug purposes.
	String() string

	// Compare offers a comparator for Outputs which returns -1 if the other Output is bigger, 1 if it is smaller and 0
	// if they are the same.
	Compare(other Output) int

	// StorableObject makes Outputs storable in the ObjectStorage.
	objectstorage.StorableObject
}

Output is a generic interface for the different types of Outputs (with different unlock behaviors).

type OutputType

type OutputType uint8

OutputType represents the type of an Output. Outputs of different types can have different unlock rules and allow for some relatively basic smart contract logic.

const (
	// SigLockedSingleOutputType represents an Output holding vanilla IOTA tokens that gets unlocked by a signature.
	SigLockedSingleOutputType OutputType = iota

	// SigLockedColoredOutputType represents an Output that holds colored coins that gets unlocked by a signature.
	SigLockedColoredOutputType

	// AliasOutputType represents an Output which makes a chain with optional governance.
	AliasOutputType

	// ExtendedLockedOutputType represents an Output which extends SigLockedColoredOutput with alias locking and fallback.
	ExtendedLockedOutputType
)

func OutputTypeFromString

func OutputTypeFromString(ot string) (OutputType, error)

OutputTypeFromString returns the output type from a string.

func (OutputType) String

func (o OutputType) String() string

String returns a human readable representation of the OutputType.

type Outputs

type Outputs []Output

Outputs represents a list of Outputs that can be used in a Transaction.

func NewOutputs

func NewOutputs(optionalOutputs ...Output) (outputs Outputs)

NewOutputs returns a deterministically ordered collection of Outputs. It removes duplicates in the parameters and sorts the Outputs to ensure syntactical correctness.

func OutputsFromUTXOOutputs

func OutputsFromUTXOOutputs(utxoOutputs *utxo.Outputs) (outputs Outputs)

func (Outputs) ByID

func (o Outputs) ByID() (outputsByID OutputsByID)

ByID returns a map of Outputs where the key is the OutputID.

func (Outputs) Clone

func (o Outputs) Clone() (clonedOutputs Outputs)

Clone creates a copy of the Outputs.

func (Outputs) Filter

func (o Outputs) Filter(condition func(output Output) bool) (filteredOutputs Outputs)

Filter removes all elements from the Outputs that do not pass the given condition.

func (Outputs) Inputs

func (o Outputs) Inputs() Inputs

Inputs returns the Inputs that reference the Outputs.

func (Outputs) String

func (o Outputs) String() string

String returns a human-readable version of the Outputs.

func (Outputs) Strings

func (o Outputs) Strings() (result []string)

Strings returns the Outputs in the form []transactionID:index.

func (Outputs) UTXOOutputs

func (o Outputs) UTXOOutputs() (utxoOutputs []utxo.Output)

type OutputsByID

type OutputsByID map[utxo.OutputID]Output

OutputsByID represents a map of Outputs where every Output is stored with its corresponding OutputID as the key.

func NewOutputsByID

func NewOutputsByID(optionalOutputs ...Output) (outputsByID OutputsByID)

NewOutputsByID returns a map of Outputs where every Output is stored with its corresponding OutputID as the key.

func (OutputsByID) Clone

func (o OutputsByID) Clone() (clonedOutputs OutputsByID)

Clone creates a copy of the OutputsByID.

func (OutputsByID) Inputs

func (o OutputsByID) Inputs() Inputs

Inputs returns the Inputs that reference the Outputs.

func (OutputsByID) Outputs

func (o OutputsByID) Outputs() Outputs

Outputs returns a list of Outputs from the OutputsByID.

func (OutputsByID) String

func (o OutputsByID) String() string

String returns a human readable version of the OutputsByID.

type ReferenceUnlockBlock

type ReferenceUnlockBlock struct {
	model.Immutable[ReferenceUnlockBlock, *ReferenceUnlockBlock, referenceUnlockBlockModel] `serix:"0"`
}

ReferenceUnlockBlock defines an UnlockBlock which references a previous UnlockBlock (which must not be another ReferenceUnlockBlock).

func NewReferenceUnlockBlock

func NewReferenceUnlockBlock(referencedIndex uint16) *ReferenceUnlockBlock

NewReferenceUnlockBlock is the constructor for ReferenceUnlockBlocks.

func ReferenceUnlockBlockFromBytes

func ReferenceUnlockBlockFromBytes(bytes []byte) (unlockBlock *ReferenceUnlockBlock, consumedBytes int, err error)

ReferenceUnlockBlockFromBytes unmarshals a ReferenceUnlockBlock from a sequence of bytes.

func (*ReferenceUnlockBlock) ReferencedIndex

func (r *ReferenceUnlockBlock) ReferencedIndex() uint16

ReferencedIndex returns the index of the referenced UnlockBlock.

func (*ReferenceUnlockBlock) Type

Type returns the UnlockBlockType of the UnlockBlock.

type SigLockedColoredOutput

type SigLockedColoredOutput struct {
	model.Storable[utxo.OutputID, SigLockedColoredOutput, *SigLockedColoredOutput, sigLockedColoredOutput] `serix:"0"`
}

SigLockedColoredOutput is an Output that holds colored balances and that can be unlocked by providing a signature for an Address.

func NewSigLockedColoredOutput

func NewSigLockedColoredOutput(balances *ColoredBalances, address Address) *SigLockedColoredOutput

NewSigLockedColoredOutput is the constructor for a SigLockedColoredOutput.

func (*SigLockedColoredOutput) Address

func (s *SigLockedColoredOutput) Address() Address

Address returns the Address that the Output is associated to.

func (*SigLockedColoredOutput) Balances

func (s *SigLockedColoredOutput) Balances() *ColoredBalances

Balances returns the funds that are associated with the Output.

func (*SigLockedColoredOutput) Bytes

func (s *SigLockedColoredOutput) Bytes() (bytes []byte, err error)

func (*SigLockedColoredOutput) Clone

func (s *SigLockedColoredOutput) Clone() Output

Clone creates a copy of the Output.

func (*SigLockedColoredOutput) Compare

func (s *SigLockedColoredOutput) Compare(other Output) int

Compare offers a comparator for Outputs which returns -1 if the other Output is bigger, 1 if it is smaller and 0 if they are the same.

func (*SigLockedColoredOutput) FromBytes

func (s *SigLockedColoredOutput) FromBytes(bytes []byte) (err error)

func (*SigLockedColoredOutput) FromObjectStorage

func (s *SigLockedColoredOutput) FromObjectStorage(key, data []byte) (err error)

func (*SigLockedColoredOutput) Input

func (s *SigLockedColoredOutput) Input() Input

Input returns an Input that references the Output.

func (*SigLockedColoredOutput) ObjectStorageValue

func (s *SigLockedColoredOutput) ObjectStorageValue() (value []byte)

ObjectStorageValue marshals the Output into a sequence of bytes. The ID is not serialized here as it is only used as a key in the ObjectStorage.

func (*SigLockedColoredOutput) Type

Type returns the type of the Output which allows us to generically handle Outputs of different types.

func (*SigLockedColoredOutput) UnlockValid

func (s *SigLockedColoredOutput) UnlockValid(tx *Transaction, unlockBlock UnlockBlock, inputs []Output) (unlockValid bool, err error)

UnlockValid determines if the given Transaction and the corresponding UnlockBlock are allowed to spend the Output.

func (*SigLockedColoredOutput) UpdateMintingColor

func (s *SigLockedColoredOutput) UpdateMintingColor() (updatedOutput Output)

UpdateMintingColor replaces the ColorMint in the balances of the Output with the hash of the OutputID. It returns a copy of the original Output with the modified balances.

type SigLockedSingleOutput

type SigLockedSingleOutput struct {
	model.Storable[utxo.OutputID, SigLockedSingleOutput, *SigLockedSingleOutput, sigLockedSingleOutput] `serix:"0"`
}

SigLockedSingleOutput is an Output that holds exactly one uncolored balance and that can be unlocked by providing a signature for an Address.

func NewSigLockedSingleOutput

func NewSigLockedSingleOutput(balance uint64, address Address) *SigLockedSingleOutput

NewSigLockedSingleOutput is the constructor for a SigLockedSingleOutput.

func (*SigLockedSingleOutput) Address

func (s *SigLockedSingleOutput) Address() Address

Address returns the Address that the Output is associated to.

func (*SigLockedSingleOutput) Balances

func (s *SigLockedSingleOutput) Balances() *ColoredBalances

Balances returns the funds that are associated with the Output.

func (*SigLockedSingleOutput) Clone

func (s *SigLockedSingleOutput) Clone() Output

Clone creates a copy of the Output.

func (*SigLockedSingleOutput) Compare

func (s *SigLockedSingleOutput) Compare(other Output) int

Compare offers a comparator for Outputs which returns -1 if the other Output is bigger, 1 if it is smaller and 0 if they are the same.

func (*SigLockedSingleOutput) Input

func (s *SigLockedSingleOutput) Input() Input

Input returns an Input that references the Output.

func (*SigLockedSingleOutput) Type

Type returns the type of the Output which allows us to generically handle Outputs of different types.

func (*SigLockedSingleOutput) UnlockValid

func (s *SigLockedSingleOutput) UnlockValid(tx *Transaction, unlockBlock UnlockBlock, inputs []Output) (unlockValid bool, err error)

UnlockValid determines if the given Transaction and the corresponding UnlockBlock are allowed to spend the Output.

func (*SigLockedSingleOutput) UpdateMintingColor

func (s *SigLockedSingleOutput) UpdateMintingColor() Output

UpdateMintingColor does nothing for SigLockedSingleOutput.

type Signature

type Signature interface {
	// Type returns the SignatureType of this Signature.
	Type() SignatureType

	// SignatureValid returns true if the Signature signs the given data.
	SignatureValid(data []byte) bool

	// AddressSignatureValid returns true if the Signature signs the given Address.
	AddressSignatureValid(address Address, data []byte) bool

	// Bytes returns a marshaled version of the Signature.
	Bytes() []byte

	// Base58 returns a base58 encoded version of the Signature.
	Base58() string

	// String returns a human readable version of the Signature.
	String() string
}

Signature is an interface for the different kinds of Signatures that are supported by the ledger state.

func SignatureFromBase58EncodedString

func SignatureFromBase58EncodedString(base58String string) (signature Signature, err error)

SignatureFromBase58EncodedString creates a Signature from a base58 encoded string.

func SignatureFromBytes

func SignatureFromBytes(data []byte) (signature Signature, consumedBytes int, err error)

SignatureFromBytes unmarshals a Signature from a sequence of bytes.

type SignatureType

type SignatureType uint8

SignatureType represents the type of the signature scheme.

const (
	// ED25519SignatureType represents an ED25519 Signature.
	ED25519SignatureType SignatureType = iota

	// BLSSignatureType represents a BLS Signature.
	BLSSignatureType
)

func (SignatureType) String

func (s SignatureType) String() string

String returns a human readable representation of the SignatureType.

type SignatureUnlockBlock

type SignatureUnlockBlock struct {
	model.Immutable[SignatureUnlockBlock, *SignatureUnlockBlock, signatureUnlockBlockModel] `serix:"0"`
}

SignatureUnlockBlock represents an UnlockBlock that contains a Signature for an Address.

func NewSignatureUnlockBlock

func NewSignatureUnlockBlock(signature Signature) *SignatureUnlockBlock

NewSignatureUnlockBlock is the constructor for SignatureUnlockBlock objects.

func (*SignatureUnlockBlock) AddressSignatureValid

func (s *SignatureUnlockBlock) AddressSignatureValid(address Address, signedData []byte) bool

AddressSignatureValid returns true if the UnlockBlock correctly signs the given Address.

func (*SignatureUnlockBlock) Signature

func (s *SignatureUnlockBlock) Signature() Signature

Signature return the signature itself.

func (*SignatureUnlockBlock) Type

Type returns the UnlockBlockType of the UnlockBlock.

type Transaction

type Transaction struct {
	model.Storable[utxo.TransactionID, Transaction, *Transaction, transactionModel] `serix:"0"`
}

Transaction represents a payload that executes a value transfer in the ledger state.

func NewTransaction

func NewTransaction(essence *TransactionEssence, unlockBlocks UnlockBlocks) (transaction *Transaction)

NewTransaction creates a new Transaction from the given details.

func (*Transaction) Essence

func (t *Transaction) Essence() *TransactionEssence

Essence returns the TransactionEssence of the Transaction.

func (*Transaction) FromBytes

func (t *Transaction) FromBytes(data []byte) error

FromBytes unmarshals a Transaction from a sequence of bytes.

func (*Transaction) FromObjectStorage

func (t *Transaction) FromObjectStorage(key, value []byte) error

FromObjectStorage creates an Transaction from sequences of key and bytes.

func (*Transaction) ID

func (t *Transaction) ID() utxo.TransactionID

ID returns the identifier of the Transaction. Since calculating the TransactionID is a resource intensive operation we calculate this value lazy and use double-checked locking.

func (*Transaction) Inputs

func (t *Transaction) Inputs() (inputs []utxo.Input)

func (*Transaction) Type

func (t *Transaction) Type() payload.Type

Type returns the Type of the Payload.

func (*Transaction) UnlockBlocks

func (t *Transaction) UnlockBlocks() UnlockBlocks

UnlockBlocks returns the UnlockBlocks of the Transaction.

type TransactionEssence

type TransactionEssence struct {
	model.Immutable[TransactionEssence, *TransactionEssence, transactionEssenceModel] `serix:"0"`
}

TransactionEssence contains the transfer related information of the Transaction (without the unlocking details).

func NewTransactionEssence

func NewTransactionEssence(
	version TransactionEssenceVersion,
	timestamp time.Time,
	accessPledgeID identity.ID,
	consensusPledgeID identity.ID,
	inputs Inputs,
	outputs Outputs,
) *TransactionEssence

NewTransactionEssence creates a new TransactionEssence from the given details.

func TransactionEssenceFromBytes

func TransactionEssenceFromBytes(data []byte) (transactionEssence *TransactionEssence, consumedBytes int, err error)

TransactionEssenceFromBytes unmarshals a TransactionEssence from a sequence of bytes.

func (*TransactionEssence) AccessPledgeID

func (t *TransactionEssence) AccessPledgeID() identity.ID

AccessPledgeID returns the access mana pledge nodeID of the TransactionEssence.

func (*TransactionEssence) ConsensusPledgeID

func (t *TransactionEssence) ConsensusPledgeID() identity.ID

ConsensusPledgeID returns the consensus mana pledge nodeID of the TransactionEssence.

func (*TransactionEssence) Inputs

func (t *TransactionEssence) Inputs() Inputs

Inputs returns the Inputs of the TransactionEssence.

func (*TransactionEssence) Outputs

func (t *TransactionEssence) Outputs() Outputs

Outputs returns the Outputs of the TransactionEssence.

func (*TransactionEssence) Payload

func (t *TransactionEssence) Payload() payload.Payload

Payload returns the optional Payload of the TransactionEssence.

func (*TransactionEssence) SetPayload

func (t *TransactionEssence) SetPayload(p payload.Payload)

SetPayload set the optional Payload of the TransactionEssence.

func (*TransactionEssence) Timestamp

func (t *TransactionEssence) Timestamp() time.Time

Timestamp returns the timestamp of the TransactionEssence.

func (*TransactionEssence) Version

Version returns the Version of the TransactionEssence.

type TransactionEssenceVersion

type TransactionEssenceVersion uint8

TransactionEssenceVersion represents a version number for the TransactionEssence which can be used to ensure backward compatibility if the structure ever needs to get changed.

func (TransactionEssenceVersion) Bytes

func (t TransactionEssenceVersion) Bytes() []byte

Bytes returns a marshaled version of the TransactionEssenceVersion.

func (TransactionEssenceVersion) Compare

Compare offers a comparator for TransactionEssenceVersions which returns -1 if the other TransactionEssenceVersion is bigger, 1 if it is smaller and 0 if they are the same.

func (TransactionEssenceVersion) String

func (t TransactionEssenceVersion) String() string

String returns a human-readable version of the TransactionEssenceVersion.

type TransactionIDs

type TransactionIDs map[utxo.TransactionID]types.Empty

TransactionIDs represents a collection of TransactionIDs.

func (TransactionIDs) Base58s

func (t TransactionIDs) Base58s() (transactionIDs []string)

Base58s returns a slice of base58 encoded versions of the contained TransactionIDs.

func (TransactionIDs) Clone

func (t TransactionIDs) Clone() (transactionIDs TransactionIDs)

Clone returns a copy of the collection of TransactionIDs.

func (TransactionIDs) String

func (t TransactionIDs) String() (result string)

String returns a human-readable version of the TransactionIDs.

type UTXOInput

type UTXOInput struct {
	model.Immutable[UTXOInput, *UTXOInput, utxoInputModel] `serix:"0"`
}

UTXOInput represents a reference to an Output in the UTXODAG.

func NewUTXOInput

func NewUTXOInput(referencedOutputID utxo.OutputID) *UTXOInput

NewUTXOInput is the constructor for UTXOInputs.

func (*UTXOInput) Base58

func (u *UTXOInput) Base58() string

Base58 returns the base58 encoded referenced output ID of this input.

func (*UTXOInput) Compare

func (u *UTXOInput) Compare(other Input) int

Compare offers a comparator for Inputs which returns -1 if other Input is bigger, 1 if it is smaller and 0 if they are the same.

func (*UTXOInput) ReferencedOutputID

func (u *UTXOInput) ReferencedOutputID() utxo.OutputID

ReferencedOutputID returns the OutputID that this Input references.

func (*UTXOInput) Type

func (u *UTXOInput) Type() InputType

Type returns the type of the Input.

type UnlockBlock

type UnlockBlock interface {
	// Type returns the UnlockBlockType of the UnlockBlock.
	Type() UnlockBlockType

	// Bytes returns a marshaled version of the UnlockBlock.
	Bytes() ([]byte, error)

	// String returns a human readable version of the UnlockBlock.
	String() string
}

UnlockBlock represents a generic interface to address the different kinds of unlock information that are required to authorize the spending of different Output types.

type UnlockBlockType

type UnlockBlockType uint8

UnlockBlockType represents the type of the UnlockBlock. Different types of UnlockBlocks can unlock different types of Outputs.

const (
	// SignatureUnlockBlockType represents the type of a SignatureUnlockBlock.
	SignatureUnlockBlockType UnlockBlockType = iota

	// ReferenceUnlockBlockType represents the type of a ReferenceUnlockBlock.
	ReferenceUnlockBlockType

	// AliasUnlockBlockType represents the type of a AliasUnlockBlock.
	AliasUnlockBlockType
)

region UnlockBlockType. //////////////////////////////////////////////////////////////////////////////////////////////

func (UnlockBlockType) String

func (a UnlockBlockType) String() string

String returns a human readable representation of the UnlockBlockType.

type UnlockBlocks

type UnlockBlocks []UnlockBlock

UnlockBlocks is slice of UnlockBlocks that offers additional methods for easier marshaling and unmarshaling.

func UnlockBlocksFromBytes

func UnlockBlocksFromBytes(bytes []byte) (unlockBlocks UnlockBlocks, consumedBytes int, err error)

UnlockBlocksFromBytes unmarshals UnlockBlocks from a sequence of bytes.

func (UnlockBlocks) Bytes

func (u UnlockBlocks) Bytes() []byte

Bytes returns a marshaled version of the UnlockBlocks.

func (UnlockBlocks) String

func (u UnlockBlocks) String() string

String returns a human readable version of the UnlockBlocks.

type UnlockGraph

type UnlockGraph struct {
	// Vertices are the unlock blocks themselves, identified by their index
	// uint16 is enough
	Vertices []uint16
	// maps unlockBlock to referenced unlocked block
	// each vertex has at most 1 referenced unlock block, so one outgoing edge
	Edges map[uint16]uint16
}

UnlockGraph builds a graph from the references of the unlock blocks with the aim of detecting cycles.

func NewUnlockGraph

func NewUnlockGraph(blocks UnlockBlocks) (*UnlockGraph, error)

NewUnlockGraph creates a new UnlockGraph and checks semantic validity of the unlock block references.

func (*UnlockGraph) IsCycleDetected

func (g *UnlockGraph) IsCycleDetected() bool

IsCycleDetected checks if a cycle is detected by checking the dfs paths from every node.

type VM

type VM struct{}

func (*VM) ExecuteTransaction

func (d *VM) ExecuteTransaction(transaction utxo.Transaction, inputs *utxo.Outputs, _ ...uint64) (outputs []utxo.Output, err error)

func (*VM) ParseOutput

func (d *VM) ParseOutput(outputBytes []byte) (output utxo.Output, err error)

func (*VM) ParseTransaction

func (d *VM) ParseTransaction(transactionBytes []byte) (transaction utxo.Transaction, err error)

func (*VM) ResolveInput

func (d *VM) ResolveInput(input utxo.Input) (outputID utxo.OutputID)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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