compiler/interop: add support for working with witnesses

This commit is contained in:
Roman Khimov 2020-05-18 19:04:20 +03:00
parent 085d50b430
commit 8c19b8f2a1
3 changed files with 26 additions and 0 deletions

View file

@ -69,6 +69,7 @@ var syscalls = map[string]map[string]string{
"GetReferences": "Neo.Transaction.GetReferences", "GetReferences": "Neo.Transaction.GetReferences",
"GetScript": "Neo.InvocationTransaction.GetScript", "GetScript": "Neo.InvocationTransaction.GetScript",
"GetType": "Neo.Transaction.GetType", "GetType": "Neo.Transaction.GetType",
"GetWitnesses": "Neo.Transaction.GetWitnesses",
}, },
"asset": { "asset": {
"Create": "Neo.Asset.Create", "Create": "Neo.Asset.Create",
@ -114,4 +115,7 @@ var syscalls = map[string]map[string]string{
"Value": "Neo.Iterator.Value", "Value": "Neo.Iterator.Value",
"Values": "Neo.Iterator.Values", "Values": "Neo.Iterator.Values",
}, },
"witness": {
"GetVerificationScript": "Neo.Witness.GetVerificationScript",
},
} }

View file

@ -7,6 +7,7 @@ import (
"github.com/nspcc-dev/neo-go/pkg/interop/attribute" "github.com/nspcc-dev/neo-go/pkg/interop/attribute"
"github.com/nspcc-dev/neo-go/pkg/interop/input" "github.com/nspcc-dev/neo-go/pkg/interop/input"
"github.com/nspcc-dev/neo-go/pkg/interop/output" "github.com/nspcc-dev/neo-go/pkg/interop/output"
"github.com/nspcc-dev/neo-go/pkg/interop/witness"
) )
// Transaction represents a NEO transaction, it's an opaque data structure // Transaction represents a NEO transaction, it's an opaque data structure
@ -72,3 +73,10 @@ func GetOutputs(t Transaction) []output.Output {
func GetScript(t Transaction) []byte { func GetScript(t Transaction) []byte {
return nil return nil
} }
// GetWitnesses returns a slice of witnesses of a given Transaction. Refer to
// witness package on how to use them. This function uses
// `Neo.Transaction.GetWitnesses` syscall.
func GetWitnesses(t Transaction) []witness.Witness {
return []witness.Witness{}
}

View file

@ -0,0 +1,14 @@
/*
Package witness provides functions dealing with transaction's witnesses.
*/
package witness
// Witness is an opaque data structure that can only be created by
// transaction.GetWitnesses and representing transaction's witness.
type Witness struct{}
// GetVerificationScript returns verification script stored in the given
// witness. It uses `Neo.Witness.GetVerificationScript` syscall.
func GetVerificationScript(w Witness) []byte {
return nil
}