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