Skip to content

Commit 050b149

Browse files
committed
askrene: handle maxparts parameter values 1 and 0.
For 1, we use single-path. For 0, reject. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
1 parent 330f51a commit 050b149

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

plugins/askrene/askrene.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,12 @@ static struct command_result *do_getroutes(struct command *cmd,
639639
"Layer no_mpp_support is active we switch to a "
640640
"single path algorithm.");
641641
}
642+
if (rq->maxparts == 1 &&
643+
info->dev_algo != ALGO_SINGLE_PATH) {
644+
info->dev_algo = ALGO_SINGLE_PATH;
645+
rq_log(tmpctx, rq, LOG_DBG,
646+
"maxparts == 1: switching to a single path algorithm.");
647+
}
642648

643649
/* Compute the routes. At this point we might select between multiple
644650
* algorithms. Right now there is only one algorithm available. */
@@ -830,6 +836,11 @@ static struct command_result *json_getroutes(struct command *cmd,
830836
"amount must be non-zero");
831837
}
832838

839+
if (maxparts == 0) {
840+
return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
841+
"maxparts must be non-zero");
842+
}
843+
833844
if (*maxdelay > maxdelay_allowed) {
834845
return command_fail(cmd, PAY_USER_ERROR,
835846
"maximum delay allowed is %d",

0 commit comments

Comments
 (0)