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

Function json_listinvoicerequests

lightningd/offer.c:607–659  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

605AUTODATA(json_command, &payersign_command);
606
607static struct command_result *json_listinvoicerequests(struct command *cmd,
608 const char *buffer,
609 const jsmntok_t *obj UNNEEDED,
610 const jsmntok_t *params)
611{
612 struct sha256 *invreq_id;
613 struct json_stream *response;
614 struct wallet *wallet = cmd->ld->wallet;
615 const char *b12;
616 const struct json_escape *label;
617 bool *active_only;
618 enum offer_status status;
619
620 if (!param(cmd, buffer, params,
621 p_opt("invreq_id", param_sha256, &invreq_id),
622 p_opt_def("active_only", param_bool, &active_only, false),
623 NULL))
624 return command_param_failed();
625
626 response = json_stream_success(cmd);
627 json_array_start(response, "invoicerequests");
628 if (invreq_id) {
629 b12 = wallet_invoice_request_find(tmpctx, wallet,
630 invreq_id, &label,
631 &status);
632 if (b12 && offer_status_active(status) >= *active_only) {
633 json_object_start(response, NULL);
634 json_populate_invreq(response,
635 invreq_id, b12,
636 label, status);
637 json_object_end(response);
638 }
639 } else {
640 struct db_stmt *stmt;
641 struct sha256 id;
642
643 for (stmt = wallet_invreq_id_first(cmd->ld->wallet, &id);
644 stmt;
645 stmt = wallet_invreq_id_next(cmd->ld->wallet, stmt, &id)) {
646 b12 = wallet_invoice_request_find(tmpctx, wallet, &id,
647 &label, &status);
648 if (offer_status_active(status) >= *active_only) {
649 json_object_start(response, NULL);
650 json_populate_invreq(response,
651 &id, b12,
652 label, status);
653 json_object_end(response);
654 }
655 }
656 }
657 json_array_end(response);
658 return command_success(cmd, response);
659}
660
661static const struct json_command listinvoicerequests_command = {
662 "listinvoicerequests",

Callers

nothing calls this directly

Calls 13

json_array_startFunction · 0.85
offer_status_activeFunction · 0.85
json_object_startFunction · 0.85
json_populate_invreqFunction · 0.85
json_object_endFunction · 0.85
wallet_invreq_id_firstFunction · 0.85
wallet_invreq_id_nextFunction · 0.85
json_array_endFunction · 0.85
command_param_failedFunction · 0.70
json_stream_successFunction · 0.70
command_successFunction · 0.70

Tested by

no test coverage detected