From 3e9bd0be72717bbc57bb0a0a2e8006f7ca37628a Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Thu, 11 Mar 2021 19:55:20 +0300 Subject: [PATCH] smartcontract: use base64 encoding for verifiable items See neo-project/neo#1199. --- pkg/smartcontract/context/context.go | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/pkg/smartcontract/context/context.go b/pkg/smartcontract/context/context.go index 842273a15..c7facc572 100644 --- a/pkg/smartcontract/context/context.go +++ b/pkg/smartcontract/context/context.go @@ -32,7 +32,7 @@ type ParameterContext struct { type paramContext struct { Type string `json:"type"` - Hex string `json:"hex"` + Hex []byte `json:"hex"` Items map[string]json.RawMessage `json:"items"` } @@ -164,7 +164,7 @@ func (c ParameterContext) MarshalJSON() ([]byte, error) { } pc := ¶mContext{ Type: c.Type, - Hex: hex.EncodeToString(verif), + Hex: verif, Items: items, } return json.Marshal(pc) @@ -176,10 +176,6 @@ func (c *ParameterContext) UnmarshalJSON(data []byte) error { if err := json.Unmarshal(data, pc); err != nil { return err } - data, err := hex.DecodeString(pc.Hex) - if err != nil { - return err - } var verif crypto.VerifiableDecodable switch pc.Type { @@ -188,7 +184,7 @@ func (c *ParameterContext) UnmarshalJSON(data []byte) error { default: return fmt.Errorf("unsupported type: %s", c.Type) } - err = verif.DecodeSignedPart(data) + err := verif.DecodeSignedPart(pc.Hex) if err != nil { return err }