Skip to content

Commit

Permalink
channeld: allow remote node to exceed their own HTLC count limits.
Browse files Browse the repository at this point in the history
We try not to exceed either side, but the spec still allows them to
(we don't, but older nodes would have, as could other implementations).

Fixes: #3953
Changelog-Fixed: protocol: overzealous close when peer sent more HTLCs than they'd told us we could send.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
  • Loading branch information
rustyrussell committed Mar 16, 2021
1 parent 1b02d15 commit 3bfcd9c
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions channeld/full_channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -573,16 +573,19 @@ static enum channel_add_err add_htlc(struct channel *channel,
* HTLCs to its local commitment transaction...
* - SHOULD fail the channel.
*/
/* Also we should not add more htlc's than sender or recipient
* configured. This mitigates attacks in which a peer can force the
* opener of the channel to pay unnecessary onchain fees during a fee
if (tal_count(committed) - tal_count(removing) + tal_count(adding)
> channel->config[recipient].max_accepted_htlcs) {
return CHANNEL_ERR_TOO_MANY_HTLCS;
}

/* Also *we* should not add more htlc's we configured. This
* mitigates attacks in which a peer can force the opener of
* the channel to pay unnecessary onchain fees during a fee
* spike with large commitment transactions.
*/
min_concurrent_htlcs = channel->config[recipient].max_accepted_htlcs;
if (min_concurrent_htlcs > channel->config[sender].max_accepted_htlcs)
min_concurrent_htlcs = channel->config[sender].max_accepted_htlcs;
if (tal_count(committed) - tal_count(removing) + tal_count(adding)
> min_concurrent_htlcs) {
if (sender == LOCAL
&& tal_count(committed) - tal_count(removing) + tal_count(adding)
> channel->config[LOCAL].max_accepted_htlcs) {
return CHANNEL_ERR_TOO_MANY_HTLCS;
}

Expand Down

0 comments on commit 3bfcd9c

Please sign in to comment.