@@ -4,16 +4,16 @@ import (
44 "bytes"
55 "encoding/binary"
66 "fmt"
7- "io"
8- "strconv"
9- "strings"
10-
117 "github.com/mr-tron/base58/base58"
128 "github.com/pkg/errors"
139 "github.com/wavesplatform/gowaves/pkg/crypto"
1410 "github.com/wavesplatform/gowaves/pkg/errs"
1511 g "github.com/wavesplatform/gowaves/pkg/grpc/generated/waves"
1612 "github.com/wavesplatform/gowaves/pkg/libs/serializer"
13+ "io"
14+ "strconv"
15+ "strings"
16+ "unicode/utf8"
1717)
1818
1919const (
@@ -344,12 +344,14 @@ func NewAlias(scheme byte, alias string) *Alias {
344344 return & Alias {aliasVersion , scheme , alias }
345345}
346346
347- // Valid validates the Alias checking it length, version and symbols.
347+ // Valid validates the Alias checking it UTF8 length, version and symbols.
348348func (a Alias ) Valid () (bool , error ) {
349349 if v := a .Version ; v != aliasVersion {
350350 return false , errors .Errorf ("%d is incorrect alias version, expected %d" , v , aliasVersion )
351351 }
352- if l := len (a .Alias ); l < AliasMinLength || l > AliasMaxLength {
352+ // nickeskov: runes count because non ASCII symbols can have length > 1 byte
353+ // Using of utf8.RuneCountInString repeats scala node behaviour
354+ if l := utf8 .RuneCountInString (a .Alias ); l < AliasMinLength || l > AliasMaxLength {
353355 return false , errs .NewTxValidationError (fmt .Sprintf ("Alias '%s' length should be between %d and %d" , a .Alias , AliasMinLength , AliasMaxLength ))
354356 }
355357 if ! correctAlphabet (a .Alias ) {
0 commit comments