2021-02-02 17:42:05 +00:00
|
|
|
package common
|
|
|
|
|
2021-02-02 18:26:34 +00:00
|
|
|
import (
|
|
|
|
"github.com/nspcc-dev/neo-go/pkg/interop/crypto"
|
|
|
|
"github.com/nspcc-dev/neo-go/pkg/interop/runtime"
|
|
|
|
)
|
2021-02-02 17:42:05 +00:00
|
|
|
|
|
|
|
func InvokeID(args []interface{}, prefix []byte) []byte {
|
|
|
|
for i := range args {
|
|
|
|
arg := args[i].([]byte)
|
|
|
|
prefix = append(prefix, arg...)
|
|
|
|
}
|
|
|
|
|
|
|
|
return crypto.SHA256(prefix)
|
|
|
|
}
|
2021-02-02 18:26:34 +00:00
|
|
|
|
|
|
|
type IRNode struct {
|
|
|
|
PublicKey []byte
|
|
|
|
}
|
|
|
|
|
|
|
|
// InnerRingInvoker returns public key of inner ring node that invoked contract.
|
|
|
|
func InnerRingInvoker(ir []IRNode) []byte {
|
|
|
|
for i := 0; i < len(ir); i++ {
|
|
|
|
node := ir[i]
|
|
|
|
if runtime.CheckWitness(node.PublicKey) {
|
|
|
|
return node.PublicKey
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|