lightningd: check command should return as much detail as possible.

If they're explicitly calling "check", don't obfuscate the result!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2024-06-24 13:15:52 +09:30
parent 9fd29d35dd
commit cb4dd7489c
2 changed files with 7 additions and 1 deletions

View file

@ -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,

View file

@ -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\"'"