Skip to content

Commit a26b96a

Browse files
committed
channeld: update dust limit checks to the final version of PR 919.
This is what was merged in the spec, so update our checks (and bolt quote). Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
1 parent 969445c commit a26b96a

File tree

1 file changed

+23
-9
lines changed

1 file changed

+23
-9
lines changed

channeld/full_channel.c

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1434,16 +1434,30 @@ bool channel_update_feerate(struct channel *channel, u32 feerate_per_kw)
14341434
if (!can_opener_afford_feerate(channel, feerate_per_kw))
14351435
return false;
14361436

1437-
/* BOLT-919 #2:
1438-
* - if the `dust_balance_on_holder_tx` at the
1439-
* new `dust_buffer_feerate` is superior to
1440-
* the `max_dust_htlc_exposure_msat`:
1441-
* ...
1442-
* - MAY fail the channel
1437+
/* BOLT #2:
1438+
* - if `option_anchors` was not negotiated:
1439+
* - if the `update_fee` increases `feerate_per_kw`:
1440+
* - if the dust balance of the remote transaction at the
1441+
* updated `feerate_per_kw` is greater then `max_dust_htlc_exposure_msat`:
1442+
* - MAY fail the channel
1443+
* - if the dust balance of the local transaction at the
1444+
* updated `feerate_per_kw` is greater than `max_dust_htlc_exposure_msat`:
1445+
* - MAY fail the channel
14431446
*/
1444-
if (!htlc_dust_ok(channel, feerate_per_kw, REMOTE) ||
1445-
!htlc_dust_ok(channel, feerate_per_kw, LOCAL))
1446-
return false;
1447+
if (!channel_has(channel, OPT_ANCHORS_ZERO_FEE_HTLC_TX)) {
1448+
if (feerate_per_kw > channel_feerate(channel, REMOTE)) {
1449+
if (!htlc_dust_ok(channel, feerate_per_kw, REMOTE)) {
1450+
status_unusual("Feerate %u is too dusty for remote",
1451+
feerate_per_kw);
1452+
return false;
1453+
}
1454+
}
1455+
if (!htlc_dust_ok(channel, feerate_per_kw, LOCAL)) {
1456+
status_unusual("Feerate %u is too dusty for local",
1457+
feerate_per_kw);
1458+
return false;
1459+
}
1460+
}
14471461

14481462
status_debug("Setting %s feerate to %u",
14491463
side_to_str(!channel->opener), feerate_per_kw);

0 commit comments

Comments
 (0)