MCPcopy Create free account
hub / github.com/ElementsProject/lightning / createinvoice_done

Function createinvoice_done

plugins/offers_invreq_hook.c:179–210  ·  view source on GitHub ↗

We can fail to create the invoice if we've already done so. */

Source from the content-addressed store, hash-verified

177
178/* We can fail to create the invoice if we've already done so. */
179static 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
212static struct command_result *createinvoice_error(struct command *cmd,
213 const char *method,

Callers 1

createinvoice_errorFunction · 0.70

Calls 7

json_get_memberFunction · 0.85
send_onion_replyFunction · 0.85
fail_internalerrFunction · 0.70
command_hook_successFunction · 0.70
from_bech32_charsetFunction · 0.50
json_tok_full_lenFunction · 0.50
json_tok_fullFunction · 0.50

Tested by

no test coverage detected