OP_RETURN: upgrade to utf8 (#583)

Co-authored-by: motty <admin@fujicoin.org>
This commit is contained in:
FujiCoin 2021-04-17 20:09:23 +09:00 committed by Martin Boehm
parent 9a0851b7a1
commit 02369a9cce

View File

@ -4,6 +4,7 @@ import (
"bytes" "bytes"
"encoding/binary" "encoding/binary"
"encoding/hex" "encoding/hex"
"unicode/utf8"
"math/big" "math/big"
"strconv" "strconv"
@ -160,14 +161,7 @@ func (p *BitcoinParser) TryParseOPReturn(script []byte) string {
return ed return ed
} }
isASCII := true if utf8.Valid(data) {
for _, c := range data {
if c < 32 || c > 127 {
isASCII = false
break
}
}
if isASCII {
ed = "(" + string(data) + ")" ed = "(" + string(data) + ")"
} else { } else {
ed = hex.EncodeToString(data) ed = hex.EncodeToString(data)