pay: fix bolt12 blinded path cltv logic.

The spec has moved a bit here: the `outgoing_cltv_value` in the final onion
is basically the blockheight now (plus the 1 block delta we give ourselves).

Also, we were doubling ours, since p->min_final_cltv_expiry was already set
to p->blindedpay->cltv_expiry_delta above.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2024-05-14 21:18:24 +09:30
committed by Alex Myers
parent 121403b5df
commit 3c48438821
3 changed files with 14 additions and 4 deletions

View File

@@ -1869,11 +1869,24 @@ static void payment_compute_onion_payloads(struct payment *p)
/* If we're headed to a blinded path, connect that now. */
if (root->blindedpath) {
/* This final_cltv matches our payment heuristic of adding 1 block. */
/* BOLT #4:
* - For every node inside a blinded route:
*...
* - If it is the final node:
*...
* - The value set for `outgoing_cltv_value`:
* - MUST use the current block height as a baseline value.
* - if a [random offset](07-routing-gossip.md#recommendations-for-routing) was added to improve privacy:
* - SHOULD add the offset to the baseline value.
*/
u32 final_cltv = p->start_block + 1;
payment_add_blindedpath(cr->hops, cr->hops + hopcount - 1,
root->blindedpath,
root->blindedouramount,
root->blindedfinalamount,
root->blindedfinalcltv);
final_cltv);
tal_append_fmt(&routetxt, "%s -> blinded path (%zu hops)",
fmt_short_channel_id(tmpctx,
p->route[hopcount-1].scid),