<blockquote>
  <p>Why is the description field limited to 639 bytes?</p>
</blockquote>

<p>Every field in lightning invoice is of the form:</p>

<ol>
<li><code>type</code> (5 bits)</li>
<li><code>data_length</code> (10 bits, big-endian)</li>
<li><code>data</code> (<code>data_length</code> x 5 bits)</li>
</ol>

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

CC BY-SA 4.0
2019-09-17T05:23:27.093Z
Ah thank you for your answer, I understand now, it is due to the number of bits on `data_length`.
ascendzor
CC BY-SA 4.0
2019-09-17T04:59:49.103Z
2019-09-17T04:59:49.103Z
Ugam Kamat
<p>Why is the description field in a Lightning Network invoice limited to 639 bytes?</p>

<p><a href="https://github.com/lightningnetwork/lightning-rfc/blob/master/11-payment-encoding.md#tagged-fields" rel="nofollow noreferrer">https://github.com/lightningnetwork/lightning-rfc/blob/master/11-payment-encoding.md#tagged-fields</a></p>

<p><a href="https://github.com/lightningnetwork/lnd/blob/95502da7e87d7f1ae96e9d69fcdb2f1b038d6497/channeldb/invoices.go#L85" rel="nofollow noreferrer">https://github.com/lightningnetwork/lnd/blob/95502da7e87d7f1ae96e9d69fcdb2f1b038d6497/channeldb/invoices.go#L85</a> (LND limits it to 1024)</p>

<p>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.</p>

<lightning-network><lightning-rfc>
BOLT 11 - Why is the description field limited to 639 bytes?
ascendzor
# BOLT 11 - Why is the description field limited to 639 bytes?

(Asked by: username_0 on 2019-09-17)

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.

**Tags:** lightning-network, lightning-rfc


---

## 1 answers

### Answer by username_1 on 2019-09-17. Score: 1 | Accepted answer

> 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.

> **Comments:**
> **username_0**: Ah thank you for your answer, I understand now, it is due to the number of bits on `data_length`.  

---

