From b4e6a0fcadce4c40ddbe81d2f8d0b3816977e60f Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 9 Aug 2018 09:55:29 +0930 Subject: [PATCH] peer_failed: write error message to peer directly. We currently hand the error back to the master, who then stores it for future connections and hands it back to another openingd to send and exit. Just send directly; it's more reliable and simpler. Signed-off-by: Rusty Russell --- common/peer_failed.c | 11 ++++++++--- lightningd/peer_control.c | 3 --- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/common/peer_failed.c b/common/peer_failed.c index bf738b28f..e74c9ee5e 100644 --- a/common/peer_failed.c +++ b/common/peer_failed.c @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -15,16 +16,20 @@ void peer_failed_(int peer_fd, int gossip_fd, { va_list ap; const char *desc; - u8 *msg; + u8 *msg, *err; va_start(ap, fmt); desc = tal_vfmt(NULL, fmt, ap); va_end(ap); + /* Tell peer the error. */ + err = towire_errorfmt(desc, channel_id, "%s", desc); + sync_crypto_write(cs, peer_fd, err); + + /* Tell master the error so it can re-xmit. */ msg = towire_status_peer_error(NULL, channel_id, desc, cs, - towire_errorfmt(desc, channel_id, - "%s", desc)); + err); peer_billboard(true, desc); tal_free(desc); status_send_fatal(take(msg), peer_fd, gossip_fd); diff --git a/lightningd/peer_control.c b/lightningd/peer_control.c index 443b10118..eb2d9ff2c 100644 --- a/lightningd/peer_control.c +++ b/lightningd/peer_control.c @@ -418,9 +418,6 @@ void channel_errmsg(struct channel *channel, channel_fail_permanent(channel, "%s: %s ERROR %s", channel->owner->name, err_for_them ? "sent" : "received", desc); - - /* Get openingd to chat with them, maybe sending error. */ - peer_start_openingd(channel->peer, cs, peer_fd, gossip_fd, err_for_them); } /* Connectd tells us a peer has connected: it never hands us duplicates, since