Skip to content

Commit 64e4519

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 <rusty@rustcorp.com.au>
1 parent cff488d commit 64e4519

12 files changed

Lines changed: 704 additions & 626 deletions

File tree

.msggen.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3337,6 +3337,7 @@
33373337
"Offer.absolute_expiry": 6,
33383338
"Offer.amount": 1,
33393339
"Offer.description": 2,
3340+
"Offer.fronting_nodes[]": 15,
33403341
"Offer.issuer": 3,
33413342
"Offer.label": 4,
33423343
"Offer.optional_recurrence": 14,
@@ -11988,6 +11989,10 @@
1198811989
"added": "pre-v0.10.1",
1198911990
"deprecated": null
1199011991
},
11992+
"Offer.fronting_nodes[]": {
11993+
"added": "v26.04",
11994+
"deprecated": null
11995+
},
1199111996
"Offer.issuer": {
1199211997
"added": "pre-v0.10.1",
1199311998
"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: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27735,6 +27735,17 @@
2773527735
"Make recurrence optional, for backwards compatibility (older payers will only pay once)."
2773627736
]
2773727737
},
27738+
"fronting_nodes": {
27739+
"added": "v26.04",
27740+
"type": "array",
27741+
"items": {
27742+
"type": "pubkey"
27743+
},
27744+
"description": [
27745+
"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. This overrides the `payment-fronting-node` configuration setting. If set to the empty array, this means *no fronting nodes*."
27746+
],
27747+
"default": "The `payment-fronting-node` configuration setting"
27748+
},
2773827749
"dev_paths": {
2773927750
"hidden": true
2774027751
}

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

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

11211121
def offer(self, amount, description=None, issuer=None, label=None, quantity_max=None, absolute_expiry=None,
11221122
recurrence=None, recurrence_base=None, recurrence_paywindow=None, recurrence_limit=None,
1123-
single_use=None):
1123+
single_use=None, fronting_nodes=None):
11241124
"""
11251125
Create an offer (or returns an existing one), which is a precursor to creating one or more invoices.
11261126
It automatically enables the processing of an incoming invoice_request, and issuing of invoices.
@@ -1137,6 +1137,7 @@ def offer(self, amount, description=None, issuer=None, label=None, quantity_max=
11371137
"recurrence_paywindow": recurrence_paywindow,
11381138
"recurrence_limit": recurrence_limit,
11391139
"single_use": single_use,
1140+
"fronting_nodes": fronting_nodes,
11401141
}
11411142
return self.call("offer", payload)
11421143

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

Lines changed: 608 additions & 608 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: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,17 @@
103103
"Make recurrence optional, for backwards compatibility (older payers will only pay once)."
104104
]
105105
},
106+
"fronting_nodes": {
107+
"added": "v26.04",
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. This overrides the `payment-fronting-node` configuration setting. If set to the empty array, this means *no fronting nodes*."
114+
],
115+
"default": "The `payment-fronting-node` configuration setting"
116+
},
106117
"dev_paths": {
107118
"hidden": true
108119
}

plugins/offers.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ struct gossmap *get_gossmap(struct plugin *plugin)
6464
* - MUST include `offer_paths` containing one or more paths to the node
6565
* from publicly reachable nodes.
6666
*/
67-
bool we_want_blinded_path(struct plugin *plugin, bool for_payment)
67+
bool we_want_blinded_path(struct plugin *plugin,
68+
const struct pubkey *fronting_nodes,
69+
bool for_payment)
6870
{
6971
const struct offers_data *od = get_offers_data(plugin);
7072
struct node_id local_nodeid;
@@ -79,7 +81,7 @@ bool we_want_blinded_path(struct plugin *plugin, bool for_payment)
7981
struct tlv_node_ann_tlvs *na_tlvs;
8082

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

8587
node_id_from_pubkey(&local_nodeid, &od->id);
@@ -318,7 +320,7 @@ struct find_best_peer_data {
318320
const struct chaninfo *,
319321
void *);
320322
u64 needed_features;
321-
const struct pubkey *fronting_only;
323+
const struct pubkey *fronting_nodes;
322324
void *arg;
323325
};
324326

@@ -377,8 +379,8 @@ static struct command_result *listincoming_done(struct command *cmd,
377379
}
378380
ci.feebase = feebase.millisatoshis; /* Raw: feebase */
379381

380-
if (data->fronting_only) {
381-
if (!is_in_pubkeys(data->fronting_only, &ci.id))
382+
if (data->fronting_nodes) {
383+
if (!is_in_pubkeys(data->fronting_nodes, &ci.id))
382384
continue;
383385

384386
/* If disconnected, don't eliminate, simply
@@ -423,7 +425,7 @@ static struct command_result *listincoming_done(struct command *cmd,
423425

424426
struct command_result *find_best_peer_(struct command *cmd,
425427
u64 needed_features,
426-
const struct pubkey *fronting_only,
428+
const struct pubkey *fronting_nodes,
427429
struct command_result *(*cb)(struct command *,
428430
const struct chaninfo *,
429431
void *),
@@ -434,7 +436,10 @@ struct command_result *find_best_peer_(struct command *cmd,
434436
data->cb = cb;
435437
data->arg = arg;
436438
data->needed_features = needed_features;
437-
data->fronting_only = fronting_only;
439+
if (fronting_nodes)
440+
data->fronting_nodes = tal_dup_talarr(data, struct pubkey, fronting_nodes);
441+
else
442+
data->fronting_nodes = NULL;
438443
req = jsonrpc_request_start(cmd, "listincoming",
439444
listincoming_done, forward_error, data);
440445
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
u64 needed_features,
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_features, fronting_only, cb, arg) \
96-
find_best_peer_((cmd), (needed_features), (fronting_only), \
95+
#define find_best_peer(cmd, needed_features, fronting_nodes, cb, arg) \
96+
find_best_peer_((cmd), (needed_features), (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)