lightningd: don't try to "save" incoming channel by closing early if incoming already onchain.

From test_penalty_htlc_tx_timeout[False] flake (with keys replaced by l2 and l5, for clarity)

```
lightningd-3 2024-06-04T04:34:00.942Z UNUSUAL l2-chan#1: Peer permanent failure in CHANNELD_NORMAL: Funding transaction spent
lightningd-3 2024-06-04T04:34:01.570Z UNUSUAL l5-chan#3: Peer permanent failure in CHANNELD_NORMAL: Funding transaction spent
lightningd-3 2024-06-04T04:34:01.655Z UNUSUAL l5-chan#3: Abandoning unresolved onchain HTLC at block 132 (expired at 125) to avoid peer closing incoming HTLC at block 131
lightningd-3 2024-06-04T04:34:02.802Z **BROKEN** l5-chan#3: FUNDS LOSS of 50000000msat: peer took funds onchain before we could time out the HTLC, but we abandoned incoming HTLC to save the incoming channel
```

So, we were already closing l2, no reason to abandon it.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2024-06-04 17:12:09 +09:30 committed by Vincenzo Palazzo
parent db67df3364
commit 1a1696f2f9

View file

@ -2700,6 +2700,10 @@ static void consider_failing_incoming(struct lightningd *ld,
if (height + 3 < hout->in->cltv_expiry)
return;
/* Unless incoming is already onchain, then it can't get worse! */
if (!channel_state_can_remove_htlc(hout->in->key.channel->state))
return;
log_unusual(hout->key.channel->log,
"Abandoning unresolved onchain HTLC at block %u"
" (expired at %u) to avoid peer closing incoming HTLC at block %u",