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

1

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

https://github.com/lightningnetwork/lightning-rfc/blob/master/11-payment-encoding.md#tagged-fields

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.

ascendzor

Posted 2019-09-17T01:36:01.247

Reputation: 65

Answers

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.

Ugam Kamat

Posted 2019-09-17T01:36:01.247

Reputation: 5 180

Ah thank you for your answer, I understand now, it is due to the number of bits on data_length.ascendzor 2019-09-17T05:23:27.093