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

Function pull_uint

common/bolt11.c:65–90  ·  view source on GitHub ↗

Helper for pulling a variable-length big-endian int. */

Source from the content-addressed store, hash-verified

63
64/* Helper for pulling a variable-length big-endian int. */
65static const char *pull_uint(struct hash_u5 *hu5,
66 const u5 **data, size_t *data_len,
67 u64 *val, size_t databits,
68 bool must_be_minimal)
69{
70 be64 be_val;
71 const char *err;
72
73 /* Too big. */
74 if (databits > sizeof(be_val) * CHAR_BIT)
75 return "integer too large";
76 if (must_be_minimal
77 && databits >= 5
78 && *data_len > 1
79 && (*data)[0] == 0)
80 return "not a minimal value";
81 err = pull_bits(hu5, data, data_len, &be_val, databits, true);
82 if (err)
83 return err;
84 if (databits == 0)
85 *val = 0;
86 else
87 *val = be64_to_cpu(be_val) >>
88 (sizeof(be_val) * CHAR_BIT - databits);
89 return NULL;
90}
91
92static void *pull_all(const tal_t *ctx,
93 struct hash_u5 *hu5,

Callers 4

decode_xFunction · 0.85
decode_cFunction · 0.85
decode_fFunction · 0.85
bolt11_decode_nosigFunction · 0.85

Calls 2

pull_bitsFunction · 0.85
be64_to_cpuFunction · 0.85

Tested by

no test coverage detected