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

Function peer_accepted_htlc

lightningd/peer_htlcs.c:1217–1362  ·  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

1215 * If this returns false, exactly one of @badonion or @failmsg is set.
1216 */
1217static bool peer_accepted_htlc(const tal_t *ctx,
1218 struct channel *channel, u64 id,
1219 bool replay,
1220 enum onion_wire *badonion,
1221 u8 **failmsg)
1222{
1223 struct htlc_in *hin;
1224 struct route_step *rs;
1225 struct onionpacket *op;
1226 struct lightningd *ld = channel->peer->ld;
1227 struct htlc_accepted_hook_payload *hook_payload;
1228
1229 *failmsg = NULL;
1230 *badonion = 0;
1231
1232 hin = find_htlc_in(&ld->htlcs_in, channel, id);
1233 if (!hin) {
1234 channel_internal_error(channel,
1235 "peer_got_revoke unknown htlc %"PRIu64, id);
1236 *failmsg = towire_temporary_node_failure(ctx);
1237 goto fail;
1238 }
1239
1240 if (hin->fail_immediate && htlc_in_update_state(channel, hin, RCVD_ADD_ACK_REVOCATION)) {
1241 log_debug(channel->log, "failing immediately, as requested");
1242 /* Failing the htlc, typically done because of htlc dust */
1243 *failmsg = towire_temporary_node_failure(ctx);
1244 goto fail;
1245 }
1246
1247 if (!replay && !htlc_in_update_state(channel, hin, RCVD_ADD_ACK_REVOCATION)) {
1248 *failmsg = towire_temporary_node_failure(ctx);
1249 goto fail;
1250 }
1251
1252 htlc_in_check(hin, __func__);
1253
1254#if DEVELOPER
1255 if (channel->peer->ignore_htlcs) {
1256 log_debug(channel->log, "their htlc %"PRIu64" dev_ignore_htlcs",
1257 id);
1258 return true;
1259 }
1260#endif
1261 /* BOLT #2:
1262 *
1263 * - SHOULD fail to route any HTLC added after it has sent `shutdown`.
1264 */
1265 if (channel->state == CHANNELD_SHUTTING_DOWN) {
1266 *failmsg = towire_permanent_channel_failure(ctx);
1267 log_debug(channel->log,
1268 "Rejecting their htlc %"PRIu64
1269 " since we're shutting down",
1270 id);
1271 goto fail;
1272 }
1273
1274 /* 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
htlc_in_checkFunction · 0.85
onion_wire_nameFunction · 0.85
calc_forwarding_channelFunction · 0.85
tal_freeFunction · 0.85
channel_internal_errorFunction · 0.70
parse_onionpacketFunction · 0.50
process_onionpacketFunction · 0.50
type_to_stringClass · 0.50

Tested by

no test coverage detected