We can fail to create the invoice if we've already done so. */
| 177 | |
| 178 | /* We can fail to create the invoice if we've already done so. */ |
| 179 | static struct command_result *createinvoice_done(struct command *cmd, |
| 180 | const char *method, |
| 181 | const char *buf, |
| 182 | const jsmntok_t *result, |
| 183 | struct invreq *ir) |
| 184 | { |
| 185 | char *hrp; |
| 186 | u8 *rawinv; |
| 187 | struct tlv_onionmsg_tlv *payload; |
| 188 | const jsmntok_t *t; |
| 189 | |
| 190 | /* We have a signed invoice, use it as a reply. */ |
| 191 | t = json_get_member(buf, result, "bolt12"); |
| 192 | if (!from_bech32_charset(tmpctx, buf + t->start, t->end - t->start, |
| 193 | &hrp, &rawinv)) { |
| 194 | return fail_internalerr(cmd, ir, |
| 195 | "Bad creatinvoice bolt12 string %.*s", |
| 196 | json_tok_full_len(t), |
| 197 | json_tok_full(buf, t)); |
| 198 | } |
| 199 | |
| 200 | /* BOLT-recurrence #12: |
| 201 | * - if `invreq_recurrence_cancel` is present: |
| 202 | * - MUST NOT send an invoice in reply. |
| 203 | */ |
| 204 | if (!ir->reply_path) |
| 205 | return command_hook_success(cmd); |
| 206 | |
| 207 | payload = tlv_onionmsg_tlv_new(tmpctx); |
| 208 | payload->invoice = tal_steal(payload, rawinv); |
| 209 | return send_onion_reply(cmd, ir->reply_path, payload); |
| 210 | } |
| 211 | |
| 212 | static struct command_result *createinvoice_error(struct command *cmd, |
| 213 | const char *method, |
no test coverage detected