# Lightning Network: How was the maximum allowed HTLCs in flight computed?

The maximum acceptable `max_accepted_htlcs` (maximum number of HTLCs forwarded concurrently) is specified by the BOLTS as being `483`.

The rationale is given in BOLT #2:

`max_accepted_htlcs` is limited to 483 to ensure that, even if both sides send the maximum number of HTLCs, the `commitment_signed` message will still be under the maximum message size. It also ensures that a single penalty transaction can spend the entire commitment transaction, as calculated in BOLT #5.

The maximum message size is set in BOLT #8 to about 65kB. Therefore it is necessary to limit the size of a commitment transaction, which is otherwise bounded by the block size (4M Weight Units) according to consensus and the maximum standard transaction size (400k Weight Units) according to relay policy.

The second part of the rationale is maybe less clear. An outgoing HTLC in your channel adds an output to each of the two commitment transactions. Same for an incoming HTLC. The limit therefore makes it so there is at most 966 HTLC outputs in a single transaction.

The calculation in BOLT #5 to justify this choice is the following:

``````max_num_htlcs = (400000 - 324 - 272 - (4 * 53) - 2) / 413 = 966
``````

Here is what each of the number corresponds to:

• 400'000: the maximum standard transaction weight
• 324: the weight of the input spending the output in the commitment transaction paying yourself.
• 272: the weight of the input spending the output in the commitment transaction paying your peer.
• 53: the size of the header and the outputs of the penalty transaction. Multiplied by 4 because it is not witness data.
• 2 : the size of the witness header.
• 413 : the maximum weight to spend an HTLC output.
• Great explanation, except that it's 400,000 WU, not 4,000,000, because it's limited by transaction standardness, not block size (see my answer above). Mar 20, 2020 at 10:48
• Thanks Stephan, will amend ! Mar 21, 2020 at 10:09
• @AntoinePoinsot: I don’t understand why an HTLC would add two new outputs to the commitment transaction. Wouldn’t it just be one that can be spent in two different ways?
– Murch
Apr 2 at 11:54
• @Murch yeah there is multiple things wrong with this answser. I'm not sure where this 2-outputs per HTLC comes from, and some links are incorrect. I'm trying to understand what my 4-years-ago self meant now. Apr 2 at 12:35
• Aaah alright. Just understood what i meant! It's maximum 483 htlcs accepted by each side! So it's 2 outputs added per bi-directional HTLC per commitment transaction. Maybe i was also confused, but maybe it was just english lacking even more back then. Making an edit now. Apr 2 at 13:57

The maximum standard weight is a restriction on bitcoin transaction size. It's the maximum weight that a transaction can have to be 'standard', which means it is still relayed by unmodified bitcoin core nodes. You could have a bigger tx in a block, but you would probably have to find a miner yourself that is willing to include it.

The concept of weight is important here, it's the new way of measuring transaction size since segwit and is thoroughly described here

Aside from that, what exactly don't you understand in the calculation?

• Oh I don't understand how calculation of `max_num_htlcs` turns into 966. What does `(400000 - 324 - 272 - (4 * 53) - 2) / 413` mean? Mar 12, 2020 at 0:18
• I think you need to try a little harder. Please take the time to try to understand the text that you linked to. They tried to explain what they did there. Now it may be that you don't understand every part of what they are trying to explain. That's fine. Then you can ask a specific question. But just asking people to write an even more elaborate text in case you might take the time to read it this time seem a little lazy to me. Mar 13, 2020 at 9:07