Skip to content

Commit 49e4d09

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

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

plugins/offers_offer.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,12 @@ static struct command_result *found_best_peer_invrequest(struct command *cmd,
650650
const struct offers_data *od = get_offers_data(cmd->plugin);
651651

652652
if (!best) {
653+
/* Don't allow bare invoices if they explicitly told us to front */
654+
if (od->fronting_nodes) {
655+
return command_fail(cmd, LIGHTNINGD,
656+
"Could not find neighbour fronting node");
657+
}
658+
653659
/* FIXME: Make this a warning in the result! */
654660
plugin_log(cmd->plugin, LOG_UNUSUAL,
655661
"No incoming channel to public peer, so no blinded path for invoice request");
@@ -773,14 +779,12 @@ struct command_result *json_invoicerequest(struct command *cmd,
773779
* - MUST set `invreq_features`.`features` to the bitmap of features.
774780
*/
775781

776-
/* FIXME: We only set blinded path if private/noaddr, we should allow
777-
* setting otherwise! */
778782
if (we_want_blinded_path(cmd->plugin, false)) {
779783
struct invrequest_data *idata = tal(cmd, struct invrequest_data);
780784
idata->invreq = invreq;
781785
idata->single_use = *single_use;
782786
idata->label = label;
783-
return find_best_peer(cmd, OPT_ONION_MESSAGES, NULL,
787+
return find_best_peer(cmd, OPT_ONION_MESSAGES, od->fronting_nodes,
784788
found_best_peer_invrequest, idata);
785789
}
786790

tests/test_invoices.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -979,3 +979,12 @@ def test_payment_fronting(node_factory):
979979

980980
l1.rpc.xpay(l3invb12)
981981
l1.rpc.xpay(l4invb12)
982+
983+
# Balance so l3 can pay ->l1->l4.
984+
l3inv2 = l3.rpc.invoice(10000000, 'l3inv2', 'l3inv2')['bolt11']
985+
l1.rpc.xpay(l3inv2)
986+
987+
# When l3 creates an invoice request, it will also use the fronting nodes.
988+
l3invreq = l3.rpc.invoicerequest(amount=1000, description='l3invreq')['bolt12']
989+
assert only_one(l3.rpc.decode(l3invreq)['invreq_paths'])['first_node_id'] == l1.info['id']
990+
l4.rpc.sendinvoice(invreq=l3invreq, label='l3invreq')

0 commit comments

Comments
 (0)