Skip to content

Commit 2068bef

Browse files
committed
offers: honor payment-fronting-nodes when creating invoices.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
1 parent 8dcb077 commit 2068bef

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

plugins/offers_invreq_hook.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,12 @@ static struct command_result *found_best_peer(struct command *cmd,
261261
* for each `blinded_path` in `paths`, in order.
262262
*/
263263
if (!best) {
264+
/* Don't allow bare invoices if they explicitly told us to front */
265+
if (od->fronting_nodes) {
266+
return fail_invreq(cmd, ir,
267+
"Could not find path from payment-fronting-node");
268+
}
269+
264270
/* Note: since we don't make one, createinvoice adds a dummy. */
265271
plugin_log(cmd->plugin, LOG_UNUSUAL,
266272
"No incoming channel for %s, so no blinded path",
@@ -358,10 +364,12 @@ static struct command_result *found_best_peer(struct command *cmd,
358364
static struct command_result *add_blindedpaths(struct command *cmd,
359365
struct invreq *ir)
360366
{
367+
const struct offers_data *od = get_offers_data(cmd->plugin);
368+
361369
if (!we_want_blinded_path(cmd->plugin, true))
362370
return create_invoicereq(cmd, ir);
363371

364-
return find_best_peer(cmd, OPT_ROUTE_BLINDING, NULL,
372+
return find_best_peer(cmd, OPT_ROUTE_BLINDING, od->fronting_nodes,
365373
found_best_peer, ir);
366374
}
367375

tests/test_invoices.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -972,3 +972,10 @@ def test_payment_fronting(node_factory):
972972

973973
l3invb12 = l1.rpc.fetchinvoice(l3offer)['invoice']
974974
l4invb12 = l1.rpc.fetchinvoice(l4offer)['invoice']
975+
976+
assert only_one(l3.rpc.decode(l3invb12)['invoice_paths'])['first_node_id'] == l1.info['id']
977+
# Given multiple, it will pick one.
978+
assert only_one(l3.rpc.decode(l3invb12)['invoice_paths'])['first_node_id'] in (l1.info['id'], l2.info['id'])
979+
980+
l1.rpc.xpay(l3invb12)
981+
l1.rpc.xpay(l4invb12)

0 commit comments

Comments
 (0)