From ffeab49ed3a06d6c8e02d6b0a853be10acfcf5a6 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Fri, 1 Jul 2016 11:19:28 +0930 Subject: [PATCH] htlc_add: only limit is on receiving side. BOLT has been updated, so update code and comments. The receiving side check is sufficient, as the limit is per-offerer, and that's the only way the HTLCs get back to the offerer's side. Signed-off-by: Rusty Russell --- daemon/packets.c | 5 ++--- daemon/peer.c | 6 ++---- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/daemon/packets.c b/daemon/packets.c index d0116679b..a9b36445e 100644 --- a/daemon/packets.c +++ b/daemon/packets.c @@ -619,10 +619,9 @@ Pkt *accept_pkt_htlc_add(struct peer *peer, const Pkt *pkt) /* BOLT #2: * * A node MUST NOT add a HTLC if it would result in it - * offering more than 300 HTLCs in either commitment transaction. + * offering more than 300 HTLCs in the remote commitment transaction. */ - if (tal_count(peer->remote.staging_cstate->side[THEIRS].htlcs) == 300 - || tal_count(peer->local.staging_cstate->side[THEIRS].htlcs) == 300) + if (tal_count(peer->remote.staging_cstate->side[THEIRS].htlcs) == 300) return pkt_err(peer, "Too many HTLCs"); /* BOLT #2: diff --git a/daemon/peer.c b/daemon/peer.c index 0af60500f..a3bd95fed 100644 --- a/daemon/peer.c +++ b/daemon/peer.c @@ -714,14 +714,12 @@ struct htlc *command_htlc_add(struct peer *peer, u64 msatoshis, return NULL; } - /* FIXME: This is wrong: constraint on remote is sufficient. */ /* BOLT #2: * * A node MUST NOT add a HTLC if it would result in it - * offering more than 300 HTLCs in either commitment transaction. + * offering more than 300 HTLCs in the remote commitment transaction. */ - if (tal_count(peer->local.staging_cstate->side[OURS].htlcs) == 300 - || tal_count(peer->remote.staging_cstate->side[OURS].htlcs) == 300) { + if (tal_count(peer->remote.staging_cstate->side[OURS].htlcs) == 300) { log_unusual(peer->log, "add_htlc: fail: already at limit"); return NULL; }