forked from lightninglabs/taproot-assets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtx_validator.go
33 lines (26 loc) · 845 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 taro
import (
"github.com/lightninglabs/taro/asset"
"github.com/lightninglabs/taro/commitment"
"github.com/lightninglabs/taro/taroscript"
"github.com/lightninglabs/taro/vm"
)
// ValidatorV0 is an implementation of the taroscript.TxValidator interface
// that supports Taro script version 0.
type ValidatorV0 struct{}
// Execute creates and runs an instance of the Taro 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
// taroscript.TxValidator interface.
var _ taroscript.TxValidator = (*ValidatorV0)(nil)