Skip to content

Commit c50a73e

Browse files
committed
channeld: accept SHUTDOWN before channel is locked.
Fixes: ElementsProject#1308 Signed-off-by: Rusty Russell <[email protected]>
1 parent b56ec53 commit c50a73e

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

channeld/channel.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1590,7 +1590,9 @@ static void peer_in(struct peer *peer, const u8 *msg)
15901590

15911591
/* Must get funding_locked before almost anything. */
15921592
if (!peer->funding_locked[REMOTE]) {
1593-
if (type != WIRE_FUNDING_LOCKED && type != WIRE_PONG) {
1593+
if (type != WIRE_FUNDING_LOCKED
1594+
&& type != WIRE_PONG
1595+
&& type != WIRE_SHUTDOWN) {
15941596
peer_failed(&peer->cs,
15951597
peer->gossip_index,
15961598
&peer->channel_id,

lightningd/channel_control.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ static void peer_got_shutdown(struct channel *channel, const u8 *msg)
7777
}
7878

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

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

0 commit comments

Comments
 (0)