diff --git a/plugins/libplugin-pay.c b/plugins/libplugin-pay.c index 3ca2a253f..6769b4a74 100644 --- a/plugins/libplugin-pay.c +++ b/plugins/libplugin-pay.c @@ -3476,14 +3476,20 @@ static void presplit_cb(struct presplit_mod_data *d, struct payment *p) if (htlcs >= PRESPLIT_MAX_HTLC_SHARE) htlcs /= PRESPLIT_MAX_HTLC_SHARE; + int targethtlcs = + p->amount.millisatoshis / target_amount; /* Raw: division */ if (htlcs == 0) { p->abort = true; return payment_fail( p, "Cannot attempt payment, we have no channel to " "which we can add an HTLC"); - } else if (p->amount.millisatoshis / target_amount > htlcs) /* Raw: division */ - target = amount_msat_div(p->amount, htlcs); - else + } else if (targethtlcs > htlcs) { + paymod_log(p, LOG_INFORM, + "Number of pre-split HTLCs (%d) exceeds our " + "HTLC budget (%d), skipping pre-splitter", + targethtlcs, htlcs); + return payment_continue(p); + } else target = amount_msat(target_amount); /* If we are already below the target size don't split it diff --git a/tests/test_pay.py b/tests/test_pay.py index f49ac5250..c701c38d4 100644 --- a/tests/test_pay.py +++ b/tests/test_pay.py @@ -4294,7 +4294,6 @@ gives a routehint straight to us causes an issue l2.rpc.pay(inv) -@pytest.mark.xfail(strict=True) def test_pay_low_max_htlcs(node_factory): """Test we can pay if *any* HTLC slots are available""" @@ -4302,3 +4301,6 @@ def test_pay_low_max_htlcs(node_factory): opts={'max-concurrent-htlcs': 1}, wait_for_announce=True) l1.rpc.pay(l3.rpc.invoice(FUNDAMOUNT * 50, "test", "test")['bolt11']) + l1.daemon.wait_for_log( + r'Number of pre-split HTLCs \([0-9]+\) exceeds our HTLC budget \([0-9]+\), skipping pre-splitter' + )