You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 02-peer-protocol.md
+16Lines changed: 16 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -786,6 +786,12 @@ A fulfilling node:
786
786
transaction, AND is past this fulfillment deadline:
787
787
- MUST fail the channel.
788
788
789
+
### Hold fees
790
+
791
+
To prevent abuse of the network, nodes will charge a fee for the time that their money is locked up in htlcs. The general direction of this fee stream is backwards. Every node along the route that receives an htlc will pay a time-dependent hold fee rate to its predecessor when the htlc resolves, regardless of whether the htlc was fulfilled or failed. The hold fee rate increases with every hop downstream, because more and more money gets locked up. An intermediary or final node that holds on to the htlc for an unreasonably long period of time will need to pay for that (indirectly) to every node upstream.
792
+
793
+
Forwarding an htlc will always add some delay. To prevent senders from collecting 'free' hold fees, routing nodes will demand a discount on the hold fee. If the routing node forwards swiftly, this discount will turn the hold fee negative and require the sender to pay. Ultimately the sum of all these discounts is paid by the original sender of the payment. This is a protection against spam.
794
+
789
795
### Adding an HTLC: `update_add_htlc`
790
796
791
797
Either node can send `update_add_htlc` to offer an HTLC to the other,
@@ -805,6 +811,8 @@ is destined, is described in [BOLT #4](04-onion-routing.md).
805
811
*[`sha256`:`payment_hash`]
806
812
*[`u32`:`cltv_expiry`]
807
813
*[`1366*byte`:`onion_routing_packet`]
814
+
*[`u64`:`hold_fee_rate_day`]
815
+
*[`u64`:`hold_fee_discount`]
808
816
809
817
#### Requirements
810
818
@@ -829,6 +837,8 @@ A sending node:
829
837
its commitment transaction, it cannot pay the fee for the updated local or
830
838
remote transaction at the current `feerate_per_kw` while maintaining its
831
839
channel reserve.
840
+
- SHOULD NOT offer a combination of `amount_msat`, `cltv_expiry`, `hold_fee_rate_day` and `hold_fee_discount` such that the remote node cannot pay the hold fee for the longest possible hold duration. The longest possible hold duration is the `cltv_expiry` delta in blocks multiplied by ten minutes. This must also take into account all currently outstanding htlcs.
841
+
- SHOULD NOT offer a `hold_fee_discount` that it cannot pay for. This must also take into account all currently outstanding htlcs.
832
842
- MUST offer `amount_msat` greater than 0.
833
843
- MUST NOT offer `amount_msat` below the receiving node's `htlc_minimum_msat`
834
844
- MUST set `cltv_expiry` less than 500000000.
@@ -916,6 +926,7 @@ To supply the preimage:
916
926
*[`channel_id`:`channel_id`]
917
927
*[`u64`:`id`]
918
928
*[`32*byte`:`payment_preimage`]
929
+
*[`u64:hold fee`]
919
930
920
931
For a timed out or route-failed HTLC:
921
932
@@ -925,6 +936,7 @@ For a timed out or route-failed HTLC:
925
936
*[`u64`:`id`]
926
937
*[`u16`:`len`]
927
938
*[`len*byte`:`reason`]
939
+
*[`u64:hold fee`]
928
940
929
941
The `reason` field is an opaque encrypted blob for the benefit of the
930
942
original HTLC initiator, as defined in [BOLT #4](04-onion-routing.md);
@@ -940,6 +952,7 @@ For an unparsable HTLC:
940
952
*[`u64`:`id`]
941
953
*[`sha256`:`sha256_of_onion`]
942
954
*[`u16`:`failure_code`]
955
+
*[`u64:hold fee`]
943
956
944
957
#### Requirements
945
958
@@ -950,6 +963,7 @@ A node:
950
963
commitment transactions:
951
964
- MUST NOT send an `update_fulfill_htlc`, `update_fail_htlc`, or
952
965
`update_fail_malformed_htlc`.
966
+
- MUST set `hold_fee` to the hold fees that it owes the sending node. Let `hold_duration_days` be the actual time what the htlc was held expressed in days. This value is calculated as `hold_fee_rate_day` (from `update_add_htlc`) * `hold_duration_days` - `hold_fee_discount` (also from `update_add_htlc`). Example: `hold_fee_rate_day`=200, `hold_fee_discount`=3, `hold_duration_days`=0.02 (30 minutes). Then `hold_fee` is 200 * 0.02 - 3 = 1 sat. `hold_fee` can be negative in which case the sending node owes the receiving node.
953
967
954
968
A receiving node:
955
969
- if the `id` does not correspond to an HTLC in its current commitment transaction:
@@ -967,6 +981,8 @@ A receiving node:
967
981
- MUST return an error in the `update_fail_htlc` sent to the link which
968
982
originally sent the HTLC, using the `failure_code` given and setting the
969
983
data to `sha256_of_onion`.
984
+
- MUST fail the channel if `hold_fee` is more than 1% below the expected value. This tolerance exists to accommodate for clock skew.
985
+
- MUST account for the `hold_fee` internally by adding the value to its balance and subtracting the value from the remote balance.
Copy file name to clipboardExpand all lines: 04-onion-routing.md
+8-1Lines changed: 8 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -263,6 +263,10 @@ It is formatted according to the Type-Length-Value format defined in [BOLT #1](0
263
263
2. data:
264
264
*[`32*byte`:`payment_secret`]
265
265
*[`tu64`:`total_msat`]
266
+
1. type: 10 (`hold_fee`)
267
+
2. data:
268
+
*[`u64`:`hold_fee_rate_day`]
269
+
*[`u64`:`hold_fee_discount`]
266
270
267
271
### Requirements
268
272
@@ -271,16 +275,19 @@ The writer:
271
275
- MUST use the legacy payload format instead.
272
276
- For every node:
273
277
- MUST include `amt_to_forward` and `outgoing_cltv_value`.
278
+
- MUST include `hold_fee`
274
279
- For every non-final node:
275
280
- MUST include `short_channel_id`
276
281
- MUST NOT include `payment_data`
282
+
- MUST set `hold_fee_rate_day` so that difference between incoming and outgoing `hold_fee_rate_day` for the receiving node is at least the expected value based on the receiving node's channel policy.
283
+
- MUST set `hold_fee_discount` to the amount that the reading node would owe its predecessor if the htlc would remain locked for `hold_grace_period_sec` (as advertised by the reading node), plus all amounts owed by nodes further downstream to their predecessors if they'd all hold the htlc for their `hold_grace_period_sec`.
277
284
- For the final node:
278
285
- MUST NOT include `short_channel_id`
279
286
- if the recipient provided `payment_secret`:
280
287
- MUST include `payment_data`
281
288
- MUST set `payment_secret` to the one provided
282
289
- MUST set `total_msat` to the total amount it will send
283
-
290
+
- MUST set `hold_fee_discount` to the amount that the reading node would owe its predecessor if the htlc would remain locked for `hold_grace_period_sec` (as advertised by the reading node).
284
291
The reader:
285
292
- MUST return an error if `amt_to_forward` or `outgoing_cltv_value` are not present.
The `channel_flags` bitfield is used to indicate the direction of the channel: it
413
416
identifies the node that this update originated from and signals various options
@@ -485,6 +488,9 @@ The origin node:
485
488
- MUST set `fee_proportional_millionths` to the amount (in millionths of a
486
489
satoshi) it will charge per transferred satoshi.
487
490
- SHOULD NOT create redundant `channel_update`s
491
+
- SHOULD set `hold_grace_period_sec` to the total processing time that it needs for forwarding an htlc over this channel. This includes both the forward (`update_add_htlc`) and the backward pass (`update_fulfill_htlc` / `update_fail_htlc`). As long as this node's delay stays within the grace period, there won't be any hold fee to pay.
492
+
- MUST set `hold_fee_rate_base_day` to the base fee per day that it expects to get paid via its outgoing link for having the htlc in flight.
493
+
- MUST set `hold_fee_rate_ppm_day` to the proportional fee (in parts per million) per day that is expects to get paid back via its outgoing link for having the htlc in flight. Example: `hold_fee_rate_base_day` = 10, `hold_fee_rate_ppm_day` = 1000, htlc amount = 2000000 sat, hold duration = 1 hour. The node will then expect to get paid (10 + 2000000 * 1000000 / 1000) / 24 = 83.75 sat in hold fees.
488
494
489
495
The receiving node:
490
496
- if the `short_channel_id` does NOT match a previous `channel_announcement`,
0 commit comments