Skip to content

Commit 74cfd84

Browse files
committed
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 <[email protected]> Changelog-Fixed: JSON-RPC: `pay` and `decodepay` with description now correctly handle JSON escapes (e.g " inside description)
1 parent 96d3ca2 commit 74cfd84

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

lightningd/invoice.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1530,7 +1530,7 @@ static struct command_result *json_decodepay(struct command *cmd,
15301530

15311531
if (!param(cmd, buffer, params,
15321532
p_req("bolt11", param_string, &str),
1533-
p_opt("description", param_string, &desc),
1533+
p_opt("description", param_escaped_string, &desc),
15341534
NULL))
15351535
return command_param_failed();
15361536

plugins/pay.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1006,7 +1006,7 @@ static struct command_result *json_pay(struct command *cmd,
10061006
p_opt("localinvreqid", param_sha256, &local_invreq_id),
10071007
p_opt("exclude", param_route_exclusion_array, &exclusions),
10081008
p_opt("maxfee", param_msat, &maxfee),
1009-
p_opt("description", param_string, &description),
1009+
p_opt("description", param_escaped_string, &description),
10101010
#if DEVELOPER
10111011
p_opt_def("use_shadow", param_bool, &use_shadow, true),
10121012
#endif

tests/test_pay.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5403,3 +5403,17 @@ def test_fetchinvoice_with_no_quantity(node_factory):
54035403
inv = inv['invoice']
54045404
decode_inv = l2.rpc.decode(inv)
54055405
assert decode_inv['invreq_quantity'] == 2, f'`invreq_quantity` in the invoice did not match, received {decode_inv["quantity"]}, expected 2'
5406+
5407+
5408+
def test_invoice_pay_desc_with_quotes(node_factory):
5409+
"""Test that we can decode and pay invoice where hashed description contains double quotes"""
5410+
l1, l2 = node_factory.line_graph(2)
5411+
description = '[["text/plain","Funding @odell on stacker.news"],["text/identifier","[email protected]"]]'
5412+
5413+
invoice = l2.rpc.invoice(label="test12345", amount_msat=1000,
5414+
description=description, deschashonly=True)["bolt11"]
5415+
5416+
l1.rpc.decodepay(invoice, description)
5417+
5418+
# pay an invoice
5419+
l1.rpc.pay(invoice, description=description)

0 commit comments

Comments
 (0)