neo-go/pkg/smartcontract/context/item.go
Roman Khimov efb67a0ea3 context: scripts and signatures are base64-encoded in C# now
So use base64 too and add compatibility test. Unfortunately this breaks
support for old (hex-based) files, but those should be completed a long time
ago.
2021-07-23 11:57:35 +03:00

26 lines
732 B
Go

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"`
Parameters []smartcontract.Parameter `json:"parameters"`
Signatures map[string][]byte `json:"signatures"`
}
// 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
}