pay: Skip the presplitter mod if it'd exhaust our HTLC budget
Changelog-Fixed: pay: The presplitter mod will no longer exhaust the HTLC budget.
This commit is contained in:
parent
803c048a1f
commit
5e1fadf799
|
@ -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
|
||||
|
|
|
@ -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'
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue