From 641abd4d1ce7210606d50bcf5c825c15059881c4 Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Tue, 11 Oct 2022 13:34:14 +0300 Subject: [PATCH] smartcontract: fix underlying PublicKey parameter value Value of PublicKey parameter always stores public key bytes, not the deserialized representation. All other code (CLI parameters parsing with its NewParameterFromString, Parameter unmarshaller, etc.) is based on the idea that value of PublicKey is []byte. --- pkg/smartcontract/parameter.go | 2 -- pkg/smartcontract/parameter_test.go | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/pkg/smartcontract/parameter.go b/pkg/smartcontract/parameter.go index e5799b82e..dd7c1a396 100644 --- a/pkg/smartcontract/parameter.go +++ b/pkg/smartcontract/parameter.go @@ -387,8 +387,6 @@ func NewParametersFromValues(values ...interface{}) ([]Parameter, error) { func ExpandParameterToEmitable(param Parameter) (interface{}, error) { var err error switch t := param.Type; t { - case PublicKeyType: - return param.Value.(*keys.PublicKey).Bytes(), nil case ArrayType: arr := param.Value.([]Parameter) res := make([]interface{}, len(arr)) diff --git a/pkg/smartcontract/parameter_test.go b/pkg/smartcontract/parameter_test.go index 01aa977d8..e07218777 100644 --- a/pkg/smartcontract/parameter_test.go +++ b/pkg/smartcontract/parameter_test.go @@ -477,7 +477,7 @@ func TestExpandParameterToEmitable(t *testing.T) { Expected: util.Uint256{1, 2, 3}, }, { - In: Parameter{Type: PublicKeyType, Value: pk.PublicKey()}, + In: Parameter{Type: PublicKeyType, Value: pk.PublicKey().Bytes()}, Expected: pk.PublicKey().Bytes(), }, {