utxo

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2022 License: Apache-2.0, BSD-2-Clause Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Input

type Input interface {
	// String returns a human-readable version of the Input.
	String() (humanReadable string)
}

Input is an entity that allows to "address" which Outputs are supposed to be used by a Transaction.

type Output

type Output interface {
	// ID returns the identifier of the Output.
	ID() (id OutputID)

	// SetID sets the identifier of the Output.
	SetID(id OutputID)

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

	// String returns a human-readable version of the Output.
	String() (humanReadable string)

	objectstorage.StorableObject
}

Output is the container for the data produced by executing a Transaction.

type OutputCommitment

type OutputCommitment struct {
	StateRoot       types.Identifier `serix:"0"`
	NumberOfOutputs uint64           `serix:"1"`
	// contains filtered or unexported fields
}

OutputCommitment represents a cryptographic commitment to the Outputs generated by a Transaction.

func (*OutputCommitment) Bytes

func (o *OutputCommitment) Bytes() (serialized []byte)

Bytes returns a serialized version of the OutputCommitment.

func (*OutputCommitment) FromOutputs

func (o *OutputCommitment) FromOutputs(outputs ...Output) (err error)

FromOutputs creates a new OutputCommitment from the given Outputs.

func (*OutputCommitment) Proof

func (o *OutputCommitment) Proof(outputIndex uint64) (proof *OutputCommitmentProof, err error)

Proof generates a proof that the Output at the given index is included in the OutputCommitment.

type OutputCommitmentProof

type OutputCommitmentProof struct {
	OutputCommitment *OutputCommitment `serix:"0"`
	ProofSet         [][32]byte        `serix:"1,lengthPrefixType=uint32"`
	ProofIndex       uint64            `serix:"2"`
}

OutputCommitmentProof is a cryptographic proof that an Output is part of an OutputCommitment.

func (*OutputCommitmentProof) Bytes

func (o *OutputCommitmentProof) Bytes() (bytes []byte)

Bytes returns a serialized version of the OutputCommitmentProof.

func (*OutputCommitmentProof) Validate

func (o *OutputCommitmentProof) Validate(output Output) (err error)

Validate validates the proof and checks if the given Output is indeed part of the OutputCommitment that is referenced in the proof.

type OutputFactory

type OutputFactory func([]byte) (output Output, err error)

type OutputID

type OutputID struct {
	TransactionID TransactionID `serix:"0"`
	Index         uint16        `serix:"1"`
}

OutputID is a unique identifier for an Output.

var EmptyOutputID OutputID

EmptyOutputID contains the null-value of the OutputID type.

func NewOutputID

func NewOutputID(txID TransactionID, index uint16) OutputID

NewOutputID returns a new OutputID for the given details.

func (OutputID) Alias

func (o OutputID) Alias() (alias string)

Alias returns the human-readable alias of the OutputID (or the base58 encoded bytes of no alias was set).

func (OutputID) Base58

func (o OutputID) Base58() (base58Encoded string)

Base58 returns a base58 encoded version of the OutputID.

func (OutputID) Bytes

func (o OutputID) Bytes() (serialized []byte)

Bytes returns a serialized version of the OutputID.

func (*OutputID) FromBase58

func (o *OutputID) FromBase58(base58EncodedString string) (err error)

FromBase58 un-serializes an OutputID from a base58 encoded string.

func (*OutputID) FromRandomness

func (o *OutputID) FromRandomness() (err error)

FromRandomness generates a random OutputID.

func (OutputID) Length

func (o OutputID) Length() int

Length returns number of bytes of OutputID

func (OutputID) RegisterAlias

func (o OutputID) RegisterAlias(alias string)

RegisterAlias allows to register a human-readable alias for the OutputID which will be used as a replacement for the String method.

func (OutputID) String

func (o OutputID) String() (humanReadable string)

String returns a human-readable version of the OutputID.

func (OutputID) UnregisterAlias

func (o OutputID) UnregisterAlias()

UnregisterAlias allows to unregister a previously registered alias.

type OutputIDs

type OutputIDs = *set.AdvancedSet[OutputID]

OutputIDs represents a collection of OutputIDs.

func NewOutputIDs

func NewOutputIDs(ids ...OutputID) (newOutputIDs OutputIDs)

NewOutputIDs returns a new OutputID collection with the given elements.

type OutputStateProof

type OutputStateProof struct {
	OutputID              OutputID
	TransactionCommitment TransactionCommitment
	OutputCommitmentProof *OutputCommitmentProof
}

OutputStateProof represents a cryptographic proof that a specific Output is the one named in the OutputID referenced in the proof.

func (*OutputStateProof) Validate

func (o *OutputStateProof) Validate(output Output) (err error)

Validate validates the proof and checks if the given Output is indeed the one that is referenced in the proof.

type Outputs

type Outputs struct {
	// OrderedMap is the underlying data structure that holds the Outputs.
	orderedmap.OrderedMap[OutputID, Output] `serix:"0"`
}

Outputs represents a collection of Output objects indexed by their OutputID.

func NewOutputs

func NewOutputs(outputs ...Output) (newOutputs *Outputs)

NewOutputs returns a new Output collection with the given elements.

func (*Outputs) Add

func (o *Outputs) Add(output Output)

Add adds the given Output to the collection.

func (*Outputs) ForEach

func (o *Outputs) ForEach(callback func(output Output) error) (err error)

ForEach executes the callback for each element in the collection (it aborts if the callback returns an error).

func (*Outputs) IDs

func (o *Outputs) IDs() (ids OutputIDs)

IDs returns the identifiers of the stored Outputs.

func (*Outputs) String

func (o *Outputs) String() (humanReadable string)

Strings returns a human-readable version of the Outputs.

type Snapshot

type Snapshot interface {
	Outputs() (outputs []Output)
}

Snapshot is a snapshot of the ledger state.

type Transaction

type Transaction interface {
	// ID returns the identifier of the Transaction.
	ID() (id TransactionID)

	// SetID sets the identifier of the Transaction.
	//
	// Note: Since determining the identifier of a Transaction is an operation that requires at least a few hashing
	// operations, we allow the ID to be set from the outside.
	//
	// This allows us to potentially skip the ID calculation in cases where the ID is known upfront (e.g. when loading
	// Transactions from the object storage).
	SetID(id TransactionID)

	// Inputs returns the inputs of the Transaction.
	Inputs() (inputs []Input)

	// String returns a human-readable version of the Transaction.
	String() (humanReadable string)

	objectstorage.StorableObject
}

Transaction is the type that is used to describe instructions how to modify the ledger state.

type TransactionCommitment

type TransactionCommitment types.Identifier

TransactionCommitment represents a cryptographic commitment to the content of a transaction.

type TransactionID

type TransactionID struct {
	types.Identifier `serix:"0"`
}

TransactionID is a unique identifier for a Transaction.

var EmptyTransactionID TransactionID

EmptyTransactionID contains the null-value of the TransactionID type.

func NewTransactionID

func NewTransactionID(txData []byte) (newTransactionID TransactionID)

NewTransactionID returns a new TransactionID for the given data.

func (TransactionID) IsEmpty

func (t TransactionID) IsEmpty() (isEmpty bool)

IsEmpty returns true if the TransactionID is empty.

func (TransactionID) Length

func (t TransactionID) Length() (length int)

Length returns the byte length of a serialized TransactionID.

func (TransactionID) String

func (t TransactionID) String() (humanReadable string)

String returns a human-readable version of the TransactionID.

type TransactionIDs

type TransactionIDs = *set.AdvancedSet[TransactionID]

TransactionIDs represents a collection of TransactionIDs.

func NewTransactionIDs

func NewTransactionIDs(ids ...TransactionID) (newTransactionIDs TransactionIDs)

NewTransactionIDs returns a new TransactionID collection with the given elements.

Jump to

Keyboard shortcuts

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