From 1954844fbff805020ad0ccc460edd212070d9719 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 12 Oct 2017 17:05:07 +1030 Subject: [PATCH] lightningd: make peer_fail_permanent() only save the first error for peer. Signed-off-by: Rusty Russell --- lightningd/peer_control.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lightningd/peer_control.c b/lightningd/peer_control.c index c59ce12fd..1240d40d5 100644 --- a/lightningd/peer_control.c +++ b/lightningd/peer_control.c @@ -156,7 +156,11 @@ void peer_fail_permanent(struct peer *peer, const u8 *msg TAKES) log_unusual(peer->log, "Peer permanent failure in %s: %.*s", peer_state_name(peer->state), (int)tal_len(msg), (char *)msg); - peer->error = towire_error(peer, &all_channels, msg); + + /* We can have multiple errors, eg. onchaind failures. */ + if (!peer->error) + peer->error = towire_error(peer, &all_channels, msg); + peer_set_owner(peer, NULL); if (taken(msg)) tal_free(msg);