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

Function fail_exists

lightningd/invoice.c:1597–1615  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

1595
1596/* If we fail because it exists, we also return the clashing invoice */
1597static struct command_result *fail_exists(struct command *cmd,
1598 const struct json_escape *label)
1599{
1600 struct json_stream *data;
1601 u64 inv_dbid;
1602 struct wallet *wallet = cmd->ld->wallet;
1603
1604 data = json_stream_fail(cmd, INVOICE_LABEL_ALREADY_EXISTS,
1605 "Duplicate label");
1606 if (!invoices_find_by_label(wallet->invoices, &inv_dbid, label))
1607 fatal("Duplicate invoice %s not found any more?",
1608 label->s);
1609
1610 json_add_invoice_fields(data,
1611 invoices_get_details(cmd, wallet->invoices, inv_dbid));
1612 json_object_end(data);
1613
1614 return command_failed(cmd, data);
1615}
1616
1617/* This is only if we're a public node; otherwise, the offers plugin
1618 * 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