Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove excessive wrapping in the rpc_command hook call #3560

Merged
merged 2 commits into from
Mar 10, 2020

Conversation

cdecker
Copy link
Member

@cdecker cdecker commented Mar 3, 2020

We were nesting like the following:

{"params": {
  "rpc_command": {
    "rpc_command": {
    }
  }
}

This is really excessive, so we unwrap once, and now have the following:

{"params": {
  "rpc_command": {
  }
}

Still more wrapping than necessary (the method is repeated in the params
object), but it's getting closer.

Suggested-by: @fiatjaf
Signed-off-by: Christian Decker <@cdecker>

Fixes #3558

@cdecker cdecker added this to the 0.8.2 milestone Mar 3, 2020
@cdecker cdecker self-assigned this Mar 3, 2020
@cdecker cdecker changed the title Issue 3558 Remove excessive wrapping in the rpc_command hook call Mar 3, 2020
@@ -611,8 +611,21 @@ struct rpc_command_hook_payload {
static void rpc_command_hook_serialize(struct rpc_command_hook_payload *p,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this commit needs a Changelog-Deprecated line ?

Copy link
Collaborator

@darosior darosior left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated libwally failure

ACK 206e197


#ifdef COMPAT_V081
if (deprecated_apis)
json_add_tok(s, "rpc_command", p->request, p->buffer);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

heh i came across this yesterday. can you remove the outer object and instead do this line? it should achieve the same result without needing to iterate through the object.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to do that, however if I use json_add_tok to fill in {"rpc_command": <copy>} I cannot re-enter the rpc_command key to then add the compat version, i.e., {"rpc_command": {"rpc_command": <copy>, <copied-fields}}. Once we remove the COMPAT_V081 flag we can actually do this and avoid iterating through, but until then I'm afraid we need to keep this.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack. i understand what this outputs now. thanks.

@cdecker cdecker force-pushed the issue-3558 branch 2 times, most recently from e0b9ecd to 81ad2a5 Compare March 6, 2020 12:52
We were nesting like the following:

```json
{"params": {
  "rpc_command": {
    "rpc_command": {
    }
  }
}
```

This is really excessive, so we unwrap once, and now have the following:

```json
{"params": {
  "rpc_command": {
  }
}
```

Still more wrapping than necessary (the method is repeated in the `params`
object), but it's getting closer.

Changelog-Deprecated: JSON-RPC: Removed double wrapping of `rpc_command` payload in `rpc_command` JSON field.

Suggested-by: @fiatjaf
Signed-off-by: Christian Decker <@cdecker>
@cdecker
Copy link
Member Author

cdecker commented Mar 9, 2020

Rebased and squashed :-)

Copy link
Collaborator

@darosior darosior left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack 6f78c31

@rustyrussell rustyrussell merged commit d2688bb into ElementsProject:master Mar 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

rpc_command hook passes wrong payload
4 participants