Fetches an invoice for this offer, and makes sure it corresponds. */
| 915 | |
| 916 | /* Fetches an invoice for this offer, and makes sure it corresponds. */ |
| 917 | struct command_result *json_fetchinvoice(struct command *cmd, |
| 918 | const char *buffer, |
| 919 | const jsmntok_t *params) |
| 920 | { |
| 921 | const struct offers_data *od = get_offers_data(cmd->plugin); |
| 922 | struct amount_msat *msat; |
| 923 | const char *rec_label, *payer_note; |
| 924 | u8 *payer_metadata; |
| 925 | struct out_req *req; |
| 926 | struct tlv_invoice_request *invreq; |
| 927 | struct sent *sent = tal(cmd, struct sent); |
| 928 | struct bip_353_name *bip353; |
| 929 | u32 *timeout; |
| 930 | u64 *quantity; |
| 931 | u32 *recurrence_counter, *recurrence_start; |
| 932 | |
| 933 | if (!param_check(cmd, buffer, params, |
| 934 | p_req("offer", param_offer, &sent->offer), |
| 935 | p_opt("amount_msat", param_msat, &msat), |
| 936 | p_opt("quantity", param_u64, &quantity), |
| 937 | p_opt("recurrence_counter", param_number, &recurrence_counter), |
| 938 | p_opt("recurrence_start", param_number, &recurrence_start), |
| 939 | p_opt("recurrence_label", param_string, &rec_label), |
| 940 | p_opt_def("timeout", param_number, &timeout, 60), |
| 941 | p_opt("payer_note", param_string, &payer_note), |
| 942 | p_opt("payer_metadata", param_bin_from_hex, &payer_metadata), |
| 943 | p_opt("bip353", param_bip353, &bip353), |
| 944 | p_opt("dev_path_use_scidd", param_dev_scidd, &sent->dev_path_use_scidd), |
| 945 | p_opt("dev_reply_path", param_dev_reply_path, &sent->dev_reply_path), |
| 946 | NULL)) |
| 947 | return command_param_failed(); |
| 948 | |
| 949 | sent->wait_timeout = *timeout; |
| 950 | sent->their_paths = sent->offer->offer_paths; |
| 951 | if (sent->their_paths) |
| 952 | sent->direct_dest = NULL; |
| 953 | else |
| 954 | sent->direct_dest = sent->offer->offer_issuer_id; |
| 955 | /* This is NULL if offer_issuer_id is missing, and set by try_establish */ |
| 956 | sent->issuer_key = sent->offer->offer_issuer_id; |
| 957 | |
| 958 | /* BOLT #12: |
| 959 | * - if the current time is after `offer_absolute_expiry`: |
| 960 | * - MUST NOT respond to the offer. |
| 961 | */ |
| 962 | /* BOLT-recurrence #12: |
| 963 | * - if the current time is after `offer_absolute_expiry`: |
| 964 | * - MUST NOT make an initial response to the offer |
| 965 | * (i.e. continuing an existing offer with recurrence is ok) |
| 966 | */ |
| 967 | if (sent->offer->offer_absolute_expiry |
| 968 | && clock_time().ts.tv_sec > *sent->offer->offer_absolute_expiry |
| 969 | && (!recurrence_counter || *recurrence_counter == 0)) { |
| 970 | return command_fail(cmd, OFFER_EXPIRED, "Offer expired"); |
| 971 | } |
| 972 | |
| 973 | /* BOLT #12: |
| 974 | * The writer: |
nothing calls this directly
no test coverage detected