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

Function decode_r

common/bolt11.c:504–537  ·  view source on GitHub ↗

BOLT #11: * * `r` (3): `data_length` variable. One or more entries containing * extra routing information for a private route; there may be more * than one `r` field * * * `pubkey` (264 bits) * * `short_channel_id` (64 bits) * * `fee_base_msat` (32 bits, big-endian) * * `fee_proportional_millionths` (32 bits, big-endian) * * `cltv_expiry_delta` (16 bits, big-endian) */

Source from the content-addressed store, hash-verified

502 * * `cltv_expiry_delta` (16 bits, big-endian)
503 */
504static const char *decode_r(struct bolt11 *b11,
505 const struct feature_set *our_features,
506 struct hash_u5 *hu5,
507 const u5 **data, size_t *field_len,
508 bool *have_r)
509{
510 const u8 *r8;
511 size_t n = 0;
512 struct route_info *r = tal_arr(b11->routes, struct route_info, n);
513 const char *err;
514 size_t rlen;
515
516 /* Route hops don't split in 5 bit boundaries, so convert whole thing */
517 r8 = pull_all(tmpctx, hu5, data, field_len, false, &err);
518 if (!r8)
519 return err;
520 rlen = tal_bytelen(r8);
521
522 do {
523 struct route_info ri;
524 if (!fromwire_route_info(&r8, &rlen, &ri)) {
525 return tal_fmt(b11, "r: hop %zu truncated", n);
526 }
527 if (!node_id_valid(&ri.pubkey)) {
528 return tal_fmt(b11, "r: hop %zu pubkey invalid", n);
529 }
530 tal_arr_expand(&r, ri);
531 } while (rlen);
532
533 /* Append route */
534 tal_arr_expand(&b11->routes, r);
535 *have_r = true;
536 return NULL;
537}
538
539static void shift_bitmap_down(u8 *bitmap, size_t bits)
540{

Callers

nothing calls this directly

Calls 4

pull_allFunction · 0.85
tal_bytelenFunction · 0.85
fromwire_route_infoFunction · 0.85
node_id_validFunction · 0.85

Tested by

no test coverage detected