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

Function found_best_peer_invrequest

plugins/offers_offer.c:693–750  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

691};
692
693static struct command_result *found_best_peer_invrequest(struct command *cmd,
694 const struct chaninfo *best,
695 struct invrequest_data *irdata)
696{
697 const struct offers_data *od = get_offers_data(cmd->plugin);
698
699 if (!best) {
700 /* Don't allow bare invoices if they explicitly told us to front */
701 if (od->fronting_nodes) {
702 return command_fail(cmd, LIGHTNINGD,
703 "Could not find neighbour fronting node");
704 }
705
706 /* FIXME: Make this a warning in the result! */
707 plugin_log(cmd->plugin, LOG_UNUSUAL,
708 "No incoming channel to public peer, so no blinded path for invoice request");
709 } else {
710 struct pubkey *ids;
711 struct secret blinding_path_secret;
712 struct sha256 invreq_id;
713
714 /* BOLT #12:
715 * - MUST set `invreq_paths` as it would set (or not set) `offer_paths` for an offer.
716 */
717 /* BOLT #12:
718 *
719 * - if it is connected only by private channels:
720 * - MUST include `offer_paths` containing one or more paths to the node from
721 * publicly reachable nodes.
722 */
723 /* Note: "id" of invreq minus paths (which we haven't added yet!) */
724 invreq_invreq_id(irdata->invreq, &invreq_id);
725
726 /* Make a small 1-hop path to us */
727 ids = tal_arr(tmpctx, struct pubkey, 2);
728 ids[0] = best->id;
729 ids[1] = od->id;
730
731 /* So we recognize this */
732 /* We can check this when they try to take up invoice_request. */
733 bolt12_path_secret(&od->offerblinding_base, &invreq_id,
734 &blinding_path_secret);
735
736 plugin_log(cmd->plugin, LOG_DBG,
737 "Setting blinided path (invreq_id = %s, path_secret = %s)",
738 fmt_sha256(tmpctx, &invreq_id),
739 fmt_secret(tmpctx, &blinding_path_secret));
740 irdata->invreq->invreq_paths = tal_arr(irdata->invreq, struct blinded_path *, 1);
741 irdata->invreq->invreq_paths[0]
742 = incoming_message_blinded_path(irdata->invreq->invreq_paths,
743 ids,
744 NULL,
745 &blinding_path_secret);
746 }
747
748 return call_createinvoicerequest(cmd,
749 irdata->invreq, irdata->single_use, irdata->label);
750}

Callers

nothing calls this directly

Calls 9

get_offers_dataFunction · 0.85
invreq_invreq_idFunction · 0.85
bolt12_path_secretFunction · 0.85
fmt_sha256Function · 0.85
fmt_secretFunction · 0.85
command_failFunction · 0.70
plugin_logFunction · 0.70

Tested by

no test coverage detected