Why is the description field in a Lightning Network invoice limited to 639 bytes?


https://github.com/lightningnetwork/lnd/blob/95502da7e87d7f1ae96e9d69fcdb2f1b038d6497/channeldb/invoices.go#L85 (LND limits it to 1024)

I would like to send data over the lightning network using the description field for the anonymizing aspects of onion routing in conjunction with the economic incentive for honest nodes.

1 Answer 1


Why is the description field limited to 639 bytes?

Every field in lightning invoice is of the form:

  1. type (5 bits)
  2. data_length (10 bits, big-endian)
  3. 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.

  • Ah thank you for your answer, I understand now, it is due to the number of bits on data_length.
    – ascendzor
    Sep 17, 2019 at 5:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.