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

Function createinvoice_done

plugins/fetchinvoice.c:1370–1415  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1368}
1369
1370static struct command_result *createinvoice_done(struct command *cmd,
1371 const char *method,
1372 const char *buf,
1373 const jsmntok_t *result,
1374 struct sent *sent)
1375{
1376 struct tlv_onionmsg_tlv *payload;
1377 const jsmntok_t *invtok = json_get_member(buf, result, "bolt12");
1378 const char *fail;
1379
1380 /* Replace invoice with signed one */
1381 tal_free(sent->inv);
1382 sent->inv = invoice_decode(sent,
1383 buf + invtok->start,
1384 invtok->end - invtok->start,
1385 plugin_feature_set(cmd->plugin),
1386 chainparams,
1387 &fail);
1388 if (!sent->inv) {
1389 plugin_log(cmd->plugin, LOG_BROKEN,
1390 "Bad createinvoice %.*s: %s",
1391 json_tok_full_len(invtok),
1392 json_tok_full(buf, invtok),
1393 fail);
1394 return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
1395 "Bad createinvoice response %s", fail);
1396 }
1397
1398 /* BOLT #12:
1399 * - if it sends an invoice in response:
1400 * - MUST use `invreq_paths` if present, otherwise MUST use
1401 * `invreq_payer_id` as the node id to send to.
1402 */
1403 sent->their_paths = sent->invreq->invreq_paths;
1404 if (sent->their_paths)
1405 sent->direct_dest = NULL;
1406 else
1407 sent->direct_dest = sent->invreq->invreq_payer_id;
1408
1409 payload = tlv_onionmsg_tlv_new(sent);
1410
1411 payload->invoice = tal_arr(payload, u8, 0);
1412 towire_tlv_invoice(&payload->invoice, sent->inv);
1413
1414 return send_message(cmd, sent, true, payload, prepare_inv_timeout);
1415}
1416
1417static struct command_result *sign_invoice(struct command *cmd,
1418 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