Skip to content

Commit

Permalink
offers: update block height correctly.
Browse files Browse the repository at this point in the history
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 <rusty@rustcorp.com.au>
Changelog-Fixed: Offers: Receiving bolt12 payments where we have no public channels would fail a few blocks after startup.
  • Loading branch information
rustyrussell authored and vincenzopalazzo committed Nov 20, 2024
1 parent 6f4f33d commit 2bf1053
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
9 changes: 7 additions & 2 deletions plugins/offers.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
1 change: 0 additions & 1 deletion tests/test_pay.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions tests/test_xpay.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 2bf1053

Please sign in to comment.