diff --git a/types/coin.go b/types/coin.go index 8c66866900..93d42b4bb0 100644 --- a/types/coin.go +++ b/types/coin.go @@ -875,22 +875,22 @@ func ValidateDenom(denom string) error { } // isValidRune checks if a given rune is a valid character for a rune. -// It returns true if the rune is a letter, digit, '/', ':', '.', '_', or '-'. +// It returns true if the rune is a letter, digit, '/', ':', '.', '_', '-', or '$'. func isValidRune(r rune) bool { - return unicode.IsLetter(r) || unicode.IsDigit(r) || r == '/' || r == ':' || r == '.' || r == '_' || r == '-' + return unicode.IsLetter(r) || unicode.IsDigit(r) || r == '/' || r == ':' || r == '.' || r == '_' || r == '-' || r == '$' } // MatchDenom checks if the given string is a valid denomination. -// A valid denomination must have a length between 3 and 128 characters, +// A valid denomination must have a length between 2 and 128 characters, // start with a letter, and only contain valid runes. func MatchDenom(s string) bool { length := len(s) - if length < 3 || length > 128 { + if length < 2 || length > 128 { return false } firstRune := rune(s[0]) - if !unicode.IsLetter(firstRune) { + if !unicode.IsLetter(firstRune) && firstRune != '$' { return false } diff --git a/types/dec_coin.go b/types/dec_coin.go index 9a2a499424..82f317ed0b 100644 --- a/types/dec_coin.go +++ b/types/dec_coin.go @@ -676,7 +676,7 @@ func ParseDecAmount(coinStr string) (string, string, error) { amountRune = append(amountRune, r) } else if unicode.IsSpace(r) { // if space is seen, indicates that we have finished parsing amount parsingAmount = false - } else if unicode.IsLetter(r) { // if letter is seen, indicates that it is the start of denom + } else if unicode.IsLetter(r) || r == '$' { // if letter is seen, indicates that it is the start of denom parsingAmount = false seenLetter = true denomRune = append(denomRune, r) @@ -693,7 +693,7 @@ func ParseDecAmount(coinStr string) (string, string, error) { } } else { // Parsing the denomination - if unicode.IsLetter(r) || unicode.IsDigit(r) || r == '/' || r == ':' || r == '.' || r == '_' || r == '-' { + if unicode.IsLetter(r) || unicode.IsDigit(r) || r == '/' || r == ':' || r == '.' || r == '_' || r == '-' || r == '$' { denomRune = append(denomRune, r) } else { // Invalid character encountered in denomination part