Skip to content

Commit 39a2893

Browse files
adi2011rustyrussell
authored andcommitted
Workaround for LND to cause a force-close on our channel
Unfortunately LND does not force close the channels on receiving an error, they blame us for this behaviour (https://github.com/lightningnetwork/lnd/blob/abb1e3463f3a83bbb843d5c399869dbe930ad94f/htlcswitch/link.go#L2119) To fix this we will send them a Bogus Channel Reestablish with 0 commitment_number and invalid last_per_commit_secret. Key Changes: - In connect_activate_subd, if we detect a stub channel, we serialize and send a bogus channel_reestablish message. Changelog-Fixed: Fixing LND's non responsive behaviour on receiving an error.
1 parent 99ef16f commit 39a2893

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

lightningd/peer_control.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1377,6 +1377,32 @@ static void connect_activate_subd(struct lightningd *ld, struct channel *channel
13771377
send_error:
13781378
log_debug(channel->log, "Telling connectd to send error %s",
13791379
tal_hex(tmpctx, error));
1380+
1381+
/* LND does not respond to errors with a unilateral close
1382+
* (https://github.com/lightningnetwork/lnd/blob/abb1e3463f3a83bbb843d5c399869dbe930ad94f/htlcswitch/link.go#L2119).
1383+
* We fix this by sending a `ChannelReestablish` msg with `0` commitment numbers and an
1384+
* invalid `your_last_per_commitment_secret`. */
1385+
if (is_stub_scid(*channel->scid)) {
1386+
struct secret your_last_per_commit_secret;
1387+
memset(&your_last_per_commit_secret, 1,
1388+
sizeof(your_last_per_commit_secret));
1389+
1390+
const u8 *msg = towire_channel_reestablish(tmpctx, &channel->cid,
1391+
0,
1392+
0,
1393+
&your_last_per_commit_secret,
1394+
&channel->channel_info.remote_per_commit,
1395+
NULL);
1396+
1397+
log_debug(channel->log, "Sending a bogus channel_reestablish message to make the peer "
1398+
"unilaterally close the channel.");
1399+
1400+
subd_send_msg(ld->connectd,
1401+
take(towire_connectd_peer_send_msg(NULL, &channel->peer->id,
1402+
channel->peer->connectd_counter,
1403+
msg)));
1404+
}
1405+
13801406
/* Get connectd to send error and close. */
13811407
subd_send_msg(ld->connectd,
13821408
take(towire_connectd_peer_send_msg(NULL, &channel->peer->id,

0 commit comments

Comments
 (0)