Skip to content

Commit 0e9598f

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 a55255e commit 0e9598f

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

plugins/xpay/xpay.c

Lines changed: 9 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);
@@ -1551,6 +1555,7 @@ static struct command_result *json_xpay_core(struct command *cmd,
15511555
if (payment->payinfos[i]->cltv_expiry_delta > payment->final_cltv)
15521556
payment->final_cltv = payment->payinfos[i]->cltv_expiry_delta;
15531557
}
1558+
payment->disable_mpp = false;
15541559
} else {
15551560
struct bolt11 *b11
15561561
= bolt11_decode(tmpctx, payment->invstring,
@@ -1586,12 +1591,16 @@ static struct command_result *json_xpay_core(struct command *cmd,
15861591
else
15871592
payment->full_amount = *msat;
15881593

1594+
payment->disable_mpp = !feature_offered(b11->features, OPT_BASIC_MPP);
15891595
if (amount_msat_is_zero(payment->full_amount))
15901596
return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
15911597
"Cannot pay bolt11 invoice with zero amount");
15921598
invexpiry = b11->timestamp + b11->expiry;
15931599
}
15941600

1601+
if (payment->disable_mpp)
1602+
payment_log(payment, LOG_INFORM, "No MPP support: this is going to be hard to pay");
1603+
15951604
now = time_now().ts.tv_sec;
15961605
if (now > invexpiry)
15971606
return command_fail(cmd, PAY_INVOICE_EXPIRED,

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)