| 665 | AUTODATA(json_command, &listinvoicerequests_command); |
| 666 | |
| 667 | static struct command_result *json_disableinvoicerequest(struct command *cmd, |
| 668 | const char *buffer, |
| 669 | const jsmntok_t *obj UNNEEDED, |
| 670 | const jsmntok_t *params) |
| 671 | { |
| 672 | struct json_stream *response; |
| 673 | struct sha256 *invreq_id; |
| 674 | struct wallet *wallet = cmd->ld->wallet; |
| 675 | const char *b12; |
| 676 | const struct json_escape *label; |
| 677 | enum offer_status status; |
| 678 | |
| 679 | if (!param_check(cmd, buffer, params, |
| 680 | p_req("invreq_id", param_sha256, &invreq_id), |
| 681 | NULL)) |
| 682 | return command_param_failed(); |
| 683 | |
| 684 | b12 = wallet_invoice_request_find(tmpctx, wallet, invreq_id, |
| 685 | &label, &status); |
| 686 | if (!b12) |
| 687 | return command_fail(cmd, LIGHTNINGD, "Unknown invoice_request"); |
| 688 | |
| 689 | if (!offer_status_active(status)) |
| 690 | return command_fail(cmd, OFFER_ALREADY_DISABLED, |
| 691 | "invoice_request is not active"); |
| 692 | |
| 693 | if (command_check_only(cmd)) |
| 694 | return command_check_done(cmd); |
| 695 | |
| 696 | status = wallet_invoice_request_disable(wallet, invreq_id, status); |
| 697 | |
| 698 | response = json_stream_success(cmd); |
| 699 | json_populate_invreq(response, invreq_id, b12, label, status); |
| 700 | return command_success(cmd, response); |
| 701 | } |
| 702 | |
| 703 | static const struct json_command disableinvoicerequest_command = { |
| 704 | "disableinvoicerequest", |
nothing calls this directly
no test coverage detected