@@ -435,7 +435,6 @@ static bool handle_local_channel_announcement(struct daemon *daemon,
435435 return true;
436436}
437437
438- #if EXPERIMENTAL_FEATURES
439438/* Peer sends onion msg. */
440439static u8 * handle_onion_message (struct peer * peer , const u8 * msg )
441440{
@@ -450,6 +449,11 @@ static u8 *handle_onion_message(struct peer *peer, const u8 *msg)
450449 struct tlv_onionmsg_payload * om ;
451450 struct tlv_onion_message_tlvs * tlvs = tlv_onion_message_tlvs_new (msg );
452451
452+ /* Ignore unless explicitly turned on. */
453+ if (!feature_offered (peer -> daemon -> our_features -> bits [NODE_ANNOUNCE_FEATURE ],
454+ OPT_ONION_MESSAGES ))
455+ return NULL ;
456+
453457 /* FIXME: ratelimit! */
454458 if (!fromwire_onion_message (msg , msg , & onion , tlvs ))
455459 return towire_errorfmt (peer , NULL , "Bad onion_message" );
@@ -690,7 +694,6 @@ static struct io_plan *onionmsg_req(struct io_conn *conn, struct daemon *daemon,
690694 }
691695 return daemon_conn_read_next (conn , daemon -> master );
692696}
693- #endif /* EXPERIMENTAL_FEATURES */
694697
695698/*~ This is where the per-peer daemons send us messages. It's either forwarded
696699 * gossip, or a request for information. We deliberately use non-overlapping
@@ -731,11 +734,9 @@ static struct io_plan *peer_msg_in(struct io_conn *conn,
731734 case WIRE_PONG :
732735 err = handle_pong (peer , msg );
733736 goto handled_relay ;
734- #if EXPERIMENTAL_FEATURES
735737 case WIRE_ONION_MESSAGE :
736738 err = handle_onion_message (peer , msg );
737739 goto handled_relay ;
738- #endif
739740
740741 /* These are non-gossip messages (!is_msg_for_gossipd()) */
741742 case WIRE_INIT :
@@ -757,9 +758,6 @@ static struct io_plan *peer_msg_in(struct io_conn *conn,
757758 case WIRE_CHANNEL_REESTABLISH :
758759 case WIRE_ANNOUNCEMENT_SIGNATURES :
759760 case WIRE_GOSSIP_TIMESTAMP_FILTER :
760- #if !EXPERIMENTAL_FEATURES
761- case WIRE_ONION_MESSAGE :
762- #endif
763761#if EXPERIMENTAL_FEATURES
764762 case WIRE_TX_ADD_INPUT :
765763 case WIRE_TX_REMOVE_INPUT :
@@ -1934,9 +1932,7 @@ static struct io_plan *recv_req(struct io_conn *conn,
19341932#endif /* !DEVELOPER */
19351933
19361934 case WIRE_GOSSIPD_SEND_ONIONMSG :
1937- #if EXPERIMENTAL_FEATURES
19381935 return onionmsg_req (conn , daemon , msg );
1939- #endif
19401936 /* We send these, we don't receive them */
19411937 case WIRE_GOSSIPD_GETNODES_REPLY :
19421938 case WIRE_GOSSIPD_GETROUTE_REPLY :
0 commit comments