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