Skip to content

Commit d2f4196

Browse files
rustyrussellendothermicdev
authored andcommitted
offers: don't send blinded path to neighbor for *invoices*.
In 6e4ff6a ("offers: add a blinded path if we have no advertized address") we were overzealous, and set blinded paths not just for offers and invoicerequests, but for invoices themselves. This has revealed various interop issues (which is great, but not good for our users!) so we should disable that. It also reduces the reliability of payments in general. Changelog-None: fixes previously overzealous addition Signed-off-by: Rusty Russell <[email protected]>
1 parent 05f0100 commit d2f4196

File tree

5 files changed

+25
-15
lines changed

5 files changed

+25
-15
lines changed

plugins/offers.c

+6-2
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ struct gossmap *get_gossmap(struct plugin *plugin)
6767
* - MUST include `offer_paths` containing one or more paths to the node
6868
* from publicly reachable nodes.
6969
*/
70-
bool we_want_blinded_path(struct plugin *plugin)
70+
bool we_want_blinded_path(struct plugin *plugin, bool for_payment)
7171
{
7272
struct node_id local_nodeid;
7373
const struct gossmap_node *node;
@@ -87,7 +87,11 @@ bool we_want_blinded_path(struct plugin *plugin)
8787
return true;
8888

8989
/* Matt Corallo also suggests we do this (for now) if we don't
90-
* advertize an address to connect to. */
90+
* advertize an address to connect to, so they can fetch the
91+
* invoice for the offer, or send the invoice for the invoicerequest.
92+
* For actual payments they can use any route. */
93+
if (for_payment)
94+
return false;
9195

9296
/* We expect to know our own node announcements, but just in case. */
9397
nannounce = gossmap_node_get_announce(tmpctx, gossmap, node);

plugins/offers.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,5 +93,5 @@ struct command_result *find_best_peer_(struct command *cmd,
9393
(arg))
9494

9595
/* Do we want a blinded path from a peer? */
96-
bool we_want_blinded_path(struct plugin *plugin);
96+
bool we_want_blinded_path(struct plugin *plugin, bool for_payment);
9797
#endif /* LIGHTNING_PLUGINS_OFFERS_H */

plugins/offers_invreq_hook.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ static struct command_result *found_best_peer(struct command *cmd,
352352
static struct command_result *add_blindedpaths(struct command *cmd,
353353
struct invreq *ir)
354354
{
355-
if (!we_want_blinded_path(cmd->plugin))
355+
if (!we_want_blinded_path(cmd->plugin, true))
356356
return create_invoicereq(cmd, ir);
357357

358358
return find_best_peer(cmd, OPT_ROUTE_BLINDING,

plugins/offers_offer.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ static struct command_result *maybe_add_path(struct command *cmd,
329329
* publicly reachable nodes.
330330
*/
331331
if (!offinfo->offer->offer_paths) {
332-
if (we_want_blinded_path(cmd->plugin))
332+
if (we_want_blinded_path(cmd->plugin, false))
333333
return find_best_peer(cmd, OPT_ONION_MESSAGES,
334334
found_best_peer, offinfo);
335335
}
@@ -726,9 +726,9 @@ struct command_result *json_invoicerequest(struct command *cmd,
726726
* - MUST set `invreq_features`.`features` to the bitmap of features.
727727
*/
728728

729-
/* FIXME: We only set blinded path if private, we should allow
729+
/* FIXME: We only set blinded path if private/noaddr, we should allow
730730
* setting otherwise! */
731-
if (we_want_blinded_path(cmd->plugin)) {
731+
if (we_want_blinded_path(cmd->plugin, false)) {
732732
struct invrequest_data *idata = tal(cmd, struct invrequest_data);
733733
idata->invreq = invreq;
734734
idata->single_use = *single_use;

tests/test_xpay.py

+14-8
Original file line numberDiff line numberDiff line change
@@ -789,11 +789,17 @@ def test_xpay_twohop_bug(node_factory):
789789
"status": "complete"
790790
}
791791
"""
792-
l1, l2, l3, l4 = node_factory.line_graph(4, wait_for_announce=True,
793-
opts=[{'cltv-delta': 50},
794-
{'cltv-delta': 100},
795-
{'cltv-delta': 200},
796-
{'cltv-final': 400}])
792+
l1, l2, l3 = node_factory.line_graph(3, wait_for_announce=True,
793+
opts=[{'cltv-delta': 50},
794+
{'cltv-delta': 100},
795+
{'cltv-delta': 200}])
796+
797+
# Connect l3->l4 via private channel, to force blinded path
798+
l4 = node_factory.get_node(options={'cltv-final': 400})
799+
node_factory.join_nodes([l3, l4], announce_channels=False)
800+
801+
# Make sure l4 sees all the gossip
802+
wait_for(lambda: len(l4.rpc.listchannels()['channels']) == 2 * 2)
797803

798804
offer = l4.rpc.offer('any')
799805
inv = l1.rpc.fetchinvoice(offer['bolt12'], '15000msat')['invoice']
@@ -806,10 +812,10 @@ def test_xpay_twohop_bug(node_factory):
806812

807813
# This works.
808814
l1.rpc.pay(inv)
809-
# CLTV is blockheight (108) + 1 + 100 + 200 + 400
810-
l1.daemon.wait_for_log(f'Adding HTLC 0 amount=15002msat cltv={108 + 1 + 100 + 200 + 400}')
815+
# CLTV is blockheight (110) + 1 + 100 + 200 + 400
816+
l1.daemon.wait_for_log(f'Adding HTLC 0 amount=15002msat cltv={110 + 1 + 100 + 200 + 400}')
811817

812818
inv = l1.rpc.fetchinvoice(offer['bolt12'], '15000msat')['invoice']
813819
# This doesn't!
814820
l1.rpc.xpay(inv)
815-
l1.daemon.wait_for_log(f'Adding HTLC 1 amount=15002msat cltv={108 + 1 + 100 + 200 + 400}')
821+
l1.daemon.wait_for_log(f'Adding HTLC 1 amount=15002msat cltv={110 + 1 + 100 + 200 + 400}')

0 commit comments

Comments
 (0)