Skip to content

Commit 9afc10b

Browse files
Lagrang3ShahanaFarooqui
authored andcommitted
renepay: add cli option exclude
msggen cannot handle the complex type in renepay-exclude, therefore I added a rule override for it, just like pay-exclude. ``` msggen cln-grpc/proto/node.proto Traceback (most recent call last): File "/home/rusty/devel/cvs/lightning/contrib/msggen/msggen/__main__.py", line 131, in <module> main() File "/home/rusty/devel/cvs/lightning/contrib/msggen/msggen/__main__.py", line 115, in main run() File "/home/rusty/devel/cvs/lightning/contrib/msggen/msggen/__main__.py", line 72, in run service = load_jsonrpc_service( ^^^^^^^^^^^^^^^^^^^^^ File "/home/rusty/devel/cvs/lightning/contrib/msggen/msggen/utils/utils.py", line 241, in load_jsonrpc_service methods = [load_jsonrpc_method(name) for name in grpc_method_names] ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/rusty/devel/cvs/lightning/contrib/msggen/msggen/utils/utils.py", line 209, in load_jsonrpc_method request = CompositeField.from_js(schema["methods"][rpc_name]['request'], path=name) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/rusty/devel/cvs/lightning/contrib/msggen/msggen/model.py", line 297, in from_js field = ArrayField.from_js(fpath, ftype) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/rusty/devel/cvs/lightning/contrib/msggen/msggen/model.py", line 464, in from_js itemtype = UnionField.from_js(child_js, path) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/rusty/devel/cvs/lightning/contrib/msggen/msggen/model.py", line 393, in from_js itemtype = PrimitiveField( ^^^^^^^^^^^^^^^ TypeError: PrimitiveField.__init__() missing 2 required positional arguments: 'added' and 'deprecated' ``` Signed-off-by: Lagrang3 <[email protected]> Changelog-EXPERIMENTAL: renepay: add cli option "exclude" to manually disable channels and nodes.
1 parent 44d53dc commit 9afc10b

File tree

11 files changed

+444
-370
lines changed

11 files changed

+444
-370
lines changed

.msggen.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2842,6 +2842,7 @@
28422842
"RenePay.amount_msat": 2,
28432843
"RenePay.description": 6,
28442844
"RenePay.dev_use_shadow": 8,
2845+
"RenePay.exclude": 9,
28452846
"RenePay.invstring": 1,
28462847
"RenePay.label": 7,
28472848
"RenePay.maxdelay": 4,
@@ -10097,6 +10098,10 @@
1009710098
"added": "pre-v0.10.1",
1009810099
"deprecated": null
1009910100
},
10101+
"RenePay.exclude": {
10102+
"added": "v24.08",
10103+
"deprecated": null
10104+
},
1010010105
"RenePay.invstring": {
1010110106
"added": "pre-v0.10.1",
1010210107
"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/model.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,7 @@ def __str__(self):
500500
DatastoreUsageKeyField = ArrayField(itemtype=PrimitiveField("string", None, None, added="v23.11", deprecated=None), dims=1, path=None, description=None, added="v23.11", deprecated=None)
501501
InvoiceExposeprivatechannelsField = ArrayField(itemtype=PrimitiveField("short_channel_id", None, None, added=None, deprecated=None), dims=1, path=None, description=None, added=None, deprecated=None)
502502
PayExclude = ArrayField(itemtype=PrimitiveField("string", None, None, added=None, deprecated=None), dims=1, path=None, description=None, added=None, deprecated=None)
503+
RenePayExclude = ArrayField(itemtype=PrimitiveField("string", None, None, added=None, deprecated=None), dims=1, path=None, description=None, added="v24.08", deprecated=None)
503504
RoutehintListField = PrimitiveField(
504505
"RoutehintList",
505506
None,
@@ -539,6 +540,7 @@ def __str__(self):
539540
'ListDatastore.key': DatastoreKeyField,
540541
'Invoice.exposeprivatechannels': InvoiceExposeprivatechannelsField,
541542
'Pay.exclude': PayExclude,
543+
'RenePay.exclude': RenePayExclude,
542544
'KeySend.routehints': RoutehintListField,
543545
'KeySend.extratlvs': TlvStreamField,
544546
'Decode.routes': DecodeRoutehintListField,

contrib/msggen/msggen/schema.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28620,6 +28620,24 @@
2862028620
"Used to attach a label to payments, and is returned in lightning-listpays(7) and lightning-listsendpays(7)."
2862128621
]
2862228622
},
28623+
"exclude": {
28624+
"added": "v24.08",
28625+
"type": "array",
28626+
"description": [
28627+
"*exclude* is a JSON array of short-channel-id/direction (e.g. [ '564334x877x1/0', '564195x1292x0/1' ]) or pubkey which should be excluded from consideration for routing."
28628+
],
28629+
"default": "not to exclude any channels or nodes",
28630+
"items": {
28631+
"oneOf": [
28632+
{
28633+
"type": "short_channel_id_dir"
28634+
},
28635+
{
28636+
"type": "pubkey"
28637+
}
28638+
]
28639+
}
28640+
},
2862328641
"dev_use_shadow": {
2862428642
"hidden": true,
2862528643
"type": "boolean"

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

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

doc/schemas/lightning-renepay.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,24 @@
6060
"Used to attach a label to payments, and is returned in lightning-listpays(7) and lightning-listsendpays(7)."
6161
]
6262
},
63+
"exclude": {
64+
"added": "v24.08",
65+
"type": "array",
66+
"description": [
67+
"*exclude* is a JSON array of short-channel-id/direction (e.g. [ '564334x877x1/0', '564195x1292x0/1' ]) or pubkey which should be excluded from consideration for routing."
68+
],
69+
"default": "not to exclude any channels or nodes",
70+
"items": {
71+
"oneOf": [
72+
{
73+
"type": "short_channel_id_dir"
74+
},
75+
{
76+
"type": "pubkey"
77+
}
78+
]
79+
}
80+
},
6381
"dev_use_shadow": {
6482
"hidden": true,
6583
"type": "boolean"

plugins/renepay/main.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ static struct command_result *json_pay(struct command *cmd, const char *buf,
173173
u32 *retryfor;
174174
const char *description;
175175
const char *label;
176+
struct route_exclusion **exclusions;
176177

177178
// dev options
178179
bool *use_shadow;
@@ -198,6 +199,7 @@ static struct command_result *json_pay(struct command *cmd, const char *buf,
198199
60), // 60 seconds
199200
p_opt("description", param_string, &description),
200201
p_opt("label", param_string, &label),
202+
p_opt("exclude", param_route_exclusion_array, &exclusions),
201203

202204
// FIXME add support for offers
203205
// p_opt("localofferid", param_sha256, &local_offer_id),
@@ -313,7 +315,8 @@ static struct command_result *json_pay(struct command *cmd, const char *buf,
313315
*prob_cost_factor_millionths,
314316
*riskfactor_millionths,
315317
*min_prob_success_millionths,
316-
use_shadow);
318+
use_shadow,
319+
cast_const2(const struct route_exclusion**, exclusions));
317320

318321
if (!payment)
319322
return command_fail(cmd, PLUGIN_ERROR,
@@ -349,7 +352,8 @@ static struct command_result *json_pay(struct command *cmd, const char *buf,
349352
*prob_cost_factor_millionths,
350353
*riskfactor_millionths,
351354
*min_prob_success_millionths,
352-
use_shadow))
355+
use_shadow,
356+
cast_const2(const struct route_exclusion**, exclusions)))
353357
return command_fail(
354358
cmd, PLUGIN_ERROR,
355359
"failed to update the payment parameters");

plugins/renepay/payment.c

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ struct payment *payment_new(
3232
u64 prob_cost_factor_millionths,
3333
u64 riskfactor_millionths,
3434
u64 min_prob_success_millionths,
35-
bool use_shadow)
35+
bool use_shadow,
36+
const struct route_exclusion **exclusions)
3637
{
3738
struct payment *p = tal(ctx, struct payment);
3839
struct payment_info *pinfo = &p->payment_info;
@@ -101,6 +102,14 @@ struct payment *payment_new(
101102
p->local_gossmods = NULL;
102103
p->disabledmap = disabledmap_new(p);
103104

105+
for (size_t i = 0; i < tal_count(exclusions); i++) {
106+
const struct route_exclusion *ex = exclusions[i];
107+
if (ex->type == EXCLUDE_CHANNEL)
108+
disabledmap_add_channel(p->disabledmap, ex->u.chan_id);
109+
else
110+
disabledmap_add_node(p->disabledmap, ex->u.node_id);
111+
}
112+
104113
p->have_results = false;
105114
p->retry = false;
106115
p->waitresult_timer = NULL;
@@ -137,7 +146,8 @@ bool payment_update(
137146
u64 prob_cost_factor_millionths,
138147
u64 riskfactor_millionths,
139148
u64 min_prob_success_millionths,
140-
bool use_shadow)
149+
bool use_shadow,
150+
const struct route_exclusion **exclusions)
141151
{
142152
assert(p);
143153
struct payment_info *pinfo = &p->payment_info;
@@ -192,6 +202,14 @@ bool payment_update(
192202
assert(p->disabledmap);
193203
disabledmap_reset(p->disabledmap);
194204

205+
for (size_t i = 0; i < tal_count(exclusions); i++) {
206+
const struct route_exclusion *ex = exclusions[i];
207+
if (ex->type == EXCLUDE_CHANNEL)
208+
disabledmap_add_channel(p->disabledmap, ex->u.chan_id);
209+
else
210+
disabledmap_add_node(p->disabledmap, ex->u.node_id);
211+
}
212+
195213
p->have_results = false;
196214
p->retry = false;
197215
p->waitresult_timer = tal_free(p->waitresult_timer);

0 commit comments

Comments
 (0)