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

Function make_tlv_hop

common/onion.c:19–37  ·  view source on GitHub ↗

BOLT #4: * * ### `tlv_payload` format * * This is a more flexible format, which avoids the redundant * `short_channel_id` field for the final node. It 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

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

Callers 2

onion_nonfinal_hopFunction · 0.85
onion_final_hopFunction · 0.85

Calls 3

tal_bytelenFunction · 0.85
abortFunction · 0.85
bigsize_putFunction · 0.70

Tested by

no test coverage detected