plugin/pay: prevent presplitter from dividing if max already tiny.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2021-05-28 13:56:33 +09:30
parent 05a3be15a3
commit d4def7e73a

View File

@ -3446,7 +3446,7 @@ static void presplit_cb(struct presplit_mod_data *d, struct payment *p)
/* The presplitter only acts on the root and only in the first
* step. */
size_t count = 0;
u32 htlcs = payment_max_htlcs(p) / PRESPLIT_MAX_HTLC_SHARE;
u32 htlcs;
struct amount_msat target, amt = p->amount;
char *partids = tal_strdup(tmpctx, "");
u64 target_amount = MPP_TARGET_SIZE;
@ -3471,6 +3471,11 @@ static void presplit_cb(struct presplit_mod_data *d, struct payment *p)
* but makes debugging a bit easier. */
root->next_partid++;
htlcs = payment_max_htlcs(p);
/* Divide it up if we can, but it might be v low already */
if (htlcs >= PRESPLIT_MAX_HTLC_SHARE)
htlcs /= PRESPLIT_MAX_HTLC_SHARE;
if (htlcs == 0) {
p->abort = true;
return payment_fail(