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

Function fail_exists

lightningd/invoice.c:1584–1602  ·  view source on GitHub ↗

If we fail because it exists, we also return the clashing invoice */

Source from the content-addressed store, hash-verified

1582
1583/* If we fail because it exists, we also return the clashing invoice */
1584static struct command_result *fail_exists(struct command *cmd,
1585 const struct json_escape *label)
1586{
1587 struct json_stream *data;
1588 u64 inv_dbid;
1589 struct wallet *wallet = cmd->ld->wallet;
1590
1591 data = json_stream_fail(cmd, INVOICE_LABEL_ALREADY_EXISTS,
1592 "Duplicate label");
1593 if (!invoices_find_by_label(wallet->invoices, &inv_dbid, label))
1594 fatal("Duplicate invoice %s not found any more?",
1595 label->s);
1596
1597 json_add_invoice_fields(data,
1598 invoices_get_details(cmd, wallet->invoices, inv_dbid));
1599 json_object_end(data);
1600
1601 return command_failed(cmd, data);
1602}
1603
1604/* This is only if we're a public node; otherwise, the offers plugin
1605 * will have populated a real blinded path */

Callers 1

json_createinvoiceFunction · 0.85

Calls 7

json_object_endFunction · 0.85
json_stream_failFunction · 0.70
fatalFunction · 0.70
json_add_invoice_fieldsFunction · 0.70
command_failedFunction · 0.70
invoices_find_by_labelFunction · 0.50
invoices_get_detailsFunction · 0.50

Tested by

no test coverage detected