Skip to content

Commit 0d2b5f0

Browse files
committed
xpay: in future, don't MPP to pay bolt12 invoices unless invoice explicitly says so.
We don't want to enable this yet, since we only just fixed CLN this release! Signed-off-by: Rusty Russell <[email protected]>
1 parent 55b7c81 commit 0d2b5f0

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

doc/developers-guide/deprecations.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ hidden: false
3737
| close.tx | Field | v24.11 | v25.11 | Use txs array instead |
3838
| close.txid | Field | v24.11 | v25.11 | Use txids array instead |
3939
| experimental-offers | Config | v24.11 | v25.05 | Now the default |
40+
| xpay.ignore_bolt12_mpp | Field | v25.05 | v25.11 | Try MPP even if the BOLT12 invoice doesn't explicitly allow it (CLN didn't until 25.02) |
4041

4142
Inevitably there are features which need to change: either to be generalized, or removed when they can no longer be supported.
4243

plugins/xpay/xpay.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1555,7 +1555,10 @@ static struct command_result *json_xpay_core(struct command *cmd,
15551555
if (payment->payinfos[i]->cltv_expiry_delta > payment->final_cltv)
15561556
payment->final_cltv = payment->payinfos[i]->cltv_expiry_delta;
15571557
}
1558-
payment->disable_mpp = false;
1558+
/* We will start honoring this flag in future */
1559+
payment->disable_mpp = !feature_offered(b12inv->invoice_features, OPT_BASIC_MPP);
1560+
if (payment->disable_mpp && command_deprecated_in_ok(cmd, "ignore_bolt12_mpp", "v25.05", "v25.11"))
1561+
payment->disable_mpp = false;
15591562
} else {
15601563
struct bolt11 *b11
15611564
= bolt11_decode(tmpctx, payment->invstring,

tests/test_xpay.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -649,3 +649,27 @@ def test_xpay_no_mpp(node_factory, chainparams):
649649
assert ret['successful_parts'] == 1
650650
assert ret['amount_msat'] == AMOUNT
651651
assert ret['amount_sent_msat'] == AMOUNT + AMOUNT // 100000 + 1
652+
653+
654+
def test_xpay_bolt12_no_mpp(node_factory, chainparams):
655+
"""We should not (yet!) avoid mpp if BOLT12 invoice doesn't say we should"""
656+
l1, l2, l3, l4 = node_factory.get_nodes(4)
657+
node_factory.join_nodes([l1, l2, l3], wait_for_announce=True)
658+
node_factory.join_nodes([l1, l4, l3], wait_for_announce=True)
659+
660+
# Amount needs to be enought that it bothers splitting, but not
661+
# so much that it can't pay without mpp.
662+
AMOUNT = 500000000
663+
664+
# We create a version of this which doesn't advertize support for MPP
665+
# (I grabbed this from a real instance)
666+
inv = l3.rpc.createinvoice(invstring="lni1qqg00rlfqualt5wvj9meezlx202qwq3qqc3xu3s3rg94nj40zfsy866mhu5vxne6tcej5878k2mneuvgjy8sspqae4jsqzshw3jhxazl0pcxz72lvfhkcap3xf0kum6ld4c8q93pqdwjkyvjm7apxnssu4qgwhfkd67ghs6n6k48v6uqczgt88p6tky965pqqc3xu3s3rg94nj40zfsy866mhu5vxne6tcej5878k2mneuvgjy84sggrv4a2zv5mfvds5pz9ehe40uws375pc4u6ausees3xuezw7d4kssx6gpr854lme2pqavazfzxk4pgv4pvnamxv7e26787e3zm53kpek3qzmpjx50jc6t625pqae4jspvppqdwjkyvjm7apxnssu4qgwhfkd67ghs6n6k48v6uqczgt88p6tky96",
667+
preimage="637f5b64ae540986826288ed24db980e756b2eb680b6db17f1072643c12ae531",
668+
label="b53c2f55f53a0f979df864d36fff53bbf10454130df9bbf478f1727386f6ef93-03657aa1329b4b1b0a0445cdf357f1d08fa81c579aef219cc226e644ef36b6840d-0")['bolt12']
669+
670+
# This will MPP ANYWAY, even though MPP is not specified!
671+
ret = l1.rpc.xpay(inv)
672+
assert ret['failed_parts'] == 0
673+
assert ret['successful_parts'] == 2
674+
assert ret['amount_msat'] == AMOUNT
675+
assert ret['amount_sent_msat'] == AMOUNT + AMOUNT // 100000 + 1

0 commit comments

Comments
 (0)