Skip to content

Commit

Permalink
asset: ensure asset name does not exceed max const
Browse files Browse the repository at this point in the history
  • Loading branch information
ffranr committed Sep 20, 2023
1 parent 67c3f94 commit de9d24c
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions asset/asset.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}

0 comments on commit de9d24c

Please sign in to comment.