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

Function createinvoice_done

plugins/fetchinvoice.c:1461–1506  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1459}
1460
1461static struct command_result *createinvoice_done(struct command *cmd,
1462 const char *method,
1463 const char *buf,
1464 const jsmntok_t *result,
1465 struct sent *sent)
1466{
1467 struct tlv_onionmsg_tlv *payload;
1468 const jsmntok_t *invtok = json_get_member(buf, result, "bolt12");
1469 const char *fail;
1470
1471 /* Replace invoice with signed one */
1472 tal_free(sent->inv);
1473 sent->inv = invoice_decode(sent,
1474 buf + invtok->start,
1475 invtok->end - invtok->start,
1476 plugin_feature_set(cmd->plugin),
1477 chainparams,
1478 &fail);
1479 if (!sent->inv) {
1480 plugin_log(cmd->plugin, LOG_BROKEN,
1481 "Bad createinvoice %.*s: %s",
1482 json_tok_full_len(invtok),
1483 json_tok_full(buf, invtok),
1484 fail);
1485 return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
1486 "Bad createinvoice response %s", fail);
1487 }
1488
1489 /* BOLT #12:
1490 * - if it sends an invoice in response:
1491 * - MUST use `invreq_paths` if present, otherwise MUST use
1492 * `invreq_payer_id` as the node id to send to.
1493 */
1494 sent->their_paths = sent->invreq->invreq_paths;
1495 if (sent->their_paths)
1496 sent->direct_dest = NULL;
1497 else
1498 sent->direct_dest = sent->invreq->invreq_payer_id;
1499
1500 payload = tlv_onionmsg_tlv_new(sent);
1501
1502 payload->invoice = tal_arr(payload, u8, 0);
1503 towire_tlv_invoice(&payload->invoice, sent->inv);
1504
1505 return send_message(cmd, sent, true, payload, prepare_inv_timeout);
1506}
1507
1508static struct command_result *sign_invoice(struct command *cmd,
1509 struct sent *sent)

Callers

nothing calls this directly

Calls 10

json_get_memberFunction · 0.85
tal_freeFunction · 0.85
invoice_decodeFunction · 0.85
send_messageFunction · 0.85
plugin_feature_setFunction · 0.70
plugin_logFunction · 0.70
command_failFunction · 0.70
json_tok_full_lenFunction · 0.50
json_tok_fullFunction · 0.50
towire_tlv_invoiceFunction · 0.50

Tested by

no test coverage detected