Skip to content

Commit 8141795

Browse files
Lagrang3rustyrussell
authored andcommitted
askrene-inform-channel: change order of operations
Change order of operations to ensure that askrene-inform-channel with inform=constrained computes the correct upper bound on the liquidity: upperBound = reserves + amount - 1 With the previous order of operations in the case amount=0 we would get: upperBound = reserves instead of upperBound = reserves - 1 Changelog-None Signed-off-by: Lagrang3 <[email protected]>
1 parent 52a9bb1 commit 8141795

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

plugins/askrene/askrene.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,11 +1036,11 @@ static struct command_result *json_askrene_inform_channel(struct command *cmd,
10361036
case INFORM_CONSTRAINED:
10371037
/* It didn't pass, so minimal assumption is that reserve was all used
10381038
* then there we were one msat short. */
1039-
if (!amount_msat_sub(amount, *amount, AMOUNT_MSAT(1)))
1040-
*amount = AMOUNT_MSAT(0);
10411039
if (!reserve_accumulate(askrene->reserved, scidd, amount))
10421040
return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
10431041
"Amount overflow with reserves");
1042+
if (!amount_msat_sub(amount, *amount, AMOUNT_MSAT(1)))
1043+
*amount = AMOUNT_MSAT(0);
10441044
if (command_check_only(cmd))
10451045
return command_check_done(cmd);
10461046
c = layer_add_constraint(layer, scidd, time_now().ts.tv_sec,

0 commit comments

Comments
 (0)