pay, decodepay: handle descriptions with " inside them where we use hashed descriptions.

This means we need to push off requring this for another full deprecation cycle!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Fixed: JSON-RPC: `pay` and `decodepay` with description now correctly handle JSON escapes (e.g " inside description)
This commit is contained in:
Rusty Russell 2023-06-15 14:52:50 +09:30
parent 7a57f7024c
commit 92ff0fd8c0
3 changed files with 16 additions and 2 deletions

View file

@ -1530,7 +1530,7 @@ static struct command_result *json_decodepay(struct command *cmd,
if (!param(cmd, buffer, params,
p_req("bolt11", param_string, &str),
p_opt("description", param_string, &desc),
p_opt("description", param_escaped_string, &desc),
NULL))
return command_param_failed();

View file

@ -1008,7 +1008,7 @@ static struct command_result *json_pay(struct command *cmd,
p_opt("localinvreqid", param_sha256, &local_invreq_id),
p_opt("exclude", param_route_exclusion_array, &exclusions),
p_opt("maxfee", param_msat, &maxfee),
p_opt("description", param_string, &description),
p_opt("description", param_escaped_string, &description),
#if DEVELOPER
p_opt_def("use_shadow", param_bool, &use_shadow, true),
#endif

View file

@ -5400,3 +5400,17 @@ def test_fetchinvoice_with_no_quantity(node_factory):
inv = inv['invoice']
decode_inv = l2.rpc.decode(inv)
assert decode_inv['invreq_quantity'] == 2, f'`invreq_quantity` in the invoice did not match, received {decode_inv["quantity"]}, expected 2'
def test_invoice_pay_desc_with_quotes(node_factory):
"""Test that we can decode and pay invoice where hashed description contains double quotes"""
l1, l2 = node_factory.line_graph(2)
description = '[["text/plain","Funding @odell on stacker.news"],["text/identifier","odell@stacker.news"]]'
invoice = l2.rpc.invoice(label="test12345", amount_msat=1000,
description=description, deschashonly=True)["bolt11"]
l1.rpc.decodepay(invoice, description)
# pay an invoice
l1.rpc.pay(invoice, description=description)