From 91ea85be36f1b8884af761a07907fad2b27ab80e Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 7 Aug 2023 13:11:50 +0930 Subject: [PATCH] lightningd: close connection when HTLC addition times out. I noticed this while debugging an issue with ACINQ, that we got upset, but didn't trigger a reconnect cycle. Signed-off-by: Rusty Russell Changelog-Fixed: Protocol: We now close connection with a peer if adding an HTLC times out (which may be a TCP connectivity issue). --- lightningd/peer_htlcs.c | 9 +++++++++ tests/test_closing.py | 1 - 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lightningd/peer_htlcs.c b/lightningd/peer_htlcs.c index 0688099cb..242f29de9 100644 --- a/lightningd/peer_htlcs.c +++ b/lightningd/peer_htlcs.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -591,6 +592,14 @@ static void htlc_offer_timeout(struct htlc_out *out) tal_free(channel->owner); channel_set_billboard(channel, false, "Adding HTLC timed out: killed connection"); + + /* Force a disconnect in case the issue is with TCP */ + if (channel->peer->ld->connectd) { + const struct peer *peer = channel->peer; + subd_send_msg(peer->ld->connectd, + take(towire_connectd_discard_peer(NULL, &peer->id, + peer->connectd_counter))); + } } /* Returns failmsg, or NULL on success. */ diff --git a/tests/test_closing.py b/tests/test_closing.py index c4de52d26..7c6be181f 100644 --- a/tests/test_closing.py +++ b/tests/test_closing.py @@ -3641,7 +3641,6 @@ def test_close_weight_estimate(node_factory, bitcoind): assert signed_weight + 6 >= final_estimate # 70byte signature -@pytest.mark.xfail(strict=True) @pytest.mark.developer("needs dev_disconnect") def test_onchain_close_upstream(node_factory, bitcoind): """https://github.com/ElementsProject/lightning/issues/4649