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

Function invoice_decode_minimal

common/bolt12.c:396–437  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

394}
395
396struct tlv_invoice *invoice_decode_minimal(const tal_t *ctx,
397 const char *b12, size_t b12len,
398 const struct feature_set *our_features,
399 const struct chainparams *must_be_chain,
400 const char **fail)
401{
402 struct tlv_invoice *invoice;
403 const u8 *data;
404 size_t dlen;
405
406 data = b12_string_to_data(tmpctx, b12, b12len, "lni", &dlen, fail);
407 if (!data) {
408 tal_steal(ctx, *fail);
409 return NULL;
410 }
411
412 invoice = fromwire_tlv_invoice(ctx, &data, &dlen);
413 if (!invoice) {
414 *fail = tal_fmt(ctx, "invalid invoice data");
415 return NULL;
416 }
417
418 /* BOLT #12:
419 * - if `invreq_chain` is not present:
420 * - MUST reject the invoice if bitcoin is not a supported chain.
421 * - otherwise:
422 * - MUST reject the invoice if `invreq_chain`.`chain` is not a supported chain.
423 * - if `invoice_features` contains unknown _odd_ bits that are non-zero:
424 * - MUST ignore the bit.
425 * - if `invoice_features` contains unknown _even_ bits that are non-zero:
426 * - MUST reject the invoice.
427 */
428 *fail = check_features_and_chain(ctx,
429 our_features, must_be_chain,
430 invoice->invoice_features,
431 BOLT12_INVOICE_FEATURE,
432 invoice->invreq_chain, 1);
433 if (*fail)
434 return tal_free(invoice);
435
436 return invoice;
437}
438
439static void add_days(struct tm *tm, u32 number)
440{

Callers 3

json_createinvoiceFunction · 0.85
invoice_decodeFunction · 0.85
fetch_out_desc_invstrFunction · 0.85

Calls 4

b12_string_to_dataFunction · 0.85
check_features_and_chainFunction · 0.85
tal_freeFunction · 0.85
fromwire_tlv_invoiceFunction · 0.50

Tested by

no test coverage detected