From 0e8945f198b485a76a40aa706760f371d63ff5c0 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 11 Apr 2019 15:13:53 +0930 Subject: [PATCH] closingd: ignore premature messages here, too. Fixes the less common case where we reconnect during mutual close. Signed-off-by: Rusty Russell --- closingd/closingd.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/closingd/closingd.c b/closingd/closingd.c index 85ed3107f..25bdb3691 100644 --- a/closingd/closingd.c +++ b/closingd/closingd.c @@ -171,8 +171,17 @@ static void do_reconnect(struct crypto_state *cs, sync_crypto_write(cs, PEER_FD, take(msg)); /* They might have already send reestablish, which triggered us */ - if (!channel_reestablish) - channel_reestablish = closing_read_peer_msg(tmpctx, cs, channel_id); + if (!channel_reestablish) { + do { + tal_free(channel_reestablish); + channel_reestablish = closing_read_peer_msg(tmpctx, cs, + channel_id); + /* They *should* send reestablish first, but lnd + * sends other messages, which we can ignore since + * we're closing anyway... */ + } while (fromwire_peektype(channel_reestablish) + != WIRE_CHANNEL_REESTABLISH); + } if (!fromwire_channel_reestablish(channel_reestablish, &their_channel_id, &next_local_commitment_number,