| 473 | } |
| 474 | |
| 475 | struct command_result *json_offer(struct command *cmd, |
| 476 | const char *buffer, |
| 477 | const jsmntok_t *params) |
| 478 | { |
| 479 | const struct offers_data *od = get_offers_data(cmd->plugin); |
| 480 | const char *desc, *issuer; |
| 481 | struct tlv_offer *offer; |
| 482 | struct offer_info *offinfo = tal(cmd, struct offer_info); |
| 483 | struct path **paths; |
| 484 | bool *proportional, *optional_recurrence; |
| 485 | |
| 486 | offinfo->offer = offer = tlv_offer_new(offinfo); |
| 487 | |
| 488 | if (!param_check(cmd, buffer, params, |
| 489 | p_req("amount", param_amount, offer), |
| 490 | p_opt("description", param_escaped_string, &desc), |
| 491 | p_opt("issuer", param_escaped_string, &issuer), |
| 492 | p_opt("label", param_escaped_string, &offinfo->label), |
| 493 | p_opt("quantity_max", param_u64, &offer->offer_quantity_max), |
| 494 | p_opt("absolute_expiry", param_u64, &offer->offer_absolute_expiry), |
| 495 | p_opt("recurrence", param_recurrence, &offer->offer_recurrence_compulsory), |
| 496 | p_opt("recurrence_base", |
| 497 | param_recurrence_base, |
| 498 | &offer->offer_recurrence_base), |
| 499 | p_opt("recurrence_paywindow", |
| 500 | param_recurrence_paywindow, |
| 501 | &offer->offer_recurrence_paywindow), |
| 502 | p_opt("recurrence_limit", |
| 503 | param_number, |
| 504 | &offer->offer_recurrence_limit), |
| 505 | p_opt_def("single_use", param_bool, |
| 506 | &offinfo->single_use, false), |
| 507 | p_opt_def("proportional_amount", |
| 508 | param_bool, |
| 509 | &proportional, false), |
| 510 | p_opt_def("optional_recurrence", |
| 511 | param_bool, |
| 512 | &optional_recurrence, false), |
| 513 | p_opt("fronting_nodes", |
| 514 | param_pubkey_arr, |
| 515 | &offinfo->fronting_nodes), |
| 516 | p_opt("dev_paths", param_paths, &paths), |
| 517 | NULL)) |
| 518 | return command_param_failed(); |
| 519 | |
| 520 | |
| 521 | /* If they don't specify explicitly, use config (if any) */ |
| 522 | if (!offinfo->fronting_nodes) |
| 523 | offinfo->fronting_nodes = od->fronting_nodes; |
| 524 | else if (tal_count(offinfo->fronting_nodes) == 0) { |
| 525 | /* [] means "no fronting" */ |
| 526 | offinfo->fronting_nodes = tal_free(offinfo->fronting_nodes); |
| 527 | } |
| 528 | |
| 529 | /* BOLT #12: |
| 530 | * |
| 531 | * - if the chain for the invoice is not solely bitcoin: |
| 532 | * - MUST specify `offer_chains` the offer is valid for. |
nothing calls this directly
no test coverage detected