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