jsonrpc: add double '\n' to end of JSON RPC commands.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2018-11-18 20:13:39 +10:30 committed by Christian Decker
parent 0c3f85d931
commit b2378654d7
2 changed files with 6 additions and 3 deletions

View File

@ -8,6 +8,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Added
- JSON API: use `\n\n` to terminate responses, for simplified parsing.
### Changed
### Deprecated
@ -22,6 +24,7 @@ changes.
- JSON API: uppercase invoices now parsed correctly (broken in 0.6.2).
- pylightning: handle multiple simultanous RPC replies reliably.
### Security

View File

@ -363,7 +363,7 @@ void command_success(struct command *cmd, struct json_stream *result)
assert(cmd);
assert(cmd->have_json_stream);
if (cmd->jcon)
jcon_append(cmd->jcon, " }\n");
jcon_append(cmd->jcon, " }\n\n");
if (cmd->ok)
*(cmd->ok) = true;
tal_free(cmd);
@ -375,7 +375,7 @@ void command_failed(struct command *cmd, struct json_stream *result)
assert(cmd->have_json_stream);
/* Have to close error */
if (cmd->jcon)
jcon_append(cmd->jcon, " } }\n");
jcon_append(cmd->jcon, " } }\n\n");
if (cmd->ok)
*(cmd->ok) = false;
tal_free(cmd);
@ -418,7 +418,7 @@ static void json_command_malformed(struct json_connection *jcon,
jcon_append(jcon,
tal_fmt(tmpctx, " \"error\" : "
"{ \"code\" : %d,"
" \"message\" : \"%s\" } }\n",
" \"message\" : \"%s\" } }\n\n",
JSONRPC2_INVALID_REQUEST, error));
}