If we fail because it exists, we also return the clashing invoice */
| 1582 | |
| 1583 | /* If we fail because it exists, we also return the clashing invoice */ |
| 1584 | static 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 */ |
no test coverage detected