Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
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 ¶
func ValidateWitnesses ¶ added in v0.4.0
func ValidateWitnesses(newAsset *asset.Asset, splitAssets []*commitment.SplitAsset, prevAssets commitment.InputSet) error
ValidateWitnesses is a helper method that checks the witnesses provided over an asset transfer. This method may be used for transfers that are not yet complete, in order to check if the existing signatures are valid.
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, opts ...NewEngineOpt) (*Engine, error)
New returns a new virtual machine capable of executing and verifying Taproot Asset state transitions.
type Error ¶
Error represents an error returned by the Taproot Asset VM.
func (Error) Error ¶
Error returns a human-readable version of the error. This implements the main error interface.
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 // ErrUnfinalizedAsset represents an error case where the asset has not // been finalized. A virtual TX may only contain finalized assets. ErrUnfinalizedAsset )
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"` BlockHeight uint32 `json:"block_height"` Error string `json:"error"` Comment string `json:"comment"` }
type NewEngineOpt ¶ added in v0.4.0
type NewEngineOpt func(*newEngineOptions)
NewEngineOpt is used to modify how a new engine is to be created.
func WithBlockHeight ¶ added in v0.4.0
func WithBlockHeight(blockHeight uint32) NewEngineOpt
WithBlockHeight can be used to create an engine that validates time locks against the given block height instead of the current best known block.
func WithChainLookup ¶ added in v0.4.0
func WithChainLookup(chainLookup asset.ChainLookup) NewEngineOpt
WithChainLookup can be used to create an engine that is capable of validating time locks.
func WithSkipTimeLockValidation ¶ added in v0.4.0
func WithSkipTimeLockValidation() NewEngineOpt
WithSkipTimeLockValidation can be used to create an engine that skips validating time locks.
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"` BlockHeight uint32 `json:"block_height"` Comment string `json:"comment"` }