Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setchannelfee: fix crash when channel is not in valid state. #4282

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions lightningd/peer_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -2027,6 +2027,12 @@ static struct command_result *json_setchannelfee(struct command *cmd,
NULL))
return command_param_failed();

if (channel
&& channel->state != CHANNELD_NORMAL
&& channel->state != CHANNELD_AWAITING_LOCKIN)
return command_fail(cmd, LIGHTNINGD,
"Channel is in state %s", channel_state_name(channel));

/* Open JSON response object for later iteration */
response = json_stream_success(cmd);
json_add_num(response, "base", *base);
Expand All @@ -2047,10 +2053,6 @@ static struct command_result *json_setchannelfee(struct command *cmd,

/* single channel should be updated */
} else {
if (channel->state != CHANNELD_NORMAL &&
channel->state != CHANNELD_AWAITING_LOCKIN)
return command_fail(cmd, LIGHTNINGD,
"Channel is in state %s", channel_state_name(channel));
set_channel_fees(cmd, channel, *base, *ppm, response);
}

Expand Down