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

Function make_tlv_hop

common/onion_encode.c:15–33  ·  view source on GitHub ↗

BOLT #4: * * ### `payload` format * * This is formatted according to the Type-Length-Value format defined * in [BOLT #1](01-messaging.md#type-length-value-format). */

Source from the content-addressed store, hash-verified

13 * in [BOLT #1](01-messaging.md#type-length-value-format).
14 */
15static u8 *make_tlv_hop(const tal_t *ctx,
16 const struct tlv_payload *tlv)
17{
18 /* We can't have over 64k anyway */
19 u8 *tlvs = tal_arr(ctx, u8, 3);
20
21 towire_tlv_payload(&tlvs, tlv);
22
23 switch (bigsize_put(tlvs, tal_bytelen(tlvs) - 3)) {
24 case 1:
25 /* Move over two unused bytes */
26 memmove(tlvs + 1, tlvs + 3, tal_bytelen(tlvs) - 3);
27 tal_resize(&tlvs, tal_bytelen(tlvs) - 2);
28 return tlvs;
29 case 3:
30 return tlvs;
31 }
32 abort();
33}
34
35u8 *onion_nonfinal_hop(const tal_t *ctx,
36 const struct short_channel_id *scid,

Callers 3

onion_nonfinal_hopFunction · 0.85
onion_final_hopFunction · 0.85
onion_blinded_hopFunction · 0.85

Calls 3

tal_bytelenFunction · 0.85
abortFunction · 0.85
bigsize_putFunction · 0.70

Tested by

no test coverage detected