mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 01:43:36 +01:00
511e8e6477
Don't shoehorn it into onion_nonfinal_hop() and onion_final_hop(), but provide an explicit routine "blinded_onion_hops" and an onion helper "onion_blinded_hop()" for it to call. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
41 lines
1.2 KiB
C
41 lines
1.2 KiB
C
#include "config.h"
|
|
#include <assert.h>
|
|
#include <common/blindedpay.h>
|
|
#include <common/bolt12.h>
|
|
#include <common/onion.h>
|
|
|
|
u8 **blinded_onion_hops(const tal_t *ctx,
|
|
struct amount_msat final_amount,
|
|
u32 final_cltv,
|
|
const struct blinded_path *path)
|
|
{
|
|
u8 **onions = tal_arr(ctx, u8 *, tal_count(path->path));
|
|
|
|
assert(tal_count(onions) > 0);
|
|
|
|
for (size_t i = 0; i < tal_count(onions); i++) {
|
|
bool first = (i == 0);
|
|
bool final = (i == tal_count(onions) - 1);
|
|
|
|
/* BOLT-route-blinding #4:
|
|
* - For every node inside a blinded route:
|
|
* - MUST include the `encrypted_data` provided by the
|
|
* recipient
|
|
* - For the first node in the blinded route:
|
|
* - MUST include the `blinding_point` provided by the
|
|
* recipient
|
|
* - If it is the final node:
|
|
* - MUST include `amt_to_forward` and `outgoing_cltv_value`.
|
|
* - Otherwise:
|
|
* - MUST NOT include `amt_to_forward` and
|
|
* `outgoing_cltv_value`.
|
|
*/
|
|
onions[i] = onion_blinded_hop(onions,
|
|
final ? &final_amount : NULL,
|
|
final ? &final_cltv : NULL,
|
|
path->path[i]->encrypted_recipient_data,
|
|
first ? &path->blinding : NULL);
|
|
}
|
|
return onions;
|
|
}
|