Skip to content
Open
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
24 changes: 24 additions & 0 deletions lightningd/peer_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -2137,6 +2137,21 @@ void handle_peer_spoke(struct lightningd *ld, const u8 *msg)
"Channel is closed and forgotten");
goto send_error;
}
/* Unknown channel: send error but don't disconnect.
* If we hang up, the peer's dualopend may not
* receive the error (it races with the disconnect),
* leaving the peer with a saved channel that we
* don't know about, causing an infinite reconnect
* loop. */
log_peer_unusual(ld->log, &peer->id,
"Unknown channel %s for %s",
fmt_channel_id(tmpctx,
&channel_id),
peer_wire_name(msgtype));
error = towire_errorfmt(tmpctx, &channel_id,
"Unknown channel for %s",
peer_wire_name(msgtype));
goto send_error_nohangup;
}

/* Weird message? Log and reply with error. */
Expand All @@ -2162,6 +2177,15 @@ void handle_peer_spoke(struct lightningd *ld, const u8 *msg)
peer->connectd_counter)));
return;

send_error_nohangup:
log_peer_debug(ld->log, &peer->id, "Telling connectd to send error %s",
tal_hex(tmpctx, error));
subd_send_msg(ld->connectd,
take(towire_connectd_peer_send_msg(NULL, &peer->id,
peer->connectd_counter,
error)));
return;

tell_connectd:
subd_send_msg(ld->connectd,
take(towire_connectd_peer_connect_subd(NULL, &id,
Expand Down
Loading