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

Function htlc_accepted_hook_final

lightningd/peer_htlcs.c:1307–1360  ·  view source on GitHub ↗

* Callback when a plugin answers to the htlc_accepted hook */

Source from the content-addressed store, hash-verified

1305 * Callback when a plugin answers to the htlc_accepted hook
1306 */
1307static void
1308htlc_accepted_hook_final(struct htlc_accepted_hook_payload *request STEALS)
1309{
1310 struct route_step *rs = request->route_step;
1311 struct htlc_in *hin = request->hin;
1312 struct channel *channel = request->channel;
1313
1314 request->hin->status = tal_free(request->hin->status);
1315
1316 /* Hand the payload to the htlc_in since we'll want to have that info
1317 * handy for the hooks and notifications. */
1318 request->hin->payload = tal_steal(request->hin, request->payload);
1319
1320 /* *Now* we barf if it failed to decode */
1321 if (!request->payload) {
1322 log_debug(channel->log,
1323 "Failing HTLC because of an invalid payload (TLV %"PRIu64" pos %zu): %s",
1324 request->failtlvtype, request->failtlvpos,
1325 request->failexplanation);
1326 local_fail_in_htlc(hin,
1327 take(towire_invalid_onion_payload(
1328 NULL, request->failtlvtype,
1329 request->failtlvpos)));
1330 } else if (rs->nextcase == ONION_FORWARD) {
1331 struct tlv_field *extra_tlvs;
1332
1333 if (request->extra_tlvs_raw) {
1334 const u8 *cursor = request->extra_tlvs_raw;
1335 size_t max = tal_bytelen(cursor);
1336 extra_tlvs = tal_arr(request, struct tlv_field, 0);
1337 fromwire_tlv(&cursor, &max, NULL, 0, request,
1338 &extra_tlvs, NULL, NULL, NULL);
1339 } else {
1340 extra_tlvs = NULL;
1341 }
1342
1343 forward_htlc(hin, hin->cltv_expiry,
1344 request->payload->amt_to_forward,
1345 request->payload->outgoing_cltv,
1346 request->payload->forward_channel,
1347 request->fwd_channel_id,
1348 serialize_onionpacket(tmpctx, rs->next),
1349 request->next_path_key, extra_tlvs);
1350 } else
1351 handle_localpay(hin,
1352 request->payload->amt_to_forward,
1353 request->payload->outgoing_cltv,
1354 *request->payload->total_msat,
1355 request->invoice_msat,
1356 request->payload->payment_secret,
1357 request->payload->payment_metadata);
1358
1359 tal_free(request);
1360}
1361
1362/* Apply tweak to ephemeral key if path_key is non-NULL, then do ECDH */
1363bool ecdh_maybe_blinding(const struct pubkey *ephemeral_key,

Callers

nothing calls this directly

Calls 7

tal_freeFunction · 0.85
tal_bytelenFunction · 0.85
serialize_onionpacketFunction · 0.85
handle_localpayFunction · 0.85
local_fail_in_htlcFunction · 0.70
forward_htlcFunction · 0.70
fromwire_tlvFunction · 0.50

Tested by

no test coverage detected