mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-21 22:31:48 +01:00
included feedback by Rusty to check the max_concurrent_htlc value for both peers of a channel
This commit is contained in:
parent
1dd890825a
commit
dfac1d15a2
1 changed files with 10 additions and 1 deletions
|
@ -367,6 +367,7 @@ static enum channel_add_err add_htlc(struct channel *channel,
|
||||||
enum side sender = htlc_state_owner(state), recipient = !sender;
|
enum side sender = htlc_state_owner(state), recipient = !sender;
|
||||||
const struct htlc **committed, **adding, **removing;
|
const struct htlc **committed, **adding, **removing;
|
||||||
const struct channel_view *view;
|
const struct channel_view *view;
|
||||||
|
u32 min_concurrent_htlcs;
|
||||||
|
|
||||||
htlc = tal(tmpctx, struct htlc);
|
htlc = tal(tmpctx, struct htlc);
|
||||||
|
|
||||||
|
@ -443,8 +444,16 @@ static enum channel_add_err add_htlc(struct channel *channel,
|
||||||
* HTLCs to its local commitment transaction...
|
* HTLCs to its local commitment transaction...
|
||||||
* - SHOULD fail the channel.
|
* - 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
|
||||||
|
* funder 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)
|
if (tal_count(committed) - tal_count(removing) + tal_count(adding)
|
||||||
> channel->config[recipient].max_accepted_htlcs) {
|
> min_concurrent_htlcs) {
|
||||||
return CHANNEL_ERR_TOO_MANY_HTLCS;
|
return CHANNEL_ERR_TOO_MANY_HTLCS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue