-
Notifications
You must be signed in to change notification settings - Fork 912
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
common/blindedpay: routines to construct a blinded payment.
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>
- Loading branch information
1 parent
325fe2e
commit 511e8e6
Showing
9 changed files
with
98 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* Code to create onion fragments to make payment down this struct blinded_path */ | ||
#ifndef LIGHTNING_COMMON_BLINDEDPAY_H | ||
#define LIGHTNING_COMMON_BLINDEDPAY_H | ||
#include "config.h" | ||
#include <ccan/tal/tal.h> | ||
#include <common/amount.h> | ||
|
||
struct blinded_path; | ||
|
||
/** | ||
* blinded_onion_hops - turn this path into a series of onion hops | ||
* @ctx: context to allocate from | ||
* @final_amount: amount we want to reach the end | ||
* @final_cltv: cltv we want to at end | ||
* @payinfo: fee and other restriction info | ||
* | ||
* This calls onion_nonfinal_hop and onion_final_hop to create onion | ||
* blobs. | ||
*/ | ||
u8 **blinded_onion_hops(const tal_t *ctx, | ||
struct amount_msat final_amount, | ||
u32 final_cltv, | ||
const struct blinded_path *path); | ||
|
||
#endif /* LIGHTNING_COMMON_BLINDEDPAY_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters