From 63fffd41c894d8316423f4c1e4861c8a1a518224 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 12 Dec 2019 10:22:28 +1030 Subject: [PATCH] configure: make partid payments only available with EXPERIMENTAL_FEATURES and payment_secret Explicit #if EXPERIMENTAL_FEATURES check in case we enable them at different times, but it requires a payment_secret since we put them in the same field. This incidently stops it working on legacy nodes. Signed-off-by: Rusty Russell --- lightningd/pay.c | 9 +++++++++ tests/test_pay.py | 1 + 2 files changed, 10 insertions(+) diff --git a/lightningd/pay.c b/lightningd/pay.c index 8043b04cb..ff6f49964 100644 --- a/lightningd/pay.c +++ b/lightningd/pay.c @@ -978,6 +978,11 @@ send_payment(struct lightningd *ld, if (!final_tlv && payment_secret) final_tlv = true; + /* Parallel payments are invalid for legacy. */ + if (partid && !final_tlv) + return command_fail(cmd, PAY_DESTINATION_PERM_FAIL, + "Cannot do parallel payments to legacy node"); + onion = onion_final_hop(cmd, final_tlv, route[i].amount, @@ -1306,6 +1311,10 @@ static struct command_result *json_sendpay(struct command *cmd, } #endif + if (*partid && !payment_secret) + return command_fail(cmd, JSONRPC2_INVALID_PARAMS, + "partid requires payment_secret"); + return send_payment(cmd->ld, cmd, rhash, *partid, route, route[routetok->size-1].amount, diff --git a/tests/test_pay.py b/tests/test_pay.py index 009a7cb4f..9b3198278 100644 --- a/tests/test_pay.py +++ b/tests/test_pay.py @@ -2570,6 +2570,7 @@ def test_sendonion_rpc(node_factory): @unittest.skipIf(not DEVELOPER, "needs DEVELOPER=1") +@unittest.skipIf(not EXPERIMENTAL_FEATURES, "needs partid support") def test_partial_payment(node_factory, bitcoind, executor): # We want to test two payments at the same time, before we send commit l1, l2, l3, l4 = node_factory.get_nodes(4, [{}] + [{'disconnect': ['=WIRE_UPDATE_ADD_HTLC-nocommit']}] * 2 + [{}])