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

Function handle_invoice_onion_message

plugins/fetchinvoice.c:404–438  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

402}
403
404struct command_result *handle_invoice_onion_message(struct command *cmd,
405 const char *buf,
406 const jsmntok_t *om,
407 const struct secret *pathsecret)
408{
409 struct sent *sent;
410 struct command_result *err;
411
412 /* BOLT #4:
413 * - otherwise (it is the final node):
414 * - if `path_id` is set and corresponds to a path the reader has previously published in a `reply_path`:
415 * - if the onion message is not a reply to that previous onion:
416 * - MUST ignore the onion message
417 * - otherwise (unknown or unset `path_id`):
418 * - if the onion message is a reply to an onion message which contained a `path_id`:
419 * - MUST respond (or not respond) exactly as if it did not send the initial onion message.
420 */
421 /* We unmarshal the path_id into our secret: if it is NULL or wrong, we exit here */
422 sent = find_sent_by_secret(pathsecret);
423 if (!sent)
424 return NULL;
425
426 plugin_log(cmd->plugin, LOG_DBG, "Received onion message reply for invoice_request: %.*s",
427 json_tok_full_len(om),
428 json_tok_full(buf, om));
429
430 err = handle_error(cmd, sent, buf, om);
431 if (err)
432 return err;
433
434 if (sent->invreq)
435 return handle_invreq_response(cmd, sent, buf, om);
436
437 return NULL;
438}
439
440static void destroy_sent(struct sent *sent)
441{

Callers 1

onion_message_recvFunction · 0.70

Calls 6

find_sent_by_secretFunction · 0.85
handle_errorFunction · 0.85
handle_invreq_responseFunction · 0.85
plugin_logFunction · 0.70
json_tok_full_lenFunction · 0.50
json_tok_fullFunction · 0.50

Tested by

no test coverage detected