From 2bf1053cdb79cccca8fe2be5048edd7a78aa6ee9 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 20 Nov 2024 19:27:44 +1030 Subject: [PATCH] offers: update block height correctly. As we can see from the previous test, l3 tells us why it rejected the payment: ``` lightningd-3 2024-11-19T03:56:27.151Z DEBUG 022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59-chan#1: Failing HTLC because of an invalid payload (TLV 10 pos 104): cltv_expiry 136 > payment_constraint 130 ``` It turns out, we were not updating the block height in the plugin! Without this, when we create a (non-dummy) blinded path we set a too-low CLTV restriction, and it doesn't work after a few blocks! Note we were actually triggering this error in the xpay tests! Reported-by: Vincenzo Palazzo Signed-off-by: Rusty Russell Changelog-Fixed: Offers: Receiving bolt12 payments where we have no public channels would fail a few blocks after startup. --- plugins/offers.c | 9 +++++++-- tests/test_pay.py | 1 - tests/test_xpay.py | 3 +-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/plugins/offers.c b/plugins/offers.c index 3d2e54282e39..03620a6fd302 100644 --- a/plugins/offers.c +++ b/plugins/offers.c @@ -351,8 +351,13 @@ static struct command_result *block_added_notify(struct command *cmd, const char *buf, const jsmntok_t *params) { - json_scan(cmd, buf, params, "{block:{height:%}}", - JSON_SCAN(json_to_u32, &blockheight)); + const char *err = json_scan(cmd, buf, params, "{block_added:{height:%}}", + JSON_SCAN(json_to_u32, &blockheight)); + if (err) + plugin_err(cmd->plugin, "Failed to parse block_added (%.*s): %s", + json_tok_full_len(params), + json_tok_full(buf, params), + err); return notification_handled(cmd); } diff --git a/tests/test_pay.py b/tests/test_pay.py index 2d49670d0dad..02b43ec30536 100644 --- a/tests/test_pay.py +++ b/tests/test_pay.py @@ -5992,7 +5992,6 @@ def test_enableoffer(node_factory): l1.rpc.enableoffer(offer_id=offer1['offer_id']) -@pytest.mark.xfail(strict=True) def test_offer_with_private_channels_multyhop2(node_factory): """We should be able to fetch an invoice through a private path and pay the invoice""" l1, l2, l3, l4, l5 = node_factory.line_graph(5, fundchannel=False) diff --git a/tests/test_xpay.py b/tests/test_xpay.py index f3a4bdccaa55..62450ec5c440 100644 --- a/tests/test_xpay.py +++ b/tests/test_xpay.py @@ -188,8 +188,7 @@ def test_xpay_simple(node_factory): l1.rpc.xpay(b11) # Failure from l3 (with blinded path) - # FIXME: We return wrong error here! - with pytest.raises(RpcError, match=r"Failed after 1 attempts\. Unexpected error \(invalid_onion_payload\) from intermediate node: disabling the invoice's blinded path \(0x0x0/[01]\) for this payment\. Then routing failed: We could not find a usable set of paths\. The destination has disabled 1 of 1 channels, leaving capacity only 0msat of 10605000msat\."): + with pytest.raises(RpcError, match=r"Failed after 1 attempts. We got an error from inside the blinded path 0x0x0/1: we assume it means insufficient capacity. Then routing failed: We could not find a usable set of paths. The shortest path is [0-9x]*->[0-9x]*->0x0x0, but 0x0x0/1 layer xpay-7 says max is 99999msat"): l1.rpc.xpay(b12) # Restart, try pay already paid one again.