MCPcopy Create free account
hub / github.com/ElementsProject/lightning / peer_accepted_htlc

Function peer_accepted_htlc

lightningd/peer_htlcs.c:1451–1615  ·  view source on GitHub ↗

* Everyone is committed to this htlc of theirs * * @param ctx: context for failmsg, if any. * @param channel: The channel this HTLC was accepted from. * @param id: the ID of the HTLC we accepted * @param replay: Are we loading from the database and therefore should not * perform the transition to RCVD_ADD_ACK_REVOCATION? * @param[out] badonion: Set non-zero if the onion was bad. * @

Source from the content-addressed store, hash-verified

1449 * If this returns false, exactly one of @badonion or @failmsg is set.
1450 */
1451static bool peer_accepted_htlc(const tal_t *ctx,
1452 struct channel *channel, u64 id,
1453 bool replay,
1454 enum onion_wire *badonion,
1455 u8 **failmsg)
1456{
1457 struct htlc_in *hin;
1458 struct route_step *rs;
1459 struct onionpacket *op;
1460 struct lightningd *ld = channel->peer->ld;
1461 struct htlc_accepted_hook_payload *hook_payload;
1462
1463
1464 *failmsg = NULL;
1465 *badonion = 0;
1466
1467 hin = find_htlc_in(ld->htlcs_in, channel, id);
1468 if (!hin) {
1469 channel_internal_error(channel,
1470 "peer_got_revoke unknown htlc %"PRIu64, id);
1471 *failmsg = towire_temporary_node_failure(ctx);
1472 goto fail;
1473 }
1474
1475 if (hin->fail_immediate && htlc_in_update_state(channel, hin, RCVD_ADD_ACK_REVOCATION)) {
1476 log_debug(channel->log, "failing immediately, as requested");
1477 /* Failing the htlc, typically done because of htlc dust */
1478 *failmsg = towire_temporary_node_failure(ctx);
1479 goto fail;
1480 }
1481
1482 if (!replay && !htlc_in_update_state(channel, hin, RCVD_ADD_ACK_REVOCATION)) {
1483 *failmsg = towire_temporary_node_failure(ctx);
1484 goto fail;
1485 }
1486
1487 htlc_in_check(hin, __func__);
1488
1489 if (channel->peer->dev_ignore_htlcs) {
1490 log_debug(channel->log, "their htlc %"PRIu64" dev_ignore_htlcs",
1491 id);
1492 return true;
1493 }
1494
1495 /* BOLT #2:
1496 *
1497 * - SHOULD fail to route any HTLC added after it has sent `shutdown`.
1498 */
1499 if (!channel_state_can_add_htlc(channel->state)) {
1500 *failmsg = towire_permanent_channel_failure(ctx);
1501 log_debug(channel->log,
1502 "Rejecting their htlc %"PRIu64
1503 " since we're shutting down",
1504 id);
1505 goto fail;
1506 }
1507
1508 /* BOLT #2:

Callers 2

peer_got_revokeFunction · 0.85
htlcs_resubmitFunction · 0.85

Calls 15

find_htlc_inFunction · 0.85
htlc_in_update_stateFunction · 0.85
parse_onionpacketFunction · 0.85
process_onionpacketFunction · 0.85
fmt_secretFunction · 0.85
onion_decodeFunction · 0.85
serialize_onionpacketFunction · 0.85
blinding_hash_e_and_ssFunction · 0.85
blinding_next_path_keyFunction · 0.85
calc_forwarding_channelFunction · 0.85
towire_tlvstream_rawFunction · 0.85

Tested by

no test coverage detected