Skip to content

Commit 52a8b8f

Browse files
committed
paymod: Update step before creating child payments
The child payments will sometimes depend on the step of the parent, and making sure that the parent state is correct before we create the children is therefore important.
1 parent 2556df5 commit 52a8b8f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

plugins/libplugin-pay.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1607,9 +1607,9 @@ static inline void retry_step_cb(struct retry_mod_data *rd,
16071607

16081608
/* If the failure was not final, and we tried a route, try again. */
16091609
if (rdata->retries > 0) {
1610+
payment_set_step(p, PAYMENT_STEP_RETRY);
16101611
subpayment = payment_new(p, NULL, p, p->modifiers);
16111612
payment_start(subpayment);
1612-
payment_set_step(p, PAYMENT_STEP_RETRY);
16131613
subpayment->why =
16141614
tal_fmt(subpayment, "Still have %d attempts left",
16151615
rdata->retries - 1);
@@ -2600,6 +2600,7 @@ static void presplit_cb(struct presplit_mod_data *d, struct payment *p)
26002600
if (amount_msat_greater(target, p->amount))
26012601
return payment_continue(p);
26022602

2603+
payment_set_step(p, PAYMENT_STEP_SPLIT);
26032604
/* Ok, we know we should split, so split here and then skip this
26042605
* payment and start the children instead. */
26052606
while (!amount_msat_eq(amt, AMOUNT_MSAT(0))) {
@@ -2636,7 +2637,6 @@ static void presplit_cb(struct presplit_mod_data *d, struct payment *p)
26362637
count,
26372638
type_to_string(tmpctx, struct amount_msat, &root->amount),
26382639
type_to_string(tmpctx, struct amount_msat, &target));
2639-
payment_set_step(p, PAYMENT_STEP_SPLIT);
26402640
plugin_log(p->plugin, LOG_INFORM, "%s", p->why);
26412641
}
26422642
payment_continue(p);
@@ -2734,6 +2734,7 @@ static void adaptive_splitter_cb(struct adaptive_split_mod_data *d, struct payme
27342734
"allowed by our channels");
27352735
}
27362736

2737+
p->step = PAYMENT_STEP_SPLIT;
27372738
a = payment_new(p, NULL, p, p->modifiers);
27382739
b = payment_new(p, NULL, p, p->modifiers);
27392740

@@ -2758,7 +2759,6 @@ static void adaptive_splitter_cb(struct adaptive_split_mod_data *d, struct payme
27582759

27592760
payment_start(a);
27602761
payment_start(b);
2761-
p->step = PAYMENT_STEP_SPLIT;
27622762

27632763
/* Take note that we now have an additional split that
27642764
* may end up using an HTLC. */

0 commit comments

Comments
 (0)