Skip to content

Commit cff488d

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

2 files changed

Lines changed: 17 additions & 3 deletions

File tree

plugins/offers_offer.c

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

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

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

783788
return call_createinvoicerequest(cmd, invreq, *single_use, label);

tests/test_invoices.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -986,6 +986,15 @@ def test_payment_fronting(node_factory):
986986
l1.rpc.xpay(l3invb12)
987987
l1.rpc.xpay(l4invb12)
988988

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

990999
def test_invoice_maxdesc(node_factory, chainparams):
9911000
l1, l2 = node_factory.line_graph(2)

0 commit comments

Comments
 (0)