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

Function decode_c

common/bolt11.c:287–313  ·  view source on GitHub ↗

BOLT #11: * * `c` (24): `data_length` variable. `min_final_cltv_expiry_delta` to use for the * last HTLC in the route. Default is 18 if not specified. */

Source from the content-addressed store, hash-verified

285 * last HTLC in the route. Default is 18 if not specified.
286 */
287static const char *decode_c(struct bolt11 *b11,
288 const struct feature_set *our_features,
289 struct hash_u5 *hu5,
290 const u5 **data, size_t *field_len,
291 bool *have_c)
292{
293 u64 c;
294 const char *err;
295
296 assert(!*have_c);
297
298 /* BOLT #11:
299 * - if a `c`, `x`, or `9` field is provided which has a non-minimal `data_length`
300 * (i.e. begins with 0 field elements):
301 * - SHOULD treat the invoice as invalid.
302 */
303 err = pull_uint(hu5, data, field_len, &c, *field_len * 5, true);
304 if (err)
305 return tal_fmt(b11, "c: %s", err);
306 b11->min_final_cltv_expiry = c;
307 /* Can overflow, since c is 64 bits but value must be < 32 bits */
308 if (b11->min_final_cltv_expiry != c)
309 return tal_fmt(b11, "c: %"PRIu64" is too large", c);
310
311 *have_c = true;
312 return NULL;
313}
314
315static const char *decode_n(struct bolt11 *b11,
316 const struct feature_set *our_features,

Callers

nothing calls this directly

Calls 1

pull_uintFunction · 0.85

Tested by

no test coverage detected