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 <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2019-12-12 10:22:28 +10:30 committed by Christian Decker
parent cd35835c5a
commit 63fffd41c8
2 changed files with 10 additions and 0 deletions

View File

@ -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,

View File

@ -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 + [{}])