From a948cf5c1061ef7b69b194d56f4d19477adf74e4 Mon Sep 17 00:00:00 2001 From: niftynei Date: Thu, 1 Apr 2021 13:22:44 -0500 Subject: [PATCH] closingd: handle custommessages We fail on odd messages in otherwise. --------------------------------------------------------- Captured stderr call ---------------------------------------------------------- lightning_closingd: common/read_peer_msg.c:170: handle_peer_gossip_or_error: Assertion `!is_unknown_msg_discardable(msg)' failed. lightning_closingd: FATAL SIGNAL 6 (version v0.10.0-3-gd0c30a4) 0x563b8eabd9a2 send_backtrace common/daemon.c:39 0x563b8eabda4c crashdump common/daemon.c:52 0x7f496292020f ??? ???:0 0x7f496292018b ??? ???:0 0x7f49628ff858 ??? ???:0 0x7f49628ff728 ??? ???:0 0x7f4962910f35 ??? ???:0 0x563b8eaca7e3 handle_peer_gossip_or_error common/read_peer_msg.c:170 0x563b8eab79f2 closing_read_peer_msg closingd/closingd.c:116 0x563b8eab838a receive_offer closingd/closingd.c:362 0x563b8eab9299 main closingd/closingd.c:752 0x7f49629010b2 ??? ???:0 0x563b8eab75dd ??? ???:0 0xffffffffffffffff ??? ???:0 lightning_closingd: FATAL SIGNAL (version v0.10.0-3-gd0c30a4) 0x563b8eabd9a2 send_backtrace common/daemon.c:39 0x563b8eacb384 status_failed common/status.c:207 0x563b8eacb5f0 status_backtrace_exit common/subdaemon.c:25 0x563b8eabda55 crashdump common/daemon.c:55 0x7f496292020f ??? ???:0 0x7f496292018b ??? ???:0 0x7f49628ff858 ??? ???:0 0x7f49628ff728 ??? ???:0 0x7f4962910f35 ??? ???:0 0x563b8eaca7e3 handle_peer_gossip_or_error common/read_peer_msg.c:170 0x563b8eab79f2 closing_read_peer_msg closingd/closingd.c:116 0x563b8eab838a receive_offer closingd/closingd.c:362 0x563b8eab9299 main closingd/closingd.c:752 0x7f49629010b2 ??? ???:0 0x563b8eab75dd ??? ???:0 0xffffffffffffffff ??? ???:0 --- closingd/closingd.c | 12 ++++++++++++ lightningd/closing_control.c | 14 ++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/closingd/closingd.c b/closingd/closingd.c index 569c3ed0c..80c10adca 100644 --- a/closingd/closingd.c +++ b/closingd/closingd.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -113,6 +114,17 @@ static u8 *closing_read_peer_msg(const tal_t *ctx, handle_gossip_msg(pps, take(msg)); continue; } +#if DEVELOPER + /* Handle custommsgs */ + enum peer_wire type = fromwire_peektype(msg); + if (type % 2 == 1 && !peer_wire_is_defined(type)) { + /* The message is not part of the messages we know + * how to handle. Assume is custommsg, forward it + * to master. */ + wire_sync_write(REQ_FD, take(towire_custommsg_in(NULL, msg))); + continue; + } +#endif if (!handle_peer_gossip_or_error(pps, channel_id, false, msg)) return msg; } diff --git a/lightningd/closing_control.c b/lightningd/closing_control.c index 813d069fb..2df07d6f5 100644 --- a/lightningd/closing_control.c +++ b/lightningd/closing_control.c @@ -19,6 +19,7 @@ #include #include #include +#include static struct amount_sat calc_tx_fee(struct amount_sat sat_in, const struct bitcoin_tx *tx) @@ -163,6 +164,19 @@ static unsigned closing_msg(struct subd *sd, const u8 *msg, const int *fds UNUSE break; } + switch ((enum common_wire)t) { +#if DEVELOPER + case WIRE_CUSTOMMSG_IN: + handle_custommsg_in(sd->ld, sd->node_id, msg); + break; +#else + case WIRE_CUSTOMMSG_IN: +#endif + /* We send these. */ + case WIRE_CUSTOMMSG_OUT: + break; + } + return 0; }