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

Function invoice_decode_minimal

common/bolt12.c:620–661  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

618}
619
620struct tlv_invoice *invoice_decode_minimal(const tal_t *ctx,
621 const char *b12, size_t b12len,
622 const struct feature_set *our_features,
623 const struct chainparams *must_be_chain,
624 const char **fail)
625{
626 struct tlv_invoice *invoice;
627 const u8 *data;
628 size_t dlen;
629
630 data = b12_string_to_data(tmpctx, b12, b12len, "lni", &dlen, fail);
631 if (!data) {
632 tal_steal(ctx, *fail);
633 return NULL;
634 }
635
636 invoice = fromwire_tlv_invoice(ctx, &data, &dlen);
637 if (!invoice) {
638 *fail = tal_fmt(ctx, "invalid invoice data");
639 return NULL;
640 }
641
642 /* BOLT #12:
643 * - if `invreq_chain` is not present:
644 * - MUST reject the invoice if bitcoin is not a supported chain.
645 * - otherwise:
646 * - MUST reject the invoice if `invreq_chain`.`chain` is not a supported chain.
647 * - if `invoice_features` contains unknown _odd_ bits that are non-zero:
648 * - MUST ignore the bit.
649 * - if `invoice_features` contains unknown _even_ bits that are non-zero:
650 * - MUST reject the invoice.
651 */
652 *fail = check_features_and_chain(ctx,
653 our_features, must_be_chain,
654 invoice->invoice_features,
655 BOLT12_INVOICE_FEATURE,
656 invoice->invreq_chain, 1);
657 if (*fail)
658 return tal_free(invoice);
659
660 return invoice;
661}
662
663static bool add_days(struct tm *tm, u32 number)
664{

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