Skip to content

Commit 2408233

Browse files
rustyrussellendothermicdev
authored andcommitted
pay: use correct CLTV values for blinded paths.
We added twice, which caused spurious failures in real-world cases. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Reported-by: https://github.com/hMsats Fixes: #8119 Changelog-Fixed: `xpay` would double the CLTV values in blinded paths, sometimes causing spurious failures.
1 parent 69476db commit 2408233

2 files changed

Lines changed: 4 additions & 7 deletions

File tree

plugins/xpay/xpay.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -899,7 +899,7 @@ static void append_blinded_payloads(struct sphinx_path *sp,
899899
size_t path_num)
900900
{
901901
const struct blinded_path *path = attempt->payment->paths[path_num];
902-
u32 final_cltv = attempt->payment->final_cltv + effective_bheight;
902+
u32 final_cltv = effective_bheight;
903903

904904
for (size_t i = 0; i < tal_count(path->path); i++) {
905905
bool first = (i == 0);
@@ -1635,12 +1635,10 @@ static struct command_result *json_xpay_core(struct command *cmd,
16351635
"Could not resolve any paths: unknown short_channel_id");
16361636
}
16371637

1638-
/* Use worst-case CLTV. */
1638+
/* We don't actually know the final_cltv for blinded
1639+
* paths, we just know the cltv we use to enter the
1640+
* final hop. */
16391641
payment->final_cltv = 0;
1640-
for (size_t i = 0; i < tal_count(payment->payinfos); i++) {
1641-
if (payment->payinfos[i]->cltv_expiry_delta > payment->final_cltv)
1642-
payment->final_cltv = payment->payinfos[i]->cltv_expiry_delta;
1643-
}
16441642
/* We will start honoring this flag in future */
16451643
payment->disable_mpp = !feature_offered(b12inv->invoice_features, OPT_BASIC_MPP);
16461644
if (payment->disable_mpp && command_deprecated_in_ok(cmd, "ignore_bolt12_mpp", "v25.05", "v25.11"))

tests/test_xpay.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,6 @@ def test_fail_after_success(node_factory, bitcoind, executor, slow_mode):
768768
'successful_parts': 1}
769769

770770

771-
@pytest.mark.xfail(strict=True)
772771
def test_xpay_twohop_bug(node_factory):
773772
"""From https://github.com/ElementsProject/lightning/issues/8119:
774773
Oh, interesting! I tried again and got a two-hop blinded path. xpay returned the same error you saw while pay was successful.

0 commit comments

Comments
 (0)