| 210 | } |
| 211 | |
| 212 | static struct command_result *createinvoice_error(struct command *cmd, |
| 213 | const char *method, |
| 214 | const char *buf, |
| 215 | const jsmntok_t *err, |
| 216 | struct invreq *ir) |
| 217 | { |
| 218 | u32 code; |
| 219 | const char *status; |
| 220 | |
| 221 | /* If it already exists, we can reuse its bolt12 directly. */ |
| 222 | if (json_scan(tmpctx, buf, err, |
| 223 | "{code:%,data:{status:%}}", |
| 224 | JSON_SCAN(json_to_u32, &code), |
| 225 | JSON_SCAN_TAL(tmpctx, json_strdup, &status)) == NULL |
| 226 | && code == INVOICE_LABEL_ALREADY_EXISTS) { |
| 227 | if (streq(status, "unpaid")) |
| 228 | return createinvoice_done(cmd, method, buf, |
| 229 | json_get_member(buf, err, "data"), ir); |
| 230 | if (streq(status, "expired")) |
| 231 | return fail_invreq(cmd, ir, "invoice expired (cancelled?)"); |
| 232 | } |
| 233 | return error(cmd, method, buf, err, ir); |
| 234 | } |
| 235 | |
| 236 | static struct command_result *create_invoicereq(struct command *cmd, |
| 237 | struct invreq *ir) |
nothing calls this directly
no test coverage detected