channeld: support HTLCs with blinding (EXPERIMENTAL_FEATURES)

Note that it's channeld which calculates the shared secret, too.  This
minimizes the work that lightningd has to do, at cost of passing this
through.

We also don't yet save the blinding field(s) to the database.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2020-04-11 12:52:40 +09:30
parent 539a73e1ec
commit b29d1ed3ff
19 changed files with 245 additions and 72 deletions

View File

@@ -48,6 +48,11 @@ struct htlc_in {
/* Remember the timestamp we received this HTLC so we can later record
* it, and the resolution time, in the forwards table. */
struct timeabs received_time;
/* If it was blinded. */
struct pubkey *blinding;
/* Only set if blinding != NULL */
struct secret blinding_ss;
};
struct htlc_out {
@@ -83,6 +88,9 @@ struct htlc_out {
/* Where it's from, if not going to us. */
struct htlc_in *in;
/* Blinding to send alongside, if any. */
struct pubkey *blinding;
};
static inline const struct htlc_key *keyof_htlc_in(const struct htlc_in *in)
@@ -133,6 +141,8 @@ struct htlc_in *new_htlc_in(const tal_t *ctx,
struct amount_msat msat, u32 cltv_expiry,
const struct sha256 *payment_hash,
const struct secret *shared_secret TAKES,
const struct pubkey *blinding TAKES,
const struct secret *blinding_ss,
const u8 *onion_routing_packet);
/* You need to set the ID, then connect_htlc_out this! */
@@ -142,6 +152,7 @@ struct htlc_out *new_htlc_out(const tal_t *ctx,
u32 cltv_expiry,
const struct sha256 *payment_hash,
const u8 *onion_routing_packet,
const struct pubkey *blinding,
bool am_origin,
u64 partid,
struct htlc_in *in);