From 02d99acca1b4f7821c20b2f4feae52db3f977b76 Mon Sep 17 00:00:00 2001 From: niftynei Date: Fri, 22 Jan 2021 11:25:21 -0600 Subject: [PATCH] dualopen: check that peer is connected for json calls Before we start trying to talk to the peer, check that they're connected. --- lightningd/dual_open_control.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lightningd/dual_open_control.c b/lightningd/dual_open_control.c index 26f1f203f..d77d57821 100644 --- a/lightningd/dual_open_control.c +++ b/lightningd/dual_open_control.c @@ -1719,6 +1719,10 @@ json_openchannel_bump(struct command *cmd, type_to_string(tmpctx, struct channel_id, cid)); + if (!channel->owner) + return command_fail(cmd, LIGHTNINGD, + "Peer not connected."); + if (channel->open_attempt) return command_fail(cmd, LIGHTNINGD, "Commitments for this channel not " @@ -1763,6 +1767,10 @@ json_openchannel_signed(struct command *cmd, if (!channel) return command_fail(cmd, FUNDING_UNKNOWN_CHANNEL, "Unknown channel"); + if (!channel->owner) + return command_fail(cmd, LIGHTNINGD, + "Peer not connected"); + if (channel->open_attempt) return command_fail(cmd, LIGHTNINGD, "Commitments for this channel not " @@ -1870,6 +1878,10 @@ static struct command_result *json_openchannel_update(struct command *cmd, "Unknown channel %s", type_to_string(tmpctx, struct channel_id, cid)); + if (!channel->owner) + return command_fail(cmd, LIGHTNINGD, + "Peer not connected"); + if (!channel->open_attempt) return command_fail(cmd, LIGHTNINGD, "Channel open not in progress"); @@ -1979,10 +1991,9 @@ static struct command_result *json_openchannel_init(struct command *cmd, } channel = peer_unsaved_channel(peer); - if (!channel) + if (!channel || !channel->owner) return command_fail(cmd, FUNDING_PEER_NOT_CONNECTED, "Peer not connected"); - if (channel->open_attempt || !list_empty(&channel->inflights)) return command_fail(cmd, LIGHTNINGD, "Channel funding"