2

Assume we have a route n1 -> n2 -> n3 -> n4. My intuition here is that n2 charges n1 a fee and that n3 charges n2 a fee for routing payments. However, there's no fee for the last hop where n3 forwards the payment to n4. Is this correct? And if so, is this just an implementation detail, or is this somehow enforced on the protocol level?

1

The last channel in the route does have an impact on the fees of the payment. It's a bit counter-intuitive but when a payment is being forwarded by intermediate nodes it pays to the node the fees necessary to traverse an outgoing channel of that node. In a situation A -> B -> C A sends to B amount + fee(BC) because A knows that B will subtract the fees according to the cost of traversing the channel to C namely 'fee(BC)'; note that if there are multiple channels between B and C, A can't choose which one to traverse. In the case of the last hop you want to it to have the amount that was requested in the invoice (or whatever amount you want it to receive), in the { A, B, C } example A is effectively paying for the last hop even though the amount that comes out of B is without fees because B takes them in advance (before forwarding it to C).

As reference you can look here and specifically in the field descriptions: every forwarding node has to respect the equality incoming_htlc_amt - fee >= amt_to_forward where incoming_htlc_amt is the amount being received upstream and amt_to_forward is what will be sent downstream.So to answer your question, an LN route with N channels requires exactly N-1 fee payments.

1

As far as I know it is not specified on a protocol level. Since routing a payment triggers setting up an htlc I believe that n4 will also charge a fee as people did not differentiate in the code if it is the last hop or not.

I observed this when playing lightning tennis sending back and forth one Satoshi in one channel and got this answer from a c lightning developer. I didn't check the code but it makes sense.

1

The fee is implied by the difference in routed amounts across the channels in the payment route. The htlc amounts reflecting the payment amount will decrease from channel to channel.

  • n1 -> n2: Incoming amount
  • n2 -> n3: Incoming amount - fee_2 (n2 earns a fee_2)
  • n3 -> n4: Incoming amount - fee_2 - fee_3 (n3 earns a fee of fee_3)

Each fee is earned by a single node which relays the payment from one of its payment channels to another. On balance, the peer receives an amount A, and forwards an amount A - fee to the channel it is connected to along the route.

Each peer can decide which fee it wishes to set when providing routing services. When the route is negotiated, the announced fees of each peer are taken into consideration to construct the optimal route.

Once peers agree to participate in forwarding a route, the payment amounts along the route are committed to the htlc outputs in each channel. Theses htlc amounts will decrease along the route, reflecting the forwarding fees charged by each peer.

  • Are you sure that the hop from n1 to n2 is without fee? Ist the inbound channel always charging and in that sense we would have 3 fees to be paid? – Rene Pickhardt Feb 6 at 11:26

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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