We can fail to create the invoice if we've already done so. */
| 165 | |
| 166 | /* We can fail to create the invoice if we've already done so. */ |
| 167 | static struct command_result *createinvoice_done(struct command *cmd, |
| 168 | const char *buf, |
| 169 | const jsmntok_t *result, |
| 170 | struct invreq *ir) |
| 171 | { |
| 172 | char *hrp; |
| 173 | u8 *rawinv; |
| 174 | struct tlv_onionmsg_payload *payload; |
| 175 | const jsmntok_t *t; |
| 176 | |
| 177 | /* We have a signed invoice, use it as a reply. */ |
| 178 | t = json_get_member(buf, result, "bolt12"); |
| 179 | if (!from_bech32_charset(tmpctx, buf + t->start, t->end - t->start, |
| 180 | &hrp, &rawinv)) { |
| 181 | return fail_internalerr(cmd, ir, |
| 182 | "Bad creatinvoice bolt12 string %.*s", |
| 183 | json_tok_full_len(t), |
| 184 | json_tok_full(buf, t)); |
| 185 | } |
| 186 | |
| 187 | payload = tlv_onionmsg_payload_new(tmpctx); |
| 188 | payload->invoice = rawinv; |
| 189 | return send_onion_reply(cmd, ir->reply_path, payload); |
| 190 | } |
| 191 | |
| 192 | static struct command_result *createinvoice_error(struct command *cmd, |
| 193 | const char *buf, |
no test coverage detected