Skip to content

Commit

Permalink
EXPERMENTAL_FEATURES: Import onion message types.
Browse files Browse the repository at this point in the history
This tracks lightning/bolts#759

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
  • Loading branch information
rustyrussell committed Mar 20, 2020
1 parent f69a208 commit efdad8b
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 1 deletion.
4 changes: 4 additions & 0 deletions channeld/channeld.c
Original file line number Diff line number Diff line change
Expand Up @@ -1693,6 +1693,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:
Expand Down
3 changes: 3 additions & 0 deletions gossipd/gossipd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
Expand Down
2 changes: 1 addition & 1 deletion tools/check-spelling.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
--- wire/extracted_onion_wire_csv 2020-02-25 05:52:39.612291156 +1030
+++ - 2020-03-20 15:11:55.763880895 +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_short_channel_id,2
+tlvdata,onionmsg_payload,next_short_channel_id,short_channel_id,short_channel_id,
+tlvtype,onionmsg_payload,next_node_id,4
+tlvdata,onionmsg_payload,next_node_id,node_id,point,
+tlvtype,onionmsg_payload,enctlv,6
+tlvdata,onionmsg_payload,enctlv,enctlv,byte,...
+tlvtype,onionmsg_payload,reply_path,8
+tlvdata,onionmsg_payload,reply_path,blinding,point,
+tlvdata,onionmsg_payload,reply_path,path,onionmsg_path,...
+tlvtype,onionmsg_payload,blinding,10
+tlvdata,onionmsg_payload,blinding,blinding,point,
+tlvtype,encmsg_tlvs,next_short_channel_id,2
+tlvdata,encmsg_tlvs,next_short_channel_id,short_channel_id,short_channel_id,
+tlvtype,encmsg_tlvs,next_node_id,4
+tlvdata,encmsg_tlvs,next_node_id,node_id,point,
+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
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- wire/extracted_peer_wire_csv 2020-03-11 10:30:35.744376417 +1030
+++ - 2020-03-20 15:11:55.730046232 +1030
@@ -208,3 +208,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,
6 changes: 6 additions & 0 deletions wire/peer_wire.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
14 changes: 14 additions & 0 deletions wire/wire.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

0 comments on commit efdad8b

Please sign in to comment.