vm

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidScriptVersion represents an error case where an asset input
	// commits to an invalid script version.
	ErrInvalidScriptVersion = tapscript.ErrInvalidScriptVersion

	// ErrInputMismatch represents an error case where an asset's set of
	// inputs mismatch the set provided to the virtual machine.
	ErrInputMismatch = tapscript.ErrInputMismatch

	// ErrNoInputs represents an error case where an asset undergoing a
	// state transition does not have any or a specific input required.
	ErrNoInputs = tapscript.ErrNoInputs
)

Wrap select errors related to virtual TX handling to provide more context to callers.

Functions

This section is empty.

Types

type Engine

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

Engine is a virtual machine capable of executing and verifying Taproot asset state transitions.

func New

func New(newAsset *asset.Asset, splitAssets []*commitment.SplitAsset,
	prevAssets commitment.InputSet) (*Engine, error)

New returns a new virtual machine capable of executing and verifying Taproot Asset state transitions.

func (*Engine) Execute

func (vm *Engine) Execute() error

Execute attempts to execute an asset's state transition to determine whether it was valid or not represented by the error returned.

type Error

type Error struct {
	Kind  ErrorKind
	Inner error
}

Error represents an error returned by the Taproot Asset VM.

func (Error) Error

func (e Error) Error() string

Error returns a human readable version of the error. This implements the main error interface.

func (Error) String

func (e Error) String() string

String is the same as Error, but intended to be used for string formatting.

func (Error) Unwrap

func (e Error) Unwrap() error

Unwrap implements the extended error interface, with the ability to expose a wrapped error to the caller.

type ErrorKind

type ErrorKind uint8

ErrorKind uniquely identifies the kind of Error returned by the Taproot Asset VM.

const (
	// ErrNoSplitCommitment represents an error case where a split
	// commitment root is not present when required.
	ErrNoSplitCommitment ErrorKind = iota

	// ErrIDMismatch represents an error case where an asset, or asset
	// split, do not match the asset genesis of their inputs.
	ErrIDMismatch

	// ErrTypeMismatch represents an error case where an asset, or asset
	// split, do not match the asset type of their inputs.
	ErrTypeMismatch

	// ErrScriptKeyMismatch represents an error case where an the script key
	// of an asset input does not match the one of the input provided to the
	// virtual machine.
	ErrScriptKeyMismatch

	// ErrAmountMismatch represents an error case where an asset, along with
	// its splits, do not match the total asset amount of their inputs.
	ErrAmountMismatch

	// ErrInvalidSigHashFlag represents an error case where an asset witness
	// contains signatures created with any sighash flag other than
	// SIGHASH_DEFAULT.
	ErrInvalidSigHashFlag

	// ErrInvalidGenesisStateTransition represents an error case where an
	// asset has a valid genesis witness but the virtual machine was
	// provided asset inputs.
	ErrInvalidGenesisStateTransition

	// ErrInvalidTransferWitness represents an error case where an asset
	// input has a malformed or invalid transfer witness as deemed by the
	// virtual machine.
	ErrInvalidTransferWitness

	// ErrInvalidSplitAssetType represents an error case where an asset
	// split type does not match the root asset.
	ErrInvalidSplitAssetType

	// ErrInvalidSplitCommitmentWitness represents an error case where an
	// asset input has a malformed split commitment witness.
	ErrInvalidSplitCommitmentWitness

	// ErrInvalidSplitCommitmentProof represents an error case where an
	// asset split has an invalid split commitment proof.
	ErrInvalidSplitCommitmentProof

	// ErrInvalidRootAsset represents an error case where the root asset
	// of an asset split has zero value but a spendable script key.
	ErrInvalidRootAsset
)

func (ErrorKind) String

func (k ErrorKind) String() string

type ErrorTestCase added in v0.3.0

type ErrorTestCase struct {
	Asset    *asset.TestAsset        `json:"asset"`
	SplitSet commitment.TestSplitSet `json:"split_set"`
	InputSet commitment.TestInputSet `json:"input_set"`
	Error    string                  `json:"error"`
	Comment  string                  `json:"comment"`
}

type TestVectors added in v0.3.0

type TestVectors struct {
	ValidTestCases []*ValidTestCase `json:"valid_test_cases"`
	ErrorTestCases []*ErrorTestCase `json:"error_test_cases"`
}

type ValidTestCase added in v0.3.0

type ValidTestCase struct {
	Asset    *asset.TestAsset        `json:"asset"`
	SplitSet commitment.TestSplitSet `json:"split_set"`
	InputSet commitment.TestInputSet `json:"input_set"`
	Comment  string                  `json:"comment"`
}

Jump to

Keyboard shortcuts

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