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

Function json_invoicerequest

plugins/offers_offer.c:752–842  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

750}
751
752struct command_result *json_invoicerequest(struct command *cmd,
753 const char *buffer,
754 const jsmntok_t *params)
755{
756 const struct offers_data *od = get_offers_data(cmd->plugin);
757 const char *desc, *issuer, *label;
758 struct tlv_invoice_request *invreq;
759 struct amount_msat *msat;
760 bool *single_use;
761
762 invreq = tlv_invoice_request_new(cmd);
763
764 if (!param(cmd, buffer, params,
765 p_req("amount", param_msat, &msat),
766 p_opt("description", param_escaped_string, &desc),
767 p_opt("issuer", param_escaped_string, &issuer),
768 p_opt("label", param_escaped_string, &label),
769 p_opt("absolute_expiry", param_u64,
770 &invreq->offer_absolute_expiry),
771 p_opt_def("single_use", param_bool, &single_use, true),
772 NULL))
773 return command_param_failed();
774
775 /* BOLT #12:
776 * - otherwise (not responding to an offer):
777 * - MUST set `offer_description` to a complete description of the purpose of the payment.
778 * - MUST set (or not set) `offer_absolute_expiry` and `offer_issuer` as it would for an offer.
779 * - MUST set `invreq_payer_id` (as it would set `offer_issuer_id` for an offer).
780 * - MUST set `invreq_paths` as it would set (or not set) `offer_paths` for an offer.
781 * - MUST NOT include `signature`, `offer_metadata`, `offer_chains`, `offer_amount`, `offer_currency`, `offer_features`, `offer_quantity_max`, `offer_paths` or `offer_issuer_id`
782 * - if the chain for the invoice is not solely bitcoin:
783 * - MUST specify `invreq_chain` the offer is valid for.
784 * - MUST set `invreq_amount`.
785 */
786 if (desc)
787 invreq->offer_description = tal_dup_arr(invreq, char, desc, strlen(desc), 0);
788 else
789 invreq->offer_description = NULL;
790
791 if (issuer) {
792 invreq->offer_issuer
793 = tal_dup_arr(invreq, char, issuer, strlen(issuer), 0);
794 }
795
796 if (!streq(chainparams->network_name, "bitcoin")) {
797 invreq->invreq_chain
798 = tal_dup(invreq, struct bitcoin_blkid,
799 &chainparams->genesis_blockhash);
800 }
801 /* BOLT #12:
802 * - if it sets `invreq_amount`:
803 * - MUST set `msat` in multiples of the minimum lightning-payable unit
804 * (e.g. milli-satoshis for bitcoin) for `invreq_chain` (or for bitcoin, if there is no `invreq_chain`).
805 */
806 invreq->invreq_amount
807 = tal_dup(invreq, u64, &msat->millisatoshis); /* Raw: wire */
808
809 /* BOLT #12:

Callers

nothing calls this directly

Calls 6

get_offers_dataFunction · 0.85
tal_bytelenFunction · 0.85
we_want_blinded_pathFunction · 0.85
command_param_failedFunction · 0.70
paramFunction · 0.50

Tested by

no test coverage detected