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

Function htlc_accepted_hook_final

lightningd/peer_htlcs.c:1263–1316  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

1261 * Callback when a plugin answers to the htlc_accepted hook
1262 */
1263static void
1264htlc_accepted_hook_final(struct htlc_accepted_hook_payload *request STEALS)
1265{
1266 struct route_step *rs = request->route_step;
1267 struct htlc_in *hin = request->hin;
1268 struct channel *channel = request->channel;
1269
1270 request->hin->status = tal_free(request->hin->status);
1271
1272 /* Hand the payload to the htlc_in since we'll want to have that info
1273 * handy for the hooks and notifications. */
1274 request->hin->payload = tal_steal(request->hin, request->payload);
1275
1276 /* *Now* we barf if it failed to decode */
1277 if (!request->payload) {
1278 log_debug(channel->log,
1279 "Failing HTLC because of an invalid payload (TLV %"PRIu64" pos %zu): %s",
1280 request->failtlvtype, request->failtlvpos,
1281 request->failexplanation);
1282 local_fail_in_htlc(hin,
1283 take(towire_invalid_onion_payload(
1284 NULL, request->failtlvtype,
1285 request->failtlvpos)));
1286 } else if (rs->nextcase == ONION_FORWARD) {
1287 struct tlv_field *extra_tlvs;
1288
1289 if (request->extra_tlvs_raw) {
1290 const u8 *cursor = request->extra_tlvs_raw;
1291 size_t max = tal_bytelen(cursor);
1292 extra_tlvs = tal_arr(request, struct tlv_field, 0);
1293 fromwire_tlv(&cursor, &max, NULL, 0, request,
1294 &extra_tlvs, NULL, NULL, NULL);
1295 } else {
1296 extra_tlvs = NULL;
1297 }
1298
1299 forward_htlc(hin, hin->cltv_expiry,
1300 request->payload->amt_to_forward,
1301 request->payload->outgoing_cltv,
1302 request->payload->forward_channel,
1303 request->fwd_channel_id,
1304 serialize_onionpacket(tmpctx, rs->next),
1305 request->next_path_key, extra_tlvs);
1306 } else
1307 handle_localpay(hin,
1308 request->payload->amt_to_forward,
1309 request->payload->outgoing_cltv,
1310 *request->payload->total_msat,
1311 request->invoice_msat,
1312 request->payload->payment_secret,
1313 request->payload->payment_metadata);
1314
1315 tal_free(request);
1316}
1317
1318/* Apply tweak to ephemeral key if path_key is non-NULL, then do ECDH */
1319bool 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