Skip to content

Commit

Permalink
channeld: accept SHUTDOWN before channel is locked.
Browse files Browse the repository at this point in the history
Fixes: ElementsProject#1308
Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
rustyrussell authored and cdecker committed Apr 3, 2018
1 parent 71de234 commit 1773b03
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion channeld/channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -1589,7 +1589,9 @@ static void peer_in(struct peer *peer, const u8 *msg)

/* Must get funding_locked before almost anything. */
if (!peer->funding_locked[REMOTE]) {
if (type != WIRE_FUNDING_LOCKED && type != WIRE_PONG) {
if (type != WIRE_FUNDING_LOCKED
&& type != WIRE_PONG
&& type != WIRE_SHUTDOWN) {
peer_failed(&peer->cs,
peer->gossip_index,
&peer->channel_id,
Expand Down
4 changes: 2 additions & 2 deletions lightningd/channel_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ static void peer_got_shutdown(struct channel *channel, const u8 *msg)
}

/* If we weren't already shutting down, we are now */
if (channel->state == CHANNELD_NORMAL)
if (channel->state != CHANNELD_SHUTTING_DOWN)
channel_set_state(channel,
CHANNELD_NORMAL, CHANNELD_SHUTTING_DOWN);
channel->state, CHANNELD_SHUTTING_DOWN);

/* TODO(cdecker) Selectively save updated fields to DB */
wallet_channel_save(ld->wallet, channel);
Expand Down

0 comments on commit 1773b03

Please sign in to comment.