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 <rusty@rustcorp.com.au>
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!
This commit is contained in:
Rusty Russell
2025-03-27 12:05:38 +10:30
committed by Alex Myers
parent 1f0506352e
commit 19f76e1f1f

View File

@@ -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);
}