From 54bcb102276f661590a75dcffc174f8848a633fb Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 7 Aug 2023 16:01:41 +0930 Subject: [PATCH] lightningd: fix bolt11 parsing in preapproveinvocie, sendonion, listsendpays and renepay Since bolt11_decode now insists that any `lightning:` prefix be removed, we need to make sure to use param_invstring not param_string for all bolt11 parameters: ``` 2023-08-07T05:55:32.515Z **BROKEN** lightningd: FATAL SIGNAL 6 (version v23.08rc1-21-g0bf5ee6) 2023-08-07T05:55:32.515Z **BROKEN** lightningd: backtrace: common/daemon.c:38 (send_backtrace) 0x55dd94934154 2023-08-07T05:55:32.515Z **BROKEN** lightningd: backtrace: common/daemon.c:75 (crashdump) 0x55dd949342e6 2023-08-07T05:55:32.515Z **BROKEN** lightningd: backtrace: ./signal/../sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c:0 ((null)) 0x7f5cf5a3bcef 2023-08-07T05:55:32.515Z **BROKEN** lightningd: backtrace: ./nptl/pthread_kill.c:44 (__pthread_kill_implementation) 0x7f5cf5a9226b 2023-08-07T05:55:32.515Z **BROKEN** lightningd: backtrace: ./nptl/pthread_kill.c:78 (__pthread_kill_internal) 0x7f5cf5a9226b 2023-08-07T05:55:32.515Z **BROKEN** lightningd: backtrace: ./nptl/pthread_kill.c:89 (__GI___pthread_kill) 0x7f5cf5a9226b 2023-08-07T05:55:32.515Z **BROKEN** lightningd: backtrace: ../sysdeps/posix/raise.c:26 (__GI_raise) 0x7f5cf5a3bc45 2023-08-07T05:55:32.515Z **BROKEN** lightningd: backtrace: ./stdlib/abort.c:79 (__GI_abort) 0x7f5cf5a227fb 2023-08-07T05:55:32.515Z **BROKEN** lightningd: backtrace: ./assert/assert.c:92 (__assert_fail_base) 0x7f5cf5a2271a 2023-08-07T05:55:32.515Z **BROKEN** lightningd: backtrace: ./assert/assert.c:101 (__GI___assert_fail) 0x7f5cf5a33595 2023-08-07T05:55:32.515Z **BROKEN** lightningd: backtrace: common/bolt11.c:734 (bolt11_decode_nosig) 0x55dd94929967 2023-08-07T05:55:32.515Z **BROKEN** lightningd: backtrace: common/bolt11.c:953 (bolt11_decode) 0x55dd9492a44f 2023-08-07T05:55:32.515Z **BROKEN** lightningd: backtrace: lightningd/pay.c:1730 (json_listsendpays) 0x55dd948d7d72 2023-08-07T05:55:32.515Z **BROKEN** lightningd: backtrace: lightningd/jsonrpc.c:658 (command_exec) 0x55dd948b525b 2023-08-07T05:55:32.515Z **BROKEN** lightningd: backtrace: lightningd/jsonrpc.c:786 (rpc_command_hook_final) 0x55dd948b5876 2023-08-07T05:55:32.515Z **BROKEN** lightningd: backtrace: lightningd/plugin_hook.c:285 (plugin_hook_call_) 0x55dd948f6446 2023-08-07T05:55:32.515Z **BROKEN** lightningd: backtrace: lightningd/jsonrpc.c:874 (plugin_hook_call_rpc_command) 0x55dd948b5c77 2023-08-07T05:55:32.516Z **BROKEN** lightningd: backtrace: lightningd/jsonrpc.c:984 (parse_request) 0x55dd948b6234 2023-08-07T05:55:32.516Z **BROKEN** lightningd: backtrace: lightningd/jsonrpc.c:1090 (read_json) 0x55dd948b670f 2023-08-07T05:55:32.516Z **BROKEN** lightningd: backtrace: ccan/ccan/io/io.c:59 (next_plan) 0x55dd94ac9bf4 2023-08-07T05:55:32.516Z **BROKEN** lightningd: backtrace: ccan/ccan/io/io.c:407 (do_plan) 0x55dd94aca823 2023-08-07T05:55:32.516Z **BROKEN** lightningd: backtrace: ccan/ccan/io/io.c:417 (io_ready) 0x55dd94aca865 2023-08-07T05:55:32.516Z **BROKEN** lightningd: backtrace: ccan/ccan/io/poll.c:453 (io_loop) 0x55dd94accbff 2023-08-07T05:55:32.516Z **BROKEN** lightningd: backtrace: lightningd/io_loop_with_timers.c:22 (io_loop_with_timers) 0x55dd948b33c4 2023-08-07T05:55:32.516Z **BROKEN** lightningd: backtrace: lightningd/lightningd.c:1332 (main) 0x55dd948ba429 2023-08-07T05:55:32.516Z **BROKEN** lightningd: backtrace: ../sysdeps/nptl/libc_start_call_main.h:58 (__libc_start_call_main) 0x7f5cf5a2350f 2023-08-07T05:55:32.516Z **BROKEN** lightningd: backtrace: ../csu/libc-start.c:381 (__libc_start_main_impl) 0x7f5cf5a235c8 2023-08-07T05:55:32.516Z **BROKEN** lightningd: backtrace: (null):0 ((null)) 0x55dd94881e74 2023-08-07T05:55:32.516Z **BROKEN** lightningd: backtrace: (null):0 ((null)) 0xffffffffffffffff ``` Fixes: #6524 Signed-off-by: Rusty Russell Changelog-None: broken in master since last release. --- lightningd/invoice.c | 2 +- lightningd/pay.c | 4 ++-- plugins/renepay/pay.c | 4 ++-- tests/test_pay.py | 1 - 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/lightningd/invoice.c b/lightningd/invoice.c index 512edde95..cc7580a4f 100644 --- a/lightningd/invoice.c +++ b/lightningd/invoice.c @@ -1852,7 +1852,7 @@ static struct command_result *json_preapproveinvoice(struct command *cmd, if (!param(cmd, buffer, params, /* FIXME: parameter should be invstring now */ - p_req("bolt11", param_string, &invstring), + p_req("bolt11", param_invstring, &invstring), NULL)) return command_param_failed(); diff --git a/lightningd/pay.c b/lightningd/pay.c index 0dd517317..e74d92533 100644 --- a/lightningd/pay.c +++ b/lightningd/pay.c @@ -1333,7 +1333,7 @@ static struct command_result *json_sendonion(struct command *cmd, p_opt("shared_secrets", param_secrets_array, &path_secrets), p_opt_def("partid", param_u64, &partid, 0), /* FIXME: parameter should be invstring now */ - p_opt("bolt11", param_string, &invstring), + p_opt("bolt11", param_invstring, &invstring), p_opt_def("amount_msat|msatoshi", param_msat, &msat, AMOUNT_MSAT(0)), p_opt("destination", param_node_id, &destination), p_opt("localinvreqid", param_sha256, &local_invreq_id), @@ -1711,7 +1711,7 @@ static struct command_result *json_listsendpays(struct command *cmd, if (!param(cmd, buffer, params, /* FIXME: parameter should be invstring now */ - p_opt("bolt11", param_string, &invstring), + p_opt("bolt11", param_invstring, &invstring), p_opt("payment_hash", param_sha256, &rhash), p_opt("status", param_payment_status, &status), NULL)) diff --git a/plugins/renepay/pay.c b/plugins/renepay/pay.c index 27888cae4..ff1172144 100644 --- a/plugins/renepay/pay.c +++ b/plugins/renepay/pay.c @@ -625,7 +625,7 @@ static struct command_result *json_paystatus(struct command *cmd, struct payment *p; if (!param(cmd, buf, params, - p_opt("invstring", param_string, &invstring), + p_opt("invstring", param_invstring, &invstring), NULL)) return command_param_failed(); @@ -940,7 +940,7 @@ static struct command_result *json_pay(struct command *cmd, #endif if (!param(cmd, buf, params, - p_req("invstring", param_string, &invstr), + p_req("invstring", param_invstring, &invstr), p_opt("amount_msat", param_msat, &msat), p_opt("maxfee", param_msat, &maxfee), diff --git a/tests/test_pay.py b/tests/test_pay.py index 7838dff25..b16a2d7b0 100644 --- a/tests/test_pay.py +++ b/tests/test_pay.py @@ -5382,7 +5382,6 @@ def test_strip_lightning_suffix_from_inv(node_factory): assert listpays[2]['bolt11'] == inv, f"list pays contains a different invoice, expected is {inv} but we get {listpays[0]['bolt11']}" -@pytest.mark.xfail(strict=True) def test_listsendpays_crash(node_factory): l1 = node_factory.get_node()