From fa8bdff02272b127e3e4dbd1ec91a85c1fbded3a Mon Sep 17 00:00:00 2001 From: motty Date: Sat, 20 Mar 2021 07:48:33 +0900 Subject: [PATCH] OP_RETURN: upgrade to utf8 --- bchain/coins/btc/bitcoinparser.go | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/bchain/coins/btc/bitcoinparser.go b/bchain/coins/btc/bitcoinparser.go index acfeadf7..37c7af45 100644 --- a/bchain/coins/btc/bitcoinparser.go +++ b/bchain/coins/btc/bitcoinparser.go @@ -4,6 +4,7 @@ import ( "bytes" "encoding/binary" "encoding/hex" + "unicode/utf8" "math/big" "strconv" @@ -160,14 +161,7 @@ func (p *BitcoinParser) TryParseOPReturn(script []byte) string { return ed } - isASCII := true - for _, c := range data { - if c < 32 || c > 127 { - isASCII = false - break - } - } - if isASCII { + if utf8.Valid(data) { ed = "(" + string(data) + ")" } else { ed = hex.EncodeToString(data)