Skip to content

Commit

Permalink
lightningd: fix bolt11 parsing in preapproveinvocie, sendonion, lists…
Browse files Browse the repository at this point in the history
…endpays 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: ElementsProject#6524
Signed-off-by: Rusty Russell <[email protected]>
Changelog-None: broken in master since last release.
  • Loading branch information
rustyrussell committed Aug 7, 2023
1 parent 7a88900 commit 54bcb10
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lightningd/invoice.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
4 changes: 2 additions & 2 deletions lightningd/pay.c
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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))
Expand Down
4 changes: 2 additions & 2 deletions plugins/renepay/pay.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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),

Expand Down
1 change: 0 additions & 1 deletion tests/test_pay.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down

0 comments on commit 54bcb10

Please sign in to comment.