Skip to content

Commit 8e05e32

Browse files
committed
xpay: add maxparts option
Changelog-Added: xpay: a command line option "maxparts" to limit the number of pending routes at any given time. Signed-off-by: Lagrang3 <[email protected]>
1 parent 6c0f5e2 commit 8e05e32

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

doc/schemas/xpay.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,14 @@
6565
"A payment may be delayed for up to `maxdelay` blocks by another node; clients should be prepared for this worst case."
6666
],
6767
"default": "2016"
68+
},
69+
"maxparts": {
70+
"type": "u32",
71+
"added": "v25.09",
72+
"description": [
73+
"Maximum number of pending routes at any given time."
74+
],
75+
"default": "6"
6876
}
6977
}
7078
},

plugins/xpay/xpay.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ struct payment {
7878
struct amount_msat maxfee;
7979
/* Maximum delay on the route we're ok with */
8080
u32 *maxdelay;
81+
/* Maximum number of payment routes that can be pending. */
82+
u32 *maxparts;
8183
/* Do we have to do it all in a single part? */
8284
bool disable_mpp;
8385
/* BOLT11 payment secret (NULL for BOLT12, it uses blinded paths) */
@@ -113,6 +115,9 @@ struct payment {
113115
* call outstanding). */
114116
struct amount_msat amount_being_routed;
115117

118+
/* Number of routes attempted and pending */
119+
u32 pending_attempts;
120+
116121
/* Useful information from prior attempts if any. */
117122
char *prior_results;
118123

@@ -1281,6 +1286,9 @@ static struct command_result *getroutes_for(struct command *aux_cmd,
12811286
json_add_amount_msat(req->js, "maxfee_msat", maxfee);
12821287
json_add_u32(req->js, "final_cltv", payment->final_cltv);
12831288
json_add_u32(req->js, "maxdelay", *payment->maxdelay);
1289+
// FIXME: deduce pending_attempts: total - failed
1290+
json_add_u32(req->js, "maxparts",
1291+
*payment->maxparts - payment->pending_attempts);
12841292

12851293
return send_payment_req(aux_cmd, payment, req);
12861294
}
@@ -1571,6 +1579,7 @@ static struct command_result *json_xpay_core(struct command *cmd,
15711579
p_opt_def("retry_for", param_number, &retryfor, 60),
15721580
p_opt("partial_msat", param_msat, &partial),
15731581
p_opt_def("maxdelay", param_u32, &payment->maxdelay, 2016),
1582+
p_opt_def("maxparts", param_u32, &payment->maxparts, 6),
15741583
NULL))
15751584
return command_param_failed();
15761585

@@ -1579,6 +1588,7 @@ static struct command_result *json_xpay_core(struct command *cmd,
15791588
payment->plugin = cmd->plugin;
15801589
payment->cmd = cmd;
15811590
payment->amount_being_routed = AMOUNT_MSAT(0);
1591+
payment->pending_attempts = 0;
15821592
payment->group_id = pseudorand(INT64_MAX);
15831593
payment->total_num_attempts = payment->num_failures = 0;
15841594
payment->requests = tal_arr(payment, struct out_req *, 0);

0 commit comments

Comments
 (0)