From 70dcb920b71faea6dd1dde23bae9f961fbb1629a Mon Sep 17 00:00:00 2001 From: Alex Vanin Date: Fri, 26 Mar 2021 15:20:13 +0300 Subject: [PATCH] [#448] util/keyer: Prioritize hex decoding over base58 Hex encoded values are often may be misinterpreted as base58 values. Reverse case is quite rare, so it is better to try hex decoding first. Signed-off-by: Alex Vanin --- pkg/util/keyer/parser.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/util/keyer/parser.go b/pkg/util/keyer/parser.go index 45ed3ebf13..4023e3981d 100644 --- a/pkg/util/keyer/parser.go +++ b/pkg/util/keyer/parser.go @@ -36,9 +36,9 @@ func (d *Dashboard) ParseString(data string) error { ) // data could be encoded in base58 or hex formats, try both - rawData, err = base58.Decode(data) + rawData, err = hex.DecodeString(data) if err != nil { - rawData, err = hex.DecodeString(data) + rawData, err = base58.Decode(data) if err != nil { return fmt.Errorf("data is not hex or base58 encoded: %w", err) }