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

Function handle_invoice_onion_message

plugins/fetchinvoice.c:363–397  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

361}
362
363struct command_result *handle_invoice_onion_message(struct command *cmd,
364 const char *buf,
365 const jsmntok_t *om,
366 const struct secret *pathsecret)
367{
368 struct sent *sent;
369 struct command_result *err;
370
371 /* BOLT #4:
372 * - otherwise (it is the final node):
373 * - if `path_id` is set and corresponds to a path the reader has previously published in a `reply_path`:
374 * - if the onion message is not a reply to that previous onion:
375 * - MUST ignore the onion message
376 * - otherwise (unknown or unset `path_id`):
377 * - if the onion message is a reply to an onion message which contained a `path_id`:
378 * - MUST respond (or not respond) exactly as if it did not send the initial onion message.
379 */
380 /* We unmarshal the path_id into our secret: if it is NULL or wrong, we exit here */
381 sent = find_sent_by_secret(pathsecret);
382 if (!sent)
383 return NULL;
384
385 plugin_log(cmd->plugin, LOG_DBG, "Received onion message reply for invoice_request: %.*s",
386 json_tok_full_len(om),
387 json_tok_full(buf, om));
388
389 err = handle_error(cmd, sent, buf, om);
390 if (err)
391 return err;
392
393 if (sent->invreq)
394 return handle_invreq_response(cmd, sent, buf, om);
395
396 return NULL;
397}
398
399static void destroy_sent(struct sent *sent)
400{

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