Skip to content

Commit bd2f2ec

Browse files
committed
EXPERMENTAL_FEATURES: Import onion message types.
This tracks lightning/bolts#759 Signed-off-by: Rusty Russell <[email protected]>
1 parent d0605ac commit bd2f2ec

7 files changed

+67
-1
lines changed

channeld/channeld.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1692,6 +1692,10 @@ static void peer_in(struct peer *peer, const u8 *msg)
16921692
case WIRE_SHUTDOWN:
16931693
handle_peer_shutdown(peer, msg);
16941694
return;
1695+
#if EXPERIMENTAL_FEATURES
1696+
case WIRE_ONION_MESSAGE:
1697+
break;
1698+
#endif
16951699

16961700
case WIRE_INIT:
16971701
case WIRE_OPEN_CHANNEL:

gossipd/gossipd.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,9 @@ static struct io_plan *peer_msg_in(struct io_conn *conn,
488488
case WIRE_CHANNEL_REESTABLISH:
489489
case WIRE_ANNOUNCEMENT_SIGNATURES:
490490
case WIRE_GOSSIP_TIMESTAMP_FILTER:
491+
#if EXPERIMENTAL_FEATURES
492+
case WIRE_ONION_MESSAGE:
493+
#endif
491494
status_broken("peer %s: relayed unexpected msg of type %s",
492495
type_to_string(tmpctx, struct node_id, &peer->id),
493496
wire_type_name(fromwire_peektype(msg)));

tools/check-spelling.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ if git --no-pager grep -nHiE 'l[ightn]{6}g|l[ightn]{8}g|ilghtning|lgihtning|lihg
66
exit 1
77
fi
88

9-
if git --no-pager grep -nHiE 'ctlv' -- . ':!tools/check-spelling.sh'; then
9+
if git --no-pager grep -nHiE 'ctlv' | grep -v 'enctlv' -- . ':!tools/check-spelling.sh'; then
1010
echo "It's check lock time verify, not check time lock verify!" >&2
1111
exit 1
1212
fi
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
--- wire/extracted_onion_wire_csv 2020-03-25 10:24:12.861645774 +1030
2+
+++ - 2020-03-26 13:47:13.498294435 +1030
3+
@@ -8,6 +8,25 @@
4+
tlvtype,tlv_payload,payment_data,8
5+
tlvdata,tlv_payload,payment_data,payment_secret,byte,32
6+
tlvdata,tlv_payload,payment_data,total_msat,tu64,
7+
+tlvtype,onionmsg_payload,next_node_id,4
8+
+tlvdata,onionmsg_payload,next_node_id,node_id,point,
9+
+tlvtype,onionmsg_payload,next_short_channel_id,6
10+
+tlvdata,onionmsg_payload,next_short_channel_id,short_channel_id,short_channel_id,
11+
+tlvtype,onionmsg_payload,reply_path,8
12+
+tlvdata,onionmsg_payload,reply_path,blinding,point,
13+
+tlvdata,onionmsg_payload,reply_path,path,onionmsg_path,...
14+
+tlvtype,onionmsg_payload,enctlv,10
15+
+tlvdata,onionmsg_payload,enctlv,enctlv,byte,...
16+
+tlvtype,onionmsg_payload,blinding,12
17+
+tlvdata,onionmsg_payload,blinding,blinding,point,
18+
+tlvtype,encmsg_tlvs,next_node_id,4
19+
+tlvdata,encmsg_tlvs,next_node_id,node_id,point,
20+
+tlvtype,encmsg_tlvs,next_short_channel_id,6
21+
+tlvdata,encmsg_tlvs,next_short_channel_id,short_channel_id,short_channel_id,
22+
+subtype,onionmsg_path
23+
+subtypedata,onionmsg_path,node_id,point,
24+
+subtypedata,onionmsg_path,enclen,u16,
25+
+subtypedata,onionmsg_path,enctlv,byte,enclen
26+
msgtype,invalid_realm,PERM|1
27+
msgtype,temporary_node_failure,NODE|2
28+
msgtype,permanent_node_failure,PERM|NODE|2
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--- wire/extracted_peer_wire_csv 2020-03-11 10:30:35.744376417 +1030
2+
+++ - 2020-03-26 13:47:13.409755567 +1030
3+
@@ -211,3 +211,8 @@
4+
msgdata,gossip_timestamp_filter,chain_hash,chain_hash,
5+
msgdata,gossip_timestamp_filter,first_timestamp,u32,
6+
msgdata,gossip_timestamp_filter,timestamp_range,u32,
7+
+msgtype,onion_message,385,option_onion_messages
8+
+msgdata,onion_message,onionmsg,byte,1366
9+
+msgdata,onion_message,onion_message_tlvs,onion_message_tlvs,
10+
+tlvtype,onion_message_tlvs,blinding,2
11+
+tlvdata,onion_message_tlvs,blinding,blinding,point,

wire/peer_wire.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ static bool unknown_type(enum wire_type t)
3131
case WIRE_QUERY_CHANNEL_RANGE:
3232
case WIRE_REPLY_CHANNEL_RANGE:
3333
case WIRE_GOSSIP_TIMESTAMP_FILTER:
34+
#if EXPERIMENTAL_FEATURES
35+
case WIRE_ONION_MESSAGE:
36+
#endif
3437
return false;
3538
}
3639
return true;
@@ -68,6 +71,9 @@ bool is_msg_for_gossipd(const u8 *cursor)
6871
case WIRE_CHANNEL_REESTABLISH:
6972
case WIRE_ANNOUNCEMENT_SIGNATURES:
7073
case WIRE_GOSSIP_TIMESTAMP_FILTER:
74+
#if EXPERIMENTAL_FEATURES
75+
case WIRE_ONION_MESSAGE:
76+
#endif
7177
break;
7278
}
7379
return false;

wire/wire.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,4 +153,18 @@ struct witscript *fromwire_witscript(const tal_t *ctx,
153153
void fromwire_chainparams(const u8 **cursor, size_t *max,
154154
const struct chainparams **chainparams);
155155

156+
#if !EXPERIMENTAL_FEATURES
157+
/* Stubs, as this subtype is only defined when EXPERIMENTAL_FEATURES */
158+
struct onionmsg_path;
159+
160+
static inline void towire_onionmsg_path(u8 **p, const struct onionmsg_path *onionmsg_path)
161+
{
162+
}
163+
164+
static inline struct onionmsg_path *
165+
fromwire_onionmsg_path(const tal_t *ctx, const u8 **cursor, size_t *plen)
166+
{
167+
return NULL;
168+
}
169+
#endif /* EXPERIMENTAL_FEATURES */
156170
#endif /* LIGHTNING_WIRE_WIRE_H */

0 commit comments

Comments
 (0)