diff --git a/asset/asset.go b/asset/asset.go index a3818974c..e84a451fa 100644 --- a/asset/asset.go +++ b/asset/asset.go @@ -18,6 +18,13 @@ import ( "github.com/lightningnetwork/lnd/tlv" ) +const ( + // MaxAssetNameLength is the maximum byte length of an asset's name. + // This byte length is equivalent to character count for single-byte + // UTF-8 characters + MaxAssetNameLength = 64 +) + // SerializedKey is a type for representing a public key, serialized in the // compressed, 33-byte form. type SerializedKey [33]byte @@ -1051,5 +1058,9 @@ func ValidateAssetName(name string) error { if len(name) == 0 { return fmt.Errorf("asset name cannot be empty") } + if len(name) > MaxAssetNameLength { + return fmt.Errorf("asset name cannot exceed %d bytes", + MaxAssetNameLength) + } return nil }