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

Function append_blinded_payloads

plugins/xpay/xpay.c:1330–1368  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1328}
1329
1330static void append_blinded_payloads(struct sphinx_path *sp,
1331 const struct attempt *attempt,
1332 u32 effective_bheight,
1333 size_t path_num)
1334{
1335 const struct blinded_path *path = attempt->payment->paths[path_num];
1336 u32 final_cltv = effective_bheight;
1337 struct amount_msat deliver = attempt_deliver(attempt);
1338 const struct amount_msat mpp_amount = attempt_mpp_amount(attempt);
1339
1340 for (size_t i = 0; i < tal_count(path->path); i++) {
1341 bool first = (i == 0);
1342 bool final = (i == tal_count(path->path) - 1);
1343 const u8 *payload;
1344
1345 /* BOLT #4:
1346 * - For every node inside a blinded route:
1347 * - MUST include the `encrypted_recipient_data` provided by the
1348 * recipient
1349 * - For the first node in the blinded route:
1350 * - MUST include the `path_key` provided by the
1351 * recipient in `current_path_key`
1352 * - If it is the final node:
1353 * - MUST include `amt_to_forward`, `outgoing_cltv_value` and `total_amount_msat`.
1354 *...
1355 * - MUST NOT include any other tlv field.
1356 */
1357 payload = onion_blinded_hop(NULL,
1358 final ? &deliver : NULL,
1359 final ? &mpp_amount : NULL,
1360 final ? &final_cltv : NULL,
1361 path->path[i]->encrypted_recipient_data,
1362 first ? &path->first_path_key : NULL);
1363 sphinx_add_hop_has_length(sp,
1364 first ? &path->first_node_id.pubkey
1365 : &path->path[i]->blinded_node_id,
1366 take(payload));
1367 }
1368}
1369
1370/* hop has size prepended, so this isn't a simple "append" */
1371static void hop_append(u8 **hop, const u8 *appendme)

Callers 1

create_onionFunction · 0.85

Calls 4

attempt_deliverFunction · 0.85
attempt_mpp_amountFunction · 0.85
onion_blinded_hopFunction · 0.85

Tested by

no test coverage detected