lightningd: immediately fail HTLCs coming in from shutting down channels.

This can happen even without a protocol violation, if the incoming
update_add_htlc crosses over our outgoing shutdown.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2017-06-26 10:52:56 +09:30
parent 866ac79850
commit e2c5104aab

View File

@@ -600,6 +600,15 @@ static bool peer_accepted_htlc(struct peer *peer,
if (!htlc_in_update_state(peer, hin, RCVD_ADD_ACK_REVOCATION))
return false;
/* BOLT #2:
*
* A sending node SHOULD fail to route any HTLC added after it
* sent `shutdown`. */
if (peer->state == CHANNELD_SHUTTING_DOWN) {
*failcode = WIRE_PERMANENT_CHANNEL_FAILURE;
goto out;
}
/* channeld tests this, so it should have set ss to zeroes. */
op = parse_onionpacket(tmpctx, hin->onion_routing_packet,
sizeof(hin->onion_routing_packet));