Skip to content

Commit c520fad

Browse files
committed
xpay: avoid MPP if invoice does not allow it.
This is deeply annoying, and we may have to support this properly (using a separate algorithm entirely) if other implementations don't fix their crap. Signed-off-by: Rusty Russell <[email protected]> Changelog-Fixed: Plugins: xpay: suppress multi-part payment if invoice doesn't allow it (please, fix your nodes!)
1 parent 1ca31f4 commit c520fad

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

plugins/xpay/xpay.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ struct payment {
7676
struct amount_msat maxfee;
7777
/* Maximum delay on the route we're ok with */
7878
u32 *maxdelay;
79+
/* Do we have to do it all in a single part? */
80+
bool disable_mpp;
7981
/* BOLT11 payment secret (NULL for BOLT12, it uses blinded paths) */
8082
const struct secret *payment_secret;
8183
/* BOLT11 payment metadata (NULL for BOLT12, it uses blinded paths) */
@@ -1192,6 +1194,8 @@ static struct command_result *getroutes_for(struct command *aux_cmd,
11921194
/* Add user-specified layers */
11931195
for (size_t i = 0; i < tal_count(payment->layers); i++)
11941196
json_add_string(req->js, NULL, payment->layers[i]);
1197+
if (payment->disable_mpp)
1198+
json_add_string(req->js, NULL, "auto.no_mpp_support");
11951199
json_array_end(req->js);
11961200
json_add_amount_msat(req->js, "maxfee_msat", maxfee);
11971201
json_add_u32(req->js, "final_cltv", payment->final_cltv);
@@ -1457,6 +1461,11 @@ preapproveinvoice_succeed(struct command *cmd,
14571461
payment->unique_id = xpay->counter++;
14581462
payment->private_layer = tal_fmt(payment,
14591463
"xpay-%"PRIu64, payment->unique_id);
1464+
1465+
/* Now unique_id is set, we can log this message */
1466+
if (payment->disable_mpp)
1467+
payment_log(payment, LOG_INFORM, "No MPP support: this is going to be hard to pay");
1468+
14601469
return populate_private_layer(cmd, payment);
14611470
}
14621471

@@ -1551,6 +1560,7 @@ static struct command_result *json_xpay_core(struct command *cmd,
15511560
if (payment->payinfos[i]->cltv_expiry_delta > payment->final_cltv)
15521561
payment->final_cltv = payment->payinfos[i]->cltv_expiry_delta;
15531562
}
1563+
payment->disable_mpp = false;
15541564
} else {
15551565
struct bolt11 *b11
15561566
= bolt11_decode(tmpctx, payment->invstring,
@@ -1586,6 +1596,7 @@ static struct command_result *json_xpay_core(struct command *cmd,
15861596
else
15871597
payment->full_amount = *msat;
15881598

1599+
payment->disable_mpp = !feature_offered(b11->features, OPT_BASIC_MPP);
15891600
if (amount_msat_is_zero(payment->full_amount))
15901601
return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
15911602
"Cannot pay bolt11 invoice with zero amount");

tests/test_xpay.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,6 @@ def test_xpay_zeroconf(node_factory):
621621
l1.rpc.xpay(b12)
622622

623623

624-
@pytest.mark.xfail(strict=True)
625624
def test_xpay_no_mpp(node_factory, chainparams):
626625
"""Suppress mpp, resulting in a single payment part"""
627626
l1, l2, l3, l4 = node_factory.get_nodes(4)

0 commit comments

Comments
 (0)