mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-01 17:47:30 +01:00
libplugin: quick fix for bad JSON produced by plugins on bad paramters.
Internally libplugin turns ' into ", which causes these messages to produce bad JSON. The real fix is to remove the '->" convenience substitution and port the JSON creation APIs into common/ from lightningd/ Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
28699f0eca
commit
ba8a9d1fde
2 changed files with 6 additions and 3 deletions
|
@ -53,7 +53,7 @@ static struct command_result *post_check(struct command *cmd,
|
|||
while (first != last && first->required) {
|
||||
if (!first->is_set) {
|
||||
return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
|
||||
"missing required parameter: '%s'",
|
||||
"missing required parameter: %s",
|
||||
first->name);
|
||||
}
|
||||
first++;
|
||||
|
@ -124,7 +124,7 @@ static struct command_result *parse_by_name(struct command *cmd,
|
|||
if (!p) {
|
||||
if (!allow_extra) {
|
||||
return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
|
||||
"unknown parameter: '%.*s'",
|
||||
"unknown parameter: %.*s",
|
||||
t->end - t->start,
|
||||
buffer + t->start);
|
||||
}
|
||||
|
@ -133,7 +133,7 @@ static struct command_result *parse_by_name(struct command *cmd,
|
|||
|
||||
if (p->is_set) {
|
||||
return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
|
||||
"duplicate json names: '%s'",
|
||||
"duplicate json names: %s",
|
||||
p->name);
|
||||
}
|
||||
|
||||
|
|
|
@ -116,3 +116,6 @@ def test_pay_plugin(node_factory):
|
|||
|
||||
res = l1.rpc.pay(bolt11=inv['bolt11'])
|
||||
assert res['status'] == 'complete'
|
||||
|
||||
with pytest.raises(RpcError, match=r'missing required parameter'):
|
||||
l1.rpc.call('pay')
|
||||
|
|
Loading…
Add table
Reference in a new issue