| 2 | #include <common/json_command.h> |
| 3 | |
| 4 | struct command_result * |
| 5 | command_fail_badparam(struct command *cmd, |
| 6 | const char *paramname, |
| 7 | const char *buffer, |
| 8 | const jsmntok_t *tok, |
| 9 | const char *msg) |
| 10 | { |
| 11 | if (command_dev_apis(cmd) || command_check_only(cmd)) { |
| 12 | return command_fail(cmd, JSONRPC2_INVALID_PARAMS, |
| 13 | "%s: %s: invalid token '%.*s'", |
| 14 | paramname, msg, |
| 15 | json_tok_full_len(tok), |
| 16 | json_tok_full(buffer, tok)); |
| 17 | } |
| 18 | |
| 19 | /* Someone misconfigured LNBITS with "" around the rune, and so the |
| 20 | * user got a message about a bad rune parameter which *contained the |
| 21 | * rune itself*!. LNBITS should probably swallow any JSONRPC2_* error |
| 22 | * itself, but it is quite possibly not the only case where this case |
| 23 | * where this can happen. So we are a little circumspect in this |
| 24 | * case. */ |
| 25 | command_log(cmd, LOG_INFORM, |
| 26 | "Invalid parameter %s (%s): token '%.*s'", |
| 27 | paramname, msg, |
| 28 | json_tok_full_len(tok), |
| 29 | json_tok_full(buffer, tok)); |
| 30 | return command_fail(cmd, JSONRPC2_INVALID_PARAMS, |
| 31 | "%s: %s: invalid token (see logs for details)", |
| 32 | paramname, msg); |
| 33 | } |
no test coverage detected