From cd7175be8831807eb0859320838984cbe075aa96 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Fri, 19 Apr 2024 14:15:16 +0930 Subject: [PATCH] lightningd: use return value of peer_start_channeld() It tells us if it's failed, so we should use that rather than reporting failure twice. Signed-off-by: Rusty Russell --- lightningd/opening_control.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lightningd/opening_control.c b/lightningd/opening_control.c index cac7bec31108..3e81f1ae24c2 100644 --- a/lightningd/opening_control.c +++ b/lightningd/opening_control.c @@ -453,8 +453,11 @@ static void opening_funder_finished(struct subd *openingd, const u8 *resp, if (pbase) wallet_penalty_base_add(ld->wallet, channel->dbid, pbase); + /* If this fails, it cleans up */ + if (!peer_start_channeld(channel, peer_fd, NULL, false, NULL)) + return; + funding_success(channel); - peer_start_channeld(channel, peer_fd, NULL, false, NULL); cleanup: /* Frees fc too */ @@ -557,10 +560,9 @@ static void opening_fundee_finished(struct subd *openingd, if (pbase) wallet_penalty_base_add(ld->wallet, channel->dbid, pbase); - /* On to normal operation! */ - peer_start_channeld(channel, peer_fd, fwd_msg, false, NULL); - - tal_free(uc); + /* On to normal operation (frees if it fails!) */ + if (peer_start_channeld(channel, peer_fd, fwd_msg, false, NULL)) + tal_free(uc); return; failed: