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

Complete the JSON schemas. #4594

Merged
merged 13 commits into from
Jun 25, 2021

Conversation

rustyrussell
Copy link
Contributor

@rustyrussell rustyrussell commented Jun 11, 2021

Based on #4585, since that cleans up JSON outputs.

This has been a mammoth effort, but it finally works. So much documentation cleanups, and JSON output fixes in here.

Glad it's finally done!

(If someone wants to write schemas & auto-gen docs for the rpc hooks, go for it!)

@rustyrussell rustyrussell added this to the v0.10.1 milestone Jun 11, 2021
@rustyrussell rustyrussell force-pushed the guilt/formal-json branch 2 times, most recently from 61f4034 to 6637b11 Compare June 11, 2021 12:59
Copy link
Collaborator

@vincenzopalazzo vincenzopalazzo left a comment

Choose a reason for hiding this comment

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

Look really good Rusty.

ack 6637b11

This test error proof that the JSON schema works, right? :-)

JSON report written to: report.json (69796936 bytes)
===Flaky Test Report===

test_htlc_accepted_hook_direct_restart failed (2 runs remaining out of 3).
	<class 'jsonschema.exceptions.ValidationError'>
	Additional properties are not allowed ('status' was unexpected)

@rustyrussell
Copy link
Contributor Author

rustyrussell commented Jun 12, 2021

Yep! And I fixed the schema! (Which updated the documentation!)

@rustyrussell rustyrussell force-pushed the guilt/formal-json branch 2 times, most recently from 912bc45 to 2823b27 Compare June 13, 2021 04:44
In general, it's better to omit a field than put in a 'null', and
putting variable-named fields in an object is also a bad idea.

This is reflected in how hard this is to express in JSON schema, too.

Others:
1. Remove the obsolete "funding": "LOCAL" from unopened channels, but add
   "opener": "local" as used in normal channels.
2. htlc cltv_expiry is a u16.

Signed-off-by: Rusty Russell <[email protected]>
Changelog-Deprecated: JSON-RPC: `listfunds` `channels` `funding_allocation_msat` and `funding_msat`: use `funding`.
Changelog-Deprecated: JSON-RPC: `listfunds` `channels` `last_tx_fee`: use `last_tx_fee_msat`.
Changelog-Deprecated: JSON-RPC: `listfunds` `channels` `closer` is now omitted if it does not apply, not JSON `null`.
That's a terrible, terrible idea.  (Documentation comes in later patch
which has the schema).

Also, blockheight is a u32, so simplify.

Signed-off-by: Rusty Russell <[email protected]>
Changelog-Deprecated: JSON-RPC: `listtransactions` `outputs` `satoshis` field (use `msat` instead).
Makes it possible to write a decent JSON schema, but means we need to carry
additional data, so we create a `struct plugin_command`.

We remove the unused struct dynamic_plugin, too.

Signed-off-by: Rusty Russell <[email protected]>
If we have conditional fields, we often set `additionalProperties` `true`
at the top-level, but then we have to make sure to cover all the possible
combinations in conditionals, so unintended additions don't appear.

This revealed missing fields in delinvoice, for example.

Signed-off-by: Rusty Russell <[email protected]>
Signed-off-by: Rusty Russell <[email protected]>
… lists.

1. listpeers has a deprecated `"closer": null`, which we need
   to handle in the schema, while trying not to damage our
   documentation too much.

2. Don't print a condition if there are no fields to print.

3. Allow a special "untyped" marker for multifundchannel which returns
   arbitrary JSON in a field.

4. Allow a single field return (for 'stop').

Signed-off-by: Rusty Russell <[email protected]>
This is the most complex one.  It gets its own commit.

Signed-off-by: Rusty Russell <[email protected]>
Signed-off-by: Rusty Russell <[email protected]>
Changelog-Fixed: doc: Epic documentation rewrite: each now lists complete and accurate JSON output, tested against testsuite.
1. Hide the now-deprecated enable-autotor-v2-mode option.
2. Really don't print dev- options.
3. Don't print true and false as strings in some cases.

Signed-off-by: Rusty Russell <[email protected]>
Changelog-Fixed: JSON-RPC: `listconfigs` would list some boolean options as strings `"true"` or `"false"` instead of using JSON booleans.
This made me document what are options are now in plugins, too.

Signed-off-by: Rusty Russell <[email protected]>
@rustyrussell
Copy link
Contributor Author

Trivial rebase now #4585 is merged.

Copy link
Member

@cdecker cdecker left a comment

Choose a reason for hiding this comment

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

ACK 44d53d9

@rustyrussell rustyrussell merged commit 408342d into ElementsProject:master Jun 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants