<p>I once <a href="https://github.com/lightning/bolts/pull/458" rel="nofollow noreferrer">suggested a pull request to add a table with the length of all messages in the Lightning Network</a> but this was never merged.</p>
<p>I guess the table is somewhat outdated by now but for easier reference you can find it here.</p>
<p><a href="https://github.com/renepickhardt/lightning-rfc/blob/master/appendix-a-list_of_messanges.mediawiki" rel="nofollow noreferrer">https://github.com/renepickhardt/lightning-rfc/blob/master/appendix-a-list_of_messanges.mediawiki</a></p>
<p>I think taking those values und substract from the 2^16 bytes is currently the best you can do to estimate (Also think of the framing of the Lighting messages as there is a small header and the table only shows the length of the payload).</p>
<p>However you will not know what other TLV streams might be added. Yet if you are implementing this anyway you should be in full control over your data? I mean you set the length of the TLV stream yourself that you append to the message.</p>

CC BY-SA 4.0
2021-12-13T08:38:05.700Z
Thank you Rene, the table you shared is a good reference.
I do have full control over the TLV streams on the `extension`, so I'll know how much to subtract.
One thing I could not sort out yet, which messages are sent when I pay an invoice (or in my case, send a keysend or spontaneous amp payment) - if you have a reference for that (preferably "for dummies"), I'd be grateful.
Guilherme Dellagustin
CC BY-SA 4.0
2021-12-11T15:09:30.617Z
2021-12-11T15:09:30.617Z
Rene Pickhardt
<p>I working on &quot;value for value&quot; payments for podcasts using bitcoin lightning payments.
There is a standard for adding metadata to this payments, which is defined here: <a href="https://github.com/satoshisstream/satoshis.stream/blob/main/TLV_registry.md#field-7629169" rel="nofollow noreferrer">https://github.com/satoshisstream/satoshis.stream/blob/main/TLV_registry.md#field-7629169</a> (Key 7629169).</p>
<p>Now, I'd like to estimate how much space is left for the <code>extension</code> section of the lightning message (as defined in <a href="https://github.com/lightning/bolts/blob/master/01-messaging.md" rel="nofollow noreferrer">BOLT #1</a>), given that the maximum size of the total message is 2^16 bytes (65536).</p>
<p>Is there a reasonable way of doing this estimation?</p>

<lightning-network>
How to estimate available size on the extension of TLV stream of lightning payment messages
Guilherme Dellagustin
# How to estimate available size on the extension of TLV stream of lightning payment messages

(Asked by: username_0 on 2021-12-11)

I working on "value for value" payments for podcasts using bitcoin lightning payments.
There is a standard for adding metadata to this payments, which is defined here: <https://github.com/satoshisstream/satoshis.stream/blob/main/TLV_registry.md#field-7629169> (Key 7629169).

Now, I'd like to estimate how much space is left for the `extension` section of the lightning message (as defined in [BOLT #1](https://github.com/lightning/bolts/blob/master/01-messaging.md)), given that the maximum size of the total message is 2^16 bytes (65536).

Is there a reasonable way of doing this estimation?

**Tags:** lightning-network


---

## 1 answers

### Answer by username_1 on 2021-12-11. Score: 1

I once [suggested a pull request to add a table with the length of all messages in the Lightning Network](https://github.com/lightning/bolts/pull/458) but this was never merged.

I guess the table is somewhat outdated by now but for easier reference you can find it here.

<https://github.com/username_1/lightning-rfc/blob/master/appendix-a-list_of_messanges.mediawiki>

I think taking those values und substract from the 2^16 bytes is currently the best you can do to estimate (Also think of the framing of the Lighting messages as there is a small header and the table only shows the length of the payload).

However you will not know what other TLV streams might be added. Yet if you are implementing this anyway you should be in full control over your data? I mean you set the length of the TLV stream yourself that you append to the message.

> **Comments:**
> **username_0**: Thank you username_1, the table you shared is a good reference. I do have full control over the TLV streams on the `extension`, so I'll know how much to subtract. One thing I could not sort out yet, which messages are sent when I pay an invoice (or in my case, send a keysend or spontaneous amp payment) - if you have a reference for that (preferably "for dummies"), I'd be grateful.  

---

