forked from lightninglabs/taproot-assets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tx_validator.go
33 lines (26 loc) · 908 Bytes
/
tx_validator.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package taprootassets
import (
"github.com/lightninglabs/taproot-assets/asset"
"github.com/lightninglabs/taproot-assets/commitment"
"github.com/lightninglabs/taproot-assets/tapscript"
"github.com/lightninglabs/taproot-assets/vm"
)
// ValidatorV0 is an implementation of the tapscript.TxValidator interface
// that supports Taproot Asset script version 0.
type ValidatorV0 struct{}
// Execute creates and runs an instance of the Taproot Asset script V0 VM.
func (v *ValidatorV0) Execute(newAsset *asset.Asset,
splitAssets []*commitment.SplitAsset,
prevAssets commitment.InputSet) error {
engine, err := vm.New(newAsset, splitAssets, prevAssets)
if err != nil {
return err
}
if err = engine.Execute(); err != nil {
return err
}
return nil
}
// A compile time assertion to ensure ValidatorV0 meets the
// tapscript.TxValidator interface.
var _ tapscript.TxValidator = (*ValidatorV0)(nil)