From f76ab93df6c9bee1ea646b5f587a8d17dd919cdc Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 1 Apr 2020 10:22:03 +1030 Subject: [PATCH] EXPERMENTAL_FEATURES: Import onion message types. This tracks https://github.com/lightningnetwork/lightning-rfc/pull/759 Signed-off-by: Rusty Russell --- channeld/channeld.c | 4 +++ gossipd/gossipd.c | 3 ++ tools/check-spelling.sh | 2 +- ...l_1b1c9a71038bd72453cabefd3ace17ce8b8dd96e | 28 +++++++++++++++++++ ...l_1b1c9a71038bd72453cabefd3ace17ce8b8dd96e | 11 ++++++++ wire/peer_wire.c | 6 ++++ wire/wire.h | 14 ++++++++++ 7 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 wire/extracted_onion_experimental_1b1c9a71038bd72453cabefd3ace17ce8b8dd96e create mode 100644 wire/extracted_peer_experimental_1b1c9a71038bd72453cabefd3ace17ce8b8dd96e diff --git a/channeld/channeld.c b/channeld/channeld.c index c30786a41..e3cba8f45 100644 --- a/channeld/channeld.c +++ b/channeld/channeld.c @@ -1692,6 +1692,10 @@ static void peer_in(struct peer *peer, const u8 *msg) case WIRE_SHUTDOWN: handle_peer_shutdown(peer, msg); return; +#if EXPERIMENTAL_FEATURES + case WIRE_ONION_MESSAGE: + break; +#endif case WIRE_INIT: case WIRE_OPEN_CHANNEL: diff --git a/gossipd/gossipd.c b/gossipd/gossipd.c index dddb19f0b..73d55187d 100644 --- a/gossipd/gossipd.c +++ b/gossipd/gossipd.c @@ -488,6 +488,9 @@ static struct io_plan *peer_msg_in(struct io_conn *conn, case WIRE_CHANNEL_REESTABLISH: case WIRE_ANNOUNCEMENT_SIGNATURES: case WIRE_GOSSIP_TIMESTAMP_FILTER: +#if EXPERIMENTAL_FEATURES + case WIRE_ONION_MESSAGE: +#endif status_broken("peer %s: relayed unexpected msg of type %s", type_to_string(tmpctx, struct node_id, &peer->id), wire_type_name(fromwire_peektype(msg))); diff --git a/tools/check-spelling.sh b/tools/check-spelling.sh index a9f88697e..d82a77b2e 100755 --- a/tools/check-spelling.sh +++ b/tools/check-spelling.sh @@ -6,7 +6,7 @@ if git --no-pager grep -nHiE 'l[ightn]{6}g|l[ightn]{8}g|ilghtning|lgihtning|lihg exit 1 fi -if git --no-pager grep -nHiE 'ctlv' -- . ':!tools/check-spelling.sh'; then +if git --no-pager grep -nHiE 'ctlv' | grep -v 'enctlv' -- . ':!tools/check-spelling.sh'; then echo "It's check lock time verify, not check time lock verify!" >&2 exit 1 fi diff --git a/wire/extracted_onion_experimental_1b1c9a71038bd72453cabefd3ace17ce8b8dd96e b/wire/extracted_onion_experimental_1b1c9a71038bd72453cabefd3ace17ce8b8dd96e new file mode 100644 index 000000000..3b8ebbec8 --- /dev/null +++ b/wire/extracted_onion_experimental_1b1c9a71038bd72453cabefd3ace17ce8b8dd96e @@ -0,0 +1,28 @@ +--- wire/extracted_onion_wire_csv 2020-03-25 10:24:12.861645774 +1030 ++++ - 2020-03-26 13:47:13.498294435 +1030 +@@ -8,6 +8,25 @@ + tlvtype,tlv_payload,payment_data,8 + tlvdata,tlv_payload,payment_data,payment_secret,byte,32 + tlvdata,tlv_payload,payment_data,total_msat,tu64, ++tlvtype,onionmsg_payload,next_node_id,4 ++tlvdata,onionmsg_payload,next_node_id,node_id,point, ++tlvtype,onionmsg_payload,next_short_channel_id,6 ++tlvdata,onionmsg_payload,next_short_channel_id,short_channel_id,short_channel_id, ++tlvtype,onionmsg_payload,reply_path,8 ++tlvdata,onionmsg_payload,reply_path,blinding,point, ++tlvdata,onionmsg_payload,reply_path,path,onionmsg_path,... ++tlvtype,onionmsg_payload,enctlv,10 ++tlvdata,onionmsg_payload,enctlv,enctlv,byte,... ++tlvtype,onionmsg_payload,blinding,12 ++tlvdata,onionmsg_payload,blinding,blinding,point, ++tlvtype,encmsg_tlvs,next_node_id,4 ++tlvdata,encmsg_tlvs,next_node_id,node_id,point, ++tlvtype,encmsg_tlvs,next_short_channel_id,6 ++tlvdata,encmsg_tlvs,next_short_channel_id,short_channel_id,short_channel_id, ++subtype,onionmsg_path ++subtypedata,onionmsg_path,node_id,point, ++subtypedata,onionmsg_path,enclen,u16, ++subtypedata,onionmsg_path,enctlv,byte,enclen + msgtype,invalid_realm,PERM|1 + msgtype,temporary_node_failure,NODE|2 + msgtype,permanent_node_failure,PERM|NODE|2 diff --git a/wire/extracted_peer_experimental_1b1c9a71038bd72453cabefd3ace17ce8b8dd96e b/wire/extracted_peer_experimental_1b1c9a71038bd72453cabefd3ace17ce8b8dd96e new file mode 100644 index 000000000..2cb91f2f9 --- /dev/null +++ b/wire/extracted_peer_experimental_1b1c9a71038bd72453cabefd3ace17ce8b8dd96e @@ -0,0 +1,11 @@ +--- wire/extracted_peer_wire_csv 2020-03-11 10:30:35.744376417 +1030 ++++ - 2020-03-26 13:47:13.409755567 +1030 +@@ -211,3 +211,8 @@ + msgdata,gossip_timestamp_filter,chain_hash,chain_hash, + msgdata,gossip_timestamp_filter,first_timestamp,u32, + msgdata,gossip_timestamp_filter,timestamp_range,u32, ++msgtype,onion_message,385,option_onion_messages ++msgdata,onion_message,onionmsg,byte,1366 ++msgdata,onion_message,onion_message_tlvs,onion_message_tlvs, ++tlvtype,onion_message_tlvs,blinding,2 ++tlvdata,onion_message_tlvs,blinding,blinding,point, diff --git a/wire/peer_wire.c b/wire/peer_wire.c index e9210d7d8..737e2fbb6 100644 --- a/wire/peer_wire.c +++ b/wire/peer_wire.c @@ -31,6 +31,9 @@ static bool unknown_type(enum wire_type t) case WIRE_QUERY_CHANNEL_RANGE: case WIRE_REPLY_CHANNEL_RANGE: case WIRE_GOSSIP_TIMESTAMP_FILTER: +#if EXPERIMENTAL_FEATURES + case WIRE_ONION_MESSAGE: +#endif return false; } return true; @@ -68,6 +71,9 @@ bool is_msg_for_gossipd(const u8 *cursor) case WIRE_CHANNEL_REESTABLISH: case WIRE_ANNOUNCEMENT_SIGNATURES: case WIRE_GOSSIP_TIMESTAMP_FILTER: +#if EXPERIMENTAL_FEATURES + case WIRE_ONION_MESSAGE: +#endif break; } return false; diff --git a/wire/wire.h b/wire/wire.h index ea380a937..a9bc8e89d 100644 --- a/wire/wire.h +++ b/wire/wire.h @@ -153,4 +153,18 @@ struct witscript *fromwire_witscript(const tal_t *ctx, void fromwire_chainparams(const u8 **cursor, size_t *max, const struct chainparams **chainparams); +#if !EXPERIMENTAL_FEATURES +/* Stubs, as this subtype is only defined when EXPERIMENTAL_FEATURES */ +struct onionmsg_path; + +static inline void towire_onionmsg_path(u8 **p, const struct onionmsg_path *onionmsg_path) +{ +} + +static inline struct onionmsg_path * +fromwire_onionmsg_path(const tal_t *ctx, const u8 **cursor, size_t *plen) +{ + return NULL; +} +#endif /* EXPERIMENTAL_FEATURES */ #endif /* LIGHTNING_WIRE_WIRE_H */