[#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 <alexey@nspcc.ru>
This commit is contained in:
Alex Vanin 2021-03-26 15:20:13 +03:00 committed by Alex Vanin
parent 3fe5962e92
commit 70dcb920b7

View file

@ -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)
}