@@ -970,6 +970,52 @@ A fulfilling node:
970
970
- SHOULD send an ` error ` to the offering peer (if connected).
971
971
- MUST fail the channel.
972
972
973
+ ### Bounding exposure to trimmed in-flight HTLCs: ` max_dust_htlc_exposure_msat `
974
+
975
+ When an HTLC in a channel is below the "trimmed" threshold in [ BOLT3 #3 ] ( 03-transactions.md ) ,
976
+ the HTLC cannot be claimed on-chain, instead being turned into additional miner
977
+ fees if either party unilaterally closes the channel. Because the threshold is
978
+ per-HTLC, the total exposure to such HTLCs may be substantial if there are many
979
+ dust HTLCs committed when the channel is force-closed.
980
+
981
+ This can be exploited in griefing attacks or even in miner-extractable-value attacks,
982
+ if the malicious entity wins <sup >[ mining capabilities] ( https://lists.linuxfoundation.org/pipermail/lightning-dev/2020-May/002714.html ) </sup >.
983
+
984
+ The total exposure is given by the following back-of-the-envelope computation:
985
+
986
+ remote `max_accepted_htlcs` * (`HTLC-success-kiloweight` * `feerate_per_kw` + remote `dust_limit_satoshis`)
987
+ + local `max_accepted_htlcs` * (`HTLC-timeout-kiloweight` * `feerate_per_kw` + remote `dust_limit_satoshis`)
988
+
989
+ To mitigate this scenario, a ` max_dust_htlc_exposure_msat ` threshold can be
990
+ applied when sending, forwarding and receiving HTLCs.
991
+
992
+ A node:
993
+ - when receiving an HTLC:
994
+ - if the HTLC's ` amount_msat ` is smaller than the remote ` dust_limit_satoshis ` plus the HTLC-timeout fee at ` feerate_per_kw ` :
995
+ - if the ` amount_msat ` plus the dust balance of the remote transaction is greater than ` max_dust_htlc_exposure_msat ` :
996
+ - SHOULD fail this HTLC once it's committed
997
+ - SHOULD NOT reveal a preimage for this HTLC
998
+ - if the HTLC's ` amount_msat ` is smaller than the local ` dust_limit_satoshis ` plus the HTLC-success fee at ` feerate_per_kw ` :
999
+ - if the ` amount_msat ` plus the dust balance of the local transaction is greater than ` max_dust_htlc_exposure_msat ` :
1000
+ - SHOULD fail this HTLC once it's committed
1001
+ - SHOULD NOT reveal a preimage for this HTLC
1002
+ - when offering an HTLC:
1003
+ - if the HTLC's ` amount_msat ` is smaller than the remote ` dust_limit_satoshis ` plus the HTLC-success fee at ` feerate_per_kw ` :
1004
+ - if the ` amount_msat ` plus the dust balance of the remote transaction is greater than ` max_dust_htlc_exposure_msat ` :
1005
+ - SHOULD NOT send this HTLC
1006
+ - SHOULD fail the corresponding incoming HTLC (if any)
1007
+ - if the HTLC's ` amount_msat ` is inferior to the holder's ` dust_limit_satoshis ` plus the HTLC-timeout fee at the ` feerate_per_kw ` :
1008
+ - if the ` amount_msat ` plus the dust balance of the local transaction is greater than ` max_dust_htlc_exposure_msat ` :
1009
+ - SHOULD NOT send this HTLC
1010
+ - SHOULD fail the corresponding incoming HTLC (if any)
1011
+
1012
+ The ` max_dust_htlc_exposure_msat ` is an upper bound on the trimmed balance from
1013
+ dust exposure. The exact value used is a matter of node policy.
1014
+
1015
+ For channels that don't use ` option_anchors_zero_fee_htlc_tx ` , an increase of
1016
+ the ` feerate_per_kw ` may trim multiple htlcs from commitment transactions,
1017
+ which could create a large increase in dust exposure.
1018
+
973
1019
### Adding an HTLC: ` update_add_htlc `
974
1020
975
1021
Either node can send ` update_add_htlc ` to offer an HTLC to the other,
@@ -1333,6 +1379,16 @@ The node _responsible_ for paying the Bitcoin fee:
1333
1379
The node _ not responsible_ for paying the Bitcoin fee:
1334
1380
- MUST NOT send ` update_fee ` .
1335
1381
1382
+ A sending node:
1383
+ - if ` option_anchors_zero_fee_htlc_tx ` was not negotiated:
1384
+ - if the ` update_fee ` increases ` feerate_per_kw ` :
1385
+ - if the dust balance of the remote transaction at the updated ` feerate_per_kw ` is greater than ` max_dust_htlc_exposure_msat ` :
1386
+ - MAY NOT send ` update_fee `
1387
+ - MAY fail the channel
1388
+ - if the dust balance of the local transaction at the updated ` feerate_per_kw ` is greater than ` max_dust_htlc_exposure_msat ` :
1389
+ - MAY NOT send ` update_fee `
1390
+ - MAY fail the channel
1391
+
1336
1392
A receiving node:
1337
1393
- if the ` update_fee ` is too low for timely processing, OR is unreasonably large:
1338
1394
- MUST send a ` warning ` and close the connection, or send an
@@ -1345,6 +1401,12 @@ A receiving node:
1345
1401
- SHOULD send a ` warning ` and close the connection, or send an
1346
1402
` error ` and fail the channel.
1347
1403
- but MAY delay this check until the ` update_fee ` is committed.
1404
+ - if ` option_anchors_zero_fee_htlc_tx ` was not negotiated:
1405
+ - if the ` update_fee ` increases ` feerate_per_kw ` :
1406
+ - if the dust balance of the remote transaction at the updated ` feerate_per_kw ` is greater then ` max_dust_htlc_exposure_msat ` :
1407
+ - MAY fail the channel
1408
+ - if the dust balance of the local transaction at the updated ` feerate_per_kw ` is greater than ` max_dust_htlc_exposure_msat ` :
1409
+ - MAY fail the channel
1348
1410
1349
1411
#### Rationale
1350
1412
@@ -1368,6 +1430,11 @@ it's simplest to only allow it to set fee levels; however, as the same
1368
1430
fee rate applies to HTLC transactions, the receiving node must also
1369
1431
care about the reasonableness of the fee.
1370
1432
1433
+ If on-chain fees increase while commitments contain many HTLCs that will
1434
+ be trimmed at the updated feerate, this could overflow the configured
1435
+ ` max_dust_htlc_exposure_msat ` . Whether to close the channel preemptively
1436
+ or not is left as a matter of node policy.
1437
+
1371
1438
## Message Retransmission
1372
1439
1373
1440
Because communication transports are unreliable, and may need to be
0 commit comments