BOLT 11 - Why is the description field limited to 639 bytes?
Why is the description field limited to 639 bytes?


Every field in lightning invoice is of the form:


type (5 bits)
data_length (10 bits, big-endian)
data (data_length x 5 bits)


The data_length indicates the size of the data that is to be followed. Since data_length itself has a size of 10 bits, it can represent a number up to 1023 (210 -1). Thus the size of data can be at most 1023*5 bits or 639.375 bytes. This puts the upper limit of 639 bytes on the description field.