Skip to content

Commit a2a0617

Browse files
rustyrussellSaibato
authored andcommitted
channeld: accept SHUTDOWN before channel is locked.
Fixes: ElementsProject#1308 Signed-off-by: Rusty Russell <[email protected]>
1 parent 6e076f7 commit a2a0617

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
@@ -1589,7 +1589,9 @@ static void peer_in(struct peer *peer, const u8 *msg)
15891589

15901590
/* Must get funding_locked before almost anything. */
15911591
if (!peer->funding_locked[REMOTE]) {
1592-
if (type != WIRE_FUNDING_LOCKED && type != WIRE_PONG) {
1592+
if (type != WIRE_FUNDING_LOCKED
1593+
&& type != WIRE_PONG
1594+
&& type != WIRE_SHUTDOWN) {
15931595
peer_failed(&peer->cs,
15941596
peer->gossip_index,
15951597
&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)