Browse Source

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 <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 9 years ago
parent
commit
ffeab49ed3
  1. 5
      daemon/packets.c
  2. 6
      daemon/peer.c

5
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:

6
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;
}

Loading…
Cancel
Save