If we fail because it exists, we also return the clashing invoice */
| 1621 | |
| 1622 | /* If we fail because it exists, we also return the clashing invoice */ |
| 1623 | static struct command_result *fail_exists(struct command *cmd, |
| 1624 | const struct json_escape *label) |
| 1625 | { |
| 1626 | struct json_stream *data; |
| 1627 | struct invoice invoice; |
| 1628 | struct wallet *wallet = cmd->ld->wallet; |
| 1629 | |
| 1630 | data = json_stream_fail(cmd, INVOICE_LABEL_ALREADY_EXISTS, |
| 1631 | "Duplicate label"); |
| 1632 | if (!wallet_invoice_find_by_label(wallet, &invoice, label)) |
| 1633 | fatal("Duplicate invoice %s not found any more?", |
| 1634 | label->s); |
| 1635 | |
| 1636 | json_add_invoice_fields(data, |
| 1637 | wallet_invoice_details(cmd, wallet, invoice)); |
| 1638 | json_object_end(data); |
| 1639 | |
| 1640 | return command_failed(cmd, data); |
| 1641 | } |
| 1642 | |
| 1643 | static struct command_result *json_createinvoice(struct command *cmd, |
| 1644 | const char *buffer, |
no test coverage detected