neoneo-go/pkg/smartcontract/context/item.go

27 lines
732 B
Go
Raw Normal View History

2020-03-04 09:40:01 +00:00
package context
import (
"encoding/hex"
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
)
// Item represents a transaction context item.
type Item struct {
Script []byte `json:"script"`
2020-03-04 09:40:01 +00:00
Parameters []smartcontract.Parameter `json:"parameters"`
Signatures map[string][]byte `json:"signatures"`
2020-03-04 09:40:01 +00:00
}
// GetSignature returns signature for pub if present.
func (it *Item) GetSignature(pub *keys.PublicKey) []byte {
return it.Signatures[hex.EncodeToString(pub.Bytes())]
}
// AddSignature adds a signature for pub.
func (it *Item) AddSignature(pub *keys.PublicKey, sig []byte) {
pubHex := hex.EncodeToString(pub.Bytes())
it.Signatures[pubHex] = sig
}