Skip to content

Commit ce2f1f3

Browse files
committed
offers: honor payment-fronting-nodes when creating invoice_requests.
Signed-off-by: Rusty Russell <[email protected]>
1 parent 2f375f8 commit ce2f1f3

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
@@ -647,6 +647,12 @@ static struct command_result *found_best_peer_invrequest(struct command *cmd,
647647
const struct offers_data *od = get_offers_data(cmd->plugin);
648648

649649
if (!best) {
650+
/* Don't allow bare invoices if they explicitly told us to front */
651+
if (od->fronting_nodes) {
652+
return command_fail(cmd, LIGHTNINGD,
653+
"Could not find neighbour fronting node");
654+
}
655+
650656
/* FIXME: Make this a warning in the result! */
651657
plugin_log(cmd->plugin, LOG_UNUSUAL,
652658
"No incoming channel to public peer, so no blinded path for invoice request");
@@ -770,14 +776,12 @@ struct command_result *json_invoicerequest(struct command *cmd,
770776
* - MUST set `invreq_features`.`features` to the bitmap of features.
771777
*/
772778

773-
/* FIXME: We only set blinded path if private/noaddr, we should allow
774-
* setting otherwise! */
775779
if (we_want_blinded_path(cmd->plugin, false)) {
776780
struct invrequest_data *idata = tal(cmd, struct invrequest_data);
777781
idata->invreq = invreq;
778782
idata->single_use = *single_use;
779783
idata->label = label;
780-
return find_best_peer(cmd, OPT_ONION_MESSAGES, NULL,
784+
return find_best_peer(cmd, OPT_ONION_MESSAGES, od->fronting_nodes,
781785
found_best_peer_invrequest, idata);
782786
}
783787

tests/test_invoices.py

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

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

0 commit comments

Comments
 (0)