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

Function json_add_b12_invoice

plugins/offers.c:1369–1502  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1367}
1368
1369static void json_add_b12_invoice(struct command *cmd,
1370 struct json_stream *js,
1371 const struct tlv_invoice *invoice)
1372{
1373 bool valid = true;
1374
1375 /* If there's an offer_issuer_id or offer_paths, then there's an offer. */
1376 if (invoice->offer_issuer_id || invoice->offer_paths) {
1377 struct sha256 offer_id;
1378
1379 invoice_offer_id(invoice, &offer_id);
1380 json_add_sha256(js, "offer_id", &offer_id);
1381 }
1382
1383 valid &= json_add_offer_fields(cmd, js,
1384 invoice->offer_chains,
1385 invoice->offer_metadata,
1386 invoice->offer_currency,
1387 invoice->offer_amount,
1388 invoice->offer_description,
1389 invoice->offer_features,
1390 invoice->offer_absolute_expiry,
1391 invoice->offer_paths,
1392 invoice->offer_issuer,
1393 invoice->offer_quantity_max,
1394 invoice->offer_issuer_id,
1395 invoice->offer_recurrence_compulsory,
1396 invoice->offer_recurrence_optional,
1397 invoice->offer_recurrence_paywindow,
1398 invoice->offer_recurrence_limit,
1399 invoice->offer_recurrence_base);
1400 valid &= json_add_invreq_fields(cmd, js,
1401 invoice->invreq_metadata,
1402 invoice->invreq_chain,
1403 invoice->invreq_amount,
1404 invoice->invreq_features,
1405 invoice->invreq_quantity,
1406 invoice->invreq_payer_id,
1407 invoice->invreq_payer_note,
1408 invoice->invreq_paths,
1409 invoice->invreq_bip_353_name,
1410 invoice->invreq_recurrence_counter,
1411 invoice->invreq_recurrence_start,
1412 NULL);
1413
1414 /* BOLT #12:
1415 * - MUST reject the invoice if `invoice_paths` is not present
1416 * or is empty.
1417 * - MUST reject the invoice if `num_hops` is 0 in any `blinded_path` in `invoice_paths`.
1418 * - MUST reject the invoice if `invoice_blindedpay` is not present.
1419 * - MUST reject the invoice if `invoice_blindedpay` does not contain
1420 * exactly one `blinded_payinfo` per `invoice_paths`.`blinded_path`.
1421 */
1422 if (!invoice->invoice_paths) {
1423 json_add_string(js, "warning_missing_invoice_paths",
1424 "invoices without a invoice_paths are invalid");
1425 valid = false;
1426 } else if (!invoice->invoice_blindedpay) {

Callers 1

json_decodeFunction · 0.85

Calls 10

invoice_offer_idFunction · 0.85
json_add_sha256Function · 0.85
json_add_offer_fieldsFunction · 0.85
json_add_invreq_fieldsFunction · 0.85
invoice_recurrenceFunction · 0.85
json_add_bip340sigFunction · 0.85
json_add_extra_fieldsFunction · 0.85
json_add_boolFunction · 0.85
json_add_invoice_fieldsFunction · 0.70
json_add_stringFunction · 0.50

Tested by

no test coverage detected