EXPERIMENTAL: protocol TLV field for update_add_htlc to support blinding.

All NULL for now.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2020-04-11 12:19:51 +09:30
parent a9fe1a3c08
commit 990a3ec92e
3 changed files with 42 additions and 5 deletions

View file

@ -621,10 +621,17 @@ static void handle_peer_add_htlc(struct peer *peer, const u8 *msg)
u8 onion_routing_packet[TOTAL_PACKET_SIZE]; u8 onion_routing_packet[TOTAL_PACKET_SIZE];
enum channel_add_err add_err; enum channel_add_err add_err;
struct htlc *htlc; struct htlc *htlc;
#if EXPERIMENTAL_FEATURES
struct tlv_update_add_tlvs *tlvs = tlv_update_add_tlvs_new(msg);
#endif
if (!fromwire_update_add_htlc(msg, &channel_id, &id, &amount, if (!fromwire_update_add_htlc(msg, &channel_id, &id, &amount,
&payment_hash, &cltv_expiry, &payment_hash, &cltv_expiry,
onion_routing_packet)) onion_routing_packet
#if EXPERIMENTAL_FEATURES
, tlvs
#endif
))
peer_failed(peer->pps, peer_failed(peer->pps,
&peer->channel_id, &peer->channel_id,
"Bad peer_add_htlc %s", tal_hex(msg, msg)); "Bad peer_add_htlc %s", tal_hex(msg, msg));
@ -2050,7 +2057,11 @@ static void resend_commitment(struct peer *peer, const struct changed_htlc *last
&h->rhash, &h->rhash,
abs_locktime_to_blocks( abs_locktime_to_blocks(
&h->expiry), &h->expiry),
h->routing); h->routing
#if EXPERIMENTAL_FEATURES
, NULL
#endif
);
sync_crypto_write(peer->pps, take(msg)); sync_crypto_write(peer->pps, take(msg));
} else if (h->state == SENT_REMOVE_COMMIT) { } else if (h->state == SENT_REMOVE_COMMIT) {
send_fail_or_fulfill(peer, h); send_fail_or_fulfill(peer, h);
@ -2685,7 +2696,11 @@ static void handle_offer_htlc(struct peer *peer, const u8 *inmsg)
msg = towire_update_add_htlc(NULL, &peer->channel_id, msg = towire_update_add_htlc(NULL, &peer->channel_id,
peer->htlc_id, amount, peer->htlc_id, amount,
&payment_hash, cltv_expiry, &payment_hash, cltv_expiry,
onion_routing_packet); onion_routing_packet
#if EXPERIMENTAL_FEATURES
, NULL
#endif
);
sync_crypto_write(peer->pps, take(msg)); sync_crypto_write(peer->pps, take(msg));
start_commit_timer(peer); start_commit_timer(peer);
/* Tell the master. */ /* Tell the master. */

View file

@ -0,0 +1,14 @@
diff --git a/wire/extracted_peer_wire_csv b/wire/extracted_peer_wire_csv
index 5a2a8c23f..7b26242e3 100644
--- a/wire/extracted_peer_wire_csv
+++ b/wire/extracted_peer_wire_csv
@@ -95,6 +95,9 @@ msgdata,update_add_htlc,amount_msat,u64,
msgdata,update_add_htlc,payment_hash,sha256,
msgdata,update_add_htlc,cltv_expiry,u32,
msgdata,update_add_htlc,onion_routing_packet,byte,1366
+msgdata,update_add_htlc,tlvs,update_add_tlvs,
+tlvtype,update_add_tlvs,blinding,2
+tlvdata,update_add_tlvs,blinding,ecdh,byte,32
msgtype,update_fulfill_htlc,130
msgdata,update_fulfill_htlc,channel_id,channel_id,
msgdata,update_fulfill_htlc,id,u64,

View file

@ -704,7 +704,11 @@ static void *towire_struct_update_add_htlc(const tal_t *ctx,
s->amount_msat, s->amount_msat,
&s->payment_hash, &s->payment_hash,
s->expiry, s->expiry,
s->onion_routing_packet); s->onion_routing_packet
#if EXPERIMENTAL_FEATURES
,NULL
#endif
);
} }
static struct msg_update_add_htlc *fromwire_struct_update_add_htlc(const tal_t *ctx, const void *p) static struct msg_update_add_htlc *fromwire_struct_update_add_htlc(const tal_t *ctx, const void *p)
@ -717,7 +721,11 @@ static struct msg_update_add_htlc *fromwire_struct_update_add_htlc(const tal_t *
&s->amount_msat, &s->amount_msat,
&s->payment_hash, &s->payment_hash,
&s->expiry, &s->expiry,
s->onion_routing_packet)) s->onion_routing_packet
#if EXPERIMENTAL_FEATURES
,NULL
#endif
))
return s; return s;
return tal_free(s); return tal_free(s);
} }