From 4b1a300ee3c7750c42a01ea52a675f6030d6ee13 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 12 Jun 2019 15:53:24 +0930 Subject: [PATCH] lightningd: fix fundchannel_complete race. If we already have a fundchannel_complete, don't attach another one. Signed-off-by: Rusty Russell --- lightningd/opening_control.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lightningd/opening_control.c b/lightningd/opening_control.c index ec05138a4..9bdf512e7 100644 --- a/lightningd/opening_control.c +++ b/lightningd/opening_control.c @@ -312,6 +312,9 @@ static void funding_started_success(struct funding_channel *fc, scriptPubkey); if (out) json_add_string(response, "funding_address", out); + + /* Clear this so cancel doesn't think it's still in progress */ + fc->cmd = NULL; was_pending(command_success(cmd, response)); } @@ -1133,8 +1136,10 @@ static struct command_result *json_fund_channel_complete(struct command *cmd, if (!peer->uncommitted_channel->fc || !peer->uncommitted_channel->fc->inflight) return command_fail(cmd, LIGHTNINGD, "No channel funding in progress."); + if (peer->uncommitted_channel->fc->cmd) + return command_fail(cmd, LIGHTNINGD, "Channel funding in progress."); - /* Update the cmd to the new cmd */ + /* Set the cmd to this new cmd */ peer->uncommitted_channel->fc->cmd = cmd; msg = towire_opening_funder_complete(NULL, funding_txid,