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

Function tlv_span

common/bolt12.c:670–695  ·  view source on GitHub ↗

Inclusive span of tlv range >= minfield and <= maxfield */

Source from the content-addressed store, hash-verified

668
669/* Inclusive span of tlv range >= minfield and <= maxfield */
670size_t tlv_span(const u8 *tlvstream, u64 minfield, u64 maxfield,
671 size_t *startp)
672{
673 const u8 *cursor = tlvstream;
674 size_t tlvlen = tal_bytelen(tlvstream);
675 const u8 *start, *end;
676
677 start = end = NULL;
678 while (tlvlen) {
679 const u8 *before = cursor;
680 bigsize_t type = fromwire_bigsize(&cursor, &tlvlen);
681 bigsize_t len = fromwire_bigsize(&cursor, &tlvlen);
682 if (type >= minfield && start == NULL)
683 start = before;
684 if (type > maxfield)
685 break;
686 fromwire_pad(&cursor, &tlvlen, len);
687 end = cursor;
688 }
689 if (!start)
690 start = end;
691
692 if (startp)
693 *startp = start - tlvstream;
694 return end - start;
695}
696
697static void calc_offer(const u8 *tlvstream, struct sha256 *id)
698{

Callers 5

calc_offerFunction · 0.85
calc_invreqFunction · 0.85
invoice_for_invreqFunction · 0.85
mainFunction · 0.85
invoice_matches_requestFunction · 0.85

Calls 3

tal_bytelenFunction · 0.85
fromwire_bigsizeFunction · 0.70
fromwire_padFunction · 0.50

Tested by 1

mainFunction · 0.68