Skip to content

Commit

Permalink
lightningd: check command should return as much detail as possible.
Browse files Browse the repository at this point in the history
If they're explicitly calling "check", don't obfuscate the result!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
  • Loading branch information
rustyrussell committed Jun 24, 2024
1 parent 9fd29d3 commit cb4dd74
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion common/json_command.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ command_fail_badparam(struct command *cmd,
const jsmntok_t *tok,
const char *msg)
{
if (command_dev_apis(cmd)) {
if (command_dev_apis(cmd) || command_check_only(cmd)) {
return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
"%s: %s: invalid token '%.*s'",
paramname, msg,
Expand Down
6 changes: 6 additions & 0 deletions tests/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -4244,3 +4244,9 @@ def test_badparam_discretion(node_factory):
l1.rpc.checkrune(rune='THIS IS NOT ACTUALLY A RUNE')

l1.daemon.wait_for_log(r"checkrune: Invalid parameter rune \(should be base64 string\): token '\"THIS IS NOT ACTUALLY A RUNE\"'")

# But: check command *SHOULD* give as much info as we can.
with pytest.raises(RpcError, match='rune: should be base64 string: invalid token') as err:
l1.rpc.check('checkrune', rune='THIS IS NOT ACTUALLY A RUNE')

assert err.value.error['message'] == "rune: should be base64 string: invalid token '\"THIS IS NOT ACTUALLY A RUNE\"'"

0 comments on commit cb4dd74

Please sign in to comment.