From 19f76e1f1f62f08164d2f6bb20352ceaacbf83ea Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 27 Mar 2025 12:05:38 +1030 Subject: [PATCH] lightningd: fix anchorspend HTLC deadline logic. It's not the *outgoing* HTLC which sets the deadline, it's the incoming. Reported-by: @whitslack Signed-off-by: Rusty Russell Changelog-Fixed: Protocol: Egregious anchor fee paid for unilateral close txs due to HTLC timeouts; it's not as urgent as our code made out! --- lightningd/anchorspend.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lightningd/anchorspend.c b/lightningd/anchorspend.c index aa64c4316..9531c61d7 100644 --- a/lightningd/anchorspend.c +++ b/lightningd/anchorspend.c @@ -204,7 +204,12 @@ struct anchor_details *create_anchor_details(const tal_t *ctx, continue; v.msat = hout->msat; - v.block = hout->cltv_expiry; + /* Our real deadline here is the INCOMING htlc. If it's us, use the default so we don't leak + * too much information about it. */ + if (hout->in) + v.block = hout->in->cltv_expiry; + else + v.block = hout->cltv_expiry + ld->config.cltv_expiry_delta; v.important = true; tal_arr_expand(&adet->vals, v); }