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

Function blinded_onion_hops

common/blindedpay.c:7–41  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5#include <wire/onion_wiregen.h>
6
7u8 **blinded_onion_hops(const tal_t *ctx,
8 struct amount_msat final_amount,
9 u32 final_cltv,
10 struct amount_msat total_amount,
11 const struct blinded_path *path)
12{
13 u8 **onions = tal_arr(ctx, u8 *, tal_count(path->path));
14
15 assert(tal_count(onions) > 0);
16
17 for (size_t i = 0; i < tal_count(onions); i++) {
18 bool first = (i == 0);
19 bool final = (i == tal_count(onions) - 1);
20
21 /* BOLT #4:
22 * - For every node inside a blinded route:
23 * - MUST include the `encrypted_recipient_data` provided by the
24 * recipient
25 * - For the first node in the blinded route:
26 * - MUST include the `path_key` provided by the
27 * recipient in `current_path_key`
28 * - If it is the final node:
29 * - MUST include `amt_to_forward`, `outgoing_cltv_value` and `total_amount_msat`.
30 *...
31 * - MUST NOT include any other tlv field.
32 */
33 onions[i] = onion_blinded_hop(onions,
34 final ? &final_amount : NULL,
35 final ? &total_amount : NULL,
36 final ? &final_cltv : NULL,
37 path->path[i]->encrypted_recipient_data,
38 first ? &path->first_path_key : NULL);
39 }
40 return onions;
41}

Callers 2

mainFunction · 0.85
payment_add_blindedpathFunction · 0.85

Calls 1

onion_blinded_hopFunction · 0.85

Tested by 1

mainFunction · 0.68