Skip to content

Commit 7200b8a

Browse files
committed
offers: allow explicit fronting nodes for an offer.
The next commit makes us honor these when issuing a payment. Changelog-Added: JSON-RPC: `offer` now has a `fronting-nodes` option to specify neighbors for payer to use to fetch invoices and make payments. Signed-off-by: Rusty Russell <[email protected]>
1 parent ce2f1f3 commit 7200b8a

File tree

12 files changed

+646
-574
lines changed

12 files changed

+646
-574
lines changed

.msggen.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3144,6 +3144,7 @@
31443144
"Offer.absolute_expiry": 6,
31453145
"Offer.amount": 1,
31463146
"Offer.description": 2,
3147+
"Offer.fronting_nodes[]": 15,
31473148
"Offer.issuer": 3,
31483149
"Offer.label": 4,
31493150
"Offer.optional_recurrence": 14,
@@ -11328,6 +11329,10 @@
1132811329
"added": "pre-v0.10.1",
1132911330
"deprecated": null
1133011331
},
11332+
"Offer.fronting_nodes[]": {
11333+
"added": "v25.12",
11334+
"deprecated": null
11335+
},
1133111336
"Offer.issuer": {
1133211337
"added": "pre-v0.10.1",
1133311338
"deprecated": null

cln-grpc/proto/node.proto

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cln-grpc/src/convert.rs

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cln-rpc/src/model.rs

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

contrib/msggen/msggen/schema.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26796,6 +26796,16 @@
2679626796
"Make recurrence optional, for backwards compatibility (older payers will only pay once)."
2679726797
]
2679826798
},
26799+
"fronting_nodes": {
26800+
"added": "v25.12",
26801+
"type": "array",
26802+
"items": {
26803+
"type": "pubkey"
26804+
},
26805+
"description": [
26806+
"An optional array of peer nodes to create blinded paths from. One of these blinded paths will also be used for the invoice, when they request it."
26807+
]
26808+
},
2679926809
"dev_paths": {
2680026810
"hidden": true
2680126811
}

contrib/pyln-client/pyln/client/lightning.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1129,7 +1129,7 @@ def newaddr(self, addresstype=None):
11291129

11301130
def offer(self, amount, description=None, issuer=None, label=None, quantity_max=None, absolute_expiry=None,
11311131
recurrence=None, recurrence_base=None, recurrence_paywindow=None, recurrence_limit=None,
1132-
single_use=None):
1132+
single_use=None, fronting_nodes=None):
11331133
"""
11341134
Create an offer (or returns an existing one), which is a precursor to creating one or more invoices.
11351135
It automatically enables the processing of an incoming invoice_request, and issuing of invoices.
@@ -1146,6 +1146,7 @@ def offer(self, amount, description=None, issuer=None, label=None, quantity_max=
11461146
"recurrence_paywindow": recurrence_paywindow,
11471147
"recurrence_limit": recurrence_limit,
11481148
"single_use": single_use,
1149+
"fronting_nodes": fronting_nodes,
11491150
}
11501151
return self.call("offer", payload)
11511152

contrib/pyln-grpc-proto/pyln/grpc/node_pb2.py

Lines changed: 556 additions & 556 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

doc/schemas/offer.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,16 @@
103103
"Make recurrence optional, for backwards compatibility (older payers will only pay once)."
104104
]
105105
},
106+
"fronting_nodes": {
107+
"added": "v25.12",
108+
"type": "array",
109+
"items": {
110+
"type": "pubkey"
111+
},
112+
"description": [
113+
"An optional array of peer nodes to create blinded paths from. One of these blinded paths will also be used for the invoice, when they request it."
114+
]
115+
},
106116
"dev_paths": {
107117
"hidden": true
108118
}

plugins/offers.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ struct gossmap *get_gossmap(struct plugin *plugin)
6262
* - MUST include `offer_paths` containing one or more paths to the node
6363
* from publicly reachable nodes.
6464
*/
65-
bool we_want_blinded_path(struct plugin *plugin, bool for_payment)
65+
bool we_want_blinded_path(struct plugin *plugin,
66+
const struct pubkey *fronting_nodes,
67+
bool for_payment)
6668
{
6769
const struct offers_data *od = get_offers_data(plugin);
6870
struct node_id local_nodeid;
@@ -77,7 +79,7 @@ bool we_want_blinded_path(struct plugin *plugin, bool for_payment)
7779
struct tlv_node_ann_tlvs *na_tlvs;
7880

7981
/* If we're fronting, we always want a blinded path */
80-
if (od->fronting_nodes)
82+
if (fronting_nodes)
8183
return true;
8284

8385
node_id_from_pubkey(&local_nodeid, &od->id);
@@ -316,7 +318,7 @@ struct find_best_peer_data {
316318
const struct chaninfo *,
317319
void *);
318320
int needed_feature;
319-
const struct pubkey *fronting_only;
321+
const struct pubkey *fronting_nodes;
320322
void *arg;
321323
};
322324

@@ -374,8 +376,8 @@ static struct command_result *listincoming_done(struct command *cmd,
374376
}
375377
ci.feebase = feebase.millisatoshis; /* Raw: feebase */
376378

377-
if (data->fronting_only) {
378-
if (!is_in_pubkeys(data->fronting_only, &ci.id))
379+
if (data->fronting_nodes) {
380+
if (!is_in_pubkeys(data->fronting_nodes, &ci.id))
379381
continue;
380382

381383
/* If disconnected, don't eliminate, simply
@@ -411,7 +413,7 @@ static struct command_result *listincoming_done(struct command *cmd,
411413

412414
struct command_result *find_best_peer_(struct command *cmd,
413415
int needed_feature,
414-
const struct pubkey *fronting_only,
416+
const struct pubkey *fronting_nodes,
415417
struct command_result *(*cb)(struct command *,
416418
const struct chaninfo *,
417419
void *),
@@ -422,7 +424,10 @@ struct command_result *find_best_peer_(struct command *cmd,
422424
data->cb = cb;
423425
data->arg = arg;
424426
data->needed_feature = needed_feature;
425-
data->fronting_only = fronting_only;
427+
if (fronting_nodes)
428+
data->fronting_nodes = tal_dup_talarr(data, struct pubkey, fronting_nodes);
429+
else
430+
data->fronting_nodes = NULL;
426431
req = jsonrpc_request_start(cmd, "listincoming",
427432
listincoming_done, forward_error, data);
428433
return send_outreq(req);

plugins/offers.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,20 +86,22 @@ struct chaninfo {
8686
/* Calls listpeerchannels, then cb with best peer (if any!) which has needed_feature */
8787
struct command_result *find_best_peer_(struct command *cmd,
8888
int needed_feature,
89-
const struct pubkey *fronting_only,
89+
const struct pubkey *fronting_nodes,
9090
struct command_result *(*cb)(struct command *,
9191
const struct chaninfo *,
9292
void *),
9393
void *arg);
9494

95-
#define find_best_peer(cmd, needed_feature, fronting_only, cb, arg) \
96-
find_best_peer_((cmd), (needed_feature), (fronting_only), \
95+
#define find_best_peer(cmd, needed_feature, fronting_nodes, cb, arg) \
96+
find_best_peer_((cmd), (needed_feature), (fronting_nodes), \
9797
typesafe_cb_preargs(struct command_result *, void *, \
9898
(cb), (arg), \
9999
struct command *, \
100100
const struct chaninfo *), \
101101
(arg))
102102

103103
/* Do we want a blinded path from a peer? */
104-
bool we_want_blinded_path(struct plugin *plugin, bool for_payment);
104+
bool we_want_blinded_path(struct plugin *plugin,
105+
const struct pubkey *fronting_nodes,
106+
bool for_payment);
105107
#endif /* LIGHTNING_PLUGINS_OFFERS_H */

0 commit comments

Comments
 (0)