diff --git a/lightningd/invoice.c b/lightningd/invoice.c index 6458f3d58..01cfd64ea 100644 --- a/lightningd/invoice.c +++ b/lightningd/invoice.c @@ -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(); diff --git a/plugins/pay.c b/plugins/pay.c index 62d2c6f9d..9b66a548f 100644 --- a/plugins/pay.c +++ b/plugins/pay.c @@ -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 diff --git a/tests/test_pay.py b/tests/test_pay.py index 5a0ab89dc..bd839cf0b 100644 --- a/tests/test_pay.py +++ b/tests/test_pay.py @@ -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)