diff --git a/common/onion.c b/common/onion.c index 85e7df485..2f3ce4c9f 100644 --- a/common/onion.c +++ b/common/onion.c @@ -1,6 +1,7 @@ #include "common/onion.h" #include #include +#include #include #include #include @@ -60,7 +61,9 @@ u8 *onion_nonfinal_hop(const tal_t *ctx, bool use_tlv, const struct short_channel_id *scid, struct amount_msat forward, - u32 outgoing_cltv) + u32 outgoing_cltv, + const struct pubkey *blinding, + const u8 *enctlv) { if (use_tlv) { struct tlv_tlv_payload *tlv = tlv_tlv_payload_new(tmpctx); @@ -84,9 +87,24 @@ u8 *onion_nonfinal_hop(const tal_t *ctx, tlv->amt_to_forward = &tlv_amt; tlv->outgoing_cltv_value = &tlv_cltv; tlv->short_channel_id = &tlv_scid; - +#if EXPERIMENTAL_FEATURES + struct tlv_tlv_payload_blinding_seed tlv_blinding; + struct tlv_tlv_payload_enctlv tlv_enctlv; + if (blinding) { + tlv_blinding.blinding_seed = *blinding; + tlv->blinding_seed = &tlv_blinding; + } + if (enctlv) { + tlv_enctlv.enctlv = cast_const(u8 *, enctlv); + tlv->enctlv = &tlv_enctlv; + } +#endif return make_tlv_hop(ctx, tlv); } else { +#if EXPERIMENTAL_FEATURES + if (blinding || enctlv) + return NULL; +#endif return make_v0_hop(ctx, scid, forward, outgoing_cltv); } } @@ -96,6 +114,8 @@ u8 *onion_final_hop(const tal_t *ctx, struct amount_msat forward, u32 outgoing_cltv, struct amount_msat total_msat, + const struct pubkey *blinding, + const u8 *enctlv, const struct secret *payment_secret) { /* These go together! */ @@ -132,12 +152,28 @@ u8 *onion_final_hop(const tal_t *ctx, tlv_pdata.total_msat = total_msat.millisatoshis; /* Raw: TLV convert */ tlv->payment_data = &tlv_pdata; } +#if EXPERIMENTAL_FEATURES + struct tlv_tlv_payload_blinding_seed tlv_blinding; + struct tlv_tlv_payload_enctlv tlv_enctlv; + if (blinding) { + tlv_blinding.blinding_seed = *blinding; + tlv->blinding_seed = &tlv_blinding; + } + if (enctlv) { + tlv_enctlv.enctlv = cast_const(u8 *, enctlv); + tlv->enctlv = &tlv_enctlv; + } +#endif return make_tlv_hop(ctx, tlv); } else { static struct short_channel_id all_zero_scid; /* No payment secrets in legacy format. */ if (payment_secret) return NULL; +#if EXPERIMENTAL_FEATURES + if (blinding || enctlv) + return NULL; +#endif return make_v0_hop(ctx, &all_zero_scid, forward, outgoing_cltv); } } diff --git a/common/onion.h b/common/onion.h index 3eaac5a04..5dbbc6212 100644 --- a/common/onion.h +++ b/common/onion.h @@ -30,7 +30,9 @@ u8 *onion_nonfinal_hop(const tal_t *ctx, bool use_tlv, const struct short_channel_id *scid, struct amount_msat forward, - u32 outgoing_cltv); + u32 outgoing_cltv, + const struct pubkey *blinding, + const u8 *enctlv); /* Note that this can fail if we supply payment_secret and !use_tlv! */ u8 *onion_final_hop(const tal_t *ctx, @@ -38,6 +40,8 @@ u8 *onion_final_hop(const tal_t *ctx, struct amount_msat forward, u32 outgoing_cltv, struct amount_msat total_msat, + const struct pubkey *blinding, + const u8 *enctlv, const struct secret *payment_secret); /** diff --git a/devtools/onion.c b/devtools/onion.c index 5c8d1c49a..e36f14178 100644 --- a/devtools/onion.c +++ b/devtools/onion.c @@ -89,13 +89,16 @@ static void do_generate(int argc, char **argv, take(onion_final_hop(NULL, use_tlv, amt, i, amt, + NULL, NULL, NULL))); else sphinx_add_hop(sp, &path[i], take(onion_nonfinal_hop(NULL, use_tlv, &scid, - amt, i))); + amt, i, + NULL, + NULL))); } } diff --git a/lightningd/pay.c b/lightningd/pay.c index 3070a49b3..80e9ee068 100644 --- a/lightningd/pay.c +++ b/lightningd/pay.c @@ -996,7 +996,9 @@ send_payment(struct lightningd *ld, should_use_tlv(route[i].style), &route[i + 1].channel_id, route[i + 1].amount, - base_expiry + route[i + 1].delay))); + base_expiry + route[i + 1].delay, + route[i].blinding, + route[i].enctlv))); } /* And finally set the final hop to the special values in @@ -1025,7 +1027,8 @@ send_payment(struct lightningd *ld, final_tlv, route[i].amount, base_expiry + route[i].delay, - total_msat, payment_secret); + total_msat, route[i].blinding, route[i].enctlv, + payment_secret); if (!onion) { return command_fail(cmd, PAY_DESTINATION_PERM_FAIL, "Destination does not support"